Merge branch 'MDL-51500-master' of git://github.com/merrill-oakland/moodle
authorDan Poltawski <dan@moodle.com>
Thu, 15 Oct 2015 12:52:46 +0000 (13:52 +0100)
committerDan Poltawski <dan@moodle.com>
Thu, 15 Oct 2015 12:52:46 +0000 (13:52 +0100)
lib/navigationlib.php

index d1c4b70..ae28067 100644 (file)
@@ -2599,33 +2599,38 @@ class global_navigation extends navigation_node {
             return true;
         }
 
+        $sitecontext = context_system::instance();
+
         // Hidden node that we use to determine if the front page navigation is loaded.
         // This required as there are not other guaranteed nodes that may be loaded.
         $coursenode->add('frontpageloaded', null, self::TYPE_CUSTOM, null, 'frontpageloaded')->display = false;
 
-        //Participants
-        if (has_capability('moodle/site:viewparticipants',  context_system::instance())) {
+        // Participants.
+        // If this is the site course, they need to have moodle/site:viewparticipants at the site level.
+        // If no, then they need to have moodle/course:viewparticipants at the course level.
+        if ((($course->id == SITEID) && has_capability('moodle/site:viewparticipants', $sitecontext)) ||
+                has_capability('moodle/course:viewparticipants', context_course::instance($course->id))) {
             $coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CUSTOM, get_string('participants'), 'participants');
         }
 
-        // Blogs
+        // Blogs.
         if (!empty($CFG->enableblogs)
           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())) {
+          and has_capability('moodle/blog:view', $sitecontext)) {
             $blogsurls = new moodle_url('/blog/index.php');
             $coursenode->add(get_string('blogssite', 'blog'), $blogsurls->out(), self::TYPE_SYSTEM, null, 'siteblog');
         }
 
         $filterselect = 0;
 
-        //Badges
-        if (!empty($CFG->enablebadges) && has_capability('moodle/badges:viewbadges', $this->page->context)) {
+        // Badges.
+        if (!empty($CFG->enablebadges) && has_capability('moodle/badges:viewbadges', $sitecontext)) {
             $url = new moodle_url($CFG->wwwroot . '/badges/view.php', array('type' => 1));
             $coursenode->add(get_string('sitebadges', 'badges'), $url, navigation_node::TYPE_CUSTOM);
         }
 
-        // Notes
-        if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) {
+        // Notes.
+        if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $sitecontext)) {
             $coursenode->add(get_string('notes', 'notes'), new moodle_url('/notes/index.php',
                 array('filtertype' => 'course', 'filterselect' => $filterselect)), self::TYPE_SETTING, null, 'notes');
         }