@@ 132-148 (lines=17) @@ | ||
129 | * @param ElggMenuItem[] $menu Return value |
|
130 | * @return void |
|
131 | */ |
|
132 | function roles_menus_permissions($hook, $type, $menu) { |
|
133 | ||
134 | $menu_name = explode(':', $type); |
|
135 | $hook_type = array_shift($menu_name); |
|
136 | $menu_name = implode(':', $menu_name); |
|
137 | ||
138 | if ($hook_type !== 'menu' || empty($menu_name)) { |
|
139 | return; |
|
140 | } |
|
141 | ||
142 | $role = roles_get_role(); |
|
143 | if (!$role instanceof ElggRole) { |
|
144 | return; |
|
145 | } |
|
146 | ||
147 | return roles()->setupMenu($role, $menu_name, $menu); |
|
148 | } |
|
149 | ||
150 | /** |
|
151 | * Remove all menu items that link to denied pages and actions |
|
@@ 158-174 (lines=17) @@ | ||
155 | * @param ElggMenuItem[] $menu Return value |
|
156 | * @return void |
|
157 | */ |
|
158 | function roles_menus_cleanup($hook, $type, $menu) { |
|
159 | ||
160 | $menu_name = explode(':', $type); |
|
161 | $hook_type = array_shift($menu_name); |
|
162 | $menu_name = implode(':', $menu_name); |
|
163 | ||
164 | if ($hook_type !== 'menu' || empty($menu_name)) { |
|
165 | return; |
|
166 | } |
|
167 | ||
168 | $role = roles_get_role(); |
|
169 | if (!$role instanceof ElggRole) { |
|
170 | return; |
|
171 | } |
|
172 | ||
173 | return roles()->cleanMenu($role, $menu); |
|
174 | } |
|
175 | ||
176 | /** |
|
177 | * Processes page permissions from the role configuration array. This is called upon each "route" triggered hook. |