2006-10-04 09:47:05 +00:00
|
|
|
<?PHP //$Id$
|
|
|
|
|
|
|
|
// This file keeps track of upgrades to Moodle.
|
|
|
|
//
|
|
|
|
// Sometimes, changes between versions involve
|
|
|
|
// alterations to database structures and other
|
|
|
|
// major things that may break installations.
|
|
|
|
//
|
|
|
|
// The upgrade function in this file will attempt
|
|
|
|
// to perform all the necessary actions to upgrade
|
|
|
|
// your older installtion to the current version.
|
|
|
|
//
|
|
|
|
// If there's something it cannot do itself, it
|
|
|
|
// will tell you what you need to do.
|
|
|
|
//
|
|
|
|
// The commands in here will all be database-neutral,
|
2008-06-15 10:32:50 +00:00
|
|
|
// using the methods of database_manager class
|
2006-10-04 09:47:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
function xmldb_main_upgrade($oldversion=0) {
|
2008-05-15 21:40:00 +00:00
|
|
|
global $CFG, $THEME, $USER, $DB;
|
2006-10-04 09:47:05 +00:00
|
|
|
|
|
|
|
$result = true;
|
|
|
|
|
2008-05-23 22:30:42 +00:00
|
|
|
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
|
2008-05-15 21:40:00 +00:00
|
|
|
|
2008-05-01 20:29:04 +00:00
|
|
|
////////////////////////////////////////
|
|
|
|
///upgrade supported only from 1.9.x ///
|
|
|
|
////////////////////////////////////////
|
2008-02-21 09:27:11 +00:00
|
|
|
|
2008-03-07 13:23:38 +00:00
|
|
|
if ($result && $oldversion < 2008030700) {
|
|
|
|
|
|
|
|
/// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
|
2008-05-20 23:24:40 +00:00
|
|
|
$table = new xmldb_table('grade_letters');
|
2008-05-22 00:09:59 +00:00
|
|
|
$index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
|
2008-03-07 13:23:38 +00:00
|
|
|
|
|
|
|
/// Launch drop index contextid-lowerboundary
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->drop_index($table, $index);
|
2008-03-07 13:23:38 +00:00
|
|
|
|
|
|
|
/// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
|
2008-05-20 23:24:40 +00:00
|
|
|
$table = new xmldb_table('grade_letters');
|
2008-05-22 00:09:59 +00:00
|
|
|
$index = new xmldb_index('contextid-lowerboundary-letter', XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
|
2008-03-07 13:23:38 +00:00
|
|
|
|
|
|
|
/// Launch add index contextid-lowerboundary-letter
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->add_index($table, $index);
|
2008-03-07 13:23:38 +00:00
|
|
|
|
|
|
|
/// Main savepoint reached
|
2008-04-18 23:15:44 +00:00
|
|
|
upgrade_main_savepoint($result, 2008030700);
|
|
|
|
}
|
2008-03-07 13:23:38 +00:00
|
|
|
|
2008-05-01 20:29:04 +00:00
|
|
|
if ($result && $oldversion < 2008050100) {
|
|
|
|
// Update courses that used weekscss to weeks
|
2008-05-20 23:24:40 +00:00
|
|
|
$result = $DB->set_field('course', 'format', 'weeks', array('format' => 'weekscss'));
|
2008-05-01 20:29:04 +00:00
|
|
|
upgrade_main_savepoint($result, 2008050100);
|
|
|
|
}
|
|
|
|
|
2008-05-02 09:42:43 +00:00
|
|
|
if ($result && $oldversion < 2008050200) {
|
|
|
|
// remove unused config options
|
|
|
|
unset_config('statsrolesupgraded');
|
|
|
|
upgrade_main_savepoint($result, 2008050200);
|
|
|
|
}
|
|
|
|
|
2008-05-07 13:34:54 +00:00
|
|
|
if ($result && $oldversion < 2008050700) {
|
|
|
|
/// Fix minor problem caused by MDL-5482.
|
|
|
|
require_once($CFG->dirroot . '/question/upgrade.php');
|
|
|
|
$result = $result && question_fix_random_question_parents();
|
|
|
|
upgrade_main_savepoint($result, 2008050700);
|
|
|
|
}
|
|
|
|
|
2008-05-12 14:05:46 +00:00
|
|
|
if ($result && $oldversion < 2008051200) {
|
|
|
|
// if guest role used as default user role unset it and force admin to choose new setting
|
|
|
|
if (!empty($CFG->defaultuserroleid)) {
|
2008-05-30 16:50:00 +00:00
|
|
|
if ($role = $DB->get_record('role', array('id'=>$CFG->defaultuserroleid))) {
|
2008-05-12 14:05:46 +00:00
|
|
|
if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
|
|
|
|
if (isset($guestroles[$role->id])) {
|
|
|
|
set_config('defaultuserroleid', null);
|
|
|
|
notify('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set_config('defaultuserroleid', null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-12 14:38:45 +00:00
|
|
|
if ($result && $oldversion < 2008051201) {
|
|
|
|
notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
|
|
|
|
|
2008-05-15 17:03:49 +00:00
|
|
|
/// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859
|
|
|
|
if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') {
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->execute("UPDATE {user} SET idnumber = '' WHERE idnumber IS NULL");
|
2008-05-15 17:03:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-12 14:38:45 +00:00
|
|
|
/// Define index idnumber (not unique) to be dropped form user
|
2008-05-20 23:24:40 +00:00
|
|
|
$table = new xmldb_table('user');
|
2008-05-22 00:09:59 +00:00
|
|
|
$index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
|
2008-05-12 14:38:45 +00:00
|
|
|
|
|
|
|
/// Launch drop index idnumber
|
2008-05-15 21:40:00 +00:00
|
|
|
if ($dbman->index_exists($table, $index)) {
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->drop_index($table, $index);
|
2008-05-12 14:38:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Changing precision of field idnumber on table user to (255)
|
2008-05-20 23:24:40 +00:00
|
|
|
$table = new xmldb_table('user');
|
2008-05-22 00:09:59 +00:00
|
|
|
$field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'password');
|
2008-05-12 14:38:45 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field idnumber
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->change_field_precision($table, $field);
|
2008-05-12 14:38:45 +00:00
|
|
|
|
|
|
|
/// Launch add index idnumber again
|
2008-05-22 00:09:59 +00:00
|
|
|
$index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->add_index($table, $index);
|
2008-05-12 14:38:45 +00:00
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008051201);
|
|
|
|
}
|
|
|
|
|
2008-05-16 02:15:23 +00:00
|
|
|
if ($result && $oldversion < 2008051202) {
|
2008-05-30 16:50:00 +00:00
|
|
|
$log_action = new object();
|
2008-05-16 02:15:23 +00:00
|
|
|
$log_action->module = 'course';
|
|
|
|
$log_action->action = 'unenrol';
|
|
|
|
$log_action->mtable = 'course';
|
|
|
|
$log_action->field = 'fullname';
|
2008-05-30 16:50:00 +00:00
|
|
|
if (!$DB->record_exists('log_display', array('action'=>'unenrol', 'module'=>'course'))) {
|
|
|
|
$result = $result && $DB->insert_record('log_display', $log_action);
|
2008-05-16 02:15:23 +00:00
|
|
|
}
|
|
|
|
upgrade_main_savepoint($result, 2008051202);
|
|
|
|
}
|
|
|
|
|
2008-06-16 00:16:00 +00:00
|
|
|
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);
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->change_field_precision($table, $field);
|
2008-06-16 00:16:00 +00:00
|
|
|
upgrade_main_savepoint($result, 2008051203);
|
|
|
|
}
|
|
|
|
|
2008-06-30 09:04:07 +00:00
|
|
|
if ($result && $oldversion < 2008063001) {
|
|
|
|
// table to be modified
|
|
|
|
$table = new xmldb_table('tag_instance');
|
|
|
|
// 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');
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
// modify index
|
|
|
|
$index = new xmldb_index('itemtype-itemid-tagid');
|
|
|
|
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid'));
|
|
|
|
$dbman->drop_index($table, $index);
|
|
|
|
$index = new xmldb_index('itemtype-itemid-tagid-tiuserid');
|
|
|
|
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid', 'tiuserid'));
|
|
|
|
$dbman->add_index($table, $index);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008063001);
|
|
|
|
}
|
2008-06-30 11:00:42 +00:00
|
|
|
if ($result && $oldversion < 2008063002) {
|
|
|
|
|
|
|
|
/// Define table repository to be created
|
|
|
|
$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('repositoryname', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
|
|
|
$table->add_field('repositorytype', XMLDB_TYPE_CHAR, '255', null, 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('data1', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
|
|
|
$table->add_field('data2', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
|
|
|
$table->add_field('data3', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
|
|
|
$table->add_field('data4', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
|
|
|
$table->add_field('data5', 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, '0');
|
|
|
|
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
|
|
|
|
/// Adding keys to table repository
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for repository
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
2008-06-30 09:04:07 +00:00
|
|
|
|
2008-06-30 11:00:42 +00:00
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008063002);
|
|
|
|
}
|
2008-06-30 09:04:07 +00:00
|
|
|
|
2008-07-03 17:07:54 +00:00
|
|
|
if ($result && $oldversion < 2008070300) {
|
|
|
|
$result = $DB->delete_records_select('role_names', $DB->sql_isempty('role_names', 'name', false, false));
|
|
|
|
upgrade_main_savepoint($result, 2008070300);
|
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2008-07-06 23:54:07 +00:00
|
|
|
if ($result && $oldversion < 2008070700) {
|
|
|
|
if (isset($CFG->defaultuserroleid) and isset($CFG->guestroleid) and $CFG->defaultuserroleid == $CFG->guestroleid) {
|
|
|
|
// guest can not be selected in defaultuserroleid!
|
|
|
|
unset_config('defaultuserroleid');
|
|
|
|
}
|
|
|
|
upgrade_main_savepoint($result, 2008070700);
|
|
|
|
}
|
|
|
|
|
2008-07-07 15:09:40 +00:00
|
|
|
if ($result && $oldversion < 2008070701) {
|
|
|
|
|
|
|
|
/// Define table portfolio_instance to be created
|
|
|
|
$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');
|
|
|
|
|
|
|
|
/// Adding keys to table portfolio_instance
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for portfolio_instance
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
/// Define table portfolio_instance_config to be created
|
|
|
|
$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);
|
|
|
|
|
|
|
|
/// Adding keys to table portfolio_instance_config
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('instance', XMLDB_KEY_FOREIGN, array('instance'), 'portfolio_instance', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table portfolio_instance_config
|
|
|
|
$table->add_index('name', XMLDB_INDEX_NOTUNIQUE, array('name'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for portfolio_instance_config
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table portfolio_instance_user to be created
|
|
|
|
$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);
|
|
|
|
|
|
|
|
/// Adding keys to table portfolio_instance_user
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('instancefk', XMLDB_KEY_FOREIGN, array('instance'), 'portfolio_instance', array('id'));
|
|
|
|
$table->add_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for portfolio_instance_user
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008070701);
|
|
|
|
}
|
2008-07-24 08:38:03 +00:00
|
|
|
|
|
|
|
if ($result && $oldversion < 2008072400) {
|
2008-07-31 22:15:30 +00:00
|
|
|
/// Create the database tables for message_processors and message_providers
|
|
|
|
$table = new xmldb_table('message_providers');
|
|
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
|
|
|
$table->add_field('modulename', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('modulefile', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
2008-07-27 22:02:20 +00:00
|
|
|
$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_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->create_table($table);
|
|
|
|
|
2008-07-31 22:15:30 +00:00
|
|
|
|
|
|
|
$provider = new object();
|
|
|
|
$provider->modulename = 'moodle';
|
|
|
|
$provider->modulefile = 'index.php';
|
|
|
|
$DB->insert_record('message_providers', $provider);
|
|
|
|
|
2008-07-24 08:38:03 +00:00
|
|
|
/// delete old and create new fields
|
2008-07-27 22:02:20 +00:00
|
|
|
$table = new xmldb_table('message');
|
|
|
|
$field = new xmldb_field('messagetype');
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
|
|
|
|
/// fields to rename
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('message');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->rename_field($table, $field, 'fullmessage');
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('format');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->rename_field($table, $field, 'fullmessageformat');
|
|
|
|
|
|
|
|
/// new message fields
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('subject');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->add_field($table, $field);
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('fullmessagehtml');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->add_field($table, $field);
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('smallmessage');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
|
|
|
|
|
2008-07-27 22:02:20 +00:00
|
|
|
$table = new xmldb_table('message_read');
|
|
|
|
$field = new xmldb_field('messagetype');
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->drop_field($table, $field);
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('mailed');
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
|
|
|
|
/// fields to rename
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('message');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->rename_field($table, $field, 'fullmessage');
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('format');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->rename_field($table, $field, 'fullmessageformat');
|
|
|
|
|
|
|
|
|
|
|
|
/// new message fields
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('subject');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->add_field($table, $field);
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('fullmessagehtml');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->add_field($table, $field);
|
2008-07-27 22:02:20 +00:00
|
|
|
$field = new xmldb_field('smallmessage');
|
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
|
|
|
|
/// new table
|
2008-07-27 22:02:20 +00:00
|
|
|
$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_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
|
|
|
|
upgrade_main_savepoint($result, 2008072400);
|
|
|
|
}
|
|
|
|
|
2008-07-28 12:31:29 +00:00
|
|
|
if ($result && $oldversion < 2008072800) {
|
|
|
|
|
|
|
|
/// 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');
|
|
|
|
|
|
|
|
/// Launch add field enablecompletion
|
|
|
|
if(!$dbman->field_exists($table,$field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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');
|
|
|
|
|
|
|
|
/// Launch add field completion
|
|
|
|
if(!$dbman->field_exists($table,$field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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');
|
|
|
|
|
|
|
|
/// Launch add field completiongradeitemnumber
|
|
|
|
if(!$dbman->field_exists($table,$field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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');
|
|
|
|
|
|
|
|
/// Launch add field completionview
|
|
|
|
if(!$dbman->field_exists($table,$field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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');
|
|
|
|
|
|
|
|
/// Launch add field completionexpected
|
|
|
|
if(!$dbman->field_exists($table,$field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table course_modules_completion to be created
|
|
|
|
$table = new xmldb_table('course_modules_completion');
|
|
|
|
if(!$dbman->table_exists($table)) {
|
|
|
|
|
|
|
|
/// Adding fields to table course_modules_completion
|
2008-07-28 17:26:57 +00:00
|
|
|
$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);
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Adding keys to table course_modules_completion
|
2008-07-28 17:26:57 +00:00
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Adding indexes to table course_modules_completion
|
2008-07-28 17:26:57 +00:00
|
|
|
$table->add_index('coursemoduleid', XMLDB_INDEX_NOTUNIQUE, array('coursemoduleid'));
|
|
|
|
$table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Launch create table for course_modules_completion
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008072800);
|
|
|
|
}
|
|
|
|
|
2008-07-30 15:04:19 +00:00
|
|
|
if ($result && $oldversion < 2008073000) {
|
2008-07-07 15:09:40 +00:00
|
|
|
|
2008-07-30 15:04:19 +00:00
|
|
|
/// Define table portfolio_log to be created
|
|
|
|
$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);
|
|
|
|
|
|
|
|
/// Adding keys to table portfolio_log
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
$table->add_key('portfoliofk', XMLDB_KEY_FOREIGN, array('portfolio'), 'portfolio_instance', array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for portfolio_log
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008073000);
|
|
|
|
}
|
2008-07-31 08:01:46 +00:00
|
|
|
|
|
|
|
if ($result && $oldversion < 2008073104) {
|
|
|
|
/// Drop old table that might exist for some people
|
|
|
|
$table = new xmldb_table('message_providers');
|
|
|
|
if ($dbman->table_exists($table)) {
|
|
|
|
$dbman->drop_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table message_providers to be created
|
|
|
|
$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);
|
|
|
|
|
|
|
|
/// Adding keys to table message_providers
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table message_providers
|
|
|
|
$table->add_index('componentname', XMLDB_INDEX_UNIQUE, array('component', 'name'));
|
|
|
|
|
|
|
|
/// Create table for message_providers
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
upgrade_main_savepoint($result, 2008073104);
|
|
|
|
}
|
2008-07-31 22:15:30 +00:00
|
|
|
|
|
|
|
if ($result && $oldversion < 2008073111) {
|
|
|
|
/// Define table files to be created
|
|
|
|
$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);
|
|
|
|
|
|
|
|
/// Adding keys to table files
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
|
|
|
|
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table files
|
|
|
|
$table->add_index('filearea-contextid-itemid', XMLDB_INDEX_NOTUNIQUE, array('filearea', 'contextid', 'itemid'));
|
|
|
|
$table->add_index('contenthash', XMLDB_INDEX_NOTUNIQUE, array('contenthash'));
|
|
|
|
$table->add_index('pathnamehash', XMLDB_INDEX_UNIQUE, array('pathnamehash'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for files
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008073111);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008073112) {
|
|
|
|
/// Define table files_cleanup to be created
|
|
|
|
$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);
|
|
|
|
|
|
|
|
/// Adding keys to table files_cleanup
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table files_cleanup
|
|
|
|
$table->add_index('contenthash', XMLDB_INDEX_UNIQUE, array('contenthash'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for files_cleanup
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008073112);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008073113) {
|
|
|
|
/// move all course, backup and other files to new filepool based storage
|
|
|
|
upgrade_migrate_files_courses();
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008073113);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008073114) {
|
|
|
|
/// move all course, backup and other files to new filepool based storage
|
|
|
|
upgrade_migrate_files_blog();
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008073114);
|
|
|
|
}
|
2008-05-15 21:40:00 +00:00
|
|
|
|
2008-08-03 23:24:12 +00:00
|
|
|
if ($result && $oldversion < 2008080400) {
|
|
|
|
// Add field ssl_jump_url to mnet application, and populate existing default applications
|
|
|
|
$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);
|
|
|
|
$result = $result && $dbman->add_field($table, $field);
|
|
|
|
$result = $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'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008080400);
|
|
|
|
}
|
|
|
|
|
2007-06-20 23:06:29 +00:00
|
|
|
return $result;
|
2006-10-04 09:47:05 +00:00
|
|
|
}
|
2007-08-09 21:51:09 +00:00
|
|
|
|
|
|
|
|
2006-10-04 09:47:05 +00:00
|
|
|
?>
|