MDL-48935 navigation: Update the user nav breadcrumbs.
authorAdrian Greeve <adrian@moodle.com>
Thu, 19 Mar 2015 02:59:27 +0000 (10:59 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 10 Apr 2015 09:17:07 +0000 (17:17 +0800)
Part of MDL-45774.

19 files changed:
admin/roles/check.php
admin/roles/permissions.php
blog/edit.php
blog/index.php
course/user.php
grade/report/overview/index.php
index.php
lang/en/moodle.php
lib/navigationlib.php
lib/outputrenderers.php
message/edit.php
message/index.php
mod/forum/user.php
my/index.php
notes/index.php
theme/bootstrapbase/renderers/core_renderer.php
user/editadvanced.php
user/preferences.php
user/profile.php

index 938fc90..79c697b 100644 (file)
@@ -52,6 +52,7 @@ if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
 $PAGE->set_url($url);
 
 if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
+    $PAGE->navbar->includesettingsbase = true;
     $PAGE->navigation->extend_for_user($user);
     $PAGE->set_context(context_course::instance($course->id));
 } else {
index 01ddbaa..841732d 100644 (file)
@@ -59,6 +59,7 @@ require_capability('moodle/role:review', $context);
 $PAGE->set_url($url);
 
 if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
+    $PAGE->navbar->includesettingsbase = true;
     $PAGE->navigation->extend_for_user($user);
     $PAGE->set_context(context_user::instance($user->id));
 } else {
index 783a2bd..1963c28 100644 (file)
@@ -51,6 +51,8 @@ if (!empty($id) && $action == 'add') {
 $sitecontext = context_system::instance();
 $usercontext = context_user::instance($USER->id);
 $PAGE->set_context($usercontext);
+$blognode = $PAGE->settingsnav->find('blogadd', null);
+$blognode->make_active();
 
 require_login($courseid);
 
index 0c9a7f6..0f43d24 100644 (file)
@@ -66,6 +66,11 @@ $PAGE->set_context($context);
 
 $sitecontext = context_system::instance();
 
+if (isset($userid) && $USER->id == $userid) {
+    $blognode = $PAGE->navigation->find('siteblog', null);
+    $blognode->make_inactive();
+}
+
 // Check basic permissions.
 if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
     // Everybody can see anything - no login required unless site is locked down using forcelogin.
index 3320c3e..879ac71 100644 (file)
@@ -139,6 +139,8 @@ switch ($mode) {
             $coursenode = $PAGE->navigation->find($course->id, navigation_node::TYPE_COURSE);
             $coursenode->collapse = true;
             $coursenode->make_inactive();
+            $url = new moodle_url('/course/user.php', array('id' => $id, 'user' => $user->id, 'mode' => $mode));
+            $reportnode = $PAGE->navbar->add(get_string('pluginname', 'gradereport_user'), $url);
         }
         echo $OUTPUT->header();
 
index 513ec54..80def1c 100644 (file)
@@ -61,6 +61,8 @@ if (isset($personalcontext)) {
 } else {
     $PAGE->set_context($context);
 }
+$settings = $PAGE->settingsnav->find('mygrades', null);
+$settings->make_active();
 
 $access = false;
 if (has_capability('moodle/grade:viewall', $systemcontext)) {
index a54e202..9c9bdef 100644 (file)
--- a/index.php
+++ b/index.php
@@ -71,7 +71,7 @@ if (get_home_page() != HOMEPAGE_SITE) {
     } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && $redirect === 1) {
         redirect($CFG->wwwroot .'/my/');
     } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) {
-        $PAGE->settingsnav->get('usercurrentsettings')->add(
+        $PAGE->settingsnav->find('usercurrentsettings', null)->add(
             get_string('makethismyhome'),
             new moodle_url('/', array('setdefaulthome' => true)),
             navigation_node::TYPE_SETTING);
index b0f8ace..6287de5 100644 (file)
@@ -1908,7 +1908,6 @@ $string['usemessageform'] = 'or use the form below to send a message to the sele
 $string['user'] = 'User';
 $string['useraccount'] = 'User account';
 $string['userconfirmed'] = 'Confirmed {$a}';
-$string['usercurrentsettings'] = 'Preferences';
 $string['useractivity'] = 'Activity';
 $string['userdata'] = 'User data';
 $string['userdeleted'] = 'This user account has been deleted';
@@ -1935,7 +1934,6 @@ $string['usersnew'] = 'New users';
 $string['usersnoaccesssince'] = 'Inactive for more than';
 $string['userswithfiles'] = 'Users with files';
 $string['useruploadtype'] = 'User upload type: {$a}';
-$string['userviewingsettings'] = '{$a}\'s preferences';
 $string['userzones'] = 'User zones';
 $string['usetheme'] = 'Use theme';
 $string['usingexistingcourse'] = 'Using existing course';
index 921fe30..e57e7d5 100644 (file)
@@ -382,7 +382,7 @@ class navigation_node implements renderable {
     /**
      * Get the child of this node that has the given key + (optional) type.
      *
-     * If you are looking for a node and want to search all children + thier children
+     * If you are looking for a node and want to search all children + their children
      * then please use the find method instead.
      *
      * @param int|string $key The key of the node we are looking for
@@ -2153,197 +2153,202 @@ class global_navigation extends navigation_node {
         }
 
         // Create a node to add user information under.
-        if ($iscurrentuser && !$forceforcontext) {
-            // If it's the current user the information will go under the profile root node
-            $usernode = $this->rootnodes['myprofile'];
-            $course = get_site();
-            $coursecontext = context_course::instance($course->id);
-            $issitecourse = true;
-        } else {
-            if (!$issitecourse) {
-                // Not the current user so add it to the participants node for the current course
-                $usersnode = $coursenode->get('participants', navigation_node::TYPE_CONTAINER);
-                $userviewurl = new moodle_url('/user/view.php', $baseargs);
-            } else {
-                // This is the site so add a users node to the root branch
-                $usersnode = $this->rootnodes['users'];
-                if (has_capability('moodle/course:viewparticipants', $coursecontext)) {
-                    $usersnode->action = new moodle_url('/user/index.php', array('id'=>$course->id));
-                }
-                $userviewurl = new moodle_url('/user/profile.php', $baseargs);
-            }
-            if (!$usersnode) {
-                // We should NEVER get here, if the course hasn't been populated
-                // with a participants node then the navigaiton either wasn't generated
-                // for it (you are missing a require_login or set_context call) or
-                // you don't have access.... in the interests of no leaking informatin
-                // we simply quit...
-                return false;
-            }
-            // Add a branch for the current user
-            $canseefullname = has_capability('moodle/site:viewfullnames', $coursecontext);
-            $usernode = $usersnode->add(fullname($user, $canseefullname), $userviewurl, self::TYPE_USER, null, $user->id);
-
-            if ($this->page->context->contextlevel == CONTEXT_USER && $user->id == $this->page->context->instanceid) {
-                $usernode->make_active();
-            }
+        $usersnode = null;
+        if (!$issitecourse) {
+            // Not the current user so add it to the participants node for the current course.
+            $usersnode = $coursenode->get('participants', navigation_node::TYPE_CONTAINER);
+            $userviewurl = new moodle_url('/user/view.php', $baseargs);
+        } else if ($USER->id != $user->id) {
+            // This is the site so add a users node to the root branch.
+            $usersnode = $this->rootnodes['users'];
+            if (has_capability('moodle/course:viewparticipants', $coursecontext)) {
+                $usersnode->action = new moodle_url('/user/index.php', array('id'=>$course->id));
+            }
+            $userviewurl = new moodle_url('/user/profile.php', $baseargs);
+        }
+        if (!$usersnode) {
+            // We should NEVER get here, if the course hasn't been populated
+            // with a participants node then the navigaiton either wasn't generated
+            // for it (you are missing a require_login or set_context call) or
+            // you don't have access.... in the interests of no leaking informatin
+            // we simply quit...
+            return false;
         }
-
-        // If the user is the current user or has permission to view the details of the requested
-        // user than add a view profile link.
-        if ($iscurrentuser || has_capability('moodle/user:viewdetails', $coursecontext) || has_capability('moodle/user:viewdetails', $usercontext)) {
-            if ($issitecourse || ($iscurrentuser && !$forceforcontext)) {
-                $usernode->add(get_string('viewprofile'), new moodle_url('/user/profile.php',$baseargs));
-            } else {
-                $usernode->add(get_string('viewprofile'), new moodle_url('/user/view.php',$baseargs));
-            }
+        // Add a branch for the current user.
+        $canseefullname = has_capability('moodle/site:viewfullnames', $coursecontext);
+        $usernode = $usersnode->add(fullname($user, $canseefullname), $userviewurl, self::TYPE_USER, null, 'user' . $user->id);
+        if ($this->page->context->contextlevel == CONTEXT_USER && $user->id == $this->page->context->instanceid) {
+            $usernode->make_active();
         }
 
-        if (!empty($CFG->navadduserpostslinks)) {
-            // Add nodes for forum posts and discussions if the user can view either or both
-            // There are no capability checks here as the content of the page is based
-            // purely on the forums the current user has access too.
-            $forumtab = $usernode->add(get_string('forumposts', 'forum'));
-            $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs));
-            $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode'=>'discussions'))));
-        }
+        // Add user information to the participants or user node.
+        if ($issitecourse) {
 
-        // Add blog nodes
-        if (!empty($CFG->enableblogs)) {
-            if (!$this->cache->cached('userblogoptions'.$user->id)) {
-                require_once($CFG->dirroot.'/blog/lib.php');
-                // Get all options for the user
-                $options = blog_get_options_for_user($user);
-                $this->cache->set('userblogoptions'.$user->id, $options);
-            } else {
-                $options = $this->cache->{'userblogoptions'.$user->id};
+            // If the user is the current user or has permission to view the details of the requested
+            // user than add a view profile link.
+            if ($iscurrentuser || has_capability('moodle/user:viewdetails', $coursecontext) ||
+                    has_capability('moodle/user:viewdetails', $usercontext)) {
+                if ($issitecourse || ($iscurrentuser && !$forceforcontext)) {
+                    $usernode->add(get_string('viewprofile'), new moodle_url('/user/profile.php',$baseargs));
+                } else {
+                    $usernode->add(get_string('viewprofile'), new moodle_url('/user/view.php',$baseargs));
+                }
             }
 
-            if (count($options) > 0) {
-                $blogs = $usernode->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER);
-                foreach ($options as $type => $option) {
-                    if ($type == "rss") {
-                        $blogs->add($option['string'], $option['link'], settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
-                    } else {
-                        $blogs->add($option['string'], $option['link']);
+            if (!empty($CFG->navadduserpostslinks)) {
+                // Add nodes for forum posts and discussions if the user can view either or both
+                // There are no capability checks here as the content of the page is based
+                // purely on the forums the current user has access too.
+                $forumtab = $usernode->add(get_string('forumposts', 'forum'));
+                $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs));
+                $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
+                        array_merge($baseargs, array('mode'=>'discussions'))));
+            }
+
+            // Add blog nodes.
+            if (!empty($CFG->enableblogs)) {
+                if (!$this->cache->cached('userblogoptions'.$user->id)) {
+                    require_once($CFG->dirroot.'/blog/lib.php');
+                    // Get all options for the user.
+                    $options = blog_get_options_for_user($user);
+                    $this->cache->set('userblogoptions'.$user->id, $options);
+                } else {
+                    $options = $this->cache->{'userblogoptions'.$user->id};
+                }
+
+                if (count($options) > 0) {
+                    $blogs = $usernode->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER);
+                    foreach ($options as $type => $option) {
+                        if ($type == "rss") {
+                            $blogs->add($option['string'], $option['link'], settings_navigation::TYPE_SETTING, null, null,
+                                    new pix_icon('i/rss', ''));
+                        } else {
+                            $blogs->add($option['string'], $option['link']);
+                        }
                     }
                 }
             }
-        }
 
-        // Add the messages link.
-        // It is context based so can appear in "My profile" and in course participants information.
-        if (!empty($CFG->messaging)) {
-            $messageargs = array('user1' => $USER->id);
-            if ($USER->id != $user->id) {
-                $messageargs['user2'] = $user->id;
-            }
-            if ($course->id != $SITE->id) {
-                $messageargs['viewing'] = MESSAGE_VIEW_COURSE. $course->id;
+            // Add the messages link.
+            // It is context based so can appear in "My profile" and in course participants information.
+            if (!empty($CFG->messaging)) {
+                $messageargs = array('user1' => $USER->id);
+                if ($USER->id != $user->id) {
+                    $messageargs['user2'] = $user->id;
+                }
+                if ($course->id != $SITE->id) {
+                    $messageargs['viewing'] = MESSAGE_VIEW_COURSE. $course->id;
+                }
+                $url = new moodle_url('/message/index.php',$messageargs);
+                $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
             }
-            $url = new moodle_url('/message/index.php',$messageargs);
-            $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
-        }
-
-        // Add the "My private files" link.
-        // This link doesn't have a unique display for course context so only display it under "My profile".
-        if ($issitecourse && $iscurrentuser && has_capability('moodle/user:manageownfiles', $usercontext)) {
-            $url = new moodle_url('/user/files.php');
-            $usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING);
-        }
 
-        if (!empty($CFG->enablebadges) && $iscurrentuser &&
-                has_capability('moodle/badges:manageownbadges', $usercontext)) {
-            $url = new moodle_url('/badges/mybadges.php');
-            $usernode->add(get_string('mybadges', 'badges'), $url, self::TYPE_SETTING);
-        }
+            // Add the "My private files" link.
+            // This link doesn't have a unique display for course context so only display it under "My profile".
+            if ($issitecourse && $iscurrentuser && has_capability('moodle/user:manageownfiles', $usercontext)) {
+                $url = new moodle_url('/user/files.php');
+                $usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING);
+            }
 
-        // Add a node to view the users notes if permitted
-        if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $coursecontext)) {
-            $url = new moodle_url('/notes/index.php',array('user'=>$user->id));
-            if ($coursecontext->instanceid != SITEID) {
-                $url->param('course', $coursecontext->instanceid);
+            if (!empty($CFG->enablebadges) && $iscurrentuser &&
+                    has_capability('moodle/badges:manageownbadges', $usercontext)) {
+                $url = new moodle_url('/badges/mybadges.php');
+                $usernode->add(get_string('mybadges', 'badges'), $url, self::TYPE_SETTING);
             }
-            $usernode->add(get_string('notes', 'notes'), $url);
-        }
 
-        // Show the my grades node.
-        if (($issitecourse && $iscurrentuser) || has_capability('moodle/user:viewdetails', $usercontext)) {
-            require_once($CFG->dirroot . '/user/lib.php');
-            // Set the grades node to link to the "My grades" page.
-            if ($course->id == SITEID) {
-                $url = user_mygrades_url($user->id, $course->id);
-            } else { // Otherwise we are in a course and should redirect to the user grade report (Activity report version).
-                $url = new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id, 'user' => $user->id));
+            // Add a node to view the users notes if permitted.
+            if (!empty($CFG->enablenotes) &&
+                    has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $coursecontext)) {
+                $url = new moodle_url('/notes/index.php',array('user'=>$user->id));
+                if ($coursecontext->instanceid != SITEID) {
+                    $url->param('course', $coursecontext->instanceid);
+                }
+                $usernode->add(get_string('notes', 'notes'), $url);
             }
-            if ($USER->id != $user->id) {
-                $usernode->add(get_string('grades', 'grades'), $url);
-            } else {
-                $usernode->add(get_string('mygrades', 'grades'), $url);
+
+            // Show the my grades node.
+            if (($issitecourse && $iscurrentuser) || has_capability('moodle/user:viewdetails', $usercontext)) {
+                require_once($CFG->dirroot . '/user/lib.php');
+                // Set the grades node to link to the "My grades" page.
+                if ($course->id == SITEID) {
+                    $url = user_mygrades_url($user->id, $course->id);
+                } else { // Otherwise we are in a course and should redirect to the user grade report (Activity report version).
+                    $url = new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id, 'user' => $user->id));
+                }
+                if ($USER->id != $user->id) {
+                    $usernode->add(get_string('grades', 'grades'), $url);
+                } else {
+                    $usernode->add(get_string('mygrades', 'grades'), $url);
+                }
             }
-        }
 
-        // If the user is the current user add the repositories for the current user
-        $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
-        if (!$iscurrentuser &&
-                $course->id == $SITE->id &&
-                has_capability('moodle/user:viewdetails', $usercontext) &&
-                (!in_array('mycourses', $hiddenfields) || has_capability('moodle/user:viewhiddendetails', $coursecontext))) {
+            // If the user is the current user add the repositories for the current user.
+            $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
+            if (!$iscurrentuser &&
+                    $course->id == $SITE->id &&
+                    has_capability('moodle/user:viewdetails', $usercontext) &&
+                    (!in_array('mycourses', $hiddenfields) || has_capability('moodle/user:viewhiddendetails', $coursecontext))) {
 
-            // Add view grade report is permitted
-            $reports = core_component::get_plugin_list('gradereport');
-            arsort($reports); // user is last, we want to test it first
+                // Add view grade report is permitted.
+                $reports = core_component::get_plugin_list('gradereport');
+                arsort($reports); // user is last, we want to test it first.
 
-            $userscourses = enrol_get_users_courses($user->id);
-            $userscoursesnode = $usernode->add(get_string('courses'));
+                $userscourses = enrol_get_users_courses($user->id);
+                $userscoursesnode = $usernode->add(get_string('courses'));
 
-            $count = 0;
-            foreach ($userscourses as $usercourse) {
-                if ($count === (int)$CFG->navcourselimit) {
-                    $url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
-                    $userscoursesnode->add(get_string('showallcourses'), $url);
-                    break;
-                }
-                $count++;
-                $usercoursecontext = context_course::instance($usercourse->id);
-                $usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext));
-                $usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER);
-
-                $gradeavailable = has_capability('moodle/grade:viewall', $usercoursecontext);
-                if (!$gradeavailable && !empty($usercourse->showgrades) && is_array($reports) && !empty($reports)) {
-                    foreach ($reports as $plugin => $plugindir) {
-                        if (has_capability('gradereport/'.$plugin.':view', $usercoursecontext)) {
-                            //stop when the first visible plugin is found
-                            $gradeavailable = true;
-                            break;
+                $count = 0;
+                foreach ($userscourses as $usercourse) {
+                    if ($count === (int)$CFG->navcourselimit) {
+                        $url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
+                        $userscoursesnode->add(get_string('showallcourses'), $url);
+                        break;
+                    }
+                    $count++;
+                    $usercoursecontext = context_course::instance($usercourse->id);
+                    $usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext));
+                    $usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php',
+                            array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER);
+
+                    $gradeavailable = has_capability('moodle/grade:viewall', $usercoursecontext);
+                    if (!$gradeavailable && !empty($usercourse->showgrades) && is_array($reports) && !empty($reports)) {
+                        foreach ($reports as $plugin => $plugindir) {
+                            if (has_capability('gradereport/'.$plugin.':view', $usercoursecontext)) {
+                                //stop when the first visible plugin is found.
+                                $gradeavailable = true;
+                                break;
+                            }
                         }
                     }
-                }
 
-                if ($gradeavailable) {
-                    $url = new moodle_url('/grade/report/index.php', array('id'=>$usercourse->id));
-                    $usercoursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/grades', ''));
-                }
+                    if ($gradeavailable) {
+                        $url = new moodle_url('/grade/report/index.php', array('id'=>$usercourse->id));
+                        $usercoursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, null,
+                                new pix_icon('i/grades', ''));
+                    }
 
-                // Add a node to view the users notes if permitted
-                if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $usercoursecontext)) {
-                    $url = new moodle_url('/notes/index.php',array('user'=>$user->id, 'course'=>$usercourse->id));
-                    $usercoursenode->add(get_string('notes', 'notes'), $url, self::TYPE_SETTING);
-                }
+                    // Add a node to view the users notes if permitted.
+                    if (!empty($CFG->enablenotes) &&
+                            has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $usercoursecontext)) {
+                        $url = new moodle_url('/notes/index.php',array('user'=>$user->id, 'course'=>$usercourse->id));
+                        $usercoursenode->add(get_string('notes', 'notes'), $url, self::TYPE_SETTING);
+                    }
 
-                if (can_access_course($usercourse, $user->id)) {
-                    $usercoursenode->add(get_string('entercourse'), new moodle_url('/course/view.php', array('id'=>$usercourse->id)), self::TYPE_SETTING, null, null, new pix_icon('i/course', ''));
-                }
+                    if (can_access_course($usercourse, $user->id)) {
+                        $usercoursenode->add(get_string('entercourse'), new moodle_url('/course/view.php',
+                                array('id'=>$usercourse->id)), self::TYPE_SETTING, null, null, new pix_icon('i/course', ''));
+                    }
 
-                $reporttab = $usercoursenode->add(get_string('activityreports'));
+                    $reporttab = $usercoursenode->add(get_string('activityreports'));
 
-                $reports = get_plugin_list_with_function('report', 'extend_navigation_user', 'lib.php');
-                foreach ($reports as $reportfunction) {
-                    $reportfunction($reporttab, $user, $usercourse);
-                }
+                    $reports = get_plugin_list_with_function('report', 'extend_navigation_user', 'lib.php');
+                    foreach ($reports as $reportfunction) {
+                        $reportfunction($reporttab, $user, $usercourse);
+                    }
 
-                $reporttab->trim_if_empty();
+                    $reporttab->trim_if_empty();
+                }
             }
+
         }
         return true;
     }
@@ -2618,7 +2623,7 @@ class global_navigation extends navigation_node {
           and ($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
           and has_capability('moodle/blog:view', context_system::instance())) {
             $blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
-            $coursenode->add(get_string('blogssite','blog'), $blogsurls->out());
+            $coursenode->add(get_string('blogssite','blog'), $blogsurls->out(), self::TYPE_SYSTEM, null, 'siteblog');
         }
 
         //Badges
@@ -2629,7 +2634,8 @@ class global_navigation extends navigation_node {
 
         // Notes
         if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) {
-            $coursenode->add(get_string('notes','notes'), new moodle_url('/notes/index.php', array('filtertype'=>'course', 'filterselect'=>$filterselect)));
+            $coursenode->add(get_string('notes','notes'), new moodle_url('/notes/index.php',
+                array('filtertype'=>'course', 'filterselect'=>$filterselect)), self::TYPE_SETTING, null, 'notes');
         }
 
         // Tags
@@ -3269,20 +3275,20 @@ class navbar extends navigation_node {
             }
         }
 
-        if (is_enrolled(context_course::instance($this->page->course->id))) {
-            $courses = $this->page->navigation->get('mycourses');
-        } else {
+        // Don't show the 'course' node if enrolled in this course.
+        if (!is_enrolled(context_course::instance($this->page->course->id))) {
             $courses = $this->page->navigation->get('courses');
+            if (!$courses) {
+                // Courses node may not be present.
+                $courses = navigation_node::create(
+                    get_string('courses'),
+                    new moodle_url('/course/index.php'),
+                    self::TYPE_CONTAINER
+                );
+            }
+            $categories[] = $courses;
         }
-        if (!$courses) {
-            // Courses node may not be present.
-            $courses = navigation_node::create(
-                get_string('courses'),
-                new moodle_url('/course/index.php'),
-                self::TYPE_CONTAINER
-            );
-        }
-        $categories[] = $courses;
+
         return $categories;
     }
 
@@ -4183,21 +4189,130 @@ class settings_navigation extends navigation_node {
             $prefurl->param('userid', $userid);
         }
 
-        // Add a user setting branch
-        $usersetting = $this->add(get_string($gstitle, 'moodle', $fullname), $prefurl, self::TYPE_CONTAINER, null, $key);
-        $usersetting->id = 'usersettings';
-        if ($this->page->context->contextlevel == CONTEXT_USER && $this->page->context->instanceid == $user->id) {
-            // Automatically start by making it active
-            $usersetting->make_active();
+        // Add a user setting branch.
+        if ($gstitle == 'usercurrentsettings') {
+            $dashboard = $this->add('Dashboard', new moodle_url('/my/'), self::TYPE_CONTAINER, null, 'dashboard');
+            // This should be set to false as we don't want to show this to the user. It's only for generating the correct
+            // breadcrumb.
+            $dashboard->display = false;
+
+            $iscurrentuser = ($user->id == $USER->id);
+
+            $baseargs = array('id'=>$user->id);
+            if ($course->id != $SITE->id && !$iscurrentuser) {
+                $baseargs['course'] = $course->id;
+                $issitecourse = false;
+            } else {
+                // Load all categories and get the context for the system.
+                $issitecourse = true;
+            }
+
+            // Add the user profile to the dashboard.
+            $profilenode = $dashboard->add(get_string('myprofile'), new moodle_url('/user/profile.php',
+                    array('id' => $user->id)), null, 'myprofile');
+
+            if (!empty($CFG->navadduserpostslinks)) {
+                // Add nodes for forum posts and discussions if the user can view either or both
+                // There are no capability checks here as the content of the page is based
+                // purely on the forums the current user has access too.
+                $forumtab = $dashboard->add(get_string('forumposts', 'forum'));
+                $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs), null, 'myposts');
+                $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
+                        array_merge($baseargs, array('mode'=>'discussions'))), null, 'mydiscussions');
+            }
+
+            // Add blog nodes.
+            if (!empty($CFG->enableblogs)) {
+                if (!$this->cache->cached('userblogoptions'.$user->id)) {
+                    require_once($CFG->dirroot.'/blog/lib.php');
+                    // Get all options for the user.
+                    $options = blog_get_options_for_user($user);
+                    $this->cache->set('userblogoptions'.$user->id, $options);
+                } else {
+                    $options = $this->cache->{'userblogoptions'.$user->id};
+                }
+
+                if (count($options) > 0) {
+                    $blogs = $dashboard->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER);
+                    foreach ($options as $type => $option) {
+                        if ($type == "rss") {
+                            $blogs->add($option['string'], $option['link'], settings_navigation::TYPE_SETTING, null, null,
+                                    new pix_icon('i/rss', ''));
+                        } else {
+                            $blogs->add($option['string'], $option['link'], self::TYPE_SETTING, null, 'blog' . $type);
+                        }
+                    }
+                }
+            }
+
+            // Add the messages link.
+            // It is context based so can appear in "My profile" and in course participants information.
+            if (!empty($CFG->messaging)) {
+                $messageargs = array('user1' => $USER->id);
+                if ($USER->id != $user->id) {
+                    $messageargs['user2'] = $user->id;
+                }
+                if ($course->id != $SITE->id) {
+                    $messageargs['viewing'] = MESSAGE_VIEW_COURSE. $course->id;
+                }
+                $url = new moodle_url('/message/index.php',$messageargs);
+                $dashboard->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
+            }
+
+            // Add the "My private files" link.
+            // This link doesn't have a unique display for course context so only display it under "My profile".
+            if ($issitecourse && $iscurrentuser && has_capability('moodle/user:manageownfiles', $usercontext)) {
+                $url = new moodle_url('/user/files.php');
+                $dashboard->add(get_string('myfiles'), $url, self::TYPE_SETTING);
+            }
+
+            if (!empty($CFG->enablebadges) && $iscurrentuser &&
+                    has_capability('moodle/badges:manageownbadges', $usercontext)) {
+                $url = new moodle_url('/badges/mybadges.php');
+                $dashboard->add(get_string('mybadges', 'badges'), $url, self::TYPE_SETTING);
+            }
+
+            // Add a node to view the users notes if permitted.
+            if (!empty($CFG->enablenotes) &&
+                    has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $coursecontext)) {
+                $url = new moodle_url('/notes/index.php',array('user'=>$user->id));
+                if ($coursecontext->instanceid != SITEID) {
+                    $url->param('course', $coursecontext->instanceid);
+                }
+                $dashboard->add(get_string('notes', 'notes'), $url);
+            }
+
+            // Show the my grades node.
+            if (($issitecourse && $iscurrentuser) || has_capability('moodle/user:viewdetails', $usercontext)) {
+                require_once($CFG->dirroot . '/user/lib.php');
+                // Set the grades node to link to the "My grades" page.
+                if ($course->id == SITEID) {
+                    $url = user_mygrades_url($user->id, $course->id);
+                } else { // Otherwise we are in a course and should redirect to the user grade report (Activity report version).
+                    $url = new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id, 'user' => $user->id));
+                }
+                if ($USER->id != $user->id) {
+                    $dashboard->add(get_string('grades', 'grades'), $url, self::TYPE_SETTING, null, 'mygrades');
+                } else {
+                    $dashboard->add(get_string('mygrades', 'grades'), $url, self::TYPE_SETTING, null, 'mygrades');
+                }
+            }
+            $usersetting = navigation_node::create(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
+            $dashboard->add_node($usersetting);
+        } else {
+            $usersetting = $this->add(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
+            // Set to false when a link to preferences has been added to the my profile page. MDL-45900.
+            $usersetting->display = true;
         }
+        $usersetting->id = 'usersettings';
 
-        // Check if the user has been deleted
+        // Check if the user has been deleted.
         if ($user->deleted) {
             if (!has_capability('moodle/user:update', $coursecontext)) {
-                // We can't edit the user so just show the user deleted message
+                // We can't edit the user so just show the user deleted message.
                 $usersetting->add(get_string('userdeleted'), null, self::TYPE_SETTING);
             } else {
-                // We can edit the user so show the user deleted message and link it to the profile
+                // We can edit the user so show the user deleted message and link it to the profile.
                 if ($course->id == $SITE->id) {
                     $profileurl = new moodle_url('/user/profile.php', array('id'=>$user->id));
                 } else {
@@ -4215,12 +4330,14 @@ class settings_navigation extends navigation_node {
 
         $useraccount = $usersetting->add(get_string('useraccount'), null, self::TYPE_CONTAINER, null, 'useraccount');
 
-        // Add the profile edit link
+        // Add the profile edit link.
         if (isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) {
-            if (($currentuser || is_siteadmin($USER) || !is_siteadmin($user)) && has_capability('moodle/user:update', $systemcontext)) {
+            if (($currentuser || is_siteadmin($USER) || !is_siteadmin($user)) &&
+                    has_capability('moodle/user:update', $systemcontext)) {
                 $url = new moodle_url('/user/editadvanced.php', array('id'=>$user->id, 'course'=>$course->id));
                 $useraccount->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
-            } else if ((has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user)) || ($currentuser && has_capability('moodle/user:editownprofile', $systemcontext))) {
+            } else if ((has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user)) ||
+                    ($currentuser && has_capability('moodle/user:editownprofile', $systemcontext))) {
                 if ($userauthplugin && $userauthplugin->can_edit_profile()) {
                     $url = $userauthplugin->edit_profile_url();
                     if (empty($url)) {
@@ -4231,8 +4348,9 @@ class settings_navigation extends navigation_node {
             }
         }
 
-        // Change password link
-        if ($userauthplugin && $currentuser && !\core\session\manager::is_loggedinas() && !isguestuser() && has_capability('moodle/user:changeownpassword', $systemcontext) && $userauthplugin->can_change_password()) {
+        // Change password link.
+        if ($userauthplugin && $currentuser && !\core\session\manager::is_loggedinas() && !isguestuser() &&
+                has_capability('moodle/user:changeownpassword', $systemcontext) && $userauthplugin->can_change_password()) {
             $passwordchangeurl = $userauthplugin->change_password_url();
             if (empty($passwordchangeurl)) {
                 $passwordchangeurl = new moodle_url('/login/change_password.php', array('id'=>$course->id));
@@ -4240,8 +4358,9 @@ class settings_navigation extends navigation_node {
             $useraccount->add(get_string("changepassword"), $passwordchangeurl, self::TYPE_SETTING, null, 'changepassword');
         }
 
-        // View the roles settings
-        if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:manage'), $usercontext)) {
+        // View the roles settings.
+        if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:manage'),
+                $usercontext)) {
             $roles = $usersetting->add(get_string('roles'), null, self::TYPE_SETTING);
 
             $url = new moodle_url('/admin/roles/usersroles.php', array('userid'=>$user->id, 'courseid'=>$course->id));
@@ -4250,16 +4369,19 @@ class settings_navigation extends navigation_node {
             $assignableroles = get_assignable_roles($usercontext, ROLENAME_BOTH);
 
             if (!empty($assignableroles)) {
-                $url = new moodle_url('/admin/roles/assign.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
+                $url = new moodle_url('/admin/roles/assign.php',
+                        array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
                 $roles->add(get_string('assignrolesrelativetothisuser', 'role'), $url, self::TYPE_SETTING);
             }
 
             if (has_capability('moodle/role:review', $usercontext) || count(get_overridable_roles($usercontext, ROLENAME_BOTH))>0) {
-                $url = new moodle_url('/admin/roles/permissions.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
+                $url = new moodle_url('/admin/roles/permissions.php',
+                        array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
                 $roles->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
             }
 
-            $url = new moodle_url('/admin/roles/check.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
+            $url = new moodle_url('/admin/roles/check.php',
+                    array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
             $roles->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
         }
 
@@ -4279,7 +4401,7 @@ class settings_navigation extends navigation_node {
                 array('contextid' => $usercontext->id)));
         }
 
-        // Portfolio
+        // Portfolio.
         if ($currentuser && !empty($CFG->enableportfolios) && has_capability('moodle/portfolio:export', $systemcontext)) {
             require_once($CFG->libdir . '/portfoliolib.php');
             if (portfolio_has_visible_instances()) {
@@ -4301,25 +4423,29 @@ class settings_navigation extends navigation_node {
              && has_capability('moodle/webservice:createtoken', context_system::instance()) ) {
             $enablemanagetokens = true;
         }
-        // Security keys
+        // Security keys.
         if ($currentuser && $enablemanagetokens) {
             $url = new moodle_url('/user/managetoken.php', array('sesskey'=>sesskey()));
             $useraccount->add(get_string('securitykeys', 'webservice'), $url, self::TYPE_SETTING);
         }
 
-        // Messaging
-        if (($currentuser && has_capability('moodle/user:editownmessageprofile', $systemcontext)) || (!isguestuser($user) && has_capability('moodle/user:editmessageprofile', $usercontext) && !is_primary_admin($user->id))) {
+        // Messaging.
+        if (($currentuser && has_capability('moodle/user:editownmessageprofile', $systemcontext)) || (!isguestuser($user) &&
+                has_capability('moodle/user:editmessageprofile', $usercontext) && !is_primary_admin($user->id))) {
             $url = new moodle_url('/message/edit.php', array('id'=>$user->id));
             $useraccount->add(get_string('messaging', 'message'), $url, self::TYPE_SETTING);
         }
 
-        // Blogs
+        // Blogs.
         if ($currentuser && !empty($CFG->enableblogs)) {
             $blog = $usersetting->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER, null, 'blogs');
             $blog->add(get_string('preferences', 'blog'), new moodle_url('/blog/preferences.php'), navigation_node::TYPE_SETTING);
-            if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', context_system::instance())) {
-                $blog->add(get_string('externalblogs', 'blog'), new moodle_url('/blog/external_blogs.php'), navigation_node::TYPE_SETTING);
-                $blog->add(get_string('addnewexternalblog', 'blog'), new moodle_url('/blog/external_blog_edit.php'), navigation_node::TYPE_SETTING);
+            if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 &&
+                    has_capability('moodle/blog:manageexternal', context_system::instance())) {
+                $blog->add(get_string('externalblogs', 'blog'), new moodle_url('/blog/external_blogs.php'),
+                        navigation_node::TYPE_SETTING);
+                $blog->add(get_string('addnewexternalblog', 'blog'), new moodle_url('/blog/external_blog_edit.php'),
+                        navigation_node::TYPE_SETTING);
             }
         }
 
@@ -4328,7 +4454,8 @@ class settings_navigation extends navigation_node {
             $badges = $usersetting->add(get_string('badges'), null, navigation_node::TYPE_CONTAINER, null, 'badges');
             $badges->add(get_string('preferences'), new moodle_url('/badges/preferences.php'), navigation_node::TYPE_SETTING);
             if (!empty($CFG->badges_allowexternalbackpack)) {
-                $badges->add(get_string('backpackdetails', 'badges'), new moodle_url('/badges/mybackpack.php'), navigation_node::TYPE_SETTING);
+                $badges->add(get_string('backpackdetails', 'badges'), new moodle_url('/badges/mybackpack.php'),
+                        navigation_node::TYPE_SETTING);
             }
         }
 
@@ -4339,11 +4466,12 @@ class settings_navigation extends navigation_node {
             $reportfunction($reporttab, $user, $course);
         }
 
-        // Check the number of nodes in the report node... if there are none remove the node
+        // Check the number of nodes in the report node... if there are none remove the node.
         $reporttab->trim_if_empty();
 
         // Login as ...
-        if (!$user->deleted and !$currentuser && !\core\session\manager::is_loggedinas() && has_capability('moodle/user:loginas', $coursecontext) && !is_siteadmin($user->id)) {
+        if (!$user->deleted and !$currentuser && !\core\session\manager::is_loggedinas() &&
+                has_capability('moodle/user:loginas', $coursecontext) && !is_siteadmin($user->id)) {
             $url = new moodle_url('/course/loginas.php', array('id'=>$course->id, 'user'=>$user->id, 'sesskey'=>sesskey()));
             $useraccount->add(get_string('loginas'), $url, self::TYPE_SETTING);
         }
index 1bd2d99..059e27c 100644 (file)
@@ -3388,6 +3388,11 @@ EOD;
             return '';
         }
 
+        // Remove the Dashboard node from the breadcrumb. This saves doubling up of the same link.
+        if (get_home_page()) {
+            array_shift($items);
+        }
+
         $htmlblocks = array();
         // Iterate the navarray and display each node
         $separator = get_separator();
index c4172df..55daa9f 100644 (file)
@@ -70,6 +70,7 @@ if ($user->id == $USER->id) {
     if (is_siteadmin($user) and !is_siteadmin($USER)) {
         print_error('useradmineditadmin');
     }
+    $PAGE->navbar->includesettingsbase = true;
     $PAGE->navigation->extend_for_user($user);
 }
 
index 56070bb..9423419 100644 (file)
@@ -200,6 +200,19 @@ if ($user2realuser) {
 }
 $PAGE->set_heading(fullname($USER));
 
+// Remove the user node from the main navigation for this page.
+$usernode = $PAGE->navigation->find('users', null);
+$usernode->remove();
+
+$settings = $PAGE->settingsnav->find('messages', null);
+// Add the user we are contacting to the breadcrumb.
+if (!empty($user2realuser)) {
+    $usernode = $settings->add(fullname($user2), new moodle_url('/user/profile.php', array('id' => $user2->id)));
+    $usernode->make_active();
+} else {
+    $settings->make_active();
+}
+
 //now the page contents
 echo $OUTPUT->header();
 
index b52f807..de07281 100644 (file)
@@ -178,9 +178,43 @@ if (empty($result->posts)) {
         } else {
             $notification = get_string('nopostsmadebyyou', 'forum');
         }
+        // These are the user's forum interactions.
+        // Shut down the navigation 'Users' node.
+        $usernode = $PAGE->navigation->find('users', null);
+        $usernode->make_inactive();
+        // Edit navbar.
+        if (isset($courseid) && $courseid != SITEID) {
+            // Create as much of the navbar automatically.
+            $newusernode = $PAGE->navigation->find('user' . $user->id, null);
+            $newusernode->make_active();
+            // Check to see if this is a discussion or a post.
+            if ($mode == 'posts') {
+                $navbar = $PAGE->navbar->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php',
+                        array('id' => $user->id, 'course' => $courseid)));
+            } else {
+                $navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
+                        array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
+            }
+        }
     } else if ($canviewuser) {
         $PAGE->navigation->extend_for_user($user);
         $PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
+
+        // Edit navbar.
+        if (isset($courseid) && $courseid != SITEID) {
+            // Create as much of the navbar automatically.
+            $usernode = $PAGE->navigation->find('user' . $user->id, null);
+            $usernode->make_active();
+            // Check to see if this is a discussion or a post.
+            if ($mode == 'posts') {
+                $navbar = $PAGE->navbar->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php',
+                        array('id' => $user->id, 'course' => $courseid)));
+            } else {
+                $navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
+                        array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
+            }
+        }
+
         $fullname = fullname($user);
         if ($discussionsonly) {
             $notification = get_string('nodiscussionsstartedby', 'forum', $fullname);
@@ -340,6 +374,20 @@ $PAGE->set_heading($pageheading);
 $PAGE->navigation->extend_for_user($user);
 $PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
 
+// Edit navbar.
+if (isset($courseid) && $courseid != SITEID) {
+    $usernode = $PAGE->navigation->find('user' . $user->id , null);
+    $usernode->make_active();
+    // Check to see if this is a discussion or a post.
+    if ($mode == 'posts') {
+        $navbar = $PAGE->navbar->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php',
+                array('id' => $user->id, 'course' => $courseid)));
+    } else {
+        $navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
+                array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
+    }
+}
+
 echo $OUTPUT->header();
 echo $OUTPUT->heading($inpageheading);
 echo html_writer::start_tag('div', array('class' => 'user-content'));
index 676dd22..d212b98 100644 (file)
@@ -88,8 +88,11 @@ if (!isguestuser()) {   // Skip default home page for guests
         if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
             set_user_preference('user_home_page_preference', HOMEPAGE_MY);
         } else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
-            $PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/my/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
+            $PAGE->settingsnav->find('usercurrentsettings', null)->add(get_string('makethismyhome'), 
+                    new moodle_url('/my/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
         }
+    } else {
+        $mycoursenode = $PAGE->navigation->get('mycourses')->make_inactive();
     }
 }
 
index 8e8d846..54480c4 100644 (file)
@@ -93,6 +93,10 @@ $strnotes = get_string('notes', 'notes');
 if ($userid) {
     $PAGE->set_context(context_user::instance($user->id));
     $PAGE->navigation->extend_for_user($user);
+    // If we are looking at our own notes, then change focus to 'my notes'.
+    if ($userid == $USER->id) {
+        $notenode = $PAGE->navigation->find('notes', null)->make_inactive();
+    }
 } else {
     $link = null;
     if (has_capability('moodle/course:viewparticipants', $coursecontext)
index b169fcc..84b625f 100644 (file)
@@ -36,6 +36,12 @@ class theme_bootstrapbase_core_renderer extends core_renderer {
         if (empty($items)) {
             return '';
         }
+
+        // Remove the Dashboard node from the breadcrumb. This saves doubling up of the same link.
+        if (get_home_page()) {
+            array_shift($items);
+        }
+
         $breadcrumbs = array();
         foreach ($items as $item) {
             $item->hideicon = true;
index 5e6c486..e2eeaca 100644 (file)
@@ -78,6 +78,7 @@ if ($id == -1) {
     require_capability('moodle/user:update', $systemcontext);
     $user = $DB->get_record('user', array('id' => $id), '*', MUST_EXIST);
     $PAGE->set_context(context_user::instance($user->id));
+    $PAGE->navbar->includesettingsbase = true;
     if ($user->id != $USER->id) {
         $PAGE->navigation->extend_for_user($user);
     } else {
index c53de77..3dc8aa6 100644 (file)
@@ -53,9 +53,20 @@ $PAGE->set_heading(fullname($user));
 
 if (!$currentuser) {
     $PAGE->navigation->extend_for_user($user);
-    $settings = $PAGE->settingsnav->get('userviewingsettings' . $user->id);
+    $settings = $PAGE->settingsnav->find('userviewingsettings' . $user->id, null);
+    $settings->make_active();
+    $url = new moodle_url('/user/preferences.php', array('userid' => $userid));
+    $navbar = $PAGE->navbar->add(get_string('preferences', 'moodle'), $url);
 } else {
-    $settings = $PAGE->settingsnav->get('usercurrentsettings');
+    // Shutdown the users node in the navigation menu.
+    $usernode = $PAGE->navigation->find('users', null);
+    $usernode->make_inactive();
+
+    $PAGE->set_title(get_string('preferences'));
+    $PAGE->set_heading(get_string('preferences'));
+
+    $settings = $PAGE->settingsnav->find('usercurrentsettings', null);
+    $settings->make_active();
 }
 
 // Identifying the nodes.
index 32168f5..7b523cc 100644 (file)
@@ -140,7 +140,7 @@ if (!$currentuser) {
     if ($node = $PAGE->settingsnav->get('userviewingsettings'.$user->id)) {
         $node->forceopen = true;
     }
-} else if ($node = $PAGE->settingsnav->get('usercurrentsettings', navigation_node::TYPE_CONTAINER)) {
+} else if ($node = $PAGE->settingsnav->get('dashboard', navigation_node::TYPE_CONTAINER)) {
     $node->forceopen = true;
 }
 if ($node = $PAGE->settingsnav->get('root')) {