FIxed guest enrolment using course key MDL-6881

This commit is contained in:
moodler
2006-10-23 06:37:06 +00:00
parent 8069349d65
commit 1b068b9049
3 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -32,7 +32,7 @@
/// thus got to this script by mistake. This might occur if enrolments
/// changed during this session or something
if (has_capability('moodle/course:view', $context)) {
if (has_capability('moodle/course:view', $context) and !has_capability('moodle/legacy:guest', $context)) {
if ($SESSION->wantsurl) {
$destination = $SESSION->wantsurl;
unset($SESSION->wantsurl);
+3
View File
@@ -137,9 +137,12 @@ function check_entry($form, $course) {
$groupid = $this->check_group_entry($course->id, $form->password);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (($form->password == $course->password) or ($groupid !== false) ) {
if (has_capability('moodle/legacy:guest', $context, $USER->id, false)) {
$USER->enrolkey[$course->id] = true;
add_to_log($course->id, 'course', 'guest', 'view.php?id='.$course->id, getremoteaddr());
} else { /// Update or add new enrolment
+5 -1
View File
@@ -1631,7 +1631,11 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) {
break;
case 2: /// Guests allowed with key (drop through to logic below)
case 2: /// Guests allowed with key
if (!empty($USER->enrolkey[$course->id])) { // Set by enrol/manual/enrol.php
return true;
}
// otherwise drop through to logic below (--> enrol.php)
break;
default: /// Guests not allowed