diff --git a/lib/navigationlib.php b/lib/navigationlib.php index d3387093f15..1574d9cbefe 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2594,33 +2594,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'); } $filterselect = 0; - // 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', array('courseid' => $filterselect)); $coursenode->add(get_string('blogssite','blog'), $blogsurls->out()); } - //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))); }