From 881a77bfcf5dabf942d5c0f5616291ead81b2659 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 5 Oct 2006 08:41:06 +0000 Subject: [PATCH] Fix to ignore hidden courses when using switchrole in a course MDL-6841 --- lib/moodlelib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 97faff1093..16fabf8d0c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1592,19 +1592,21 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) { } return; } + /// If the whole course is hidden from us then we can stop now - if (!($course->visible && course_parent_visible($course)) && - !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id)) ){ - print_header(); - notice(get_string('coursehidden'), $CFG->wwwroot .'/'); - } - if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) { print_error('nocontext'); } + if (empty($USER->switchrole[$context->id]) && + !($course->visible && course_parent_visible($course)) && + !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id)) ){ + print_header_simple(); + notice(get_string('coursehidden'), $CFG->wwwroot .'/'); + } + /// If the user is a guest then treat them according to the course policy about guests if (has_capability('moodle/legacy:guest', $context, NULL, false)) { -- 2.39.5