require_login not working properly MDL-7800; backported from HEAD

This commit is contained in:
skodak
2006-12-05 09:21:39 +00:00
parent a68c438d5c
commit 4e1af8f1b3
+10 -11
View File
@@ -1614,6 +1614,16 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) {
notice(get_string('coursehidden'), $CFG->wwwroot .'/');
}
/// Non-guests who don't currently have access, check if they can be allowed in as a guest
if ($USER->username != 'guest' and !has_capability('moodle/course:view', $context)) {
if ($course->guest == 1) {
// Temporarily assign them guest role for this context,
// if it fails user is asked to enrol
load_guest_role($context);
}
}
/// 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)) {
@@ -1670,17 +1680,6 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) {
}
return; // User is allowed to see this course
/// Otherwise, for non-guests who don't currently have access, check if they can be allowed in as a guest
} else {
if ($course->guest == 1) { // Temporarily assign them guest role for this context
if (!load_guest_role($context)) {
print_header_simple();
notice(get_string('guestsnotallowed', '', $course->fullname), "$CFG->wwwroot/login/index.php");
}
return;
}
}