Permalink
Browse files

Merge branch 'w34_MDL-34901_m23_useraccess' of git://github.com/skoda…

…k/moodle into MOODLE_23_STABLE
  • Loading branch information...
danpoltawski committed Aug 21, 2012
2 parents ed22220 + cf1cb68 commit f6376dcbae0881fdbd9050f73a6efbb0b670178e
Showing with 24 additions and 9 deletions.
  1. +3 −1 auth/email/auth.php
  2. +3 −1 auth/ldap/auth.php
  3. +3 −1 auth/manual/auth.php
  4. +15 −6 lib/moodlelib.php
View
@@ -132,7 +132,9 @@ function user_confirm($username, $confirmsecret) {
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
- $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ if ($user->firstaccess == 0) {
+ $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ }
return AUTH_CONFIRM_OK;
}
} else {
View
@@ -546,7 +546,9 @@ function user_confirm($username, $confirmsecret) {
return AUTH_CONFIRM_FAIL;
}
$DB->set_field('user', 'confirmed', 1, array('id'=>$user->id));
- $DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
+ if ($user->firstaccess == 0) {
+ $DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
+ }
return AUTH_CONFIRM_OK;
}
} else {
View
@@ -170,7 +170,9 @@ function user_confirm($username, $confirmsecret = null) {
return AUTH_CONFIRM_ALREADY;
} else {
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
- $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ if ($user->firstaccess == 0) {
+ $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
+ }
return AUTH_CONFIRM_OK;
}
} else {
View
@@ -3283,11 +3283,24 @@ function get_user_key($script, $userid, $instance=null, $iprestriction=null, $va
function update_user_login_times() {
global $USER, $DB;
+ $now = time();
+
$user = new stdClass();
+ $user->id = $USER->id;
+
+ // Make sure all users that logged in have some firstaccess.
+ if ($USER->firstaccess == 0) {
+ $USER->firstaccess = $user->firstaccess = $now;
+ }
+
+ // Store the previous current as lastlogin.
$USER->lastlogin = $user->lastlogin = $USER->currentlogin;
- $USER->currentlogin = $user->lastaccess = $user->currentlogin = time();
- $user->id = $USER->id;
+ $USER->currentlogin = $user->currentlogin = $now;
+
+ // Function user_accesstime_log() may not update immediately, better do it here.
+ $USER->lastaccess = $user->lastaccess = $now;
+ $USER->lastip = $user->lastip = getremoteaddr();
$DB->update_record('user', $user);
return true;
@@ -4074,10 +4087,6 @@ function authenticate_user_login($username, $password) {
$DB->set_field('user', 'auth', $auth, array('username'=>$username));
$user->auth = $auth;
}
- if (empty($user->firstaccess)) { //prevent firstaccess from remaining 0 for manual account that never required confirmation
- $DB->set_field('user','firstaccess', $user->timemodified, array('id' => $user->id));
- $user->firstaccess = $user->timemodified;
- }
update_internal_user_password($user, $password); // just in case salt or encoding were changed (magic quotes too one day)

0 comments on commit f6376dc

Please sign in to comment.