FIxed guest enrolment using course key MDL-6881
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user