Merge branch 'w34_MDL-34901_m24_useraccess' of git://github.com/skodak/moodle

This commit is contained in:
Dan Poltawski 2012-08-21 12:02:17 +08:00
commit 6c6604350d
4 changed files with 25 additions and 10 deletions

View File

@ -132,7 +132,9 @@ class auth_plugin_email extends auth_plugin_base {
} 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 File

@ -546,7 +546,9 @@ class auth_plugin_ldap extends auth_plugin_base {
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 File

@ -170,7 +170,9 @@ class auth_plugin_manual extends auth_plugin_base {
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 File

@ -3289,12 +3289,25 @@ function get_user_key($script, $userid, $instance=null, $iprestriction=null, $va
function update_user_login_times() {
global $USER, $DB;
$user = new stdClass();
$USER->lastlogin = $user->lastlogin = $USER->currentlogin;
$USER->currentlogin = $user->lastaccess = $user->currentlogin = time();
$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->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;
}
@ -4093,10 +4106,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)