Fix to ignore hidden courses when using switchrole in a course MDL-6841

This commit is contained in:
moodler 2006-10-05 08:41:06 +00:00
parent 191acd5964
commit 881a77bfcf

View File

@ -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)) {