From 24f4bfcfcf3c0292e6f0aa292a8aa38a5c2ed7ee Mon Sep 17 00:00:00 2001 From: Simon Coggins Date: Thu, 5 Dec 2013 20:20:38 +1300 Subject: [PATCH 1/2] MDL-43218 navigation: Remove link to blogs when they are disabled --- lib/navigationlib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 7e6180824c6..de30fef76be 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2465,10 +2465,12 @@ class global_navigation extends navigation_node { $filterselect = $currentgroup; } $filterselect = clean_param($filterselect, PARAM_INT); - if (($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($filtervar => $filterselect)); - $participants->add(get_string('blogscourse','blog'), $blogsurls->out()); + if (!empty($CFG->enableblogs)) { + if (($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($filtervar => $filterselect)); + $participants->add(get_string('blogscourse','blog'), $blogsurls->out()); + } } if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) { $participants->add(get_string('notes','notes'), new moodle_url('/notes/index.php', array('filtertype'=>'course', 'filterselect'=>$course->id))); From 0967e635ac57617052c142d4eb061827b18b88e8 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 11 Dec 2013 13:27:38 +1100 Subject: [PATCH 2/2] MDL-43218 blog: prepare the blog navigation only when needed --- lib/navigationlib.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index de30fef76be..5b3e72c6889 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2453,22 +2453,17 @@ class global_navigation extends navigation_node { //Participants if (has_capability('moodle/course:viewparticipants', $this->page->context)) { $participants = $coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CONTAINER, get_string('participants'), 'participants'); - $currentgroup = groups_get_course_group($course, true); - if ($course->id == $SITE->id) { - $filtervar = 'courseid'; - $filterselect = ''; - } else if ($course->id && !$currentgroup) { - $filtervar = 'courseid'; - $filterselect = $course->id; - } else { - $filtervar = 'groupid'; - $filterselect = $currentgroup; - } - $filterselect = clean_param($filterselect, PARAM_INT); if (!empty($CFG->enableblogs)) { if (($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($filtervar => $filterselect)); + $blogsurls = new moodle_url('/blog/index.php'); + if ($course->id == $SITE->id) { + $blogsurls->param('courseid', 0); + } else if ($currentgroup = groups_get_course_group($course, true)) { + $blogsurls->param('groupid', $currentgroup); + } else { + $blogsurls->param('courseid', $course->id); + } $participants->add(get_string('blogscourse','blog'), $blogsurls->out()); } }