]> git.mjollnir.org Git - moodle.git/commitdiff
Merged guest key enrolment fix from stable MDL-6881
authormoodler <moodler>
Mon, 23 Oct 2006 06:38:15 +0000 (06:38 +0000)
committermoodler <moodler>
Mon, 23 Oct 2006 06:38:15 +0000 (06:38 +0000)
course/enrol.php
enrol/manual/enrol.php
lib/moodlelib.php

index 976a0b3e78e8080f67f86c3d54b1822553f75b70..25cf3dbe38d053122615674aea65d14e9ed579f4 100644 (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);
index 0673fd93393f1263dbfea496ec3a7bc1f864d04e..0f53667127fb372763a4d6d25d30ec8265df26ca 100644 (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
index 05d798ee587842ae9f744fa564da14caa64b2b3a..a810e153fd0555134ec1be48363bac79abf3c1f5 100644 (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