From 3175908906622b76b9e1afa3c95d1ae2a36d17cf Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Tue, 8 Sep 2009 08:43:44 +0000 Subject: [PATCH] navigation MDL-20235 Added ignore_active method for navbar and corrected user/view --- lang/en_utf8/moodle.php | 3 +-- lib/navigationlib.php | 19 ++++++++++++++----- user/tabs.php | 2 +- user/view.php | 1 + 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index d82b0a968f9..6d647fada6e 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -1680,7 +1680,6 @@ $string['usernamelowercase'] = 'Only lowercase letters allowed'; $string['usernamenotfound'] = 'The username was not found in the database'; $string['usernotconfirmed'] = 'Could not confirm $a'; $string['userpic'] = 'User picture'; -$string['userprofilefor'] = 'User profile for $a'; $string['users'] = 'Users'; $string['userselectorpreserveselected'] = 'Keep selected users, even if they no longer match the search'; $string['userselectorautoselectunique'] = 'If only one user matches the search, select them automatically'; @@ -1695,7 +1694,7 @@ $string['valuealreadyused'] = 'This value has already been used.'; $string['version'] = 'Version'; $string['view'] = 'View'; $string['viewfileinpopup'] = 'View file in a popup window'; -$string['viewmyprofile'] = 'View my profile'; +$string['viewprofile'] = 'View profile'; $string['views'] = 'Views'; $string['viewsolution'] = 'view solution'; $string['virusfound'] = 'Attention administrator! Clam AV has found a virus in a file uploaded by $a->user for the course $a->course. Here is the output of clamscan:'; diff --git a/lib/navigationlib.php b/lib/navigationlib.php index fca1f755cbc..c6f918fc924 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1793,6 +1793,8 @@ class navbar extends navigation_node { /** @var page object */ protected $page; /** @var bool */ + protected $ignoreactive = false; + /** @var bool */ protected $duringinstall = false; /** @@ -1822,7 +1824,14 @@ class navbar extends navigation_node { return false; } $this->page->navigation->initialise(); - return (count($this->page->navbar->children)>0 || $this->page->navigation->contains_active_node() || $this->page->settingsnav->contains_active_node()); + return (count($this->page->navbar->children)>0 || (!$this->ignoreactive && ( + $this->page->navigation->contains_active_node() || + $this->page->settingsnav->contains_active_node()) + )); + } + + public function ignore_active($setting=true) { + $this->ignoreactive = ($setting); } /** @@ -1857,10 +1866,10 @@ class navbar extends navigation_node { $customchildren = (count($this->children) > 0); // Check if navigation contains the active node - if ($this->page->navigation->contains_active_node()) { + if (!$this->ignoreactive && $this->page->navigation->contains_active_node()) { // Parse the navigation tree to get the active node $output .= $this->parse_branch_to_html($this->page->navigation->children, true, $customchildren); - } else if ($this->page->settingsnav->contains_active_node()) { + } else if (!$this->ignoreactive && $this->page->settingsnav->contains_active_node()) { // Parse the settings navigation to get the active node $output .= $this->parse_branch_to_html($this->page->settingsnav->children, true, $customchildren); } else { @@ -2688,9 +2697,9 @@ class settings_navigation extends navigation_node { // Add a link to view the user profile if ($currentuser) { - $usersetting->add(get_string('viewmyprofile'), $profileurl, self::TYPE_SETTING); + $usersetting->add(get_string('viewprofile'), $profileurl, self::TYPE_SETTING); } else { - $usersetting->add(get_string('userprofilefor','',$fullname), $profileurl, self::TYPE_SETTING); + $usersetting->add(get_string('viewprofile','',$fullname), $profileurl, self::TYPE_SETTING); } // Add the profile edit link diff --git a/user/tabs.php b/user/tabs.php index 181351721cd..00d7f16de7a 100644 --- a/user/tabs.php +++ b/user/tabs.php @@ -97,7 +97,7 @@ $personalcontext = get_context_instance(CONTEXT_USER, $user->id); if ($user->id == $USER->id || has_capability('moodle/user:viewdetails', $coursecontext) || has_capability('moodle/user:viewdetails', $personalcontext) ) { - $toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id, get_string('profile')); + $toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id, get_string('viewprofile')); } diff --git a/user/view.php b/user/view.php index 57ab8a03248..509d2351ba9 100644 --- a/user/view.php +++ b/user/view.php @@ -78,6 +78,7 @@ if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) { $link = new moodle_url($CFG->wwwroot."/user/index.php", array('id'=>$course->id)); } + $PAGE->navbar->ignore_active(); $PAGE->navbar->add($strparticipants, $link); /// If the user being shown is not ourselves, then make sure we are allowed to see them!