From 2647f80ecd5a54432c6df83e0a47478de78ae413 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 9 Jan 2008 17:23:47 +0000 Subject: [PATCH] MDL-12373 - If you can see your user profile, but don't have moodle/course:viewparticipants, you get a link in the nav bar that takes you to an error message - and there were also instances in blog. --- blog/header.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/blog/header.php b/blog/header.php index 699b3c230d..0200e9b012 100755 --- a/blog/header.php +++ b/blog/header.php @@ -172,16 +172,19 @@ $navlinks = array(); } if ($course->id != SITEID) { - if ($tagid || !empty($tag)) { - $navlinks[] = array('name' => $course->shortname, - 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", - 'type' => 'misc'); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Course context + $systemcontext = get_context_instance(CONTEXT_SYSTEM); // SYSTEM context + + if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) { $navlinks[] = array('name' => $participants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc'); - $navlinks[] = array('name' => fullname($user), - 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect&course=$course->id", - 'type' => 'misc'); + } + $navlinks[] = array('name' => fullname($user), + 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect&course=$course->id", + 'type' => 'misc'); + + if ($tagid || !empty($tag)) { $navlinks[] = array('name' => $blogstring, 'link' => "index.php?courseid=$course->id&filtertype=user&filterselect=$filterselect", 'type' => 'misc'); @@ -191,12 +194,6 @@ $navlinks = array(); print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } else { - $navlinks[] = array('name' => $participants, - 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", - 'type' => 'misc'); - $navlinks[] = array('name' => fullname($user), - 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect&course=$course->id", - 'type' => 'misc'); $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); -- 2.39.5