1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
4 * Represents a user's, perhaps partial, view of the complete menu
6 class Menu_Model
extends Model
10 * @todo previously create_menu, refactor user_controllers' stuff into here as well
11 * Build menu structure and possibly remove some items
17 include(APPPATH
.'views/menu/menu.php');
18 $logged_in_users_groups = Op5Auth
::instance()->get_groups();
19 $ninja_menu = Op5Config
::instance()->getConfig('ninja_menu');
20 foreach(array_intersect((array)$logged_in_users_groups, array_keys((array) $ninja_menu)) as $section) {
21 $this->remove_menu_items($menu_base, $menu_items, $ninja_menu[$section]);
27 * Remove menu item by index
28 * Both section string ['about', 'monitoring', etc]
29 * and item string ['portal', 'manual', 'support', etc] are required.
30 * As a consequence, all menu items has to be explicitly removed before removing the section
32 private function remove_menu_items(&$menu_links=false, &$menu_items=false, $section_str=false, $item_str=false)
34 if (empty($menu_links) ||
empty($menu_items) ||
empty($section_str)) {
38 if (is_array($section_str)) {
39 # we have to make recursive calls
40 foreach ($section_str as $section => $items) {
41 foreach ($items as $item) {
42 $this->remove_menu_items($menu_links, $menu_items, $section, $item);
46 if (empty($item_str) && isset($menu_links[$menu_items['section_'.$section_str]])
47 && empty($menu_links[$menu_items['section_'.$section_str]])) {
49 unset($menu_links[$menu_items['section_'.$section_str]]);
50 } elseif (!empty($item_str) && isset($menu_items['section_'.$section_str]) && isset($menu_links[$menu_items['section_'.$section_str]]) && isset($menu_items[$item_str]) && isset($menu_links[$menu_items['section_'.$section_str]][$menu_items[$item_str]])) {
51 unset($menu_links[$menu_items['section_'.$section_str]][$menu_items[$item_str]]);