├── README.md
└── system
└── expressionengine
└── third_party
└── cp_menu_master
├── ext.cp_menu_master.php
├── language
└── english
│ └── cp_menu_master_lang.php
└── views
└── index.php
/README.md:
--------------------------------------------------------------------------------
1 | CP Menu Master
2 | ==============
3 |
4 | Take control of your control panel menus! CP Menu Master allows you to hide channels from the
5 | publish and edit menus for ALL users, and display control panel menus on mouse-over instead of
6 | click. Think of all those seconds you will save!
7 |
8 | Please note: This extension does not enforce any kind of security to prevent users publishing
9 | to channels. It simply removes links from the publish menu, to reduce clutter. Smart users
10 | can still publish to those channels by accessing the correct URL.
11 |
12 | Requirements
13 | ------------
14 |
15 | * ExpressionEngine 2.1.5+
16 |
17 | Installation
18 | ------------
19 |
20 | 1. Copy the entire `cp_menu_master` folder to `/system/expressionengine/third_party` on your server.
21 | 2. Enable the extension under Add-ons > Extensions in your ExpressionEngine control panel.
22 |
23 | Updating
24 | --------
25 |
26 | When upgrading from a pre-2.0 release, please make sure you replace the entire ``cp_menu_master``
27 | directory, and not simply merge the contents. The old acc, mcp, and upd files are no longer
28 | required. Your pre-2.0 module settings will be migrated to the new version.
29 |
30 | Configuration
31 | -------------
32 |
33 | Configuration options for this extension can be found under Add-Ons > Extensions in your
34 | ExpressionEngine control panel. Settings apply to all users, even super admins.
35 |
36 | Changelog
37 | ---------
38 |
39 | ### 2.2.1
40 | *May 29, 2013*
41 |
42 | * ExpressionEngine 2.6 compatibility
43 |
44 | ### 2.2.0
45 | *March 28, 2012*
46 |
47 | * Removed "Display Content > Edit as a submenu" option to support EE 2.4+
48 |
49 | ### 2.1.0
50 | *August 18, 2011*
51 |
52 | * Added "Hide Filter by Channel on Edit Channel Entries page" option
53 |
54 | ### 2.0.0
55 | *June 7, 2011*
56 |
57 | * Rewritten as an extension to take advantage of new menu hook in EE 2.1.5+
58 |
59 | ### 1.0.1
60 | *March 25, 2011*
61 |
62 | * Added ability to hide channels from the edit menu independently of the publish menu
63 |
64 | ### 1.0.0
65 | *March 16, 2011*
66 |
67 | * Initial release
68 |
--------------------------------------------------------------------------------
/system/expressionengine/third_party/cp_menu_master/ext.cp_menu_master.php:
--------------------------------------------------------------------------------
1 | EE =& get_instance();
38 | $this->initialize($settings);
39 | }
40 |
41 | public function initialize($settings)
42 | {
43 | if (empty($settings['hidden_channels']) OR ! is_array($settings['hidden_channels']))
44 | {
45 | $settings['hidden_channels'] = array();
46 | }
47 |
48 | if (empty($settings['hidden_edit']) OR ! is_array($settings['hidden_edit']))
49 | {
50 | $settings['hidden_edit'] = array();
51 | }
52 |
53 | $this->settings = $settings;
54 | }
55 |
56 | public function activate_extension()
57 | {
58 | // check for old version settings
59 | $this->EE->db->where('module_name', 'Cp_menu_master');
60 | $row = $this->EE->db->get('modules')->row();
61 | if (empty($row->settings))
62 | {
63 | $this->settings = array();
64 | }
65 | else
66 | {
67 | $this->settings = unserialize(base64_decode($row->settings));
68 | }
69 |
70 | // remove old version module and accessory
71 | $this->EE->db->where('module_name', 'Cp_menu_master');
72 | $this->EE->db->delete('modules');
73 |
74 | $this->EE->db->where('class', 'Cp_menu_master_acc');
75 | $this->EE->db->delete('accessories');
76 |
77 | // install extension
78 | $data = array(
79 | 'class' => __CLASS__,
80 | 'method' => 'cp_menu_array',
81 | 'hook' => 'cp_menu_array',
82 | 'settings' => serialize($this->settings),
83 | 'priority' => 10,
84 | 'version' => $this->version,
85 | 'enabled' => 'y'
86 | );
87 |
88 | $this->EE->db->insert('extensions', $data);
89 | }
90 |
91 | public function update_extension($current = '')
92 | {
93 | if ($current == $this->version) return FALSE;
94 |
95 | $this->EE->db->where('class', __CLASS__);
96 | $this->EE->db->update('extensions', array('version' => $this->version));
97 | return TRUE;
98 | }
99 |
100 | public function settings_form($settings)
101 | {
102 | $this->initialize($settings);
103 |
104 | $data = array(
105 | 'post_url' => 'C=addons_extensions'.AMP.'M=save_extension_settings'.AMP.'file=cp_menu_master',
106 | 'settings' => $this->settings,
107 | );
108 |
109 | // get channel list
110 | $data['channels'] = array();
111 | $this->EE->load->model('channel_model');
112 | $channels_query = $this->EE->channel_model->get_channels()->result();
113 | foreach ($channels_query as $channel)
114 | {
115 | $data['channels'][$channel->channel_id] = $channel->channel_title;
116 | }
117 |
118 | return $this->EE->load->view('index', $data, TRUE);
119 | }
120 |
121 | public function save_settings()
122 | {
123 | if (empty($_POST))
124 | {
125 | show_error($this->EE->lang->line('unauthorized_access'));
126 | }
127 |
128 | $settings = serialize($this->EE->input->post('settings', TRUE));
129 |
130 | $this->EE->db->where('class', __CLASS__);
131 | $this->EE->db->update('extensions', array('settings' => $settings));
132 |
133 | $this->EE->session->set_flashdata('message_success', lang('preferences_updated'));
134 | }
135 |
136 | /**
137 | * CP Menu Array extension function
138 | *
139 | * Called by EE right before the top menu is generated, so we can edit it.
140 | */
141 | public function cp_menu_array($menu)
142 | {
143 | // in case other extensions use this hook
144 | if ($this->EE->extensions->last_call !== FALSE)
145 | {
146 | $menu = $this->EE->extensions->last_call;
147 | }
148 |
149 | // alter the menu as per settings
150 | if (isset($menu['content']['publish']))
151 | {
152 | $menu['content']['publish'] = $this->_remove_hidden_channels($menu['content']['publish'], $this->settings['hidden_channels']);
153 | if (empty($menu['content']['publish'])) unset($menu['content']['publish']);
154 | }
155 |
156 | if (isset($menu['content']['edit']))
157 | {
158 | $menu['content']['edit'] = $this->_remove_hidden_channels($menu['content']['edit'], $this->settings['hidden_edit']);
159 | if (empty($menu['content']['edit'])) unset($menu['content']['edit']);
160 | }
161 |
162 | $extra_css = '';
163 |
164 | // do we want to show CP menus on hover instead of click?
165 | if ( ! empty($this->settings['hover_menus']))
166 | {
167 | $extra_css .= '
168 | #navigationTabs li.parent:hover ul,
169 | #navigationTabs li.parent:hover li:hover ul,
170 | #navigationTabs li.parent:hover li:hover ul li:hover ul,
171 | #navigationTabs li.parent:hover li:hover ul li:hover ul li:hover ul {
172 | display:block;
173 | }
174 |
175 | #navigationTabs li.parent:hover ul ul,
176 | #navigationTabs li.parent:hover li:hover ul ul,
177 | #navigationTabs li.parent:hover li:hover ul li:hover ul ul {
178 | display: none;
179 | }
180 | ';
181 | }
182 |
183 | // do we want to hide the "Filter by Channel" drop-down?
184 | if ( ! empty($this->settings['hide_filter_by_channel']))
185 | {
186 | $extra_css .= '
187 | #filterMenu #f_channel_id { display: none; }
188 | #filterMenu #f_cat_id { margin-left: -0.85em; }
189 | ';
190 | }
191 |
192 | if ( ! empty($extra_css))
193 | {
194 | $this->EE->cp->add_to_head('');
195 | }
196 |
197 | return $menu;
198 | }
199 |
200 | protected function _remove_hidden_channels($menu, $hidden_channel_ids)
201 | {
202 | if (empty($menu)) return NULL;
203 | if ( ! is_array($menu)) return $menu;
204 |
205 | // remove any hidden channels
206 | foreach ($menu as $key => $url)
207 | {
208 | $channel_id = (int)substr($url, stripos($url, 'channel_id=') + 11);
209 | if (in_array($channel_id, $hidden_channel_ids))
210 | {
211 | unset($menu[$key]);
212 | }
213 | }
214 |
215 | // tidy up menu
216 | if (empty($menu))
217 | {
218 | return NULL;
219 | }
220 | elseif (count($menu) == 1)
221 | {
222 | return reset($menu);
223 | }
224 |
225 | return $menu;
226 | }
227 | }
228 |
229 | /* End of file ./system/expressionengine/third_party/cp_menu_master/ext.cp_menu_master.php */
230 |
--------------------------------------------------------------------------------
/system/expressionengine/third_party/cp_menu_master/language/english/cp_menu_master_lang.php:
--------------------------------------------------------------------------------
1 | 'Control Panel Menu Options',
5 | 'display_menus_on_hover' => 'Display menus on hover instead of click',
6 | 'hide_from_publish' => 'Hide from
Publish menu',
7 | 'hide_from_edit' => 'Hide from
Edit menu',
8 | 'hide_filter_by_channel' => 'Hide "Filter by Channel" on Edit Channel Entries page',
9 | );
10 |
11 | /* End of file ./system/expressionengine/third_party/cp_menu_master/language/english/cp_menu_master_lang.php */
12 |
--------------------------------------------------------------------------------
/system/expressionengine/third_party/cp_menu_master/views/index.php:
--------------------------------------------------------------------------------
1 | = form_open($post_url, array('id' => 'cp_menu_master_settings')) ?>
2 |
3 |