navigation MDL-20235 Added ignore_active method for navbar and corrected user/view
authorsamhemelryk <samhemelryk>
Tue, 8 Sep 2009 08:43:44 +0000 (08:43 +0000)
committersamhemelryk <samhemelryk>
Tue, 8 Sep 2009 08:43:44 +0000 (08:43 +0000)
lang/en_utf8/moodle.php
lib/navigationlib.php
user/tabs.php
user/view.php

index d82b0a968f95bb1c6c4fc727f167c4528a76de8d..6d647fada6ea298301f1e1b0cc3b3de583150ce8 100644 (file)
@@ -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:';
index fca1f755cbce37dee0058debe856d79220cc1a4f..c6f918fc924af09a9fbf8cba334f059bc2ecb16e 100644 (file)
@@ -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
index 181351721cd035d60de59c36feeacea986fd2517..00d7f16de7a7bc126405cc0fffe06fe4f142e580 100644 (file)
@@ -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.'&amp;course='.$course->id, get_string('profile'));
+            $toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id, get_string('viewprofile'));
         }
 
 
index 57ab8a03248be0d9537bb1a4f8918ac32187cec0..509d2351ba9b4c4782911aef46dfcb9bc34d32f7 100644 (file)
@@ -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!