MDL-17772 fixed guest access; MDL-17754 $USER object initialisation cleanup

This commit is contained in:
skodak
2009-01-02 21:05:16 +00:00
parent b7b64ff2e0
commit 1b813f5c2a
8 changed files with 22 additions and 21 deletions
+1 -1
View 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;
+2 -2
View 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;
+1 -1
View File
@@ -615,7 +615,7 @@
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
}
+3 -3
View 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
+1 -1
View 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();
+11 -8
View 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);
}
}
}
+2 -2
View File
@@ -44,11 +44,11 @@
// 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;
+1 -3
View File
@@ -21,10 +21,8 @@
$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();