/** * Builds a data structure representing the menu for Mahara. */ function main_nav() { if (defined('ADMIN') || defined('INSTITUTIONALADMIN')) { global $USER; $menu = $USER->get('admin') ? admin_nav() : institutional_admin_nav(); } else { // Build the menu structure for the site // The keys of each entry are as follows: // path: Where the link sits in the menu. E.g. 'myporfolio/myplugin' // url: The URL to the page, relative to wwwroot. E.g. 'artefact/myplugin/' // title: Translated text to use for the text of the link. E.g. get_string('myplugin', 'artefact.myplugin') // weight: Where in the menu the item should be inserted. Larger number are to the right. $menu = mahara_standard_nav(); } // local_main_nav_update allows sites to customise the menu by munging the $menu array. if (function_exists('local_main_nav_update')) { local_main_nav_update($menu); } $menu_structure = find_menu_children($menu, ''); return $menu_structure; }
/** * Builds a data structure representing the menu for Mahara. */ function main_nav() { if (in_admin_section()) { global $USER, $SESSION; if ($USER->get('admin')) { $menu = admin_nav(); } else { if ($USER->is_institutional_admin()) { $menu = institutional_admin_nav(); } else { if ($USER->get('staff')) { $menu = staff_nav(); } else { $menu = institutional_staff_nav(); } } } } else { // Build the menu structure for the site // The keys of each entry are as follows: // path: Where the link sits in the menu. E.g. 'myporfolio/myplugin' // url: The URL to the page, relative to wwwroot. E.g. 'artefact/myplugin/' // title: Translated text to use for the text of the link. E.g. get_string('myplugin', 'artefact.myplugin') // weight: Where in the menu the item should be inserted. Larger number are to the right. $menu = mahara_standard_nav(); } $menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);')); if ($plugins = plugins_installed('artefact')) { foreach ($plugins as &$plugin) { if (safe_require_plugin('artefact', $plugin->name)) { $plugin_menu = call_static_method(generate_class_name('artefact', $plugin->name), 'menu_items'); $menu = array_merge($menu, $plugin_menu); } } } if ($plugins = plugins_installed('interaction')) { foreach ($plugins as &$plugin) { if (safe_require_plugin('interaction', $plugin->name)) { $plugin_menu = call_static_method(generate_class_name('interaction', $plugin->name), 'menu_items'); $menu = array_merge($menu, $plugin_menu); } } } // local_main_nav_update allows sites to customise the menu by munging the $menu array. if (function_exists('local_main_nav_update')) { local_main_nav_update($menu); } $menu_structure = find_menu_children($menu, ''); return $menu_structure; }
/** * Builds a data structure representing the menu for Mahara. * * @return array */ function main_nav() { global $USER; $language = current_language(); $cachemenu = false; // Get the first institution $institution = $USER->get_primary_institution(); $menutype = ''; if (in_admin_section()) { global $USER, $SESSION; if ($USER->get('admin')) { $menutype = 'admin_nav'; if (!($cachemenu = get_config_institution($institution, $menutype . '_' . $language))) { $menu = admin_nav(); } } else { if ($USER->is_institutional_admin()) { $menutype = 'instadmin_nav'; if (!($cachemenu = get_config_institution($institution, $menutype . '_' . $language))) { $menu = institutional_admin_nav(); } } else { if ($USER->get('staff')) { $menutype = 'staff_nav'; if (!($cachemenu = get_config_institution($institution, $menutype . '_' . $language))) { $menu = staff_nav(); } } else { $menutype = 'inststaff_nav'; if (!($cachemenu = get_config_institution($institution, $menutype . '_' . $language))) { $menu = institutional_staff_nav(); } } } } } else { // Build the menu structure for the site $menutype = 'standard_nav'; if (!($cachemenu = get_config_institution($institution, $menutype . '_' . $language))) { $menu = mahara_standard_nav(); } } if ($cachemenu) { $menu = json_decode($cachemenu, true); } else { $menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);')); // enable plugins to augment the menu structure foreach (array('artefact', 'interaction', 'module', 'auth') as $plugintype) { if ($plugins = plugins_installed($plugintype)) { foreach ($plugins as &$plugin) { if (safe_require_plugin($plugintype, $plugin->name)) { $plugin_menu = call_static_method(generate_class_name($plugintype, $plugin->name), 'menu_items'); $menu = array_merge($menu, $plugin_menu); } } } } set_config_institution($institution, $menutype . '_' . $language, json_encode($menu)); } // local_main_nav_update allows sites to customise the menu by munging the $menu array. // as there is no internal way to know if the local_main_nav array has changed we keep it outside the cached menu if (function_exists('local_main_nav_update')) { local_main_nav_update($menu); } $menu_structure = find_menu_children($menu, ''); return $menu_structure; }
/** * Builds a data structure representing the menu for Mahara. * * @return array */ function main_nav() { if (in_admin_section()) { global $USER, $SESSION; if ($USER->get('admin')) { $menu = admin_nav(); } else { if ($USER->is_institutional_admin()) { $menu = institutional_admin_nav(); } else { if ($USER->get('staff')) { $menu = staff_nav(); } else { $menu = institutional_staff_nav(); } } } } else { // Build the menu structure for the site $menu = mahara_standard_nav(); } $menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);')); // enable plugins to augment the menu structure foreach (array('artefact', 'interaction', 'module') as $plugintype) { if ($plugins = plugins_installed($plugintype)) { foreach ($plugins as &$plugin) { if (safe_require_plugin($plugintype, $plugin->name)) { $plugin_menu = call_static_method(generate_class_name($plugintype, $plugin->name), 'menu_items'); $menu = array_merge($menu, $plugin_menu); } } } } // local_main_nav_update allows sites to customise the menu by munging the $menu array. if (function_exists('local_main_nav_update')) { local_main_nav_update($menu); } $menu_structure = find_menu_children($menu, ''); return $menu_structure; }