mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-18577 drop enums support - step2: enums out from editor, dbmanager and all upgrade scripts.
This commit is contained in:
parent
3ece3e4273
commit
2a88f626f7
@ -155,16 +155,6 @@ class edit_field extends XMLDBAction {
|
||||
$sequenceoptions = array (0 => $this->str['no'], 1 => 'auto-numbered');
|
||||
$o.= ' <tr valign="top"><td><label for="menusequence" accesskey="s">Sequence:</label></td>';
|
||||
$o.= ' <td colspan="2">' . choose_from_menu($sequenceoptions, 'sequence', $field->getSequence(), '', '', '', true) . '</td></tr>';
|
||||
/// xmldb_field Enum and enumvalues
|
||||
$enumoptions = array (0 => $this->str['no'], 1 => $this->str['yes']);
|
||||
$o.= ' <tr valign="top"><td><label for="menuenum" accesskey="s">Enum:</label></td>';
|
||||
$o.= ' <td>' . choose_from_menu($enumoptions, 'enum', $field->getEnum(), '', '', '', true) . '</td>';
|
||||
if (is_array($field->getEnumValues())) {
|
||||
$enumvalues = implode(', ', $field->getEnumValues());
|
||||
} else {
|
||||
$enumvalues = '';
|
||||
}
|
||||
$o.= ' <td><textarea name="enumvalues" rows="3" cols="70" id="enumvalues">' . s($enumvalues) . '</textarea></td></tr>';
|
||||
/// xmldb_field Default
|
||||
$o.= ' <tr valign="top"><td><label for="default" accesskey="d">Default:</label></td>';
|
||||
$o.= ' <td colspan="2"><input type="text" name="default" size="30" maxlength="80" id="default" value="' . s($field->getDefault()) . '" /></td></tr>';
|
||||
|
@ -7,7 +7,7 @@
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
@ -34,19 +34,16 @@
|
||||
/// Get the required fields
|
||||
var typeField = document.getElementById('menutype');
|
||||
var sequenceField = document.getElementById('menusequence');
|
||||
var enumField = document.getElementById('menuenum');
|
||||
|
||||
/// Register the rest of events
|
||||
if (typeField.addEventListener) {
|
||||
/// Standard
|
||||
typeField.addEventListener('change', transformForm, false);
|
||||
sequenceField.addEventListener('change', transformForm, false);
|
||||
enumField.addEventListener('change', transformForm, false);
|
||||
} else {
|
||||
/// IE 5.5
|
||||
typeField.attachEvent('onchange', transformForm);
|
||||
sequenceField.attachEvent('onchange', transformForm);
|
||||
enumField.attachEvent('onchange', transformForm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,8 +59,6 @@ function transformForm(event) {
|
||||
var unsignedField = document.getElementById('menuunsigned');
|
||||
var notnullField = document.getElementById('menunotnull');
|
||||
var sequenceField = document.getElementById('menusequence');
|
||||
var enumField = document.getElementById('menuenum');
|
||||
var enumvaluesField = document.getElementById('enumvalues');
|
||||
var defaultField = document.getElementById('default');
|
||||
|
||||
var lengthTip = document.getElementById('lengthtip');
|
||||
@ -74,16 +69,8 @@ function transformForm(event) {
|
||||
unsignedField.disabled = false;
|
||||
notnullField.disabled = false;
|
||||
sequenceField.disabled = false;
|
||||
enumField.disabled = false;
|
||||
enumvaluesField.disabled = false;
|
||||
defaultField.disabled = false;
|
||||
|
||||
/// Based on enum, disable some items
|
||||
if (enumField.value == '0') {
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
};
|
||||
|
||||
/// Based on sequence, disable some items
|
||||
if (sequenceField.value == '1') {
|
||||
unsignedField.disabled = true;
|
||||
@ -92,10 +79,6 @@ function transformForm(event) {
|
||||
notnullField.value = '1';
|
||||
defaultField.disabled = true;
|
||||
defaultField.value = '';
|
||||
enumField.disabled = true;
|
||||
enumField.value = '0';
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
}
|
||||
|
||||
|
||||
@ -106,26 +89,14 @@ function transformForm(event) {
|
||||
decimalsTip.innerHTML = '';
|
||||
decimalsField.disabled = true;
|
||||
decimalsField.value = '';
|
||||
enumField.disabled = true;
|
||||
enumField.value = '0';
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
break;
|
||||
case '2': // XMLDB_TYPE_NUMBER
|
||||
lengthTip.innerHTML = ' 1...20';
|
||||
decimalsTip.innerHTML = ' 0...length or empty';
|
||||
enumField.disabled = true;
|
||||
enumField.value = '0';
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
break;
|
||||
case '3': // XMLDB_TYPE_FLOAT
|
||||
lengthTip.innerHTML = ' 1...20 or empty';
|
||||
decimalsTip.innerHTML = ' 0...length or empty';
|
||||
enumField.disabled = true;
|
||||
enumField.value = '0';
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
break;
|
||||
case '4': // XMLDB_TYPE_CHAR
|
||||
lengthTip.innerHTML = ' 1...255';
|
||||
@ -158,10 +129,6 @@ function transformForm(event) {
|
||||
unsignedField.value = '0';
|
||||
sequenceField.disabled = true;
|
||||
sequenceField.value = '0';
|
||||
enumField.disabled = true;
|
||||
enumField.value = '0';
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
defaultField.disabled = true;
|
||||
defaultField.value = '';
|
||||
break;
|
||||
@ -176,10 +143,6 @@ function transformForm(event) {
|
||||
unsignedField.value = '0';
|
||||
sequenceField.disabled = true;
|
||||
sequenceField.value = '0';
|
||||
enumField.disabled = true;
|
||||
enumField.value = '0';
|
||||
enumvaluesField.disabled = true;
|
||||
enumvaluesField.value = '';
|
||||
defaultField.disabled = true;
|
||||
defaultField.value = '';
|
||||
break;
|
||||
|
@ -49,8 +49,6 @@ class edit_field_save extends XMLDBAction {
|
||||
'binaryincorrectlength' => 'xmldb',
|
||||
'numberincorrectdecimals' => 'xmldb',
|
||||
'floatincorrectdecimals' => 'xmldb',
|
||||
'enumvaluesincorrect' => 'xmldb',
|
||||
'wronglengthforenum' => 'xmldb',
|
||||
'defaultincorrect' => 'xmldb',
|
||||
'administration' => ''
|
||||
));
|
||||
@ -96,9 +94,6 @@ class edit_field_save extends XMLDBAction {
|
||||
$unsigned = optional_param('unsigned', false, PARAM_BOOL);
|
||||
$notnull = optional_param('notnull', false, PARAM_BOOL);
|
||||
$sequence = optional_param('sequence', false, PARAM_BOOL);
|
||||
$enum = optional_param('enum', false, PARAM_BOOL);
|
||||
$enumvalues = optional_param('enumvalues', 0, PARAM_CLEAN);
|
||||
$enumvalues = trim($enumvalues);
|
||||
$default = optional_param('default', NULL, PARAM_PATH);
|
||||
$default = trim($default);
|
||||
|
||||
@ -114,21 +109,14 @@ class edit_field_save extends XMLDBAction {
|
||||
if ($sequence) {
|
||||
$unsigned = true;
|
||||
$notnull = true;
|
||||
$enum = false;
|
||||
$default = NULL;
|
||||
}
|
||||
if ($type != XMLDB_TYPE_NUMBER && $type != XMLDB_TYPE_FLOAT) {
|
||||
$decimals = NULL;
|
||||
}
|
||||
if ($type != XMLDB_TYPE_CHAR && $type != XMLDB_TYPE_TEXT) {
|
||||
$enum = false;
|
||||
}
|
||||
if ($type == XMLDB_TYPE_BINARY) {
|
||||
$default = NULL;
|
||||
}
|
||||
if (!$enum) {
|
||||
$enumvalues = NULL;
|
||||
}
|
||||
if ($default === '') {
|
||||
$default = NULL;
|
||||
}
|
||||
@ -232,43 +220,6 @@ class edit_field_save extends XMLDBAction {
|
||||
$errors[] = $this->str['binaryincorrectlength'];
|
||||
}
|
||||
}
|
||||
/// Enum checks
|
||||
if ($enum) {
|
||||
$enumerr = false;
|
||||
$enumarr = explode(',',$enumvalues);
|
||||
$maxlength = 0;
|
||||
if ($enumarr) {
|
||||
foreach ($enumarr as $key => $enumelement) {
|
||||
/// Clear some spaces
|
||||
$enumarr[$key] = trim($enumelement);
|
||||
$enumelement = trim($enumelement);
|
||||
/// Calculate needed length
|
||||
$le = strlen(str_replace("'", '', $enumelement));
|
||||
if ($le > $maxlength) {
|
||||
$maxlength = $le;
|
||||
}
|
||||
/// Skip if under error
|
||||
if ($enumerr) {
|
||||
continue;
|
||||
}
|
||||
/// Look for quoted strings
|
||||
if (substr($enumelement, 0, 1) != "'" ||
|
||||
substr($enumelement, -1, 1) != "'") {
|
||||
$enumerr = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$enumerr = true;
|
||||
}
|
||||
if ($enumerr) {
|
||||
$errors[] = $this->str['enumvaluesincorrect'];
|
||||
} else {
|
||||
$enumvalues = $enumarr;
|
||||
}
|
||||
if ($length < $maxlength) {
|
||||
$errors[] = $this->str['wronglengthforenum'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$tempfield = new xmldb_field($name);
|
||||
@ -278,8 +229,6 @@ class edit_field_save extends XMLDBAction {
|
||||
$tempfield->setUnsigned($unsigned);
|
||||
$tempfield->setNotNull($notnull);
|
||||
$tempfield->setSequence($sequence);
|
||||
$tempfield->setEnum($enum);
|
||||
$tempfield->setEnumValues($enumvalues);
|
||||
$tempfield->setDefault($default);
|
||||
/// Prepare the output
|
||||
$site = get_site();
|
||||
@ -323,8 +272,6 @@ class edit_field_save extends XMLDBAction {
|
||||
$field->setUnsigned($unsigned);
|
||||
$field->setNotNull($notnull);
|
||||
$field->setSequence($sequence);
|
||||
$field->setEnum($enum);
|
||||
$field->setEnumValues($enumvalues);
|
||||
$field->setDefault($default);
|
||||
|
||||
/// If the hash has changed from the old one, change the version
|
||||
|
@ -124,8 +124,8 @@ class view_table_php extends XMLDBAction {
|
||||
$optionspacer . 'change_field_precision',
|
||||
$optionspacer . 'change_field_unsigned',
|
||||
$optionspacer . 'change_field_notnull',
|
||||
$optionspacer . 'change_field_enum',
|
||||
$optionspacer . 'change_field_default',
|
||||
$optionspacer . 'drop_enum_from_field', /// TODO: Moodle 2.1 - Drop drop_enum_from_field
|
||||
'Keys',
|
||||
$optionspacer . 'add_key',
|
||||
$optionspacer . 'drop_key',
|
||||
@ -229,9 +229,9 @@ class view_table_php extends XMLDBAction {
|
||||
$o.= $this->str['mustselectonefield'];
|
||||
}
|
||||
break;
|
||||
case 'change_field_enum':
|
||||
case 'drop_enum_from_field': /// TODO: Moodle 2.1 - Drop drop_enum_from_field
|
||||
if ($fieldkeyindexinitial == 'f') { //Only if we have got one field
|
||||
$o.= s($this->change_field_enum_php($structure, $tableparam, $fieldkeyindexparam));
|
||||
$o.= s($this->drop_enum_from_field_php($structure, $tableparam, $fieldkeyindexparam));
|
||||
} else {
|
||||
$o.= $this->str['mustselectonefield'];
|
||||
}
|
||||
@ -648,14 +648,19 @@ class view_table_php extends XMLDBAction {
|
||||
|
||||
/**
|
||||
* This function will generate all the PHP code needed to
|
||||
* change the enum values (check constraint) of one field
|
||||
* drop the enum values (check constraint) of one field
|
||||
* using XMLDB objects and functions
|
||||
*
|
||||
* Note this function is here as part of the process of
|
||||
* dropping enums completely from Moodle 2.0: MDL-18577
|
||||
* and will be out in Moodle 2.1
|
||||
* TODO: Moodle 2.1 - Drop drop_enum_from_field_php
|
||||
*
|
||||
* @param xmldb_structure structure object containing all the info
|
||||
* @param string table table name
|
||||
* @param string field field name to change its enum
|
||||
*/
|
||||
function change_field_enum_php($structure, $table, $field) {
|
||||
function drop_enum_from_field_php($structure, $table, $field) {
|
||||
|
||||
$result = '';
|
||||
/// Validate if we can do it
|
||||
@ -669,22 +674,19 @@ class view_table_php extends XMLDBAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Calculate the enum tip text
|
||||
$enum = $field->getEnum() ? implode(', ', $field->getEnumValues()) : 'none';
|
||||
|
||||
/// Add the standard PHP header
|
||||
$result .= XMLDB_PHP_HEADER;
|
||||
|
||||
/// Add contents
|
||||
$result .= XMLDB_LINEFEED;
|
||||
$result .= ' /// Changing list of values (enum) of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $enum . XMLDB_LINEFEED;
|
||||
$result .= ' /// Drop list of values (enum) from field ' . $field->getName() . ' on table ' . $table->getName() . XMLDB_LINEFEED;
|
||||
$result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
|
||||
$result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
|
||||
|
||||
/// Launch the proper DDL
|
||||
$result .= XMLDB_LINEFEED;
|
||||
$result .= ' /// Launch change of list of values for field ' . $field->getName() . XMLDB_LINEFEED;
|
||||
$result .= ' $dbman->change_field_enum($table, $field);' . XMLDB_LINEFEED;
|
||||
$result .= ' /// Launch drop of list of values from field ' . $field->getName() . XMLDB_LINEFEED;
|
||||
$result .= ' $dbman->drop_enum_from_field($table, $field);' . XMLDB_LINEFEED;
|
||||
|
||||
/// Add the proper upgrade_xxxx_savepoint call
|
||||
$result .= $this->upgrade_savepoint_php ($structure);
|
||||
|
@ -620,8 +620,8 @@ if ( !is_object($PHPCAS_CLIENT) ) {
|
||||
|
||||
/// Define table user to be created
|
||||
$table = new xmldb_table('tmp_extuser');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_index('username', XMLDB_INDEX_UNIQUE, array('mnethostid', 'username'));
|
||||
|
||||
|
@ -553,8 +553,8 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
|
||||
/// Define table user to be created
|
||||
$table = new xmldb_table('tmp_extuser');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_index('username', XMLDB_INDEX_UNIQUE, array('mnethostid', 'username'));
|
||||
|
||||
|
@ -47,7 +47,7 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field transid on table enrol_authorize to (20)
|
||||
$table = new xmldb_table('enrol_authorize');
|
||||
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'userid');
|
||||
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'userid');
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
/// Launch add index transid again
|
||||
@ -65,7 +65,7 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field transid on table enrol_authorize_refunds to (20)
|
||||
$table = new xmldb_table('enrol_authorize_refunds');
|
||||
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null, null, '0', 'amount');
|
||||
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, '0', 'amount');
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
/// Launch add index transid again
|
||||
@ -79,10 +79,10 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
|
||||
|
||||
/// Changing list of values (enum) of field paymentmethod on table enrol_authorize to none
|
||||
$table = new xmldb_table('enrol_authorize');
|
||||
$field = new xmldb_field('paymentmethod', XMLDB_TYPE_CHAR, '6', null, XMLDB_NOTNULL, null, null, null, 'cc', 'id');
|
||||
$field = new xmldb_field('paymentmethod', XMLDB_TYPE_CHAR, '6', null, XMLDB_NOTNULL, null, 'cc', 'id');
|
||||
|
||||
/// Launch change of list of values for field paymentmethod
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -195,7 +195,6 @@ $string['ddlfieldnotexist'] = 'Field \"$a->fieldname\" does not exist in table \
|
||||
$string['ddltablealreadyexists'] = 'Table \"$a\" already exists';
|
||||
$string['ddltablenotexist'] = 'Table \"$a\" does not exist';
|
||||
$string['ddlunknownerror'] = 'Unknown DDL library error';
|
||||
$string['ddlunsupportedenums'] = 'Field \"$a\" contains enum info. Enums support has been dropped in Moodle 2.0. Please modify your code to avoid them completely. If you are already using them, please use \$dbman->change_field_enum(\$table, \$field); in your upgrade scripts to drop them ASAP';
|
||||
$string['ddlxmlfileerror'] = 'XML database file errors found';
|
||||
$string['dmlreadexception'] = 'Error reading from database';
|
||||
$string['dmlwriteexception'] = 'Error writing to database';
|
||||
|
@ -37,15 +37,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('upgrade_log');
|
||||
|
||||
/// Adding fields to table upgrade_log
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
|
||||
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
|
||||
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table upgrade_log
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -141,7 +141,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field idnumber on table user to (255)
|
||||
$table = new xmldb_table('user');
|
||||
$field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'password');
|
||||
$field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'password');
|
||||
|
||||
/// Launch change of precision for field idnumber
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -168,7 +168,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
if ($result && $oldversion < 2008051203) {
|
||||
$table = new xmldb_table('mnet_enrol_course');
|
||||
$field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', true, true, null, false, false, 0);
|
||||
$field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0);
|
||||
$dbman->change_field_precision($table, $field);
|
||||
upgrade_main_savepoint($result, 2008051203);
|
||||
}
|
||||
@ -181,7 +181,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
// add field
|
||||
$field = new xmldb_field('tiuserid');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'itemid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'itemid');
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
// modify index
|
||||
@ -219,10 +219,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('portfolio_instance');
|
||||
|
||||
/// Adding fields to table portfolio_instance
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
|
||||
|
||||
/// Adding keys to table portfolio_instance
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -235,10 +235,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('portfolio_instance_config');
|
||||
|
||||
/// Adding fields to table portfolio_instance_config
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
|
||||
/// Adding keys to table portfolio_instance_config
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -256,11 +256,11 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('portfolio_instance_user');
|
||||
|
||||
/// Adding fields to table portfolio_instance_user
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
|
||||
$table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
|
||||
/// Adding keys to table portfolio_instance_user
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -279,8 +279,8 @@ function xmldb_main_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2008072400) {
|
||||
/// Create the database tables for message_processors
|
||||
$table = new xmldb_table('message_processors');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
@ -291,21 +291,21 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// fields to rename
|
||||
$field = new xmldb_field('message');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null);
|
||||
$dbman->rename_field($table, $field, 'fullmessage');
|
||||
$field = new xmldb_field('format');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '0', null);
|
||||
$dbman->rename_field($table, $field, 'fullmessageformat');
|
||||
|
||||
/// new message fields
|
||||
$field = new xmldb_field('subject');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
$field = new xmldb_field('fullmessagehtml');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
$field = new xmldb_field('smallmessage');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
|
||||
@ -317,29 +317,29 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// fields to rename
|
||||
$field = new xmldb_field('message');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null);
|
||||
$dbman->rename_field($table, $field, 'fullmessage');
|
||||
$field = new xmldb_field('format');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '0', null);
|
||||
$dbman->rename_field($table, $field, 'fullmessageformat');
|
||||
|
||||
|
||||
/// new message fields
|
||||
$field = new xmldb_field('subject');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
$field = new xmldb_field('fullmessagehtml');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
$field = new xmldb_field('smallmessage');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// new table
|
||||
$table = new xmldb_table('message_working');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('unreadmessageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('processorid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('unreadmessageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('processorid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
@ -352,7 +352,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
/// Define field enablecompletion to be added to course
|
||||
$table = new xmldb_table('course');
|
||||
$field = new xmldb_field('enablecompletion');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'defaultrole');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'defaultrole');
|
||||
|
||||
/// Launch add field enablecompletion
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
@ -362,7 +362,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
/// Define field completion to be added to course_modules
|
||||
$table = new xmldb_table('course_modules');
|
||||
$field = new xmldb_field('completion');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'groupmembersonly');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupmembersonly');
|
||||
|
||||
/// Launch add field completion
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
@ -371,7 +371,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Define field completiongradeitemnumber to be added to course_modules
|
||||
$field = new xmldb_field('completiongradeitemnumber');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'completion');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'completion');
|
||||
|
||||
/// Launch add field completiongradeitemnumber
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
@ -380,7 +380,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Define field completionview to be added to course_modules
|
||||
$field = new xmldb_field('completionview');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completiongradeitemnumber');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completiongradeitemnumber');
|
||||
|
||||
/// Launch add field completionview
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
@ -389,7 +389,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Define field completionexpected to be added to course_modules
|
||||
$field = new xmldb_field('completionexpected');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionview');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionview');
|
||||
|
||||
/// Launch add field completionexpected
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
@ -401,12 +401,12 @@ function xmldb_main_upgrade($oldversion) {
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
/// Adding fields to table course_modules_completion
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('completionstate', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('viewed', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('completionstate', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('viewed', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table course_modules_completion
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -429,13 +429,13 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('portfolio_log');
|
||||
|
||||
/// Adding fields to table portfolio_log
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('portfolio', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('caller_class', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('caller_file', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('caller_sha1', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('portfolio', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('caller_class', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('caller_file', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('caller_sha1', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table portfolio_log
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -462,10 +462,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('message_providers');
|
||||
|
||||
/// Adding fields to table message_providers
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('component', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('capability', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('component', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('capability', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
|
||||
/// Adding keys to table message_providers
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -484,20 +484,20 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('files');
|
||||
|
||||
/// Adding fields to table files
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('contenthash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('pathnamehash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('filearea', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('filepath', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('filename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('filesize', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('mimetype', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
|
||||
$table->add_field('status', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('contenthash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('pathnamehash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('filearea', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('filepath', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('filename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('filesize', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('mimetype', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('status', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table files
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -521,8 +521,8 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('files_cleanup');
|
||||
|
||||
/// Adding fields to table files_cleanup
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('contenthash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('contenthash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table files_cleanup
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -556,7 +556,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('mnet_application');
|
||||
$field = new xmldb_field('sso_jump_url');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$dbman->add_field($table, $field);
|
||||
$result = $DB->set_field('mnet_application', 'sso_jump_url', '/auth/mnet/jump.php', array('name' => 'moodle'));
|
||||
$result = $result && $DB->set_field('mnet_application', 'sso_jump_url', '/auth/xmlrpc/jump.php', array('name' => 'mahara'));
|
||||
@ -572,8 +572,8 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('portfolio_tempdata');
|
||||
|
||||
/// Adding fields to table portfolio_tempdata
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('data', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('data', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
|
||||
/// Adding keys to table portfolio_tempdata
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -592,7 +592,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$DB->delete_records('portfolio_tempdata'); // there shouldnt' be any, and it will cause problems with this upgrade.
|
||||
/// Define field expirytime to be added to portfolio_tempdata
|
||||
$table = new xmldb_table('portfolio_tempdata');
|
||||
$field = new xmldb_field('expirytime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'data');
|
||||
$field = new xmldb_field('expirytime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'data');
|
||||
|
||||
/// Conditionally launch add field expirytime
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -606,49 +606,49 @@ function xmldb_main_upgrade($oldversion) {
|
||||
/// Changing the type of all the columns that the question bank uses to store grades to be NUMBER(12, 7).
|
||||
if ($result && $oldversion < 2008081500) {
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('defaultgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'generalfeedback');
|
||||
$field = new xmldb_field('defaultgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'generalfeedback');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081500);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081501) {
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'defaultgrade');
|
||||
$field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'defaultgrade');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081501);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081502) {
|
||||
$table = new xmldb_table('question_answers');
|
||||
$field = new xmldb_field('fraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'answer');
|
||||
$field = new xmldb_field('fraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'answer');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081502);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081503) {
|
||||
$table = new xmldb_table('question_sessions');
|
||||
$field = new xmldb_field('sumpenalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'newgraded');
|
||||
$field = new xmldb_field('sumpenalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'newgraded');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081503);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081504) {
|
||||
$table = new xmldb_table('question_states');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'event');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'event');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081504);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081505) {
|
||||
$table = new xmldb_table('question_states');
|
||||
$field = new xmldb_field('raw_grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'grade');
|
||||
$field = new xmldb_field('raw_grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'grade');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081505);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081506) {
|
||||
$table = new xmldb_table('question_states');
|
||||
$field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'raw_grade');
|
||||
$field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'raw_grade');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_main_savepoint($result, 2008081506);
|
||||
}
|
||||
@ -665,7 +665,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2008081900) {
|
||||
/// Define field userid to be added to portfolio_tempdata
|
||||
$table = new xmldb_table('portfolio_tempdata');
|
||||
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'expirytime');
|
||||
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'expirytime');
|
||||
|
||||
/// Conditionally launch add field userid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -675,7 +675,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
/// now change it to be notnull
|
||||
|
||||
/// Changing nullability of field userid on table portfolio_tempdata to not null
|
||||
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'expirytime');
|
||||
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'expirytime');
|
||||
|
||||
/// Launch change of nullability for field userid
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
@ -703,10 +703,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('repository');
|
||||
|
||||
/// Adding fields to table repository
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('type', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '1');
|
||||
$table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('type', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '1');
|
||||
$table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
/// Adding keys to table repository
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -719,15 +719,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('repository_instances');
|
||||
|
||||
/// Adding fields to table repository_instances
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('typeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
||||
$table->add_field('password', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('typeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
$table->add_field('password', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
|
||||
/// Adding keys to table repository_instances
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -741,10 +741,10 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('repository_instance_config');
|
||||
|
||||
/// Adding fields to table repository_instance_config
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('instanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('instanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
|
||||
/// Adding keys to table repository_instance_config
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -764,7 +764,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Define field flagged to be added to question_sessions
|
||||
$table = new xmldb_table('question_sessions');
|
||||
$field = new xmldb_field('flagged', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, null, '0', 'manualcomment');
|
||||
$field = new xmldb_field('flagged', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'manualcomment');
|
||||
|
||||
/// Conditionally launch add field flagged
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -779,7 +779,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field parent_type on table mnet_rpc to (20)
|
||||
$table = new xmldb_table('mnet_rpc');
|
||||
$field = new xmldb_field('parent_type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, null, 'xmlrpc_path');
|
||||
$field = new xmldb_field('parent_type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, 'xmlrpc_path');
|
||||
|
||||
/// Launch change of precision for field parent_type
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -864,7 +864,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Define field readonly to be added to repository_instances
|
||||
$table = new xmldb_table('repository_instances');
|
||||
$field = new xmldb_field('readonly', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timemodified');
|
||||
$field = new xmldb_field('readonly', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
|
||||
/// Conditionally launch add field readonly
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -886,7 +886,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing the default of field lang on table user to en_utf8
|
||||
$table = new xmldb_table('user');
|
||||
$field = new xmldb_field('lang', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'en_utf8', 'country');
|
||||
$field = new xmldb_field('lang', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, 'en_utf8', 'country');
|
||||
|
||||
/// Launch change of default for field lang
|
||||
$dbman->change_field_default($table, $field);
|
||||
@ -912,9 +912,9 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('role_context_levels');
|
||||
|
||||
/// Adding fields to table role_context_levels
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('contextlevel', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('contextlevel', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table role_context_levels
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1092,7 +1092,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field shortname on table course_request to (100)
|
||||
$table = new xmldb_table('course_request');
|
||||
$field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'fullname');
|
||||
$field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'fullname');
|
||||
|
||||
/// Launch change of precision for field shortname
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -1124,7 +1124,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field shortname on table mnet_enrol_course to (100)
|
||||
$table = new xmldb_table('mnet_enrol_course');
|
||||
$field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'fullname');
|
||||
$field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'fullname');
|
||||
|
||||
/// Launch change of precision for field shortname
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -1137,7 +1137,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Define field availablefrom to be added to course_modules
|
||||
$table = new xmldb_table('course_modules');
|
||||
$field = new xmldb_field('availablefrom', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionexpected');
|
||||
$field = new xmldb_field('availablefrom', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionexpected');
|
||||
|
||||
/// Conditionally launch add field availablefrom
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -1145,7 +1145,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
/// Define field availableuntil to be added to course_modules
|
||||
$field = new xmldb_field('availableuntil', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'availablefrom');
|
||||
$field = new xmldb_field('availableuntil', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'availablefrom');
|
||||
|
||||
/// Conditionally launch add field availableuntil
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -1153,7 +1153,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
/// Define field showavailability to be added to course_modules
|
||||
$field = new xmldb_field('showavailability', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'availableuntil');
|
||||
$field = new xmldb_field('showavailability', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'availableuntil');
|
||||
|
||||
/// Conditionally launch add field showavailability
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -1164,13 +1164,13 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('course_modules_availability');
|
||||
|
||||
/// Adding fields to table course_modules_availability
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('sourcecmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('requiredcompletion', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('gradeitemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('grademin', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null);
|
||||
$table->add_field('grademax', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('sourcecmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('requiredcompletion', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('gradeitemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('grademin', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null);
|
||||
$table->add_field('grademax', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null);
|
||||
|
||||
/// Adding keys to table course_modules_availability
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1224,7 +1224,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field ip on table log to (45)
|
||||
$table = new xmldb_table('log');
|
||||
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'userid');
|
||||
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'userid');
|
||||
|
||||
/// Launch change of precision for field ip
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -1237,7 +1237,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field lastip on table user to (45)
|
||||
$table = new xmldb_table('user');
|
||||
$field = new xmldb_field('lastip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'currentlogin');
|
||||
$field = new xmldb_field('lastip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'currentlogin');
|
||||
|
||||
/// Launch change of precision for field lastip
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -1250,7 +1250,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field ip_address on table mnet_host to (45)
|
||||
$table = new xmldb_table('mnet_host');
|
||||
$field = new xmldb_field('ip_address', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'wwwroot');
|
||||
$field = new xmldb_field('ip_address', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'wwwroot');
|
||||
|
||||
/// Launch change of precision for field ip_address
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -1263,7 +1263,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field ip on table mnet_log to (45)
|
||||
$table = new xmldb_table('mnet_log');
|
||||
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'userid');
|
||||
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'userid');
|
||||
|
||||
/// Launch change of precision for field ip
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -1291,7 +1291,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
/// Changing nullability of field configdata on table block_instance to null
|
||||
$table = new xmldb_table('block_instance');
|
||||
$field = new xmldb_field('configdata');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'visible');
|
||||
|
||||
/// Launch change of nullability for field configdata
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
@ -1333,13 +1333,13 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('config_log');
|
||||
|
||||
/// Adding fields to table config_log
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('oldvalue', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('oldvalue', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
|
||||
/// Adding keys to table config_log
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1377,15 +1377,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('sessions');
|
||||
|
||||
/// Adding fields to table sessions
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('state', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('sid', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('sessdata', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('firstip', XMLDB_TYPE_CHAR, '45', null, null, null, null, null, null);
|
||||
$table->add_field('lastip', XMLDB_TYPE_CHAR, '45', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('state', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('sid', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('sessdata', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('firstip', XMLDB_TYPE_CHAR, '45', null, null, null, null);
|
||||
$table->add_field('lastip', XMLDB_TYPE_CHAR, '45', null, null, null, null);
|
||||
|
||||
/// Adding keys to table sessions
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1411,15 +1411,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table = new xmldb_table('upgrade_log');
|
||||
|
||||
/// Adding fields to table upgrade_log
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
|
||||
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null);
|
||||
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table upgrade_log
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1462,7 +1462,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
/// Define field backuptype to be added to backup_log
|
||||
$table = new XMLDBTable('backup_log');
|
||||
$field = new XMLDBField('backuptype');
|
||||
$field = new xmldb_field('backuptype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null, 'info');
|
||||
$field = new xmldb_field('backuptype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, 'info');
|
||||
/// Conditionally Launch add field backuptype and set all old records as 'scheduledbackup' records.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
@ -1504,9 +1504,9 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$table = new xmldb_table('role_allow_switch');
|
||||
|
||||
/// Adding fields to table role_allow_switch
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('allowswitch', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('allowswitch', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table role_allow_switch
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1550,11 +1550,11 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$table = new xmldb_table('filter_active');
|
||||
|
||||
/// Adding fields to table filter_active
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('filter', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('active', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('filter', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('active', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
/// Adding keys to table filter_active
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1578,11 +1578,11 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$table = new xmldb_table('filter_config');
|
||||
|
||||
/// Adding fields to table filter_config
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('filter', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('filter', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
|
||||
/// Adding keys to table filter_config
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -1673,31 +1673,31 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
|
||||
/// Changing list of values (enum) of field stattype on table stats_daily to none
|
||||
$table = new xmldb_table('stats_daily');
|
||||
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'activity', 'roleid');
|
||||
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'activity', 'roleid');
|
||||
|
||||
/// Launch change of list of values for field stattype
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
|
||||
/// Changing list of values (enum) of field stattype on table stats_weekly to none
|
||||
$table = new xmldb_table('stats_weekly');
|
||||
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'activity', 'roleid');
|
||||
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'activity', 'roleid');
|
||||
|
||||
/// Launch change of list of values for field stattype
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
|
||||
/// Changing list of values (enum) of field stattype on table stats_monthly to none
|
||||
$table = new xmldb_table('stats_monthly');
|
||||
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'activity', 'roleid');
|
||||
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'activity', 'roleid');
|
||||
|
||||
/// Launch change of list of values for field stattype
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
|
||||
/// Changing list of values (enum) of field publishstate on table post to none
|
||||
$table = new xmldb_table('post');
|
||||
$field = new xmldb_field('publishstate', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'draft', 'attachment');
|
||||
$field = new xmldb_field('publishstate', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'draft', 'attachment');
|
||||
|
||||
/// Launch change of list of values for field publishstate
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
|
||||
/// Main savepoint reached
|
||||
upgrade_main_savepoint($result, 2009042700);
|
||||
|
@ -468,14 +468,6 @@ class database_manager {
|
||||
throw new ddl_exception('ddltablealreadyexists', $xmldb_table->getName());
|
||||
}
|
||||
|
||||
/// Iterate over all fields in table, finding any attempt to add one field with enum info, throw exception
|
||||
$xmldb_fields = $xmldb_table->getFields();
|
||||
foreach ($xmldb_fields as $xmldb_field) {
|
||||
if ($xmldb_field->getEnum()) {
|
||||
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (!$sqlarr = $this->generator->getCreateTableSQL($xmldb_table)) {
|
||||
throw new ddl_exception('ddlunknownerror', null, 'table create sql not generated');
|
||||
}
|
||||
@ -501,14 +493,6 @@ class database_manager {
|
||||
$this->drop_temp_table($xmldb_table);
|
||||
}
|
||||
|
||||
/// Iterate over all fields in table, finding any attempt to add one field with enum info, throw exception
|
||||
$xmldb_fields = $xmldb_table->getFields();
|
||||
foreach ($xmldb_fields as $xmldb_field) {
|
||||
if ($xmldb_field->getEnum()) {
|
||||
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (!$sqlarr = $this->generator->getCreateTempTableSQL($xmldb_table)) {
|
||||
throw new ddl_exception('ddlunknownerror', null, 'temp table create sql not generated');
|
||||
}
|
||||
@ -599,11 +583,6 @@ class database_manager {
|
||||
' cannot be added. Not null fields added to non empty tables require default value. Create skipped');
|
||||
}
|
||||
|
||||
/// Detect any attempt to add one field with enum info, throw exception
|
||||
if ($xmldb_field->getEnum()) {
|
||||
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
|
||||
}
|
||||
|
||||
if (!$sqlarr = $this->generator->getAddFieldSQL($xmldb_table, $xmldb_field)) {
|
||||
throw new ddl_exception('ddlunknownerror', null, 'addfield sql not generated');
|
||||
}
|
||||
@ -693,13 +672,15 @@ class database_manager {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will change the enum status of the field in the table passed as arguments
|
||||
* This function will drop the existing enum of the field in the table passed as arguments
|
||||
*
|
||||
* TODO: Moodle 2.1 - Drop drop_enum_from_field()
|
||||
*
|
||||
* @param xmldb_table table object (just the name is mandatory)
|
||||
* @param xmldb_field field object (full specs are required)
|
||||
* @return void
|
||||
*/
|
||||
public function change_field_enum(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
|
||||
public function drop_enum_from_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
|
||||
if (!$this->table_exists($xmldb_table)) {
|
||||
throw new ddl_table_missing_exception($xmldb_table->getName());
|
||||
}
|
||||
@ -708,18 +689,13 @@ class database_manager {
|
||||
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
|
||||
}
|
||||
|
||||
/// If enum is defined, we're going to create it, check it doesn't exist.
|
||||
if ($xmldb_field->getEnum()) {
|
||||
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
|
||||
} else { /// Else, we're going to drop it, check it exists
|
||||
if (!$this->check_constraint_exists($xmldb_table, $xmldb_field)) {
|
||||
debugging('Enum for ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
|
||||
' does not exist. Delete skipped', DEBUG_DEVELOPER);
|
||||
return; //Enum does not exist, nothing to delete
|
||||
}
|
||||
if (!$this->check_constraint_exists($xmldb_table, $xmldb_field)) {
|
||||
debugging('Enum for ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
|
||||
' does not exist. Delete skipped', DEBUG_DEVELOPER);
|
||||
return; //Enum does not exist, nothing to delete
|
||||
}
|
||||
|
||||
if (!$sqlarr = $this->generator->getModifyEnumSQL($xmldb_table, $xmldb_field)) {
|
||||
if (!$sqlarr = $this->generator->getDropEnumSQL($xmldb_table, $xmldb_field)) {
|
||||
return; //Empty array = nothing to do = no error
|
||||
}
|
||||
|
||||
|
@ -79,9 +79,6 @@ abstract class sql_generator {
|
||||
public $sequence_name_small = false; //Different name for small (4byte) sequences or false if same
|
||||
public $sequence_only = false; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name publiciable
|
||||
|
||||
public $enum_inline_code = true; //Does the generator need to add inline code in the column definition
|
||||
public $enum_extra_code = true; //Does the generator need to add extra code to generate code for the enums in the table
|
||||
|
||||
public $add_table_comments = true; // Does the generator need to add code for table comments
|
||||
|
||||
public $add_after_clause = false; // Does the generator need to add the after clause for fields
|
||||
@ -288,15 +285,6 @@ abstract class sql_generator {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Add enum extra code if needed
|
||||
if ($this->enum_extra_code) {
|
||||
/// Iterate over fields looking for enums
|
||||
foreach ($xmldb_fields as $xmldb_field) {
|
||||
if ($xmldb_field->getEnum()) {
|
||||
$table .= "\n" . $this->getEnumExtraSQL($xmldb_table, $xmldb_field) . ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Table footer, trim the latest comma
|
||||
$table = trim($table,',');
|
||||
$table .= "\n)";
|
||||
@ -434,13 +422,8 @@ abstract class sql_generator {
|
||||
$field = $this->getEncQuoted($xmldb_field->getName());
|
||||
/// The type and length only if we don't want to skip it
|
||||
if (!$skip_type_clause) {
|
||||
/// The type and length (if the field isn't enum)
|
||||
if (!$xmldb_field->getEnum() || $this->enum_inline_code == false) {
|
||||
$field .= ' ' . $this->getTypeSQL($xmldb_field->getType(), $xmldb_field->getLength(), $xmldb_field->getDecimals());
|
||||
} else {
|
||||
/// call to custom function
|
||||
$field .= ' ' . $this->getEnumSQL($xmldb_field);
|
||||
}
|
||||
/// The type and length
|
||||
$field .= ' ' . $this->getTypeSQL($xmldb_field->getType(), $xmldb_field->getLength(), $xmldb_field->getDecimals());
|
||||
}
|
||||
/// The unsigned if supported
|
||||
if ($this->unsigned_allowed && ($xmldb_field->getType() == XMLDB_TYPE_INTEGER ||
|
||||
@ -651,14 +634,6 @@ abstract class sql_generator {
|
||||
}
|
||||
$results[] = $altertable;
|
||||
|
||||
/// If the DB has extra enum code
|
||||
if ($this->enum_extra_code) {
|
||||
/// If it's enum add the extra code
|
||||
if ($xmldb_field->getEnum()) {
|
||||
$results[] = 'ALTER TABLE ' . $tablename . ' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
@ -713,27 +688,6 @@ abstract class sql_generator {
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the enum of the field in the table
|
||||
*/
|
||||
public function getModifyEnumSQL($xmldb_table, $xmldb_field) {
|
||||
|
||||
$results = array();
|
||||
|
||||
/// Get the quoted name of the table and field
|
||||
$tablename = $this->getTableName($xmldb_table);
|
||||
$fieldname = $this->getEncQuoted($xmldb_field->getName());
|
||||
|
||||
/// Decide if we are going to create or to drop the enum (based exclusively in the values passed!)
|
||||
if (!$xmldb_field->getEnum()) {
|
||||
$results = $this->getDropEnumSQL($xmldb_table, $xmldb_field); //Drop
|
||||
} else {
|
||||
$results = $this->getCreateEnumSQL($xmldb_table, $xmldb_field); //Create/modify
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the default of the field in the table
|
||||
*/
|
||||
@ -1180,20 +1134,6 @@ abstract class sql_generator {
|
||||
*/
|
||||
public abstract function getTypeSQL($xmldb_type, $xmldb_length=null, $xmldb_decimals=null);
|
||||
|
||||
/**
|
||||
* Given one XMLDB Field, return its enum SQL to be added inline with the column definition
|
||||
*/
|
||||
public function getEnumSQL($xmldb_field) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code needed to create one enum for the xmldb_table and xmldb_field passes
|
||||
*/
|
||||
public function getEnumExtraSQL($xmldb_table, $xmldb_field) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code (array of statements) needed to execute extra statements on field rename
|
||||
*/
|
||||
@ -1231,15 +1171,11 @@ abstract class sql_generator {
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
|
||||
* (usually invoked from getModifyEnumSQL()
|
||||
*
|
||||
* TODO: Moodle 2.1 - Drop getDropEnumSQL()
|
||||
*/
|
||||
public abstract function getDropEnumSQL($xmldb_table, $xmldb_field);
|
||||
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to add its enum
|
||||
* (usually invoked from getModifyEnumSQL()
|
||||
*/
|
||||
public abstract function getCreateEnumSQL($xmldb_table, $xmldb_field);
|
||||
|
||||
/**
|
||||
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
|
||||
* (usually invoked from getModifyDefaultSQL()
|
||||
|
@ -1,7 +1,8 @@
|
||||
<!ELEMENT FIELD EMPTY >
|
||||
<!ATTLIST FIELD DECIMALS NMTOKEN #IMPLIED >
|
||||
<!ATTLIST FIELD DEFAULT NMTOKEN #IMPLIED >
|
||||
<!ATTLIST FIELD ENUM ( false | true ) #REQUIRED >
|
||||
<!-- TODO: Moodle 2.1 - Drop ENUM and ENUMVALUES attributes -->
|
||||
<!ATTLIST FIELD ENUM ( false | true ) #IMPLIED >
|
||||
<!ATTLIST FIELD ENUMVALUES CDATA #IMPLIED >
|
||||
<!ATTLIST FIELD LENGTH NMTOKEN #REQUIRED >
|
||||
<!ATTLIST FIELD NAME NMTOKEN #REQUIRED >
|
||||
|
@ -72,6 +72,7 @@
|
||||
<xs:attribute name="NOTNULL" type="trueFalse" use="required" />
|
||||
<xs:attribute name="DECIMALS" type="xs:positiveInteger" use="optional" />
|
||||
<xs:attribute name="UNSIGNED" type="trueFalse" use="optional" />
|
||||
<!-- TODO: Moodle 2.1 - Drop ENUM and ENUMVALUES attributes -->
|
||||
<xs:attribute name="ENUM" type="trueFalse" use="optional" />
|
||||
<xs:attribute name="ENUMVALUES" type="xs:string" use="optional" />
|
||||
<xs:attribute name="DEFAULT" type="xs:string" use="optional" />
|
||||
@ -199,4 +200,4 @@
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:schema>
|
||||
</xs:schema>
|
||||
|
@ -63,7 +63,6 @@
|
||||
define ('XMLDB_UNSIGNED', true); //If the field is going to be unsigned
|
||||
define ('XMLDB_NOTNULL', true); //If the field is going to be not null
|
||||
define ('XMLDB_SEQUENCE', true); //If the field is going to be a sequence
|
||||
define ('XMLDB_ENUM', true); //If the field is going to be a enumeration of possible fields
|
||||
define ('XMLDB_INDEX_UNIQUE', true); //If the index is going to be unique
|
||||
define ('XMLDB_INDEX_NOTUNIQUE',false); //If the index is NOT going to be unique
|
||||
|
||||
|
@ -34,25 +34,21 @@ class xmldb_field extends xmldb_object {
|
||||
var $notnull;
|
||||
var $default;
|
||||
var $sequence;
|
||||
var $enum;
|
||||
var $enumvalues;
|
||||
var $decimals;
|
||||
|
||||
/**
|
||||
* Creates one new xmldb_field
|
||||
*/
|
||||
function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
|
||||
function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
|
||||
$this->type = NULL;
|
||||
$this->length = NULL;
|
||||
$this->unsigned = true;
|
||||
$this->notnull = false;
|
||||
$this->default = NULL;
|
||||
$this->sequence = false;
|
||||
$this->enum = false;
|
||||
$this->enumvalues = NULL;
|
||||
$this->decimals = NULL;
|
||||
parent::__construct($name);
|
||||
$this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default, $previous);
|
||||
$this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $default, $previous);
|
||||
}
|
||||
|
||||
/// TODO: Delete for 2.1 (deprecated in 2.0).
|
||||
@ -61,8 +57,11 @@ class xmldb_field extends xmldb_object {
|
||||
function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
|
||||
|
||||
debugging('XMLDBField->setAttributes() has been deprecated in Moodle 2.0. Will be out in Moodle 2.1. Please use xmldb_field->set_attributes() instead.', DEBUG_DEVELOPER);
|
||||
if ($enum) {
|
||||
debugging('Also, ENUMs support has been dropped in Moodle 2.0. Your fields specs are incorrect because you are trying to introduce one new ENUM. Created DB estructures will ignore that.');
|
||||
}
|
||||
|
||||
return $this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default, $previous);
|
||||
return $this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $default, $previous);
|
||||
}
|
||||
/// Deprecated API ends here
|
||||
|
||||
@ -74,11 +73,9 @@ class xmldb_field extends xmldb_object {
|
||||
* @param string unsigned XMLDB_UNSIGNED or null (or false)
|
||||
* @param string notnull XMLDB_NOTNULL or null (or false)
|
||||
* @param string sequence XMLDB_SEQUENCE or null (or false)
|
||||
* @param string enum XMLDB_ENUM or null (or false)
|
||||
* @param array enumvalues an array of possible values if XMLDB_ENUM is set
|
||||
* @param string default meaningful default o null (or false)
|
||||
*/
|
||||
function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
|
||||
function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
|
||||
$this->type = $type;
|
||||
/// Try to split the precision into length and decimals and apply
|
||||
/// each one as needed
|
||||
@ -93,18 +90,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->unsigned = !empty($unsigned) ? true : false;
|
||||
$this->notnull = !empty($notnull) ? true : false;
|
||||
$this->sequence = !empty($sequence) ? true : false;
|
||||
$this->enum = !empty($enum) ? true : false;
|
||||
/// Accept both quoted and non-quoted vales (quoting them)a
|
||||
if (is_array($enumvalues)) {
|
||||
$this->enumvalues = array();
|
||||
foreach ($enumvalues as $value) {
|
||||
/// trim each value quotes
|
||||
$value = trim($value, "'");
|
||||
/// add them back
|
||||
$value = "'" . $value . "'";
|
||||
$this->enumvalues[] = $value;
|
||||
}
|
||||
}
|
||||
$this->setDefault($default);
|
||||
|
||||
$this->previous = $previous;
|
||||
@ -152,20 +137,6 @@ class xmldb_field extends xmldb_object {
|
||||
return $this->sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enum
|
||||
*/
|
||||
function getEnum() {
|
||||
return $this->enum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enumvalues
|
||||
*/
|
||||
function getEnumValues() {
|
||||
return $this->enumvalues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default
|
||||
*/
|
||||
@ -215,29 +186,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->sequence = $sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the field enum
|
||||
*/
|
||||
function setEnum($enum=true) {
|
||||
$this->enum = $enum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the field enumvalues, quoting unquoted values
|
||||
*/
|
||||
function setEnumValues($enumvalues) {
|
||||
if (is_array($enumvalues)) {
|
||||
$this->enumvalues = array();
|
||||
foreach ($enumvalues as $value) {
|
||||
/// trim each value quotes
|
||||
$value = trim($value, "'");
|
||||
/// add them back
|
||||
$value = "'" . $value . "'";
|
||||
$this->enumvalues[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the field default
|
||||
*/
|
||||
@ -265,8 +213,7 @@ class xmldb_field extends xmldb_object {
|
||||
/// $GLOBALS['traverse_array']=""; //Debug
|
||||
|
||||
/// Process table attributes (name, type, length, unsigned,
|
||||
/// notnull, sequence, enum, enumvalues, decimals, comment,
|
||||
/// previous, next)
|
||||
/// notnull, sequence, decimals, comment, previous, next)
|
||||
if (isset($xmlarr['@']['NAME'])) {
|
||||
$this->name = trim($xmlarr['@']['NAME']);
|
||||
} else {
|
||||
@ -368,62 +315,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->setDefault(trim($xmlarr['@']['DEFAULT']));
|
||||
}
|
||||
|
||||
if (isset($xmlarr['@']['ENUM'])) {
|
||||
$enum = strtolower(trim($xmlarr['@']['ENUM']));
|
||||
if ($enum == 'true') {
|
||||
$this->enum = true;
|
||||
} else if ($enum == 'false') {
|
||||
$this->enum = false;
|
||||
} else {
|
||||
$this->errormsg = 'Incorrect ENUM attribute (true/false allowed)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xmlarr['@']['ENUMVALUES'])) {
|
||||
$enumvalues = trim($xmlarr['@']['ENUMVALUES']);
|
||||
if (!$this->enum) {
|
||||
$this->errormsg = 'Wrong ENUMVALUES attribute (not ENUM)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
$this->enumvalues = $enumvalues;
|
||||
} else {
|
||||
/// Check we have a valid list (comma separated of quoted values)
|
||||
$enumarr = explode(',',$enumvalues);
|
||||
if ($enumarr) {
|
||||
foreach ($enumarr as $key => $enumelement) {
|
||||
/// Clear some spaces
|
||||
$enumarr[$key] = trim($enumelement);
|
||||
$enumelement = trim($enumelement);
|
||||
/// Skip if under error
|
||||
if (!$result) {
|
||||
continue;
|
||||
}
|
||||
/// Look for quoted strings
|
||||
if (substr($enumelement, 0, 1) != "'" ||
|
||||
substr($enumelement, -1, 1) != "'") {
|
||||
$this->errormsg = 'Incorrect ENUMVALUES attribute (some value is not properly quoted)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errormsg = 'Incorrect ENUMVALUES attribute (comma separated of quoted values)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
} else if ($this->enum) {
|
||||
$this->errormsg = 'Incorrect ENUMVALUES attribute (field is not declared as ENUM)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
}
|
||||
/// Finally, set the value
|
||||
if ($this->enum) {
|
||||
$this->enumvalues = $enumarr;
|
||||
}
|
||||
|
||||
$decimals = NULL;
|
||||
if (isset($xmlarr['@']['DECIMALS'])) {
|
||||
$decimals = trim($xmlarr['@']['DECIMALS']);
|
||||
@ -555,9 +446,6 @@ class xmldb_field extends xmldb_object {
|
||||
$key = $this->name . $this->type . $this->length .
|
||||
$this->unsigned . $this->notnull . $this->sequence .
|
||||
$this->decimals . $this->comment;
|
||||
if ($this->enum) {
|
||||
$key .= implode(', ',$this->enumvalues);
|
||||
}
|
||||
$this->hash = md5($key);
|
||||
}
|
||||
}
|
||||
@ -602,15 +490,6 @@ class xmldb_field extends xmldb_object {
|
||||
$sequence = 'false';
|
||||
}
|
||||
$o.= ' SEQUENCE="' . $sequence . '"';
|
||||
if ($this->enum) {
|
||||
$enum = 'true';
|
||||
} else {
|
||||
$enum = 'false';
|
||||
}
|
||||
$o.= ' ENUM="' . $enum . '"';
|
||||
if ($this->enum) {
|
||||
$o.= ' ENUMVALUES="' . implode(', ', $this->enumvalues) . '"';
|
||||
}
|
||||
if ($this->decimals !== NULL) {
|
||||
$o.= ' DECIMALS="' . $this->decimals . '"';
|
||||
}
|
||||
@ -745,11 +624,6 @@ class xmldb_field extends xmldb_object {
|
||||
/// Sequence fields are always unsigned
|
||||
$this->unsigned = true;
|
||||
}
|
||||
/// Calculate the enum and enumvalues field
|
||||
if ($adofield->type == 'enum') {
|
||||
$this->enum = true;
|
||||
$this->enumvalues = $adofield->enums;
|
||||
}
|
||||
/// Some more fields
|
||||
$this->loaded = true;
|
||||
$this->changed = true;
|
||||
@ -823,20 +697,6 @@ class xmldb_field extends xmldb_object {
|
||||
} else {
|
||||
$result .= 'null, ';
|
||||
}
|
||||
/// Enum
|
||||
$enum = $this->getEnum();
|
||||
if (!empty($enum)) {
|
||||
$result .= 'XMLDB_ENUM' . ', ';
|
||||
} else {
|
||||
$result .= 'null, ';
|
||||
}
|
||||
/// Enumvalues
|
||||
$enumvalues = $this->getEnumValues();
|
||||
if (!empty($enumvalues)) {
|
||||
$result .= 'array(' . implode(', ', $enumvalues) . '), ';
|
||||
} else {
|
||||
$result .= 'null, ';
|
||||
}
|
||||
/// Default
|
||||
$default = $this->getDefault();
|
||||
if ($default !== null && !$this->getSequence()) {
|
||||
@ -884,10 +744,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->type == XMLDB_TYPE_BINARY) {
|
||||
$o .= ' (' . $this->length . ')';
|
||||
}
|
||||
/// enum
|
||||
if ($this->enum) {
|
||||
$o .= ' enum(' . implode(', ', $this->enumvalues) . ')';
|
||||
}
|
||||
/// unsigned
|
||||
if ($this->type == XMLDB_TYPE_INTEGER ||
|
||||
$this->type == XMLDB_TYPE_NUMBER ||
|
||||
|
@ -700,8 +700,11 @@ class xmldb_table extends xmldb_object {
|
||||
function addFieldInfo($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
|
||||
|
||||
debugging('XMLDBTable->addFieldInfo() has been deprecated in Moodle 2.0. Will be out in Moodle 2.1. Please use xmldb_table->add_field() instead', DEBUG_DEVELOPER);
|
||||
if ($enum) {
|
||||
debugging('Also, ENUMs support has been dropped in Moodle 2.0. Your fields specs are incorrect because you are trying to introduce one new ENUM. Created DB estructures will ignore that.');
|
||||
}
|
||||
|
||||
return $this->add_field($name, $type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default, $previous);
|
||||
return $this->add_field($name, $type, $precision, $unsigned, $notnull, $sequence, $default, $previous);
|
||||
|
||||
}
|
||||
/// Deprecated API ends here
|
||||
@ -716,13 +719,11 @@ class xmldb_table extends xmldb_object {
|
||||
* @param string unsigned XMLDB_UNSIGNED or null (or false)
|
||||
* @param string notnull XMLDB_NOTNULL or null (or false)
|
||||
* @param string sequence XMLDB_SEQUENCE or null (or false)
|
||||
* @param string enum XMLDB_ENUM or null (or false)
|
||||
* @param array enumvalues an array of possible values if XMLDB_ENUM is set
|
||||
* @param string default meaningful default o null (or false)
|
||||
* @param string previous name of the previous field in the table or null (or false)
|
||||
*/
|
||||
function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
|
||||
$field = new xmldb_field($name, $type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default);
|
||||
function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
|
||||
$field = new xmldb_field($name, $type, $precision, $unsigned, $notnull, $sequence, $default);
|
||||
$this->addField($field, $previous);
|
||||
|
||||
return $field;
|
||||
|
@ -136,7 +136,7 @@ function xmldb_assignment_upgrade($oldversion) {
|
||||
|
||||
/// Rename field description on table assignment to intro
|
||||
$table = new xmldb_table('assignment');
|
||||
$field = new xmldb_field('description', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
|
||||
$field = new xmldb_field('description', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
|
||||
|
||||
/// Launch rename field description
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -149,7 +149,7 @@ function xmldb_assignment_upgrade($oldversion) {
|
||||
|
||||
/// Rename field format on table assignment to introformat
|
||||
$table = new xmldb_table('assignment');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch rename field format
|
||||
$dbman->rename_field($table, $field, 'introformat');
|
||||
|
@ -34,13 +34,13 @@ function xmldb_chat_upgrade($oldversion) {
|
||||
$table = new xmldb_table('chat_messages_current');
|
||||
|
||||
/// Adding fields to table chat_messages_current
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('chatid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('system', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('message', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timestamp', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('chatid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('system', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('message', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timestamp', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
/// Adding keys to table chat_messages_current
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -62,7 +62,7 @@ function xmldb_chat_upgrade($oldversion) {
|
||||
|
||||
/// Changing precision of field ip on table chat_users to (45)
|
||||
$table = new xmldb_table('chat_users');
|
||||
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'version');
|
||||
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'version');
|
||||
|
||||
/// Launch change of precision for field ip
|
||||
$dbman->change_field_precision($table, $field);
|
||||
@ -75,7 +75,7 @@ function xmldb_chat_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to chat
|
||||
$table = new xmldb_table('chat');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -32,7 +32,7 @@ function xmldb_choice_upgrade($oldversion) {
|
||||
|
||||
/// Rename field text on table choice to NEWNAMEGOESHERE
|
||||
$table = new xmldb_table('choice');
|
||||
$field = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
|
||||
$field = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
|
||||
|
||||
/// Launch rename field text
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -45,7 +45,7 @@ function xmldb_choice_upgrade($oldversion) {
|
||||
|
||||
/// Rename field format on table choice to NEWNAMEGOESHERE
|
||||
$table = new xmldb_table('choice');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch rename field format
|
||||
$dbman->rename_field($table, $field, 'introformat');
|
||||
|
@ -32,7 +32,7 @@ function xmldb_data_upgrade($oldversion) {
|
||||
/// Launch add field asearchtemplate again if does not exists yet - reported on several sites
|
||||
|
||||
$table = new xmldb_table('data');
|
||||
$field = new xmldb_field('asearchtemplate', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
|
||||
$field = new xmldb_field('asearchtemplate', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'jstemplate');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
@ -47,7 +47,7 @@ function xmldb_data_upgrade($oldversion) {
|
||||
$result = $DB->execute($sql);
|
||||
|
||||
$table = new xmldb_table('data');
|
||||
$field = new xmldb_field('notification', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editany');
|
||||
$field = new xmldb_field('notification', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'editany');
|
||||
// First step, Set NOT NULL
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
// Second step, Set default to 0
|
||||
@ -171,7 +171,7 @@ function xmldb_data_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to data
|
||||
$table = new xmldb_table('data');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -32,23 +32,23 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
$table = new xmldb_table('feedback_completedtmp');
|
||||
|
||||
$field = new xmldb_field('id');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('feedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('userid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('guestid');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', null);
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, null, false, '', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('timemodified');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$key = new xmldb_key('PRIMARY');
|
||||
@ -66,27 +66,27 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
$table = new xmldb_table('feedback_valuetmp');
|
||||
|
||||
$field = new xmldb_field('id');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('course_id');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('item');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('completed');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('tmp_completed');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('value');
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, null, null, null, false, null, null, '', null);
|
||||
$field->set_attributes(XMLDB_TYPE_TEXT, null, null, null, false, '', null);
|
||||
$table->addField($field);
|
||||
|
||||
$key = new xmldb_key('PRIMARY');
|
||||
@ -106,25 +106,25 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
/// Define field random_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completed');
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
/// Launch add field1
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// Define field anonymous_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completed');
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// Define field random_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completedtmp');
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
/// Launch add field1
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// Define field anonymous_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completedtmp');
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -136,7 +136,7 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
// public is a reserved word on Oracle
|
||||
|
||||
$table = new xmldb_table('feedback_template');
|
||||
$field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
|
||||
$field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
@ -208,7 +208,7 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2008042900) {
|
||||
/// Define field autonumbering to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1', 'multiple_submit');
|
||||
$field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'multiple_submit');
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -218,7 +218,7 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2008050104) {
|
||||
/// Define field site_after_submit to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', 'autonumbering');
|
||||
$field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'autonumbering');
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -244,7 +244,7 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2009031301) {
|
||||
/// Define field label to be added to feedback_item
|
||||
$table = new xmldb_table('feedback_item');
|
||||
$field = new xmldb_field('label', XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', 'name');
|
||||
$field = new xmldb_field('label', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'name');
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -255,7 +255,7 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
/// Rename field summary on table feedback to intro
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
|
||||
|
||||
/// Launch rename field summary
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -268,7 +268,7 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -67,7 +67,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
/// Define field completiondiscussions to be added to forum
|
||||
$table = new xmldb_table('forum');
|
||||
$field = new xmldb_field('completiondiscussions');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'blockperiod');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'blockperiod');
|
||||
|
||||
/// Launch add field completiondiscussions
|
||||
if(!$dbman->field_exists($table,$field)) {
|
||||
@ -75,7 +75,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
$field = new xmldb_field('completionreplies');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completiondiscussions');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completiondiscussions');
|
||||
|
||||
/// Launch add field completionreplies
|
||||
if(!$dbman->field_exists($table,$field)) {
|
||||
@ -84,7 +84,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
/// Define field completionposts to be added to forum
|
||||
$field = new xmldb_field('completionposts');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionreplies');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionreplies');
|
||||
|
||||
/// Launch add field completionposts
|
||||
if(!$dbman->field_exists($table,$field)) {
|
||||
@ -165,7 +165,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
/// Define field maxattachments to be added to forum
|
||||
$table = new xmldb_table('forum');
|
||||
$field = new xmldb_field('maxattachments', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1', 'maxbytes');
|
||||
$field = new xmldb_field('maxattachments', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'maxbytes');
|
||||
|
||||
/// Conditionally launch add field maxattachments
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -180,7 +180,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
/// Rename field format on table forum_posts to messageformat
|
||||
$table = new xmldb_table('forum_posts');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, null, '0', 'message');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'message');
|
||||
|
||||
/// Launch rename field format
|
||||
$dbman->rename_field($table, $field, 'messageformat');
|
||||
@ -193,7 +193,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
/// Define field messagetrust to be added to forum_posts
|
||||
$table = new xmldb_table('forum_posts');
|
||||
$field = new xmldb_field('messagetrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'messageformat');
|
||||
$field = new xmldb_field('messagetrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'messageformat');
|
||||
|
||||
/// Launch add field messagetrust
|
||||
$dbman->add_field($table, $field);
|
||||
@ -224,7 +224,7 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to forum
|
||||
$table = new xmldb_table('forum');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
@ -246,10 +246,10 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
/// Changing list of values (enum) of field type on table forum to none
|
||||
$table = new xmldb_table('forum');
|
||||
$field = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
|
||||
$field = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'general', 'course');
|
||||
|
||||
/// Launch change of list of values for field type
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
|
||||
/// forum savepoint reached
|
||||
upgrade_mod_savepoint($result, 2009042700, 'forum');
|
||||
|
@ -102,9 +102,9 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
if ($result && $oldversion < 2009042000) {
|
||||
|
||||
/// Rename field definitionformat on table glossary_entries to NEWNAMEGOESHERE
|
||||
/// Rename field definitionformat on table glossary_entries to definitionformat
|
||||
$table = new xmldb_table('glossary_entries');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'definition');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'definition');
|
||||
|
||||
/// Launch rename field definitionformat
|
||||
$dbman->rename_field($table, $field, 'definitionformat');
|
||||
@ -117,7 +117,7 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
/// Define field definitiontrust to be added to glossary_entries
|
||||
$table = new xmldb_table('glossary_entries');
|
||||
$field = new xmldb_field('definitiontrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'definitionformat');
|
||||
$field = new xmldb_field('definitiontrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'definitionformat');
|
||||
|
||||
/// Launch add field definitiontrust
|
||||
$dbman->add_field($table, $field);
|
||||
@ -130,7 +130,7 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
/// Rename field format on table glossary_comments to NEWNAMEGOESHERE
|
||||
$table = new xmldb_table('glossary_comments');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'entrycomment');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'entrycomment');
|
||||
|
||||
/// Launch rename field format
|
||||
$dbman->rename_field($table, $field, 'entrycommentformat');
|
||||
@ -143,7 +143,7 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
/// Define field entrycommenttrust to be added to glossary_comments
|
||||
$table = new xmldb_table('glossary_comments');
|
||||
$field = new xmldb_field('entrycommenttrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'entrycommentformat');
|
||||
$field = new xmldb_field('entrycommenttrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'entrycommentformat');
|
||||
|
||||
/// Conditionally launch add field entrycommenttrust
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -194,7 +194,7 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to glossary
|
||||
$table = new xmldb_table('glossary');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Conditionally launch add field introformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
|
@ -38,7 +38,7 @@ function xmldb_label_upgrade($oldversion) {
|
||||
|
||||
/// Rename field content on table label to intro
|
||||
$table = new xmldb_table('label');
|
||||
$field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
|
||||
$field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
|
||||
|
||||
/// Launch rename field content
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -51,7 +51,7 @@ function xmldb_label_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to label
|
||||
$table = new xmldb_table('label');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '4', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '4', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -37,7 +37,7 @@ function xmldb_lesson_upgrade($oldversion) {
|
||||
/// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177
|
||||
if ($dbman->field_exists($table, $field) && !$dbman->field_exists($table, $field2)) {
|
||||
/// Set field specs
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'ongoing');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'ongoing');
|
||||
/// Launch rename field usegrademax to usemaxgrade
|
||||
$dbman->rename_field($table, $field, 'usemaxgrade');
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
$table = new xmldb_table('quiz_report');
|
||||
|
||||
/// Adding fields to table quiz_report
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
||||
$table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
$table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table quiz_report
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -82,7 +82,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
|
||||
/// Define field lastcron to be added to quiz_report
|
||||
$table = new xmldb_table('quiz_report');
|
||||
$field = new xmldb_field('lastcron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'displayorder');
|
||||
$field = new xmldb_field('lastcron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'displayorder');
|
||||
|
||||
/// Conditionally launch add field lastcron
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -90,7 +90,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
/// Define field cron to be added to quiz_report
|
||||
$field = new xmldb_field('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'lastcron');
|
||||
$field = new xmldb_field('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'lastcron');
|
||||
|
||||
/// Conditionally launch add field cron
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -123,49 +123,49 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
/// Changing the type of all the columns that store grades to be NUMBER(10, 5) or similar.
|
||||
if ($result && $oldversion < 2008081501) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'questions');
|
||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'questions');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081501, 'quiz');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081502) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'sumgrades');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'sumgrades');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081502, 'quiz');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081503) {
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'attempt');
|
||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'attempt');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081503, 'quiz');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081504) {
|
||||
$table = new xmldb_table('quiz_feedback');
|
||||
$field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'feedbacktext');
|
||||
$field = new xmldb_field('mingrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'feedbacktext');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081504, 'quiz');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081505) {
|
||||
$table = new xmldb_table('quiz_feedback');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'mingrade');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'mingrade');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081505, 'quiz');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081506) {
|
||||
$table = new xmldb_table('quiz_grades');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null, 'userid');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'userid');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081506, 'quiz');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008081507) {
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'question');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'question');
|
||||
$dbman->change_field_type($table, $field);
|
||||
upgrade_mod_savepoint($result, 2008081507, 'quiz');
|
||||
}
|
||||
@ -201,7 +201,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
|
||||
/// Define field lastcron to be added to quiz_report
|
||||
$table = new xmldb_table('quiz_report');
|
||||
$field = new xmldb_field('capability', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null, 'cron');
|
||||
$field = new xmldb_field('capability', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'cron');
|
||||
|
||||
/// Conditionally launch add field lastcron
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -216,7 +216,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
|
||||
/// Define field showuserpicture to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('showuserpicture', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0', 'delay2');
|
||||
$field = new xmldb_field('showuserpicture', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'delay2');
|
||||
|
||||
/// Conditionally launch add field showuserpicture
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -257,7 +257,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2009031000) {
|
||||
/// Add new questiondecimaldigits setting, separate form the overall decimaldigits one.
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '2', 'decimalpoints');
|
||||
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '2', 'decimalpoints');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
@ -280,7 +280,7 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -14,13 +14,13 @@ function xmldb_quizreport_overview_upgrade($oldversion) {
|
||||
$table = new xmldb_table('quiz_question_regrade');
|
||||
|
||||
/// Adding fields to table quiz_question_regrade
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('newgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('oldgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('newgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('oldgrade', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table quiz_question_regrade
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -34,19 +34,19 @@ function xmldb_quizreport_overview_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2009030500) {
|
||||
/// Changing precision of field newgrade on table quiz_question_regrade to (12, 7).
|
||||
$table = new xmldb_table('quiz_question_regrade');
|
||||
$field = new xmldb_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null, null, null, 'attemptid');
|
||||
$field = new xmldb_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null, 'attemptid');
|
||||
|
||||
/// Launch change of precision for field newgrade
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
/// Changing precision of field oldgrade on table quiz_question_regrade to (12, 7).
|
||||
$table = new xmldb_table('quiz_question_regrade');
|
||||
$field = new xmldb_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null, null, null, 'newgrade');
|
||||
$field = new xmldb_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null, 'newgrade');
|
||||
|
||||
/// Launch change of precision for field newgrade
|
||||
$dbman->change_field_precision($table, $field);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
|
||||
/// Define field s to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('s', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'subquestion');
|
||||
$field = new xmldb_field('s', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'subquestion');
|
||||
|
||||
/// Conditionally launch add field s
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -30,7 +30,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
|
||||
/// Define field maxgrade to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'subquestions');
|
||||
|
||||
/// Conditionally launch add field maxgrade
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -43,7 +43,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
|
||||
/// Define field positions to be added to quiz_question_statistics
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('positions', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'maxgrade');
|
||||
$field = new xmldb_field('positions', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'maxgrade');
|
||||
|
||||
/// Conditionally launch add field positions
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -55,7 +55,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2008081500) {
|
||||
/// Changing type of field maxgrade on table quiz_question_statistics to number
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, null, null, 'subquestions');
|
||||
$field = new xmldb_field('maxgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'subquestions');
|
||||
|
||||
/// Launch change of type for field maxgrade
|
||||
$dbman->change_field_type($table, $field);
|
||||
@ -67,13 +67,13 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
$table = new xmldb_table('quiz_question_response_stats');
|
||||
|
||||
/// Adding fields to table quiz_question_response_stats
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('quizstatisticsid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('anssubqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('response', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
$table->add_field('rcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('credit', XMLDB_TYPE_NUMBER, '15, 5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('quizstatisticsid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('anssubqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('response', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
|
||||
$table->add_field('rcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('credit', XMLDB_TYPE_NUMBER, '15, 5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
/// Adding keys to table quiz_question_response_stats
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
@ -101,7 +101,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
/// Define field subqid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('subqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'questionid');
|
||||
$field = new xmldb_field('subqid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'questionid');
|
||||
|
||||
/// Conditionally launch add field subqid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -109,7 +109,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
/// Define field aid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('aid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'subqid');
|
||||
$field = new xmldb_field('aid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'subqid');
|
||||
|
||||
/// Conditionally launch add field aid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -126,7 +126,7 @@ function xmldb_quizreport_statistics_upgrade($oldversion) {
|
||||
/// Define field anssubqid to be dropped from quiz_question_response_stats
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
/// Define field subqid to be added to quiz_question_response_stats
|
||||
$field = new xmldb_field('negcovar', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'effectiveweight');
|
||||
$field = new xmldb_field('negcovar', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'effectiveweight');
|
||||
|
||||
/// Conditionally launch add field subqid
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
|
@ -32,7 +32,7 @@ function xmldb_resource_upgrade($oldversion) {
|
||||
|
||||
/// Rename field summary on table resource to intro
|
||||
$table = new xmldb_table('resource');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'reference');
|
||||
|
||||
/// Launch rename field summary
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -45,7 +45,7 @@ function xmldb_resource_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to resource
|
||||
$table = new xmldb_table('resource');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -32,7 +32,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
if ($result && $oldversion < 2008073000) {
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('whatgrade');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grademethod');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'grademethod');
|
||||
|
||||
/// Launch add field whatgrade
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
@ -46,7 +46,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
/// Define field scormtype to be added to scorm
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('scormtype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, 'local', 'name');
|
||||
$field = new xmldb_field('scormtype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'local', 'name');
|
||||
|
||||
/// Launch add field scormtype
|
||||
$dbman->add_field($table, $field);
|
||||
@ -59,7 +59,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
/// Define field sha1hash to be added to scorm
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('sha1hash', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null, 'updatefreq');
|
||||
$field = new xmldb_field('sha1hash', XMLDB_TYPE_CHAR, '40', null, null, null, null, 'updatefreq');
|
||||
|
||||
/// Launch add field sha1hash
|
||||
$dbman->add_field($table, $field);
|
||||
@ -72,7 +72,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
/// Define field revision to be added to scorm
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'md5hash');
|
||||
$field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'md5hash');
|
||||
|
||||
/// Launch add field revision
|
||||
$dbman->add_field($table, $field);
|
||||
@ -236,23 +236,23 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
/// Define new fields forcecompleted, forcenewattempt, displayattemptstatus, and displaycoursestructure to be added to scorm
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, '1', null, null, null, null, null, '0', 'maxattempt');
|
||||
$field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'maxattempt');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, '1', null, null, null, null, null, '0', 'forcecompleted');
|
||||
$field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'forcecompleted');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, '1', null, null, null, null, null, '0', 'forcenewattempt');
|
||||
$field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'forcenewattempt');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, '1', null, null, null, null, null, '1', 'lastattemptlock');
|
||||
$field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'lastattemptlock');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, '1', null, null, null, null, null, '1', 'displayattemptstatus');
|
||||
$field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'displayattemptstatus');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
@ -337,11 +337,11 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
if ($result && $oldversion < 2008090308) {
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'height');
|
||||
$field = new xmldb_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'height');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('timeclose', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timeopen');
|
||||
$field = new xmldb_field('timeclose', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timeopen');
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
@ -404,7 +404,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
/// Rename field summary on table scorm to intro
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'reference');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'reference');
|
||||
|
||||
/// Launch rename field summary
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -417,7 +417,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to scorm
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
@ -429,4 +429,4 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -32,7 +32,7 @@ function xmldb_survey_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to survey
|
||||
$table = new xmldb_table('survey');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Conditionally launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
@ -32,7 +32,7 @@ function xmldb_wiki_upgrade($oldversion) {
|
||||
|
||||
/// Rename field summary on table wiki to intro
|
||||
$table = new xmldb_table('wiki');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
|
||||
|
||||
/// Launch rename field summary
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
@ -45,7 +45,7 @@ function xmldb_wiki_upgrade($oldversion) {
|
||||
|
||||
/// Define field introformat to be added to wiki
|
||||
$table = new xmldb_table('wiki');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
@ -59,10 +59,10 @@ function xmldb_wiki_upgrade($oldversion) {
|
||||
|
||||
/// Changing list of values (enum) of field wtype on table wiki to none
|
||||
$table = new xmldb_table('wiki');
|
||||
$field = new xmldb_field('wtype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'group', 'pagename');
|
||||
$field = new xmldb_field('wtype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'group', 'pagename');
|
||||
|
||||
/// Launch change of list of values for field wtype
|
||||
$dbman->change_field_enum($table, $field);
|
||||
$dbman->drop_enum_from_field($table, $field);
|
||||
|
||||
/// wiki savepoint reached
|
||||
upgrade_mod_savepoint($result, 2009042700, 'wiki');
|
||||
|
Loading…
x
Reference in New Issue
Block a user