From a683da3ca1d077542aaf8b5d438361d44ee59855 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Tue, 27 Apr 2010 09:26:42 +0000 Subject: [PATCH] navigation MDL-22209 Added a callback for local plugins to allow them to add to the navigation. --- lib/navigationlib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index e4a178742be..a5a7acce223 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -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()) {