navigation MDL-22209 Added a callback for local plugins to allow them to add to the navigation.

This commit is contained in:
Sam Hemelryk 2010-04-27 09:26:42 +00:00
parent d55a8be82b
commit a683da3ca1

View File

@ -808,7 +808,7 @@ class global_navigation extends navigation_node {
* @return bool
*/
public function initialise() {
global $SITE, $USER;
global $CFG, $SITE, $USER;
// Check if it has alread been initialised
if ($this->initialised || during_initial_install()) {
return true;
@ -912,6 +912,18 @@ class global_navigation extends navigation_node {
}
}
// Give the local plugins a chance to include some navigation if they want.
foreach (get_list_of_plugins('local') as $plugin) {
if (!file_exists($CFG->dirroot.'/local/'.$plugin.'/lib.php')) {
continue;
}
require_once($CFG->dirroot.'/local/'.$plugin.'/lib.php');
$function = $plugin.'_extends_navigation';
if (function_exists($function)) {
$function($this);
}
}
// Remove any empty root nodes
foreach ($this->rootnodes as $node) {
if (!$node->has_children()) {