/// 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;
$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;
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
}
// 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
$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();
// 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);
}
}
}
// 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;
$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();