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.
This commit is contained in:
@@ -205,6 +205,7 @@ if ($formdata = $mform->is_cancelled()) {
|
||||
foreach ($line as $key => $value) {
|
||||
if ($value !== '') {
|
||||
$key = $columns[$key];
|
||||
$user->timecreated = time();
|
||||
// password is special field
|
||||
if ($key == 'password') {
|
||||
if ($value !== '') {
|
||||
|
||||
+4
-3
@@ -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>
|
||||
|
||||
@@ -3012,6 +3012,23 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -58,11 +58,12 @@ if ($mform_signup->is_cancelled()) {
|
||||
$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
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,8 @@ if ($usernew = $userform->get_data()) {
|
||||
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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user