mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Fix to ignore hidden courses when using switchrole in a course MDL-6841
This commit is contained in:
parent
191acd5964
commit
881a77bfcf
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user