]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17772 fixed guest access; MDL-17754 $USER object initialisation cleanup
authorskodak <skodak>
Fri, 2 Jan 2009 21:05:16 +0000 (21:05 +0000)
committerskodak <skodak>
Fri, 2 Jan 2009 21:05:16 +0000 (21:05 +0000)
admin/cron.php
auth/mnet/land.php
backup/lib.php
lib/adminlib.php
lib/sessionlib.php
lib/setup.php
login/confirm.php
rss/file.php

index 0b812304464a6c532c62e3c52e5aecd59b9c2b83..5382de471d84dbebca36186e458247d0d4df175d 100644 (file)
@@ -66,7 +66,7 @@
 
 
 /// emulate normal session
-    $USER = get_admin();      /// Temporarily, to provide environment for this script
+    session_set_user(get_admin());      /// Temporarily, to provide environment for this script
 
 /// ignore admins timezone, language and locale - use site deafult instead!
     $USER->timezone = $CFG->timezone;
index 5008a2fa6f3f8ca274b7c16d4aa7cf27f81b1c93..4dec821c89d0744bc0ac0d7a336bc173bb68cac0 100644 (file)
@@ -33,8 +33,8 @@ $mnetauth = get_auth_plugin('mnet');
 $localuser = $mnetauth->confirm_mnet_session($token, $remotewwwroot);
 
 // log in
-$USER = get_complete_user_data('id', $localuser->id, $localuser->mnethostid);
-complete_user_login($USER);
+$user = get_complete_user_data('id', $localuser->id, $localuser->mnethostid);
+complete_user_login($user);
 
 if (!empty($localuser->mnet_foreign_host_array)) {
     $USER->mnet_foreign_host_array = $localuser->mnet_foreign_host_array;
index f8cc143570c5c636abd95b431a34e791cefefdc9..14772eff4f06e47369c4163f6e21ea7612577831 100644 (file)
         global $CFG,$SESSION,$USER, $DB; // is there such a thing on cron? I guess so..
         global $restore; // ick
         if (empty($USER)) {
-            $USER = get_admin();
+            session_set_user(get_admin());
             $USER->admin = 1; // not sure why, but this doesn't get set
         }
 
index 8ac5a2397437b4e139ba464f809af48fc190a5ab..f62b0dac722cfd0b832585211c954d3aa38057ee 100644 (file)
@@ -1414,9 +1414,9 @@ function create_admin_user($user_input=NULL) {
 
             // Log the user in.
             set_config('rolesactive', 1);
-            $USER = get_complete_user_data('username', 'admin');
-            $USER->newadminuser = 1;
-            load_all_capabilities();
+            $user = get_complete_user_data('username', 'admin');
+            $user->newadminuser = 1;
+            complete_user_login($user);
 
             if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) {
               redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id");  // Edit thyself
index fe0c4488bc6d8ea448feb502391a8c767bf098c5..774e54d063b1130091ffd513c828351736a4eddc 100644 (file)
@@ -75,7 +75,7 @@ class moodle_session {
                     $user = guest_user();
                 }
             }
-            if (!$user and !empty($_SERVER['HTTP_REFERER'])) {
+            if (!empty($CFG->guestloginbutton) and !$user and !empty($_SERVER['HTTP_REFERER'])) {
                 // automaticaly log in users coming from search engine results
                 if (strpos($_SERVER['HTTP_REFERER'], 'google') !== false ) {
                     $user = guest_user();
index 672b9e766f6efe467cc52401acb6bcfc7ded820d..bf9e4ff3353ef7663a8c8231c63f2ecdbbec5c42 100644 (file)
@@ -450,14 +450,17 @@ global $HTTPSPAGEREQUIRED;
     // set default locale and themes - might be changed again later from require_login()
     course_setup();
 
-    if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') {    // Temporary measure to help with XHTML validation
-        if (isset($_SERVER['HTTP_USER_AGENT']) and empty($USER->id)) {      // Allow W3CValidator in as user called w3cvalidator (or guest)
-            if ((strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) or
-                (strpos($_SERVER['HTTP_USER_AGENT'], 'Cynthia') !== false )) {
-                if ($USER = get_complete_user_data("username", "w3cvalidator")) {
-                    $USER->ignoresesskey = true;
-                } else {
-                    $USER = guest_user();
+    if (!empty($CFG->guestloginbutton)) {
+        if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') {    // Temporary measure to help with XHTML validation
+            if (isset($_SERVER['HTTP_USER_AGENT']) and empty($USER->id)) {      // Allow W3CValidator in as user called w3cvalidator (or guest)
+                if ((strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) or
+                    (strpos($_SERVER['HTTP_USER_AGENT'], 'Cynthia') !== false )) {
+                    if ($user = get_complete_user_data("username", "w3cvalidator")) {
+                        $user->ignoresesskey = true;
+                    } else {
+                        $user = guest_user();
+                    }
+                    session_set_user($user);
                 }
             }
         }
index 5e4a15e9a3e1495397fe94a544475ff1b9ddbc29..72f26f664a76b5496ba134694bb89d4b0099dd63 100644 (file)
 
             // The user has confirmed successfully, let's log them in
 
-            if (!$USER = get_complete_user_data('username', $username)) {
+            if (!$user = get_complete_user_data('username', $username)) {
                 print_error('cannotfinduser', '', '', $username);
             }
 
-            set_moodle_cookie($USER->username);
+            complete_user_login($user);
 
             if ( ! empty($SESSION->wantsurl) ) {   // Send them where they were going
                 $goto = $SESSION->wantsurl;
index 362a3505055551669b6056f29b3cc3698ba44852..d35bff474fd43bdd70fb19157ae1c3c6c490b609 100644 (file)
 
     $lifetime = 3600;  // Seconds for files to remain in caches - 1 hour
 
-    // hack for problems with concurrent use of NO_MOODLE_COOKIES and capabilities MDL-7243
+    // this is a big one big hack - NO_MOODLE_COOKIES is not compatible with capabilities MDL-7243
     // it should be replaced once we get to codes in urls 
-    $USER = new object();
-    $USER->id = 0;
 
     // disable moodle specific debug messages
     disable_debugging();