From 7aee4c3ddfa68248afeb6c417f2dc804a5cf7548 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 23 Feb 2012 11:27:05 +0530 Subject: [PATCH] MDL-31466 Tags Adding a capability check to make sure hidden courses are not displayed in tag search results --- tag/coursetagslib.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tag/coursetagslib.php b/tag/coursetagslib.php index cb0e10afa5e..58602a3d6e1 100644 --- a/tag/coursetagslib.php +++ b/tag/coursetagslib.php @@ -395,15 +395,11 @@ function coursetag_get_tagged_courses($tagid) { $courses = array(); if ($crs = $DB->get_records_select('tag_instance', "tagid=:tagid AND itemtype='course'", array('tagid'=>$tagid))) { foreach ($crs as $c) { - //this capability check was introduced to stop display of courses that a student could not - //view, but arguably it is best that when clicking on a tag, the tagged course summary should - //be seen and then if the student clicks on that they will be given the opportunity to join - //note courses not visible should not have their tagid sent to this function - // $context = get_context_instance(CONTEXT_COURSE, $c->itemid); - //if (is_enrolled($context) oe is_viewing($context)) { - $course = $DB->get_record('course', array('id'=>$c->itemid)); + $course = $DB->get_record('course', array('id'=>$c->itemid)); + // check if the course is hidden + if ($course->visible == 1 || has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) { $courses[$c->itemid] = $course; - //} + } } } return $courses;