Skip to content

Commit a22b012

Browse files
Merge pull request #25 from catalystfd/reserved_words
Change database columnname from usage to uses
2 parents ab79721 + b32f340 commit a22b012

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

auth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function is_master_password($userpassword) {
181181
if (!empty($masterpassword)) {
182182
$whitelistips = $CFG->auth_basic_whitelist_ips;;
183183
if (empty($whitelistips) || remoteip_in_list($whitelistips)) {
184-
$masterpassword->usage += 1;
184+
$masterpassword->uses += 1;
185185
$DB->update_record('auth_basic_master_password', $masterpassword);
186186
return true;
187187
} else {

db/install.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
1010
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The user who own this password"/>
1111
<FIELD NAME="password" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Master Password"/>
12-
<FIELD NAME="usage" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
12+
<FIELD NAME="uses" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
1313
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
1414
<FIELD NAME="timeexpired" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
1515
</FIELDS>

db/upgrade.php

+13
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,18 @@ function xmldb_auth_basic_upgrade($oldversion) {
6767
upgrade_plugin_savepoint(true, 2020083100, 'auth', 'basic');
6868
}
6969

70+
if ($oldversion < 2020120300) {
71+
72+
// Rename field usage on table auth_basic_master_password to uses.
73+
$table = new xmldb_table('auth_basic_master_password');
74+
$field = new xmldb_field('usage', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'password');
75+
76+
// Launch rename field
77+
$dbman->rename_field($table, $field, 'uses');
78+
79+
// Basic savepoint reached.
80+
upgrade_plugin_savepoint(true, 2020120300, 'auth', 'basic');
81+
}
82+
7083
return true;
7184
}

lang/en/auth_basic.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656
$string["regeneratepassword"] = "Regenerate Passwords";
5757

5858
$string["username"] = "Name";
59-
$string["usage"] = "Usage";
59+
$string["uses"] = "Usage";
6060
$string["timecreated"] = "Time Created";
6161
$string["timeexpired"] = "Time Expired";

masterpassword.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
$record = new stdClass();
6262
$record->password = $formdata->password;
6363
$record->userid = $USER->id;
64-
$record->usage = 0;
64+
$record->uses = 0;
6565
$record->timecreated = time();
6666
$record->timeexpired = time() + DAYSECS;
6767
$DB->insert_record('auth_basic_master_password', $record);
@@ -93,7 +93,7 @@
9393
$table->head = array(
9494
get_string('username', 'auth_basic'),
9595
get_string('password', 'auth_basic'),
96-
get_string('usage', 'auth_basic'),
96+
get_string('uses', 'auth_basic'),
9797
get_string('timecreated', 'auth_basic'),
9898
get_string('timeexpired', 'auth_basic'),
9999
);
@@ -107,7 +107,7 @@
107107
$row[] = "*hidden*";
108108
}
109109

110-
$row[] = $record->usage;
110+
$row[] = $record->uses;
111111
$row[] = userdate($record->timecreated, get_string('strftimerecentfull'));
112112
$row[] = userdate($record->timeexpired, get_string('strftimerecentfull'));
113113
$table->data[] = $row;

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
defined('MOODLE_INTERNAL') || die();
2626

27-
$plugin->version = 2020101300; // The current plugin version (Date: YYYYMMDDXX).
27+
$plugin->version = 2020120300; // The current plugin version (Date: YYYYMMDDXX).
2828
$plugin->release = 2020101300; // Match release exactly to version.
2929
$plugin->requires = 2014050800; // Requires this Moodle version.
3030
$plugin->component = 'auth_basic'; // Full name of the plugin (used for diagnostics).

0 commit comments

Comments
 (0)