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
|
2008-08-16 12:16:01 +00:00
|
|
|
//
|
|
|
|
// Please do not forget to use upgrade_set_timeout()
|
|
|
|
// before any action that may take longer time to finish.
|
2006-10-04 09:47:05 +00:00
|
|
|
|
2008-08-16 12:16:01 +00:00
|
|
|
function xmldb_main_upgrade($oldversion) {
|
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
|
|
|
|
2009-01-31 20:07:32 +00:00
|
|
|
if ($result && $oldversion < 2008030600) {
|
|
|
|
//NOTE: this table was added much later, that is why this step is repeated later in this file
|
|
|
|
|
|
|
|
/// Define table upgrade_log to be created
|
|
|
|
$table = new xmldb_table('upgrade_log');
|
|
|
|
|
|
|
|
/// Adding fields to table upgrade_log
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2009-01-31 20:07:32 +00:00
|
|
|
|
|
|
|
/// Adding keys to table upgrade_log
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table upgrade_log
|
|
|
|
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
|
|
|
|
$table->add_index('type-timemodified', XMLDB_INDEX_NOTUNIQUE, array('type', 'timemodified'));
|
|
|
|
|
|
|
|
/// Create table for upgrade_log
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008030600);
|
|
|
|
}
|
|
|
|
|
2008-03-07 13:23:38 +00:00
|
|
|
if ($result && $oldversion < 2008030700) {
|
2008-08-16 12:16:01 +00:00
|
|
|
upgrade_set_timeout(60*20); // this may take a while
|
2008-03-07 13:23:38 +00:00
|
|
|
|
|
|
|
/// 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) {
|
2008-08-16 12:16:01 +00:00
|
|
|
upgrade_set_timeout(60*20); // this may take a while
|
|
|
|
|
2008-05-07 13:34:54 +00:00
|
|
|
/// 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-08-16 12:16:01 +00:00
|
|
|
upgrade_set_timeout(60*20); // this may take a while
|
2008-05-12 14:38:45 +00:00
|
|
|
|
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
|
2008-11-05 00:12:30 +00:00
|
|
|
$dbfamily = $DB->get_dbfamily();
|
|
|
|
if ($dbfamily === 'mysql' || $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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 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) {
|
2008-08-16 12:16:01 +00:00
|
|
|
upgrade_set_timeout(60*20); // this may take a while
|
|
|
|
|
2008-06-30 09:04:07 +00:00
|
|
|
// table to be modified
|
|
|
|
$table = new xmldb_table('tag_instance');
|
|
|
|
// add field
|
|
|
|
$field = new xmldb_field('tiuserid');
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'itemid');
|
2008-06-30 09:04:07 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
// modify index
|
|
|
|
$index = new xmldb_index('itemtype-itemid-tagid');
|
|
|
|
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid'));
|
2008-09-05 14:49:06 +00:00
|
|
|
if ($dbman->index_exists($table, $index)) {
|
|
|
|
$dbman->drop_index($table, $index);
|
|
|
|
}
|
2008-06-30 09:04:07 +00:00
|
|
|
$index = new xmldb_index('itemtype-itemid-tagid-tiuserid');
|
|
|
|
$index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid', 'tiuserid'));
|
2008-09-05 14:49:06 +00:00
|
|
|
if (!$dbman->index_exists($table, $index)) {
|
|
|
|
$dbman->add_index($table, $index);
|
|
|
|
}
|
2008-06-30 09:04:07 +00:00
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008063001);
|
|
|
|
}
|
|
|
|
|
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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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');
|
2008-07-07 15:09:40 +00:00
|
|
|
|
|
|
|
/// 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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-07 15:09:40 +00:00
|
|
|
|
|
|
|
/// 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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-07 15:09:40 +00:00
|
|
|
|
|
|
|
/// 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-31 22:15:30 +00:00
|
|
|
|
2008-08-16 12:16:01 +00:00
|
|
|
if ($result && $oldversion < 2008072400) {
|
|
|
|
/// Create the database tables for message_processors
|
2008-07-27 22:02:20 +00:00
|
|
|
$table = new xmldb_table('message_processors');
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-27 22:02:20 +00:00
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
2008-07-24 08:38:03 +00:00
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
/// 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-27 22:02:20 +00:00
|
|
|
$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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'defaultrole');
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Launch add field enablecompletion
|
2008-08-16 12:16:01 +00:00
|
|
|
if (!$dbman->field_exists($table,$field)) {
|
2008-07-28 12:31:29 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
2008-08-16 12:16:01 +00:00
|
|
|
|
2008-07-28 12:31:29 +00:00
|
|
|
/// Define field completion to be added to course_modules
|
|
|
|
$table = new xmldb_table('course_modules');
|
|
|
|
$field = new xmldb_field('completion');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupmembersonly');
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Launch add field completion
|
2008-08-16 12:16:01 +00:00
|
|
|
if (!$dbman->field_exists($table,$field)) {
|
2008-07-28 12:31:29 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field completiongradeitemnumber to be added to course_modules
|
|
|
|
$field = new xmldb_field('completiongradeitemnumber');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'completion');
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Launch add field completiongradeitemnumber
|
2008-08-16 12:16:01 +00:00
|
|
|
if (!$dbman->field_exists($table,$field)) {
|
2008-07-28 12:31:29 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field completionview to be added to course_modules
|
|
|
|
$field = new xmldb_field('completionview');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completiongradeitemnumber');
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Launch add field completionview
|
2008-08-16 12:16:01 +00:00
|
|
|
if (!$dbman->field_exists($table,$field)) {
|
2008-07-28 12:31:29 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field completionexpected to be added to course_modules
|
|
|
|
$field = new xmldb_field('completionexpected');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionview');
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Launch add field completionexpected
|
2008-08-16 12:16:01 +00:00
|
|
|
if (!$dbman->field_exists($table,$field)) {
|
2008-07-28 12:31:29 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table course_modules_completion to be created
|
|
|
|
$table = new xmldb_table('course_modules_completion');
|
2008-08-16 12:16:01 +00:00
|
|
|
if (!$dbman->table_exists($table)) {
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
/// Adding fields to table course_modules_completion
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-08-16 12:16:01 +00:00
|
|
|
|
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-08-16 12:16:01 +00:00
|
|
|
|
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-08-16 12:16:01 +00:00
|
|
|
|
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-08-16 12:16:01 +00:00
|
|
|
|
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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-30 15:04:19 +00:00
|
|
|
|
|
|
|
/// 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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-31 08:01:46 +00:00
|
|
|
|
|
|
|
/// 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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-31 22:15:30 +00:00
|
|
|
|
|
|
|
/// 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
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-07-31 22:15:30 +00:00
|
|
|
|
|
|
|
/// 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)) {
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
2008-08-04 02:20:43 +00:00
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
$result = $DB->set_field('mnet_application', 'sso_jump_url', '/auth/mnet/jump.php', array('name' => 'moodle'));
|
2008-08-03 23:24:12 +00:00
|
|
|
$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);
|
|
|
|
}
|
2008-08-05 13:24:47 +00:00
|
|
|
|
|
|
|
if ($result && $oldversion < 2008080500) {
|
|
|
|
|
|
|
|
/// Define table portfolio_tempdata to be created
|
|
|
|
$table = new xmldb_table('portfolio_tempdata');
|
|
|
|
|
|
|
|
/// Adding fields to table portfolio_tempdata
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-08-05 13:24:47 +00:00
|
|
|
|
|
|
|
/// Adding keys to table portfolio_tempdata
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for portfolio_tempdata
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008080500);
|
|
|
|
}
|
|
|
|
|
2008-08-06 15:27:42 +00:00
|
|
|
if ($result && $oldversion < 2008080600) {
|
|
|
|
|
|
|
|
$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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('expirytime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'data');
|
2008-08-06 15:27:42 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field expirytime
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008080600);
|
|
|
|
}
|
2008-08-16 12:16:01 +00:00
|
|
|
|
2008-08-15 11:15:08 +00:00
|
|
|
/// 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');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('defaultgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'generalfeedback');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081500);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008081501) {
|
|
|
|
$table = new xmldb_table('question');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'defaultgrade');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081501);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008081502) {
|
|
|
|
$table = new xmldb_table('question_answers');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('fraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'answer');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081502);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008081503) {
|
|
|
|
$table = new xmldb_table('question_sessions');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('sumpenalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'newgraded');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081503);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008081504) {
|
|
|
|
$table = new xmldb_table('question_states');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'event');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081504);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008081505) {
|
|
|
|
$table = new xmldb_table('question_states');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('raw_grade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'grade');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081505);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008081506) {
|
|
|
|
$table = new xmldb_table('question_states');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'raw_grade');
|
2008-08-15 11:15:08 +00:00
|
|
|
$dbman->change_field_type($table, $field);
|
|
|
|
upgrade_main_savepoint($result, 2008081506);
|
|
|
|
}
|
|
|
|
|
2008-08-16 12:16:01 +00:00
|
|
|
if ($result && $oldversion < 2008081600) {
|
|
|
|
|
|
|
|
/// all 1.9 sites and fresh installs must already be unicode, not needed anymore
|
|
|
|
unset_config('unicodedb');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008081600);
|
|
|
|
}
|
|
|
|
|
2008-08-19 15:02:46 +00:00
|
|
|
if ($result && $oldversion < 2008081900) {
|
|
|
|
/// Define field userid to be added to portfolio_tempdata
|
|
|
|
$table = new xmldb_table('portfolio_tempdata');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'expirytime');
|
2008-08-19 15:02:46 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field userid
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
$DB->set_field('portfolio_tempdata', 'userid', 0);
|
|
|
|
/// now change it to be notnull
|
|
|
|
|
|
|
|
/// Changing nullability of field userid on table portfolio_tempdata to not null
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'expirytime');
|
2008-08-19 15:02:46 +00:00
|
|
|
|
|
|
|
/// Launch change of nullability for field userid
|
|
|
|
$dbman->change_field_notnull($table, $field);
|
|
|
|
|
|
|
|
/// Define key userfk (foreign) to be added to portfolio_tempdata
|
|
|
|
$table = new xmldb_table('portfolio_tempdata');
|
|
|
|
$key = new xmldb_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Launch add key userfk
|
|
|
|
$dbman->add_key($table, $key);
|
|
|
|
|
|
|
|
upgrade_main_savepoint($result, 2008081900);
|
|
|
|
}
|
2008-08-26 19:49:54 +00:00
|
|
|
if ($result && $oldversion < 2008082602) {
|
2008-08-26 07:20:56 +00:00
|
|
|
|
|
|
|
/// Define table repository to be dropped
|
|
|
|
$table = new xmldb_table('repository');
|
|
|
|
|
|
|
|
/// Conditionally launch drop table for repository
|
|
|
|
if ($dbman->table_exists($table)) {
|
|
|
|
$dbman->drop_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table repository to be created
|
|
|
|
$table = new xmldb_table('repository');
|
|
|
|
|
|
|
|
/// Adding fields to table repository
|
2009-05-01 01:19:16 +00:00
|
|
|
$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');
|
2008-08-26 07:20:56 +00:00
|
|
|
|
|
|
|
/// 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);
|
|
|
|
}
|
|
|
|
/// Define table repository_instances to be created
|
|
|
|
$table = new xmldb_table('repository_instances');
|
|
|
|
|
|
|
|
/// Adding fields to table repository_instances
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-08-26 07:20:56 +00:00
|
|
|
|
|
|
|
/// Adding keys to table repository_instances
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for repository_instances
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table repository_instance_config to be created
|
|
|
|
$table = new xmldb_table('repository_instance_config');
|
|
|
|
|
|
|
|
/// Adding fields to table repository_instance_config
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-08-26 07:20:56 +00:00
|
|
|
|
|
|
|
/// Adding keys to table repository_instance_config
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for repository_instance_config
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2008-08-26 19:49:54 +00:00
|
|
|
upgrade_main_savepoint($result, 2008082602);
|
2008-08-26 07:20:56 +00:00
|
|
|
}
|
|
|
|
|
2008-08-29 10:08:27 +00:00
|
|
|
if ($result && $oldversion < 2008082700) {
|
|
|
|
/// Add a new column to the question sessions table to record whether a
|
|
|
|
/// question has been flagged.
|
|
|
|
|
|
|
|
/// Define field flagged to be added to question_sessions
|
|
|
|
$table = new xmldb_table('question_sessions');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('flagged', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'manualcomment');
|
2008-08-29 10:08:27 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field flagged
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008082700);
|
|
|
|
}
|
2008-08-19 15:02:46 +00:00
|
|
|
|
2008-08-29 18:30:01 +00:00
|
|
|
if ($result && $oldversion < 2008082900) {
|
|
|
|
|
|
|
|
/// Changing precision of field parent_type on table mnet_rpc to (20)
|
|
|
|
$table = new xmldb_table('mnet_rpc');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('parent_type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, 'xmlrpc_path');
|
2008-08-29 18:30:01 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field parent_type
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008082900);
|
|
|
|
}
|
|
|
|
|
2008-09-01 09:10:33 +00:00
|
|
|
if ($result && $oldversion < 2008090108) {
|
|
|
|
$repo = new object();
|
|
|
|
$repo->type = 'upload';
|
|
|
|
$repo->visible = 1;
|
|
|
|
$repo->sortorder = 1;
|
|
|
|
if (!$DB->record_exists('repository', array('type'=>'upload'))) {
|
|
|
|
$typeid = $DB->insert_record('repository', $repo);
|
|
|
|
}else{
|
|
|
|
$record = $DB->get_record('repository', array('type'=>'upload'));
|
|
|
|
$typeid = $record->id;
|
|
|
|
}
|
|
|
|
if (!$DB->record_exists('repository_instances', array('typeid'=>$typeid))) {
|
|
|
|
$instance = new object();
|
2008-09-04 06:50:44 +00:00
|
|
|
$instance->name = get_string('repositoryname', 'repository_upload');
|
2008-09-01 09:10:33 +00:00
|
|
|
$instance->typeid = $typeid;
|
|
|
|
$instance->userid = 0;
|
|
|
|
$instance->contextid = SITEID;
|
|
|
|
$instance->timecreated = time();
|
|
|
|
$instance->timemodified = time();
|
|
|
|
$result = $result && $DB->insert_record('repository_instances', $instance);
|
|
|
|
}
|
|
|
|
$repo->type = 'local';
|
|
|
|
$repo->visible = 1;
|
|
|
|
$repo->sortorder = 1;
|
|
|
|
if (!$DB->record_exists('repository', array('type'=>'local'))) {
|
|
|
|
$typeid = $DB->insert_record('repository', $repo);
|
|
|
|
}else{
|
|
|
|
$record = $DB->get_record('repository', array('type'=>'local'));
|
|
|
|
$typeid = $record->id;
|
|
|
|
}
|
|
|
|
if (!$DB->record_exists('repository_instances', array('typeid'=>$typeid))) {
|
|
|
|
$instance = new object();
|
2008-09-04 06:50:44 +00:00
|
|
|
$instance->name = get_string('repositoryname', 'repository_local');
|
2008-09-01 09:10:33 +00:00
|
|
|
$instance->typeid = $typeid;
|
|
|
|
$instance->userid = 0;
|
|
|
|
$instance->contextid = SITEID;
|
|
|
|
$instance->timecreated = time();
|
|
|
|
$instance->timemodified = time();
|
|
|
|
$result = $result && $DB->insert_record('repository_instances', $instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
upgrade_main_savepoint($result, 2008090108);
|
|
|
|
}
|
|
|
|
|
2008-09-10 10:15:05 +00:00
|
|
|
// MDL-16411 Move all plugintype_pluginname_version values from config to config_plugins.
|
|
|
|
if ($result && $oldversion < 2008091000) {
|
|
|
|
foreach (get_object_vars($CFG) as $name => $value) {
|
|
|
|
if (substr($name, strlen($name) - 8) !== '_version') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$pluginname = substr($name, 0, strlen($name) - 8);
|
|
|
|
if (!strpos($pluginname, '_')) {
|
|
|
|
// Skip things like backup_version that don't contain an extra _
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($pluginname == 'enrol_ldap_version') {
|
|
|
|
// Special case - this is something different from a plugin version number.
|
|
|
|
continue;
|
|
|
|
}
|
2008-09-10 10:30:43 +00:00
|
|
|
if (!preg_match('/^\d{10}$/', $value)) {
|
2008-09-10 10:15:05 +00:00
|
|
|
// Extra safety check, skip anything that does not look like a Moodle
|
|
|
|
// version number (10 digits).
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$result = $result && set_config('version', $value, $pluginname);
|
|
|
|
$result = $result && unset_config($name);
|
|
|
|
}
|
|
|
|
upgrade_main_savepoint($result, 2008091000);
|
|
|
|
}
|
|
|
|
|
2008-09-16 09:08:36 +00:00
|
|
|
//Add a readonly field to the repository_instances table
|
|
|
|
//in order to support instance created automatically by a repository plugin
|
|
|
|
if ($result && $oldversion < 2008091611) {
|
|
|
|
|
|
|
|
/// Define field readonly to be added to repository_instances
|
|
|
|
$table = new xmldb_table('repository_instances');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('readonly', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timemodified');
|
2008-09-16 09:08:36 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field readonly
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008091611);
|
|
|
|
}
|
|
|
|
|
2008-09-23 15:12:07 +00:00
|
|
|
if ($result && $oldversion < 2008092300) {
|
|
|
|
unset_config('editorspelling');
|
|
|
|
unset_config('editordictionary');
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008092300);
|
|
|
|
}
|
|
|
|
|
2008-10-10 18:06:16 +00:00
|
|
|
if ($result && $oldversion < 2008101000) {
|
|
|
|
|
|
|
|
/// Changing the default of field lang on table user to en_utf8
|
|
|
|
$table = new xmldb_table('user');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('lang', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, 'en_utf8', 'country');
|
2008-10-10 18:06:16 +00:00
|
|
|
|
|
|
|
/// Launch change of default for field lang
|
|
|
|
$dbman->change_field_default($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008101000);
|
|
|
|
}
|
|
|
|
|
2008-10-13 21:53:49 +00:00
|
|
|
if ($result && $oldversion < 2008101300) {
|
|
|
|
|
2008-11-08 14:24:53 +00:00
|
|
|
if (!get_config(NULL, 'statsruntimedays')) {
|
2008-10-13 21:53:49 +00:00
|
|
|
set_config('statsruntimedays', '31');
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008101300);
|
|
|
|
}
|
2008-09-23 15:12:07 +00:00
|
|
|
|
2008-11-06 07:34:01 +00:00
|
|
|
/// New table for storing which roles can be assigned in which contexts.
|
|
|
|
if ($result && $oldversion < 2008110601) {
|
|
|
|
|
|
|
|
/// Define table role_context_levels to be created
|
|
|
|
$table = new xmldb_table('role_context_levels');
|
|
|
|
|
|
|
|
/// Adding fields to table role_context_levels
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-11-06 07:34:01 +00:00
|
|
|
|
|
|
|
/// Adding keys to table role_context_levels
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('contextlevel-roleid', XMLDB_KEY_UNIQUE, array('contextlevel', 'roleid'));
|
|
|
|
$table->add_key('roleid', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for role_context_levels
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008110601);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Now populate the role_context_levels table with the defaults that match
|
|
|
|
/// moodle_install_roles, and any other combinations that exist in this system.
|
|
|
|
if ($result && $oldversion < 2008110602) {
|
|
|
|
$roleids = $DB->get_records_menu('role', array(), '', 'shortname,id');
|
|
|
|
|
|
|
|
/// Defaults, should match moodle_install_roles.
|
|
|
|
$rolecontextlevels = array();
|
|
|
|
if (isset($roleids['admin'])) {
|
|
|
|
$rolecontextlevels[$roleids['admin']] = get_default_contextlevels('admin');
|
|
|
|
}
|
|
|
|
if (isset($roleids['coursecreator'])) {
|
|
|
|
$rolecontextlevels[$roleids['coursecreator']] = get_default_contextlevels('coursecreator');
|
|
|
|
}
|
|
|
|
if (isset($roleids['editingteacher'])) {
|
|
|
|
$rolecontextlevels[$roleids['editingteacher']] = get_default_contextlevels('editingteacher');
|
|
|
|
}
|
|
|
|
if (isset($roleids['teacher'])) {
|
|
|
|
$rolecontextlevels[$roleids['teacher']] = get_default_contextlevels('teacher');
|
|
|
|
}
|
|
|
|
if (isset($roleids['student'])) {
|
|
|
|
$rolecontextlevels[$roleids['student']] = get_default_contextlevels('student');
|
|
|
|
}
|
|
|
|
if (isset($roleids['guest'])) {
|
|
|
|
$rolecontextlevels[$roleids['guest']] = get_default_contextlevels('guest');
|
|
|
|
}
|
|
|
|
if (isset($roleids['user'])) {
|
|
|
|
$rolecontextlevels[$roleids['user']] = get_default_contextlevels('user');
|
|
|
|
}
|
2009-01-06 18:14:28 +00:00
|
|
|
|
2008-11-06 07:34:01 +00:00
|
|
|
/// See what other role assignments are in this database, extend the allowed
|
|
|
|
/// lists to allow them too.
|
|
|
|
$existingrolecontextlevels = $DB->get_recordset_sql('SELECT DISTINCT ra.roleid, con.contextlevel FROM
|
|
|
|
{role_assignments} ra JOIN {context} con ON ra.contextid = con.id');
|
|
|
|
foreach ($existingrolecontextlevels as $rcl) {
|
|
|
|
if (!isset($rolecontextlevels[$rcl->roleid])) {
|
|
|
|
$rolecontextlevels[$rcl->roleid] = array($rcl->contextlevel);
|
|
|
|
} else if (!in_array($rcl->contextlevel, $rolecontextlevels[$rcl->roleid])) {
|
|
|
|
$rolecontextlevels[$rcl->roleid][] = $rcl->contextlevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Put the data into the database.
|
|
|
|
foreach ($rolecontextlevels as $roleid => $contextlevels) {
|
|
|
|
set_role_contextlevels($roleid, $contextlevels);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008110602);
|
|
|
|
}
|
|
|
|
|
2008-11-06 08:35:23 +00:00
|
|
|
/// Remove any role overrides for moodle/site:doanything, or any permissions
|
|
|
|
/// for it in a role without legacy:admin.
|
|
|
|
if ($result && $oldversion < 2008110603) {
|
|
|
|
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
|
|
|
|
|
|
|
// Remove all overrides.
|
|
|
|
$DB->delete_records_select('role_capabilities', 'capability = ? AND contextid <> ?', array('moodle/site:doanything', $systemcontext->id));
|
|
|
|
|
|
|
|
// Get the ids of all the roles that are moodle/legacy:admin.
|
|
|
|
$adminroleids = $DB->get_records_menu('role_capabilities',
|
|
|
|
array('capability' => 'moodle/legacy:admin', 'permission' => 1, 'contextid' => $systemcontext->id),
|
|
|
|
'', 'id, roleid');
|
|
|
|
|
|
|
|
// Remove moodle/site:doanything from all other roles.
|
|
|
|
list($notroletest, $params) = $DB->get_in_or_equal($adminroleids, SQL_PARAMS_QM, '', false);
|
|
|
|
$DB->delete_records_select('role_capabilities', "roleid $notroletest AND capability = ? AND contextid = ?",
|
|
|
|
array_merge($params, array('moodle/site:doanything', $systemcontext->id)));
|
|
|
|
|
|
|
|
// Ensure that for all admin-y roles, the permission for moodle/site:doanything is 1
|
|
|
|
list($isroletest, $params) = $DB->get_in_or_equal($adminroleids);
|
|
|
|
$DB->set_field_select('role_capabilities', 'permission', 1,
|
|
|
|
"roleid $isroletest AND capability = ? AND contextid = ?",
|
|
|
|
array_merge($params, array('moodle/site:doanything', $systemcontext->id)));
|
|
|
|
|
|
|
|
// And for any admin-y roles where moodle/site:doanything is not set, set it.
|
|
|
|
$doanythingroleids = $DB->get_records_menu('role_capabilities',
|
|
|
|
array('capability' => 'moodle/site:doanything', 'permission' => 1, 'contextid' => $systemcontext->id),
|
|
|
|
'', 'id, roleid');
|
|
|
|
foreach ($adminroleids as $roleid) {
|
|
|
|
if (!in_array($roleid, $doanythingroleids)) {
|
|
|
|
$rc = new stdClass;
|
|
|
|
$rc->contextid = $systemcontext->id;
|
|
|
|
$rc->roleid = $roleid;
|
|
|
|
$rc->capability = 'moodle/site:doanything';
|
|
|
|
$rc->permission = 1;
|
|
|
|
$rc->timemodified = time();
|
|
|
|
$DB->insert_record('role_capabilities', $rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008110603);
|
|
|
|
}
|
|
|
|
|
2008-11-13 08:40:57 +00:00
|
|
|
/// Drop the deprecated teacher, teachers, student and students columns from the course table.
|
|
|
|
if ($result && $oldversion < 2008111200) {
|
|
|
|
$table = new xmldb_table('course');
|
|
|
|
|
|
|
|
/// Conditionally launch drop field teacher
|
|
|
|
$field = new xmldb_field('teacher');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Conditionally launch drop field teacher
|
|
|
|
$field = new xmldb_field('teachers');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Conditionally launch drop field teacher
|
|
|
|
$field = new xmldb_field('student');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Conditionally launch drop field teacher
|
|
|
|
$field = new xmldb_field('students');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008111200);
|
|
|
|
}
|
|
|
|
|
2008-11-18 07:41:28 +00:00
|
|
|
/// Add a unique index to the role.name column.
|
|
|
|
if ($result && $oldversion < 2008111800) {
|
|
|
|
|
|
|
|
/// Define index name (unique) to be added to role
|
|
|
|
$table = new xmldb_table('role');
|
|
|
|
$index = new xmldb_index('name', XMLDB_INDEX_UNIQUE, array('name'));
|
|
|
|
|
|
|
|
/// Conditionally launch add index name
|
|
|
|
if (!$dbman->index_exists($table, $index)) {
|
|
|
|
$dbman->add_index($table, $index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008111800);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Add a unique index to the role.shortname column.
|
|
|
|
if ($result && $oldversion < 2008111801) {
|
|
|
|
|
|
|
|
/// Define index shortname (unique) to be added to role
|
|
|
|
$table = new xmldb_table('role');
|
|
|
|
$index = new xmldb_index('shortname', XMLDB_INDEX_UNIQUE, array('shortname'));
|
|
|
|
|
|
|
|
/// Conditionally launch add index shortname
|
|
|
|
if (!$dbman->index_exists($table, $index)) {
|
|
|
|
$dbman->add_index($table, $index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008111801);
|
|
|
|
}
|
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
if ($result && $oldversion < 2008120700) {
|
|
|
|
|
|
|
|
/// Changing precision of field shortname on table course_request to (100)
|
|
|
|
$table = new xmldb_table('course_request');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'fullname');
|
2008-12-17 16:37:35 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field shortname
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008120700);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// For MDL-17501. Ensure that any role that has moodle/course:update also
|
|
|
|
/// has moodle/course:visibility.
|
|
|
|
if ($result && $oldversion < 2008120800) {
|
|
|
|
/// Get the roles with 'moodle/course:update'.
|
|
|
|
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
|
|
|
$roles = get_roles_with_capability('moodle/course:update', CAP_ALLOW, $systemcontext);
|
|
|
|
|
|
|
|
/// Give those roles 'moodle/course:visibility'.
|
|
|
|
foreach ($roles as $role) {
|
|
|
|
assign_capability('moodle/course:visibility', CAP_ALLOW, $role->id, $systemcontext->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Force all sessions to refresh access data.
|
|
|
|
mark_context_dirty($systemcontext->path);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008120800);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008120801) {
|
|
|
|
|
|
|
|
/// Changing precision of field shortname on table mnet_enrol_course to (100)
|
|
|
|
$table = new xmldb_table('mnet_enrol_course');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'fullname');
|
2008-12-17 16:37:35 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field shortname
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2008120801);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2008121701) {
|
2008-11-24 17:09:55 +00:00
|
|
|
|
|
|
|
/// Define field availablefrom to be added to course_modules
|
|
|
|
$table = new xmldb_table('course_modules');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('availablefrom', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionexpected');
|
2008-11-24 17:09:55 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field availablefrom
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field availableuntil to be added to course_modules
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('availableuntil', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'availablefrom');
|
2008-11-24 17:09:55 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field availableuntil
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2008-11-24 17:09:55 +00:00
|
|
|
/// Define field showavailability to be added to course_modules
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('showavailability', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'availableuntil');
|
2008-11-24 17:09:55 +00:00
|
|
|
|
|
|
|
/// Conditionally launch add field showavailability
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2008-11-24 17:09:55 +00:00
|
|
|
/// Define table course_modules_availability to be created
|
|
|
|
$table = new xmldb_table('course_modules_availability');
|
|
|
|
|
|
|
|
/// Adding fields to table course_modules_availability
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2008-11-24 17:09:55 +00:00
|
|
|
|
|
|
|
/// Adding keys to table course_modules_availability
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
2008-11-24 17:21:30 +00:00
|
|
|
$table->add_key('coursemoduleid', XMLDB_KEY_FOREIGN, array('coursemoduleid'), 'course_modules', array('id'));
|
|
|
|
$table->add_key('sourcecmid', XMLDB_KEY_FOREIGN, array('sourcecmid'), 'course_modules', array('id'));
|
|
|
|
$table->add_key('gradeitemid', XMLDB_KEY_FOREIGN, array('gradeitemid'), 'grade_items', array('id'));
|
2008-11-24 17:09:55 +00:00
|
|
|
|
|
|
|
/// Conditionally launch create table for course_modules_availability
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
/// Changes to modinfo mean we need to rebuild course cache
|
2009-05-06 14:19:19 +00:00
|
|
|
require_once($CFG->dirroot . '/course/lib.php');
|
2008-12-17 16:37:35 +00:00
|
|
|
rebuild_course_cache(0,true);
|
2008-12-08 02:31:05 +00:00
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
/// For developer upgrades, turn on the conditional activities and completion
|
|
|
|
/// features automatically (to gain more testing)
|
|
|
|
if(debugging('',DEBUG_DEVELOPER)) {
|
|
|
|
set_config('enableavailability',1);
|
|
|
|
set_config('enablecompletion',1);
|
2008-12-08 02:31:05 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 08:21:19 +00:00
|
|
|
/// Main savepoint reached
|
2008-12-17 16:37:35 +00:00
|
|
|
upgrade_main_savepoint($result, 2008121701);
|
2008-12-08 08:21:19 +00:00
|
|
|
}
|
|
|
|
|
2009-01-06 18:14:28 +00:00
|
|
|
if ($result && $oldversion < 2009010500) {
|
|
|
|
/// clean up config table a bit
|
|
|
|
unset_config('session_error_counter');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010500);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009010600) {
|
|
|
|
|
|
|
|
/// Define field originalquestion to be dropped from question_states
|
|
|
|
$table = new xmldb_table('question_states');
|
|
|
|
$field = new xmldb_field('originalquestion');
|
|
|
|
|
|
|
|
/// Conditionally launch drop field originalquestion
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010600);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009010601) {
|
|
|
|
|
|
|
|
/// Changing precision of field ip on table log to (45)
|
|
|
|
$table = new xmldb_table('log');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'userid');
|
2009-01-06 18:14:28 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field ip
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010601);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009010602) {
|
|
|
|
|
|
|
|
/// Changing precision of field lastip on table user to (45)
|
|
|
|
$table = new xmldb_table('user');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('lastip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'currentlogin');
|
2009-01-06 18:14:28 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field lastip
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010602);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009010603) {
|
|
|
|
|
|
|
|
/// Changing precision of field ip_address on table mnet_host to (45)
|
|
|
|
$table = new xmldb_table('mnet_host');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('ip_address', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'wwwroot');
|
2009-01-06 18:14:28 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field ip_address
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010603);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009010604) {
|
|
|
|
|
|
|
|
/// Changing precision of field ip on table mnet_log to (45)
|
|
|
|
$table = new xmldb_table('mnet_log');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'userid');
|
2009-01-06 18:14:28 +00:00
|
|
|
|
|
|
|
/// Launch change of precision for field ip
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010604);
|
|
|
|
}
|
|
|
|
|
2009-01-08 07:07:00 +00:00
|
|
|
if ($result && $oldversion < 2009010800) {
|
|
|
|
/// Update the notifyloginfailures setting.
|
|
|
|
if ($CFG->notifyloginfailures == 'mainadmin') {
|
|
|
|
set_config('notifyloginfailures', get_admin()->username);
|
|
|
|
} else if ($CFG->notifyloginfailures == 'alladmins') {
|
|
|
|
set_config('notifyloginfailures', '$@ALL@$');
|
|
|
|
} else {
|
|
|
|
set_config('notifyloginfailures', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009010800);
|
|
|
|
}
|
|
|
|
|
2009-01-10 21:06:53 +00:00
|
|
|
if ($result && $oldversion < 2009011000) {
|
|
|
|
|
|
|
|
/// Changing nullability of field configdata on table block_instance to null
|
|
|
|
$table = new xmldb_table('block_instance');
|
|
|
|
$field = new xmldb_field('configdata');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'visible');
|
2009-01-10 21:06:53 +00:00
|
|
|
|
|
|
|
/// Launch change of nullability for field configdata
|
|
|
|
$dbman->change_field_notnull($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009011000);
|
|
|
|
}
|
|
|
|
|
2009-01-11 09:41:48 +00:00
|
|
|
if ($result && $oldversion < 2009011100) {
|
|
|
|
/// Remove unused settings
|
|
|
|
unset_config('zip');
|
|
|
|
unset_config('unzip');
|
|
|
|
unset_config('adminblocks_initialised');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009011100);
|
|
|
|
}
|
|
|
|
|
2009-01-11 15:49:35 +00:00
|
|
|
if ($result && $oldversion < 2009011101) {
|
|
|
|
/// Migrate backup settings to core plugin config table
|
|
|
|
$configs = $DB->get_records('backup_config');
|
|
|
|
foreach ($configs as $config) {
|
|
|
|
set_config($config->name, $config->value, 'backup');
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table to be dropped
|
|
|
|
$table = new xmldb_table('backup_config');
|
|
|
|
|
|
|
|
/// Launch drop table for old backup config
|
|
|
|
$dbman->drop_table($table);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009011101);
|
|
|
|
}
|
|
|
|
|
2009-01-13 19:02:00 +00:00
|
|
|
if ($result && $oldversion < 2009011303) {
|
|
|
|
|
|
|
|
/// Define table config_log to be created
|
|
|
|
$table = new xmldb_table('config_log');
|
|
|
|
|
|
|
|
/// Adding fields to table config_log
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2009-01-13 19:02:00 +00:00
|
|
|
|
|
|
|
/// Adding keys to table config_log
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table config_log
|
|
|
|
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
|
|
|
|
|
|
|
|
/// Launch create table for config_log
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009011303);
|
|
|
|
}
|
|
|
|
|
2009-01-19 08:03:55 +00:00
|
|
|
if ($result && $oldversion < 2009011900) {
|
2009-01-14 17:08:29 +00:00
|
|
|
|
|
|
|
/// Define table sessions2 to be dropped
|
|
|
|
$table = new xmldb_table('sessions2');
|
|
|
|
|
|
|
|
/// Conditionally launch drop table for sessions
|
|
|
|
if ($dbman->table_exists($table)) {
|
|
|
|
$dbman->drop_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table sessions to be dropped
|
|
|
|
$table = new xmldb_table('sessions');
|
|
|
|
|
|
|
|
/// Conditionally launch drop table for sessions
|
|
|
|
if ($dbman->table_exists($table)) {
|
|
|
|
$dbman->drop_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define table sessions to be created
|
|
|
|
$table = new xmldb_table('sessions');
|
|
|
|
|
|
|
|
/// Adding fields to table sessions
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2009-01-14 17:08:29 +00:00
|
|
|
|
|
|
|
/// Adding keys to table sessions
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table sessions
|
|
|
|
$table->add_index('state', XMLDB_INDEX_NOTUNIQUE, array('state'));
|
|
|
|
$table->add_index('sid', XMLDB_INDEX_UNIQUE, array('sid'));
|
|
|
|
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
|
|
|
|
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
|
|
|
|
|
|
|
|
/// Launch create table for sessions
|
|
|
|
$dbman->create_table($table);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-01-19 08:03:55 +00:00
|
|
|
upgrade_main_savepoint($result, 2009011900);
|
2009-01-14 17:08:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 20:21:33 +00:00
|
|
|
if ($result && $oldversion < 2009012901) {
|
2009-01-31 20:07:32 +00:00
|
|
|
// NOTE: this table may already exist, see beginning of this file ;-)
|
2009-01-29 19:50:02 +00:00
|
|
|
|
|
|
|
/// Define table upgrade_log to be created
|
|
|
|
$table = new xmldb_table('upgrade_log');
|
|
|
|
|
|
|
|
/// Adding fields to table upgrade_log
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2009-01-29 19:50:02 +00:00
|
|
|
|
|
|
|
/// Adding keys to table upgrade_log
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table upgrade_log
|
|
|
|
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
|
|
|
|
$table->add_index('type-timemodified', XMLDB_INDEX_NOTUNIQUE, array('type', 'timemodified'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for upgrade_log
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-01-29 20:21:33 +00:00
|
|
|
upgrade_main_savepoint($result, 2009012901);
|
2009-01-29 19:50:02 +00:00
|
|
|
}
|
2009-01-11 09:41:48 +00:00
|
|
|
|
2009-02-18 17:50:13 +00:00
|
|
|
if ($result && $oldversion < 2009021800) {
|
2009-05-06 10:22:33 +00:00
|
|
|
// Converting format of grade conditions, if any exist, to percentages.
|
2009-02-18 17:50:13 +00:00
|
|
|
$DB->execute("
|
|
|
|
UPDATE {course_modules_availability} SET grademin=(
|
|
|
|
SELECT 100.0*({course_modules_availability}.grademin-gi.grademin)
|
2009-05-06 10:22:33 +00:00
|
|
|
/(gi.grademax-gi.grademin)
|
|
|
|
FROM {grade_items} gi
|
2009-02-18 17:50:13 +00:00
|
|
|
WHERE gi.id={course_modules_availability}.gradeitemid)
|
|
|
|
WHERE gradeitemid IS NOT NULL AND grademin IS NOT NULL");
|
|
|
|
$DB->execute("
|
|
|
|
UPDATE {course_modules_availability} SET grademax=(
|
|
|
|
SELECT 100.0*({course_modules_availability}.grademax-gi.grademin)
|
2009-05-06 10:22:33 +00:00
|
|
|
/(gi.grademax-gi.grademin)
|
|
|
|
FROM {grade_items} gi
|
2009-02-18 17:50:13 +00:00
|
|
|
WHERE gi.id={course_modules_availability}.gradeitemid)
|
|
|
|
WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009021800);
|
|
|
|
}
|
2009-03-03 00:06:08 +00:00
|
|
|
if ($result && $oldversion < 2009021801) {
|
|
|
|
/// Define field backuptype to be added to backup_log
|
2009-05-04 14:33:01 +00:00
|
|
|
$table = new xmldb_table('backup_log');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('backuptype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, 'info');
|
2009-03-03 00:06:08 +00:00
|
|
|
/// Conditionally Launch add field backuptype and set all old records as 'scheduledbackup' records.
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
$DB->execute("UPDATE {backup_log} SET backuptype='scheduledbackup'");
|
|
|
|
}
|
2009-02-18 17:50:13 +00:00
|
|
|
|
2009-03-03 00:06:08 +00:00
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009021801);
|
|
|
|
}
|
2009-03-03 07:47:32 +00:00
|
|
|
/// Add default sort order for question types.
|
|
|
|
if ($result && $oldversion < 2009030300) {
|
|
|
|
set_config('multichoice_sortorder', 1, 'question');
|
|
|
|
set_config('truefalse_sortorder', 2, 'question');
|
|
|
|
set_config('shortanswer_sortorder', 3, 'question');
|
|
|
|
set_config('numerical_sortorder', 4, 'question');
|
|
|
|
set_config('calculated_sortorder', 5, 'question');
|
|
|
|
set_config('essay_sortorder', 6, 'question');
|
|
|
|
set_config('match_sortorder', 7, 'question');
|
|
|
|
set_config('randomsamatch_sortorder', 8, 'question');
|
|
|
|
set_config('multianswer_sortorder', 9, 'question');
|
|
|
|
set_config('description_sortorder', 10, 'question');
|
|
|
|
set_config('random_sortorder', 11, 'question');
|
|
|
|
set_config('missingtype_sortorder', 12, 'question');
|
|
|
|
|
|
|
|
upgrade_main_savepoint($result, 2009030300);
|
|
|
|
}
|
2009-03-05 04:40:51 +00:00
|
|
|
if ($result && $oldversion < 2009030501) {
|
|
|
|
/// setup default repository plugins
|
|
|
|
require_once($CFG->dirroot . '/repository/lib.php');
|
|
|
|
repository_setup_default_plugins();
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009030501);
|
|
|
|
}
|
2009-03-03 07:47:32 +00:00
|
|
|
|
2009-03-23 08:15:21 +00:00
|
|
|
/// MDL-18132 replace the use a new Role allow switch settings page, instead of
|
|
|
|
/// $CFG->allowuserswitchrolestheycantassign
|
|
|
|
if ($result && $oldversion < 2009032000) {
|
|
|
|
/// First create the new table.
|
|
|
|
$table = new xmldb_table('role_allow_switch');
|
|
|
|
|
|
|
|
/// Adding fields to table role_allow_switch
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2009-03-23 08:15:21 +00:00
|
|
|
|
|
|
|
/// Adding keys to table role_allow_switch
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('roleid', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id'));
|
|
|
|
$table->add_key('allowswitch', XMLDB_KEY_FOREIGN, array('allowswitch'), 'role', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table role_allow_switch
|
|
|
|
$table->add_index('roleid-allowoverride', XMLDB_INDEX_UNIQUE, array('roleid', 'allowswitch'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for role_allow_switch
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009032000);
|
|
|
|
}
|
2009-04-13 06:42:02 +00:00
|
|
|
|
2009-03-23 08:15:21 +00:00
|
|
|
if ($result && $oldversion < 2009032001) {
|
|
|
|
/// Copy from role_allow_assign into the new table.
|
2009-04-28 09:55:46 +00:00
|
|
|
$DB->execute('INSERT INTO {role_allow_switch} (roleid, allowswitch)
|
|
|
|
SELECT roleid, allowassign FROM {role_allow_assign}');
|
2009-03-23 08:15:21 +00:00
|
|
|
|
|
|
|
/// Unset the config variable used in 1.9.
|
|
|
|
unset_config('allowuserswitchrolestheycantassign');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009032001);
|
|
|
|
}
|
2009-03-31 10:03:10 +00:00
|
|
|
|
|
|
|
if ($result && $oldversion < 2009033100) {
|
|
|
|
require_once("$CFG->dirroot/filter/tex/lib.php");
|
|
|
|
filter_tex_updatedcallback(null);
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009033100);
|
|
|
|
}
|
|
|
|
|
2009-04-13 06:42:02 +00:00
|
|
|
if ($result && $oldversion < 2009040300) {
|
|
|
|
|
|
|
|
/// Define table filter_active to be created
|
|
|
|
$table = new xmldb_table('filter_active');
|
|
|
|
|
|
|
|
/// Adding fields to table filter_active
|
2009-05-01 01:19:16 +00:00
|
|
|
$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');
|
2009-04-13 06:42:02 +00:00
|
|
|
|
|
|
|
/// Adding keys to table filter_active
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table filter_active
|
|
|
|
$table->add_index('contextid-filter', XMLDB_INDEX_UNIQUE, array('contextid', 'filter'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for filter_active
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009040300);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009040301) {
|
|
|
|
|
|
|
|
/// Define table filter_config to be created
|
|
|
|
$table = new xmldb_table('filter_config');
|
|
|
|
|
|
|
|
/// Adding fields to table filter_config
|
2009-05-01 01:19:16 +00:00
|
|
|
$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);
|
2009-04-13 06:42:02 +00:00
|
|
|
|
|
|
|
/// Adding keys to table filter_config
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table filter_config
|
|
|
|
$table->add_index('contextid-filter-name', XMLDB_INDEX_UNIQUE, array('contextid', 'filter', 'name'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for filter_config
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009040301);
|
|
|
|
}
|
|
|
|
|
2009-04-13 06:51:45 +00:00
|
|
|
if ($result && $oldversion < 2009040302) {
|
|
|
|
/// Transfer current settings from $CFG->textfilters
|
|
|
|
$disabledfilters = filter_get_all_installed();
|
|
|
|
if (empty($CFG->textfilters)) {
|
|
|
|
$activefilters = array();
|
|
|
|
} else {
|
|
|
|
$activefilters = explode(',', $CFG->textfilters);
|
|
|
|
}
|
|
|
|
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
|
|
|
$sortorder = 1;
|
|
|
|
foreach ($activefilters as $filter) {
|
|
|
|
filter_set_global_state($filter, TEXTFILTER_ON, $sortorder);
|
|
|
|
$sortorder += 1;
|
|
|
|
unset($disabledfilters[$filter]);
|
|
|
|
}
|
|
|
|
foreach ($disabledfilters as $filter => $notused) {
|
|
|
|
filter_set_global_state($filter, TEXTFILTER_DISABLED, $sortorder);
|
|
|
|
$sortorder += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009040302);
|
|
|
|
}
|
|
|
|
|
2009-04-13 06:55:21 +00:00
|
|
|
if ($result && $oldversion < 2009040600) {
|
|
|
|
/// Ensure that $CFG->stringfilters is set.
|
|
|
|
if (empty($CFG->stringfilters)) {
|
|
|
|
if (!empty($CFG->filterall)) {
|
|
|
|
set_config('stringfilters', $CFG->textfilters);
|
|
|
|
} else {
|
|
|
|
set_config('stringfilters', '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_config('filterall', !empty($CFG->stringfilters));
|
|
|
|
unset_config('textfilters');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009040600);
|
|
|
|
}
|
|
|
|
|
2009-04-17 16:06:29 +00:00
|
|
|
if ($result && $oldversion < 2009041700) {
|
|
|
|
/// To ensure the UI remains consistent with no behaviour change, any
|
|
|
|
/// 'until' date in an activity condition should have 1 second subtracted
|
|
|
|
/// (to go from 0:00 on the following day to 23:59 on the previous one).
|
|
|
|
$DB->execute('UPDATE {course_modules} SET availableuntil = availableuntil - 1 WHERE availableuntil <> 0');
|
2009-04-17 16:21:15 +00:00
|
|
|
rebuild_course_cache(0, true);
|
2009-04-17 16:06:29 +00:00
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009041700);
|
|
|
|
}
|
|
|
|
|
2009-04-26 22:56:56 +00:00
|
|
|
if ($result && $oldversion < 2009042600) {
|
|
|
|
/// Deleting orphaned messages from deleted users.
|
|
|
|
require_once($CFG->dirroot.'/message/lib.php');
|
|
|
|
/// Detect deleted users with messages sent(useridfrom) and not read
|
|
|
|
if ($deletedusers = $DB->get_records_sql('SELECT DISTINCT u.id
|
|
|
|
FROM {user} u
|
|
|
|
JOIN {message} m ON m.useridfrom = u.id
|
|
|
|
WHERE u.deleted = ?', array(1))) {
|
|
|
|
foreach ($deletedusers as $deleteduser) {
|
|
|
|
message_move_userfrom_unread2read($deleteduser->id); // move messages
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009042600);
|
|
|
|
}
|
|
|
|
|
2009-04-27 20:29:01 +00:00
|
|
|
/// Dropping all enums/check contraints from core. MDL-18577
|
|
|
|
if ($result && $oldversion < 2009042700) {
|
|
|
|
|
|
|
|
/// Changing list of values (enum) of field stattype on table stats_daily to none
|
|
|
|
$table = new xmldb_table('stats_daily');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'activity', 'roleid');
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Launch change of list of values for field stattype
|
2009-05-01 01:19:16 +00:00
|
|
|
$dbman->drop_enum_from_field($table, $field);
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Changing list of values (enum) of field stattype on table stats_weekly to none
|
|
|
|
$table = new xmldb_table('stats_weekly');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'activity', 'roleid');
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Launch change of list of values for field stattype
|
2009-05-01 01:19:16 +00:00
|
|
|
$dbman->drop_enum_from_field($table, $field);
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Changing list of values (enum) of field stattype on table stats_monthly to none
|
|
|
|
$table = new xmldb_table('stats_monthly');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'activity', 'roleid');
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Launch change of list of values for field stattype
|
2009-05-01 01:19:16 +00:00
|
|
|
$dbman->drop_enum_from_field($table, $field);
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Changing list of values (enum) of field publishstate on table post to none
|
|
|
|
$table = new xmldb_table('post');
|
2009-05-01 01:19:16 +00:00
|
|
|
$field = new xmldb_field('publishstate', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'draft', 'attachment');
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Launch change of list of values for field publishstate
|
2009-05-01 01:19:16 +00:00
|
|
|
$dbman->drop_enum_from_field($table, $field);
|
2009-04-27 20:29:01 +00:00
|
|
|
|
|
|
|
/// Main savepoint reached
|
|
|
|
upgrade_main_savepoint($result, 2009042700);
|
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009043000) {
|
|
|
|
unset_config('grade_report_showgroups');
|
|
|
|
upgrade_main_savepoint($result, 2009043000);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result && $oldversion < 2009050600) {
|
2009-05-06 08:41:02 +00:00
|
|
|
/// Site front page blocks need to be moved due to page name change.
|
|
|
|
$DB->set_field('block_instance', 'pagetype', 'site-index', array('pagetype' => 'course-view', 'pageid' => SITEID));
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050600);
|
2009-05-06 08:41:02 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050601) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Define table block_instance to be renamed to block_instance_old
|
|
|
|
$table = new xmldb_table('block_instance');
|
|
|
|
|
|
|
|
/// Launch rename table for block_instance
|
2009-05-06 10:22:33 +00:00
|
|
|
$dbman->rename_table($table, 'block_instance_old');
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050601);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050602) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Define table block_instance to be renamed to block_instance_old
|
|
|
|
$table = new xmldb_table('block_pinned');
|
|
|
|
|
|
|
|
/// Launch rename table for block_instance
|
|
|
|
$dbman->rename_table($table, 'block_pinned_old');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050602);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050603) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Define table block_instance_old to be created
|
|
|
|
$table = new xmldb_table('block_instance_old');
|
|
|
|
|
|
|
|
/// Adding fields to table block_instance_old
|
|
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
|
|
|
$table->add_field('oldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('blockid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('pageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('pagetype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('region', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('weight', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('visible', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('configdata', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
|
|
|
|
|
|
|
|
/// Adding keys to table block_instance_old
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('blockid', XMLDB_KEY_FOREIGN, array('blockid'), 'block', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table block_instance_old
|
|
|
|
$table->add_index('pageid', XMLDB_INDEX_NOTUNIQUE, array('pageid'));
|
|
|
|
$table->add_index('pagetype', XMLDB_INDEX_NOTUNIQUE, array('pagetype'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for block_instance_old
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050603);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050604) {
|
2009-05-06 09:12:03 +00:00
|
|
|
/// Copy current blocks data from block_instances to block_instance_old
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute('INSERT INTO {block_instance_old} (oldid, blockid, pageid, pagetype, weight, visible, configdata)
|
|
|
|
SELECT id, blockid, pageid, pagetype, weight, visible, configdata FROM {block_instances} ORDER BY id');
|
2009-05-06 09:12:03 +00:00
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050604);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050605) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Define field multiple to be dropped from block
|
|
|
|
$table = new xmldb_table('block');
|
|
|
|
$field = new xmldb_field('multiple');
|
|
|
|
|
|
|
|
/// Conditionally launch drop field multiple
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050605);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050606) {
|
2009-05-06 09:12:03 +00:00
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
|
|
|
|
/// Rename field weight on table block_instances to defaultweight
|
|
|
|
$field = new xmldb_field('weight', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'position');
|
|
|
|
$dbman->rename_field($table, $field, 'defaultweight');
|
|
|
|
|
|
|
|
/// Rename field position on table block_instances to defaultregion
|
|
|
|
$field = new xmldb_field('position', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null, 'pagetype');
|
|
|
|
$dbman->rename_field($table, $field, 'defaultregion');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050606);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050607) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Changing precision of field defaultregion on table block_instances to (16)
|
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
$field = new xmldb_field('defaultregion', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, null, null, null, 'subpagepattern');
|
|
|
|
|
|
|
|
/// Launch change of precision for field defaultregion
|
|
|
|
$dbman->change_field_precision($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050607);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050608) {
|
2009-05-06 09:12:03 +00:00
|
|
|
/// Change regions to the new notation
|
|
|
|
$DB->set_field('block_instances', 'defaultregion', 'side-pre', array('defaultregion' => 'l'));
|
|
|
|
$DB->set_field('block_instances', 'defaultregion', 'side-post', array('defaultregion' => 'r'));
|
|
|
|
$DB->set_field('block_instances', 'defaultregion', 'course-view-top', array('defaultregion' => 'c'));
|
|
|
|
// This third one is a custom value from contrib/patches/center_blocks_position_patch and the
|
|
|
|
// flex page course format. Hopefully this new value is an adequate alternative.
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050608);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050609) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Define key blockname (unique) to be added to block
|
|
|
|
$table = new xmldb_table('block');
|
|
|
|
$key = new xmldb_key('blockname', XMLDB_KEY_UNIQUE, array('name'));
|
|
|
|
|
|
|
|
/// Launch add key blockname
|
|
|
|
$dbman->add_key($table, $key);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050609);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050610) {
|
2009-05-06 09:12:03 +00:00
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
|
|
|
|
/// Define field blockname to be added to block_instances
|
|
|
|
$field = new xmldb_field('blockname', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null, 'blockid');
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field contextid to be added to block_instances
|
|
|
|
$field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'blockname');
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field showinsubcontexts to be added to block_instances
|
|
|
|
$field = new xmldb_field('showinsubcontexts', XMLDB_TYPE_INTEGER, '4', null, null, null, null, null, null, 'contextid');
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field subpagepattern to be added to block_instances
|
|
|
|
$field = new xmldb_field('subpagepattern', XMLDB_TYPE_CHAR, '16', null, null, null, null, null, null, 'pagetype');
|
|
|
|
if (!$dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->add_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050610);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050611) {
|
2009-05-06 09:12:03 +00:00
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
|
|
|
|
/// Fill in blockname from blockid
|
|
|
|
$DB->execute("UPDATE {block_instances} SET blockname = (SELECT name FROM {block} WHERE id = blockid)");
|
|
|
|
|
|
|
|
/// Set showinsubcontexts = 0 for all rows.
|
|
|
|
$DB->execute("UPDATE {block_instances} SET showinsubcontexts = 0");
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050611);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050612) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Rename field pagetype on table block_instances to pagetypepattern
|
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
$field = new xmldb_field('pagetype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, null, 'pageid');
|
|
|
|
|
|
|
|
/// Launch rename field pagetype
|
|
|
|
$dbman->rename_field($table, $field, 'pagetypepattern');
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050612);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050613) {
|
2009-05-06 09:12:03 +00:00
|
|
|
/// fill in contextid and subpage, and update pagetypepattern from pagetype and pageid
|
|
|
|
|
|
|
|
/// site-index
|
|
|
|
$frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET contextid = " . $frontpagecontext->id . ",
|
|
|
|
pagetypepattern = 'site-index',
|
|
|
|
subpagepattern = NULL
|
|
|
|
WHERE pagetypepattern = 'site-index'");
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// course-view
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET
|
|
|
|
contextid = (
|
|
|
|
SELECT {context}.id
|
|
|
|
FROM {context}
|
|
|
|
JOIN {course} ON instanceid = {course}.id AND contextlevel = " . CONTEXT_COURSE . "
|
|
|
|
WHERE {course}.id = pageid
|
|
|
|
),
|
|
|
|
pagetypepattern = 'course-view-*',
|
|
|
|
subpagepattern = NULL
|
|
|
|
WHERE pagetypepattern = 'course-view'");
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// admin
|
|
|
|
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET
|
|
|
|
contextid = " . $syscontext->id . ",
|
|
|
|
pagetypepattern = 'admin-*',
|
|
|
|
subpagepattern = NULL
|
|
|
|
WHERE pagetypepattern = 'admin'");
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// my-index
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET
|
|
|
|
contextid = (
|
|
|
|
SELECT {context}.id
|
|
|
|
FROM {context}
|
|
|
|
JOIN {user} ON instanceid = {user}.id AND contextlevel = " . CONTEXT_USER . "
|
|
|
|
WHERE {user}.id = pageid
|
|
|
|
),
|
|
|
|
pagetypepattern = 'my-index',
|
|
|
|
subpagepattern = NULL
|
|
|
|
WHERE pagetypepattern = 'my-index'");
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// tag-index
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET
|
|
|
|
contextid = " . $syscontext->id . ",
|
|
|
|
pagetypepattern = 'tag-index',
|
|
|
|
subpagepattern = pageid
|
|
|
|
WHERE pagetypepattern = 'tag-index'");
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// blog-view
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET
|
|
|
|
contextid = (
|
|
|
|
SELECT {context}.id
|
|
|
|
FROM {context}
|
|
|
|
JOIN {user} ON instanceid = {user}.id AND contextlevel = " . CONTEXT_USER . "
|
|
|
|
WHERE {user}.id = pageid
|
|
|
|
),
|
|
|
|
pagetypepattern = 'blog-index',
|
|
|
|
subpagepattern = NULL
|
|
|
|
WHERE pagetypepattern = 'blog-view'");
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// mod-xxx-view
|
|
|
|
$moduleswithblocks = array('chat', 'data', 'lesson', 'quiz', 'dimdim', 'game', 'wiki', 'oublog');
|
|
|
|
foreach ($moduleswithblocks as $modname) {
|
|
|
|
if (!$dbman->table_exists($modname)) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-05-06 10:22:33 +00:00
|
|
|
$DB->execute("UPDATE {block_instances} SET
|
|
|
|
contextid = (
|
|
|
|
SELECT {context}.id
|
|
|
|
FROM {context}
|
|
|
|
JOIN {course_modules} ON instanceid = {course_modules}.id AND contextlevel = " . CONTEXT_MODULE . "
|
|
|
|
JOIN {modules} ON {modules}.id = {course_modules}.module AND {modules}.name = '$modname'
|
|
|
|
JOIN {{$modname}} ON {course_modules}.instance = {{$modname}}.id
|
|
|
|
WHERE {{$modname}}.id = pageid
|
|
|
|
),
|
|
|
|
pagetypepattern = 'blog-index',
|
|
|
|
subpagepattern = NULL
|
|
|
|
WHERE pagetypepattern = 'blog-view'");
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050613);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050614) {
|
2009-05-06 09:12:03 +00:00
|
|
|
/// fill in any missing contextids with a dummy value, so we can add the not-null constraint.
|
|
|
|
$DB->execute("UPDATE {block_instances} SET contextid = -1 WHERE contextid IS NULL");
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050614);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050615) {
|
2009-05-06 09:12:03 +00:00
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
|
|
|
|
/// Changing nullability of field blockname on table block_instances to not null
|
|
|
|
$field = new xmldb_field('blockname', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, null, null, 'id');
|
|
|
|
$dbman->change_field_notnull($table, $field);
|
|
|
|
|
|
|
|
/// Changing nullability of field contextid on table block_instances to not null
|
|
|
|
$field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'blockname');
|
|
|
|
$dbman->change_field_notnull($table, $field);
|
|
|
|
|
|
|
|
/// Changing nullability of field showinsubcontexts on table block_instances to not null
|
|
|
|
$field = new xmldb_field('showinsubcontexts', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, null, 'contextid');
|
|
|
|
$dbman->change_field_notnull($table, $field);
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050615);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050616) {
|
2009-05-06 09:12:03 +00:00
|
|
|
/// Add exiting sticky blocks.
|
|
|
|
$blocks = $DB->get_records('block');
|
|
|
|
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
|
|
|
$newregions = array(
|
|
|
|
'l' => 'side-pre',
|
|
|
|
'r' => 'side-post',
|
|
|
|
'c' => 'course-view-top',
|
|
|
|
);
|
|
|
|
$stickyblocks = $DB->get_recordset('block_pinned_old');
|
|
|
|
foreach ($stickyblocks as $stickyblock) {
|
|
|
|
$newblock = stdClass;
|
|
|
|
$newblock->blockname = $blocks[$stickyblock]->name;
|
|
|
|
$newblock->contextid = $syscontext->id;
|
|
|
|
$newblock->showinsubcontexts = 1;
|
|
|
|
switch ($stickyblock->pagetype) {
|
|
|
|
case 'course-view':
|
|
|
|
$newblock->pagetypepattern = 'course-view-*';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$newblock->pagetypepattern = $stickyblock->pagetype;
|
|
|
|
}
|
|
|
|
$newblock->defaultregion = $newregions[$stickyblock->position];
|
|
|
|
$newblock->defaultweight = $stickyblock->weight;
|
|
|
|
$newblock->configdata = $stickyblock->configdata;
|
|
|
|
$DB->insert_record('block_instances', $newblock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050616);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050617) {
|
2009-05-06 09:12:03 +00:00
|
|
|
|
|
|
|
/// Define table block_positions to be created
|
|
|
|
$table = new xmldb_table('block_positions');
|
|
|
|
|
|
|
|
/// Adding fields to table block_positions
|
|
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
|
|
|
$table->add_field('blockinstanceid', XMLDB_TYPE_INTEGER, '10', 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('pagetype', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('subpage', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('visible', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '1');
|
|
|
|
$table->add_field('region', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('weight', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
|
|
|
|
/// Adding keys to table block_positions
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('blockinstanceid', XMLDB_KEY_FOREIGN, array('blockinstanceid'), 'block_instances', array('id'));
|
|
|
|
$table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table block_positions
|
|
|
|
$table->add_index('blockinstanceid-contextid-pagetype-subpage', XMLDB_INDEX_UNIQUE, array('blockinstanceid', 'contextid', 'pagetype', 'subpage'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for block_positions
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050617);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050618) {
|
2009-05-06 09:12:03 +00:00
|
|
|
/// And block instances with visible = 0, copy that information to block_positions
|
|
|
|
$DB->execute("INSERT INTO {block_positions} (blockinstanceid, contextid, pagetype, subpage, visible, region, weight)
|
|
|
|
SELECT id, contextid,
|
|
|
|
CASE WHEN pagetypepattern = 'course-view-*' THEN
|
|
|
|
(SELECT " . $DB->sql_concat("'course-view-'", 'format') . "
|
|
|
|
FROM {course}
|
|
|
|
JOIN {context} ON {course}.id = {context}.instanceid
|
|
|
|
WHERE {context}.id = contextid)
|
|
|
|
ELSE pagetypepattern END,
|
|
|
|
CASE WHEN subpagepattern IS NULL THEN ''
|
|
|
|
ELSE subpagepattern END,
|
|
|
|
0, defaultregion, defaultweight
|
|
|
|
FROM {block_instances} WHERE visible = 0 AND pagetypepattern <> 'admin-*'");
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050618);
|
2009-05-06 09:12:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:31:23 +00:00
|
|
|
if ($result && $oldversion < 2009050619) {
|
2009-05-06 09:12:03 +00:00
|
|
|
$table = new xmldb_table('block_instances');
|
|
|
|
|
|
|
|
/// Define field blockid to be dropped from block_instances
|
|
|
|
$field = new xmldb_field('blockid');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field pageid to be dropped from block_instances
|
|
|
|
$field = new xmldb_field('pageid');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Define field visible to be dropped from block_instances
|
|
|
|
$field = new xmldb_field('visible');
|
|
|
|
if ($dbman->field_exists($table, $field)) {
|
|
|
|
$dbman->drop_field($table, $field);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main savepoint reached
|
2009-05-06 09:31:23 +00:00
|
|
|
upgrade_main_savepoint($result, 2009050619);
|
2009-04-30 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
?>
|