Skip to content
Browse files

MDL-21226 - add 'timecreated' column to user table. During an update,…

… the column will copy the value from 'firstaccess' column. if the account never been access, it will be set to current time of the update.

also, modified the files for signup, add new user, and upload user to initialize the value of timecreated field.
  • Loading branch information...
1 parent d90aa63 commit d3d393ab3770cb037a29d2e14ff8b5ed0fb31fe0 Rossiani Wijaya committed Feb 3, 2010
Showing with 28 additions and 7 deletions.
  1. +1 −0 admin/uploaduser.php
  2. +4 −3 lib/db/install.xml
  3. +17 −0 lib/db/upgrade.php
  4. +3 −2 login/signup.php
  5. +2 −1 user/editadvanced.php
  6. +1 −1 version.php
View
1 admin/uploaduser.php
@@ -205,6 +205,7 @@
foreach ($line as $key => $value) {
if ($value !== '') {
$key = $columns[$key];
+ $user->timecreated = time();
// password is special field
if ($key == 'password') {
if ($value !== '') {
View
7 lib/db/install.xml
@@ -600,8 +600,9 @@
<FIELD NAME="htmleditor" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="maildisplay" NEXT="ajax"/>
<FIELD NAME="ajax" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="htmleditor" NEXT="autosubscribe"/>
<FIELD NAME="autosubscribe" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="ajax" NEXT="trackforums"/>
- <FIELD NAME="trackforums" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="autosubscribe" NEXT="timemodified"/>
- <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="trackforums" NEXT="trustbitmask"/>
+ <FIELD NAME="trackforums" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="autosubscribe" NEXT="timecreated"/>
+ <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="trackforums" NEXT="timemodified"/>
+ <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="trustbitmask"/>
<FIELD NAME="trustbitmask" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timemodified" NEXT="imagealt"/>
<FIELD NAME="imagealt" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="alt tag for user uploaded image" PREVIOUS="trustbitmask" NEXT="screenreader"/>
<FIELD NAME="screenreader" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="flag for determining whehter the user uses a screenreader." PREVIOUS="imagealt"/>
@@ -2391,4 +2392,4 @@
</KEYS>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
View
17 lib/db/upgrade.php
@@ -3012,6 +3012,23 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint($result, 2010020100);
}
+ if ($result && $oldversion < 2010020300) {
+
+ /// Define field timecreated to be added to user
+ $table = new xmldb_table('user');
+ $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'trackforums');
+
+ if (!$dbman->field_exists($table, $field)) {
+ /// Launch add field timecreated
+ $dbman->add_field($table, $field);
+
+ $DB->execute("UPDATE {user} SET timecreated = firstaccess");
+
+ $sql = "UPDATE {user} SET timecreated = " . time() ." where timecreated = 0";
+ $DB->execute($sql);
+ }
+ upgrade_main_savepoint($result, 2010020300);
+ }
return $result;
}
View
5 login/signup.php
@@ -58,11 +58,12 @@ function signup_captcha_enabled() {
$user->confirmed = 0;
$user->lang = current_language();
$user->firstaccess = time();
+ $user->timecreated = time();
$user->mnethostid = $CFG->mnet_localhost_id;
$user->secret = random_string(15);
$user->auth = $CFG->registerauth;
-
- $authplugin->user_signup($user, true); // prints notice and link to login/index.php
+
+ $authplugin->user_signup($user, true); // prints notice and link to login/index.php
exit; //never reached
}
View
3 user/editadvanced.php
@@ -144,7 +144,8 @@
unset($usernew->id);
$usernew = file_postupdate_standard_editor($usernew, 'description', $editoroptions, null, 'user_profile', null);
$usernew->mnethostid = $CFG->mnet_localhost_id; // always local user
- $usernew->confirmed = 1;
+ $usernew->confirmed = 1;
+ $usernew->timecreated = time();
$usernew->password = hash_internal_user_password($usernew->newpassword);
$usernew->id = $DB->insert_record('user', $usernew);
$usercreated = true;
View
2 version.php
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2010020100; // YYYYMMDD = date of the last version bump
+ $version = 2010020300; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20100203)'; // Human-friendly version name

0 comments on commit d3d393a

Please sign in to comment.
Something went wrong with that request. Please try again.