From: skodak Date: Tue, 5 Dec 2006 09:19:26 +0000 (+0000) Subject: require_login not working properly MDL-7800 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f71346e29a4f8554c66b27aa72db0321eb456a6d;p=moodle.git require_login not working properly MDL-7800 --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index ce5b2ae924..d9e1d5202a 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1619,6 +1619,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)) { @@ -1675,17 +1685,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; - } }