MDL-11719 increased size of idnumber in user table - needed for some enrolment plugin...
authorskodak <skodak>
Mon, 12 May 2008 14:38:45 +0000 (14:38 +0000)
committerskodak <skodak>
Mon, 12 May 2008 14:38:45 +0000 (14:38 +0000)
lib/db/install.xml
lib/db/upgrade.php
lib/moodlelib.php
user/editlib.php
version.php

index ab9b8c5..8d7c29e 100644 (file)
         <FIELD NAME="mnethostid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="deleted" NEXT="username"/>
         <FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="mnethostid" NEXT="password"/>
         <FIELD NAME="password" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="username" NEXT="idnumber"/>
-        <FIELD NAME="idnumber" TYPE="char" LENGTH="64" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="firstname"/>
+        <FIELD NAME="idnumber" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="firstname"/>
         <FIELD NAME="firstname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="idnumber" NEXT="lastname"/>
         <FIELD NAME="lastname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="firstname" NEXT="email"/>
         <FIELD NAME="email" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="lastname" NEXT="emailstop"/>
index 1531197..00f7dc3 100644 (file)
@@ -84,6 +84,36 @@ function xmldb_main_upgrade($oldversion=0) {
         }
     }
 
+    if ($result && $oldversion < 2008051201) {
+        notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
+
+    /// Define index idnumber (not unique) to be dropped form user
+        $table = new XMLDBTable('user');
+        $index = new XMLDBIndex('idnumber');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
+
+    /// Launch drop index idnumber
+        if (index_exists($table, $index)) {
+            $result = $result && drop_index($table, $index);
+        }
+
+    /// Changing precision of field idnumber on table user to (255)
+        $table = new XMLDBTable('user');
+        $field = new XMLDBField('idnumber');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'password');
+
+    /// Launch change of precision for field idnumber
+        $result = $result && change_field_precision($table, $field);
+
+    /// Launch add index idnumber again
+        $index = new XMLDBIndex('idnumber');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
+        $result = $result && add_index($table, $index);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2008051201);
+    }
+
     return $result;
 }
 
index cfec8ba..44bc970 100644 (file)
@@ -2911,7 +2911,7 @@ function truncate_userinfo($info) {
     // define the limits
     $limit = array(
                     'username'    => 100,
-                    'idnumber'    =>  64,
+                    'idnumber'    => 255,
                     'firstname'   => 100,
                     'lastname'    => 100,
                     'email'       => 100,
index d8d8bcf..58b2e7d 100644 (file)
@@ -250,7 +250,7 @@ function useredit_shared_definition(&$mform) {
     $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
     $mform->setType('msn', PARAM_CLEAN);
 
-    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"');
+    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
     $mform->setType('idnumber', PARAM_CLEAN);
 
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
index c8f7335..1a38080 100644 (file)
@@ -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 = 2008051200;  // YYYYMMDD   = date of the last version bump
+    $version = 2008051201;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20080512)';  // Human-friendly version name