]> git.mjollnir.org Git - moodle.git/commitdiff
require_login not working properly MDL-7800
authorskodak <skodak>
Tue, 5 Dec 2006 09:19:26 +0000 (09:19 +0000)
committerskodak <skodak>
Tue, 5 Dec 2006 09:19:26 +0000 (09:19 +0000)
lib/moodlelib.php

index ce5b2ae9242371b8cf2b3bb78162e1e98dd620c0..d9e1d5202a717a9d82f8dbb36d2014e0e635b6b0 100644 (file)
@@ -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;
-            }
         }