Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'w02_MDL-30718_m21_usertimedb' of git://github.com/skoda…

…k/moodle into MOODLE_21_STABLE
  • Loading branch information...
commit 4d47200557b8a0b4c12131171fec39efdad0b185 2 parents b0bc0be + 23b7a0a
@nebgor nebgor authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 auth/db/auth.php
View
18 auth/db/auth.php
@@ -256,6 +256,7 @@ function sync_users($do_updates=false) {
$updateuser = new stdClass();
$updateuser->id = $user->id;
$updateuser->auth = 'nologin';
+ $updateuser->timemodified = time();
$DB->update_record('user', $updateuser);
echo "\t"; print_string('auth_dbsuspenduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id)); echo "\n";
}
@@ -343,7 +344,6 @@ function sync_users($do_updates=false) {
// prep a few params
$user->username = $username;
- $user->modified = time();
$user->confirmed = 1;
$user->auth = $this->authtype;
$user->mnethostid = $CFG->mnet_localhost_id;
@@ -352,12 +352,15 @@ function sync_users($do_updates=false) {
}
// maybe the user has been deleted before
- if ($old_user = $DB->get_record('user', array('username'=>$user->username, 'deleted'=>1, 'mnethostid'=>$user->mnethostid))) {
- $user->id = $old_user->id;
- $DB->set_field('user', 'deleted', 0, array('username'=>$user->username));
- echo "\t"; print_string('auth_dbreviveduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id)); echo "\n";
+ if ($old_user = $DB->get_record('user', array('username'=>$user->username, 'deleted'=>1, 'mnethostid'=>$user->mnethostid, 'auth'=>$user->auth))) {
+ // note: this undeleting is deprecated and will be eliminated soon
+ $DB->set_field('user', 'deleted', 0, array('id'=>$old_user->id));
+ $DB->set_field('user', 'timemodified', time(), array('id'=>$old_user->id));
+ echo "\t"; print_string('auth_dbreviveduser', 'auth_db', array('name'=>$old_user->username, 'id'=>$old_user->id)); echo "\n";
} else {
+ $user->timecreated = time();
+ $user->timemodified = $user->timecreated;
$id = $DB->insert_record ('user',$user); // it is truly a new user
echo "\t"; print_string('auth_dbinsertuser','auth_db',array('name'=>$user->username, 'id'=>$id)); echo "\n";
// if relevant, tag for password generation
@@ -463,6 +466,7 @@ function update_user_record($username, $updatekeys=false) {
// Ensure userid is not overwritten
$userid = $user->id;
+ $updated = false;
if ($newinfo = $this->get_userinfo($username)) {
$newinfo = truncate_userinfo($newinfo);
@@ -481,10 +485,14 @@ function update_user_record($username, $updatekeys=false) {
if (!empty($this->config->{'field_updatelocal_' . $key})) {
if (isset($user->{$key}) and $user->{$key} != $value) { // only update if it's changed
$DB->set_field('user', $key, $value, array('id'=>$userid));
+ $updated = true;
}
}
}
}
+ if ($updated) {
+ $DB->set_field('user', 'timemodified', time(), array('id'=>$userid));
+ }
return $DB->get_record('user', array('id'=>$userid, 'deleted'=>0));
}
Please sign in to comment.
Something went wrong with that request. Please try again.