/** * Standard Moodle upgrade function defintion * @param int $oldversion the timestamp of the old version of plugin * @return bool true on success, false otherwise */ function xmldb_local_elisreports_upgrade($oldversion = 0) { $result = true; // Migrate language strings if ($result && $oldversion < 2014030701) { $migrator = new \local_eliscore\install\migration\migrator('block_php_report', 'local_elisreports'); $result = $migrator->migrate_language_strings(); upgrade_plugin_savepoint($result, 2014030701, 'local', 'elisreports'); } return $result; }
function xmldb_block_courserequest_upgrade($oldversion = 0) { $result = true; // Migrate language strings if ($result && $oldversion < 2014030701) { $migrator = new \local_eliscore\install\migration\migrator('block_course_request', 'block_courserequest'); $result = $migrator->migrate_language_strings(); upgrade_block_savepoint($result, 2014030701, 'courserequest'); } return $result; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package block_enrolsurvey * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) */ function xmldb_block_enrolsurvey_install() { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); // Migrate block instances. $oldrecord = $DB->get_record('block', array('name' => 'enrol_survey'), 'id'); if (!empty($oldrecord)) { // Convert any existing old enrol_survey block instances to enrolsurvey blocks. $sql = "UPDATE {block_instances} SET blockname = 'enrolsurvey' WHERE blockname = 'enrol_survey'"; $DB->execute($sql); // Delete old enrol_survey record in block table. $DB->delete_records('block', array('id' => $oldrecord->id)); } // Migrate old config settings. $settings = (array) get_config('block_enrol_survey'); if (!empty($settings)) { foreach ($settings as $name => $val) { set_config($name, $val, 'block_enrolsurvey'); } } unset_all_config_for_plugin('block_enrol_survey'); // Migrate old block_enrol_survey table if it exists. $table = new xmldb_table('block_enrol_survey_taken'); // Old pre 2.6 table. if ($dbman->table_exists($table)) { $newtable = new xmldb_table('block_enrolsurvey_taken'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'block_enrolsurvey_taken'); } // Migrate capabilities. $oldcapprefix = 'block/enrol_survey'; $newcapprefix = 'block/enrolsurvey'; $sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?'; $params = array($oldcapprefix . '%'); $rolecaps = $DB->get_recordset_sql($sql, $params); foreach ($rolecaps as $rolecaprec) { $updaterec = new stdClass(); $updaterec->id = $rolecaprec->id; $updaterec->capability = str_replace($oldcapprefix, $newcapprefix, $rolecaprec->capability); $DB->update_record('role_capabilities', $updaterec); } $sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?'; $caps = $DB->get_recordset_sql($sql, $params); foreach ($caps as $cap) { $cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name); $cap->component = str_replace('block_enrol_survey', 'block_enrolsurvey', $cap->component); $DB->update_record('capabilities', $cap); } // Migrate language strings $migrator = new \local_eliscore\install\migration\migrator('block_enrol_survey', 'block_enrolsurvey'); $migrator->migrate_language_strings(); return $result; }
function xmldb_local_eliscore_upgrade($oldversion = 0) { global $DB, $CFG; $dbman = $DB->get_manager(); $result = true; // Migrate language strings if ($result && $oldversion < 2014030701) { $migrator = new \local_eliscore\install\migration\migrator('elis_core', 'local_eliscore'); $result = $migrator->migrate_language_strings(); upgrade_plugin_savepoint($result, 2014030701, 'local', 'eliscore'); } return $result; }
/** * Standard Moodle post install function defintion * @return bool true on success, false otherwise */ function xmldb_local_elisreports_install() { global $DB; $result = true; $dbman = $DB->get_manager(); $table = new xmldb_table('php_report_schedule'); // Old pre 2.6 table if ($dbman->table_exists($table)) { $newtable = new xmldb_table('local_elisreports_schedule'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'local_elisreports_schedule'); $tables = array('local_eliscore_sched_tasks', 'elis_scheduled_tasks'); foreach ($tables as $table) { $tableobj = new xmldb_table($table); if ($dbman->table_exists($tableobj)) { $tasks = $DB->get_recordset($table, array('plugin' => 'block/php_report')); foreach ($tasks as $task) { $task->plugin = 'local_elisreports'; $task->callfile = '/local/elisreports/runschedule.php'; $DB->update_record($table, $task); } } } } // Migrate capabilities $oldcapprefix = 'block/php_report'; $newcapprefix = 'local/elisreports'; $sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?'; $params = array($oldcapprefix . '%'); $rolecaps = $DB->get_recordset_sql($sql, $params); foreach ($rolecaps as $rolecap) { $rolecap->capability = str_replace($oldcapprefix, $newcapprefix, $rolecap->capability); $DB->update_record('role_capabilities', $rolecap); } $sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?'; $caps = $DB->get_recordset_sql($sql, $params); foreach ($caps as $cap) { $cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name); $cap->component = str_replace('block_php_report', 'local_elisreports', $cap->component); $DB->update_record('capabilities', $cap); } // Migrate language strings $migrator = new \local_eliscore\install\migration\migrator('block_php_report', 'local_elisreports'); $migrator->migrate_language_strings(); // Remove the old block ... $DB->delete_records('block', array('name' => 'php_report')); unset_all_config_for_plugin('block_php_report'); return $result; }
function xmldb_local_datahub_upgrade($oldversion = 0) { global $DB, $CFG; $result = true; $dbman = $DB->get_manager(); // Always upon any upgrade, ensure ELIS scheduled tasks is in good health if ($result && @file_exists($CFG->dirroot . '/local/eliscore/lib/tasklib.php')) { require_once $CFG->dirroot . '/local/eliscore/lib/tasklib.php'; elis_tasks_update_definition('local_datahub'); } // Migrate language strings if ($result && $oldversion < 2014030701) { $migrator = new \local_eliscore\install\migration\migrator('block_rlip', 'local_datahub'); $result = $migrator->migrate_language_strings(); upgrade_plugin_savepoint($result, 2014030701, 'local', 'datahub'); } return $result; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2014 onwards Remote-Learner.net Inc (http://www.remote-learner.net) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package repository_elisfiles * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) * */ function xmldb_repository_elisfiles_upgrade($oldversion = 0) { global $DB, $CFG; $result = true; if ($result && $oldversion < 2014030701) { require_once($CFG->dirroot.'/repository/elisfiles/lib/lib.php'); $ignoreresult = elis_files_update_references_in_database(); upgrade_plugin_savepoint(true, 2014030701, 'repository', 'elisfiles'); } // Migrate language strings if ($result && $oldversion < 2014030702) { $migrator = new \local_eliscore\install\migration\migrator('repository_elis_files', 'repository_elisfiles'); $result = $migrator->migrate_language_strings(); upgrade_plugin_savepoint($result, 2014030702, 'repository', 'elisfiles'); } return $result; }
function xmldb_local_datahub_install() { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); // Migrate block instances. $oldrecord = $DB->get_record('block', array('name' => 'rlip'), 'id'); if (!empty($oldrecord)) { // Convert any existing old rlip block instances to html blocks. $oldblockinsts = $DB->get_recordset('block_instances', array('blockname' => 'rlip'), '', 'id'); if ($oldblockinsts && $oldblockinsts->valid()) { $plugins = get_string('plugins', 'local_datahub'); $logs = get_string('logs', 'local_datahub'); $obj = new stdClass(); $pluginstag = html_writer::tag('a', $plugins, array('href' => $CFG->wwwroot . '/local/datahub/plugins.php', 'title' => $plugins)); $logstag = html_writer::tag('a', $logs, array('href' => $CFG->wwwroot . '/local/datahub/viewlogs.php', 'title' => $logs)); $obj->text = html_writer::tag('p', $pluginstag) . html_writer::tag('p', $logstag); $obj->title = get_string('pluginname', 'local_datahub'); $obj->format = 1; $configdata = base64_encode(serialize($obj)); $sql = "UPDATE {block_instances} SET blockname = 'html', configdata = ? WHERE blockname = 'rlip'"; $DB->execute($sql, array($configdata)); // Hide blocks from all but site admins $cap = 'moodle/block:view'; foreach ($oldblockinsts as $oldblockinst) { $context = context_block::instance($oldblockinst->id); $roles = get_roles_with_capability($cap, CAP_ALLOW, $context); foreach ($roles as $role) { if ($role->id != 1) { assign_capability($cap, CAP_PREVENT, $role->id, $context->id); } } } } // Delete old rlip record in block table. $DB->delete_records('block', array('id' => $oldrecord->id)); } // Migrate old config setting. if ($disableincron = get_config('block_rlip', 'disableincron')) { set_config('disableincron', $disableincron, 'local_datahub'); unset_config('disableincron', 'block_rlip'); } // Migrate old block_rlip_summary_logs table if it exists. $table = new xmldb_table('block_rlip_summary_logs'); // Old pre 2.6 table. if ($dbman->table_exists($table)) { $newtable = new xmldb_table('local_datahub_summary_logs'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'local_datahub_summary_logs'); } // Migrate old block_rlip_schedule table if it exists. $table = new xmldb_table('block_rlip_schedule'); // Old pre 2.6 table. if ($dbman->table_exists($table)) { $newtable = new xmldb_table('local_datahub_schedule'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'local_datahub_schedule'); // Migrate any elis_scheduled_tasks entries for block_rlip. $tableobj = new xmldb_table('elis_scheduled_tasks'); if ($dbman->table_exists($tableobj)) { $tasks = $DB->get_recordset('elis_scheduled_tasks', array('plugin' => 'block_rlip')); foreach ($tasks as $task) { $task->plugin = 'local_datahub'; $task->callfile = '/local/datahub/lib.php'; $DB->update_record('elis_scheduled_tasks', $task); } } } // Migrate language strings $migrator = new \local_eliscore\install\migration\migrator('block_rlip', 'local_datahub'); $migrator->migrate_language_strings(); unset_all_config_for_plugin('block_rlip'); // Remove the shortname for the old service. $oldservice = $DB->get_record('external_services', array('shortname' => 'rldh_webservices')); if (!empty($oldservice)) { $updated = new \stdClass(); $updated->id = $oldservice->id; $updated->shortname = 'rldh_webservices_old'; $updated->name = 'RLDH Webservices Old'; $DB->update_record('external_services', $updated); } return $result; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package block_courserequest * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) */ function xmldb_block_courserequest_install() { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); $blockid = $DB->get_field('block', 'id', array('name' => 'course_request')); if ($blockid) { // Convert any existing old course_request block instances to courserequest blocks. $sql = "UPDATE {block_instances} SET blockname = 'courserequest' WHERE blockname = 'course_request'"; $DB->execute($sql); // Migrate old config settings. $configsettings = array('course_role', 'class_role', 'use_template_by_default', 'use_course_fields', 'use_class_fields', 'create_class_with_course'); foreach ($configsettings as $configsetting) { $settingvalue = get_config('', 'block_course_request_' . $configsetting); // mtrace("Migrating setting: {$settingvalue} ..."); if ($settingvalue !== false) { set_config($configsetting, $settingvalue, 'block_courserequest'); unset_config('block_course_request_' . $configsetting, ''); } } unset_all_config_for_plugin('block_course_request'); // Delete old course_request record in block table. $DB->delete_records('block', array('id' => $blockid)); } // Migrate old block_courserequest table if it exists. $table = new xmldb_table('block_course_request'); // Old pre 2.6 table. if ($dbman->table_exists($table)) { $newtable = new xmldb_table('block_courserequest'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'block_courserequest'); } // Migrate old block_courserequest table if it exists. $table = new xmldb_table('block_course_request_fields'); // Old pre 2.6 table. if ($dbman->table_exists($table)) { $newtable = new xmldb_table('block_courserequest_fields'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'block_courserequest_fields'); } // Migrate old block_courserequest table if it exists. $table = new xmldb_table('block_course_request_data'); // Old pre 2.6 table. if ($dbman->table_exists($table)) { $newtable = new xmldb_table('block_courserequest_data'); $dbman->drop_table($newtable); $dbman->rename_table($table, 'block_courserequest_data'); } // Migrate capabilities. $oldcapprefix = 'block/course_request'; $newcapprefix = 'block/courserequest'; $sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?'; $params = array($oldcapprefix . '%'); $rolecaps = $DB->get_recordset_sql($sql, $params); foreach ($rolecaps as $rolecap) { $rolecap->capability = str_replace($oldcapprefix, $newcapprefix, $rolecap->capability); $DB->update_record('role_capabilities', $rolecap); } $sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?'; $caps = $DB->get_recordset_sql($sql, $params); foreach ($caps as $cap) { $cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name); $cap->component = str_replace('block_course_request', 'block_courserequest', $cap->component); $DB->update_record('capabilities', $cap); } // Migrate language strings $migrator = new \local_eliscore\install\migration\migrator('block_course_request', 'block_courserequest'); $migrator->migrate_language_strings(); return $result; }
/** * Install for local_eliscore * @return boolean */ function xmldb_local_eliscore_install() { global $DB, $CFG; $result = true; $dbman = $DB->get_manager(); // Run upgrade steps from old plugin if applicable $oldversion = get_config('elis_core', 'version'); if ($oldversion !== false) { if ($result && $oldversion < 2011063000) { // Define table elis_scheduled_tasks to be created $table = new xmldb_table('elis_scheduled_tasks'); // Adding fields to table elis_scheduled_tasks $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('plugin', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null); $table->add_field('taskname', XMLDB_TYPE_CHAR, '50', null, null, null, null); $table->add_field('callfile', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('callfunction', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('lastruntime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('nextruntime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('blocking', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('minute', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null); $table->add_field('hour', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null); $table->add_field('day', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null); $table->add_field('month', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null); $table->add_field('dayofweek', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null); $table->add_field('timezone', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, '99'); $table->add_field('runsremaining', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('startdate', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('enddate', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('customized', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); // Adding keys to table elis_scheduled_tasks $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table elis_scheduled_tasks $table->add_index('plugin_idx', XMLDB_INDEX_NOTUNIQUE, array('plugin', 'taskname')); $table->add_index('nextruntime_idx', XMLDB_INDEX_NOTUNIQUE, array('nextruntime')); // Conditionally launch create table for elis_scheduled_tasks if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table elis_workflow_instances to be created $table = new xmldb_table('elis_workflow_instances'); // Adding fields to table elis_workflow_instances $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('type', XMLDB_TYPE_CHAR, '127', null, XMLDB_NOTNULL, null, null); $table->add_field('subtype', XMLDB_TYPE_CHAR, '127', null, null, null, null); $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('data', XMLDB_TYPE_TEXT, 'medium', null, null, null, null); $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); // Adding keys to table elis_workflow_instances $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table elis_workflow_instances $table->add_index('usertype_idx', XMLDB_INDEX_NOTUNIQUE, array('userid', 'type', 'subtype')); // Conditionally launch create table for elis_workflow_instances if (!$dbman->table_exists($table)) { $dbman->create_table($table); } } if ($result && $oldversion < 2011080100) { // create tables that were created by block elisadmin (if upgrading a // non-CM site) // Define table context_levels to be created $table = new xmldb_table('context_levels'); // Adding fields to table context_levels $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('component', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); // Adding keys to table context_levels $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table context_levels $table->add_index('name', XMLDB_INDEX_NOTUNIQUE, array('name')); $table->add_index('component', XMLDB_INDEX_NOTUNIQUE, array('component')); // Conditionally launch create table for context_levels if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table elis_field to be created $table = new xmldb_table('elis_field'); // Adding fields to table elis_field $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('name', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null); $table->add_field('datatype', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('description', XMLDB_TYPE_TEXT, 'big', null, null, null, null); $table->add_field('categoryid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('multivalued', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0'); $table->add_field('forceunique', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('params', XMLDB_TYPE_TEXT, 'big', null, null, null, null); // Adding keys to table elis_field $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table elis_field $table->add_index('shortname_idx', XMLDB_INDEX_NOTUNIQUE, array('shortname')); // Conditionally launch create table for elis_field if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table elis_field_categories to be created $table = new xmldb_table('elis_field_categories'); // Adding fields to table elis_field_categories $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('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); // Adding keys to table elis_field_categories $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for elis_field_categories if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table elis_field_contextlevels to be created $table = new xmldb_table('elis_field_contextlevels'); // Adding fields to table elis_field_contextlevels $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('contextlevel', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); // Adding keys to table elis_field_contextlevels $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for elis_field_contextlevels if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table elis_field_category_contexts to be created $table = new xmldb_table('elis_field_category_contexts'); // Adding fields to table elis_field_category_contexts $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('categoryid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('contextlevel', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); // Adding keys to table elis_field_category_contexts $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table elis_field_category_contexts $table->add_index('contextlevel_idx', XMLDB_INDEX_NOTUNIQUE, array('contextlevel')); $table->add_index('category_idx', XMLDB_INDEX_NOTUNIQUE, array('categoryid')); // Conditionally launch create table for elis_field_category_contexts if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table local_eliscore_fld_data_text to be created $table = new xmldb_table('local_eliscore_fld_data_text'); // Adding fields to table local_eliscore_fld_data_text $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('data', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_eliscore_fld_data_text $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table local_eliscore_fld_data_text $table->add_index('context_idx', XMLDB_INDEX_NOTUNIQUE, array('contextid')); $table->add_index('field_idx', XMLDB_INDEX_NOTUNIQUE, array('fieldid')); // Conditionally launch create table for local_eliscore_fld_data_text if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table local_eliscore_fld_data_int to be created $table = new xmldb_table('local_eliscore_fld_data_int'); // Adding fields to table local_eliscore_fld_data_int $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('data', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_eliscore_fld_data_int $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table local_eliscore_fld_data_int $table->add_index('context_idx', XMLDB_INDEX_NOTUNIQUE, array('contextid')); $table->add_index('field_idx', XMLDB_INDEX_NOTUNIQUE, array('fieldid')); // Conditionally launch create table for local_eliscore_fld_data_int if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table local_eliscore_fld_data_num to be created $table = new xmldb_table('local_eliscore_fld_data_num'); // Adding fields to table local_eliscore_fld_data_num $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('data', XMLDB_TYPE_NUMBER, '15, 5', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_eliscore_fld_data_num $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table local_eliscore_fld_data_num $table->add_index('context_idx', XMLDB_INDEX_NOTUNIQUE, array('contextid')); $table->add_index('field_idx', XMLDB_INDEX_NOTUNIQUE, array('fieldid')); // Conditionally launch create table for local_eliscore_fld_data_num if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table local_eliscore_fld_data_char to be created $table = new xmldb_table('local_eliscore_fld_data_char'); // Adding fields to table local_eliscore_fld_data_char $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('data', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_eliscore_fld_data_char $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table local_eliscore_fld_data_char $table->add_index('context_idx', XMLDB_INDEX_NOTUNIQUE, array('contextid')); $table->add_index('field_idx', XMLDB_INDEX_NOTUNIQUE, array('fieldid')); // Conditionally launch create table for local_eliscore_fld_data_char if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define table elis_field_owner to be created $table = new xmldb_table('elis_field_owner'); // Adding fields to table elis_field_owner $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); $table->add_field('plugin', XMLDB_TYPE_CHAR, '255', null, null, null, null); $table->add_field('exclude', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0'); $table->add_field('params', XMLDB_TYPE_TEXT, 'big', null, null, null, null); // Adding keys to table elis_field_owner $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table elis_field_owner $table->add_index('field_idx', XMLDB_INDEX_NOTUNIQUE, array('fieldid')); // Conditionally launch create table for elis_field_owner if (!$dbman->table_exists($table)) { $dbman->create_table($table); } } if ($result && $oldversion < 2011080200) { // Define index sortorder_ix (not unique) to be dropped form elis_field // (so that we can change the default value) $table = new xmldb_table('elis_field'); $index = new xmldb_index('sortorder_ix', XMLDB_INDEX_NOTUNIQUE, array('sortorder')); // Conditionally launch drop index shortname_idx if ($dbman->index_exists($table, $index)) { $dbman->drop_index($table, $index); } // Changing the default of field sortorder on table elis_field to 0 $table = new xmldb_table('elis_field'); $field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'categoryid'); // Launch change of default for field sortorder $dbman->change_field_default($table, $field); // Changing the default of field sortorder on table elis_field_categories to 0 $table = new xmldb_table('elis_field_categories'); $field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'name'); // Launch change of default for field sortorder $dbman->change_field_default($table, $field); // Changing the default of field forceunique on table elis_field to 0 $table = new xmldb_table('elis_field'); $field = new xmldb_field('forceunique', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'multivalued'); // Launch change of default for field forceunique $dbman->change_field_default($table, $field); } if ($result && $oldversion < 2011083000) { // Remove elis_info blocks $eiblock = $DB->get_record('block', array('name' => 'elis_info')); if ($eiblock) { // elis_info block exists $eiinstance = $DB->get_record('block_instances', array('blockname' => 'elis_info')); if ($eiinstance) { // elis_info instances exist, delete them ... $DB->delete_records('block_positions', array('blockinstanceid' => $eiinstance->id)); // remove instance $DB->delete_records('block_instances', array('blockname' => 'elis_info')); } // remove any old instances if ($dbman->table_exists(new xmldb_table('block_instance_old'))) { $DB->delete_records('block_instance_old', array('blockid' => $eiblock->id)); } // remove any old pinned blocks if ($dbman->table_exists(new xmldb_table('block_pinned_old'))) { $DB->delete_records('block_pinned_old', array('blockid' => $eiblock->id)); } // remove block record $DB->delete_records('block', array('id' => $eiblock->id)); if (file_exists($CFG->dirroot . '/blocks/elis_info')) { echo $OUTPUT->notification("Warning: {$CFG->dirroot}/blocks/elis_info directory still exists - please remove it!"); } } } if ($result && $oldversion < 2011091401) { $table = new xmldb_table('elis_scheduled_tasks'); // change precisions of cron fields from varchar(25) to varchar(50) $field = new xmldb_field('minute', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); $dbman->change_field_precision($table, $field); $field = new xmldb_field('hour', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); $dbman->change_field_precision($table, $field); $field = new xmldb_field('day', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); $dbman->change_field_precision($table, $field); $field = new xmldb_field('month', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); $dbman->change_field_precision($table, $field); $field = new xmldb_field('dayofweek', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); $dbman->change_field_precision($table, $field); } if ($result && $oldversion < 2013022700) { // ELIS-8295: install missing message processors if ($dbman->table_exists('message_processors')) { foreach (core_component::get_plugin_list('message') as $name => $dir) { if (!$DB->record_exists('message_processors', array('name' => $name))) { require_once "{$dir}/db/install.php"; $installfcn = "xmldb_message_{$name}_install"; if (function_exists($installfcn)) { $installfcn(); } } } } } if ($result && $oldversion < 2013051400) { // Add new table column: (int)blocked $table = new xmldb_table('elis_scheduled_tasks'); if ($dbman->table_exists($table)) { $field = new xmldb_field('blocked', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'customized'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } } } if ($result && $oldversion < 2013082100) { // ELIS-8272: remove any old view tables that may still be around. $viewtables = array('courseNforums', 'grade_grades_with_outcome_counts', 'grade_grades_with_outcomes_ext', 'GradesListing4Transcript', 'GroupsNMembers', 'LoginDurationByUserNDate', 'LoginDurationbyUserNDate1', 'LoginDurationByUserNDate1Ext', 'LoginDurationByUserNDateExt', 'LogSummaryWithGroups', 'LogwDateSummary', 'moodleLog', 'moodleLogwDate', 'Role2RoleAssignments', 'Role2RoleAssignments5', 'SiteWideTimeStats', 'testweekdayCalc', 'Top5ForumUserTest', 'UserExt', $CFG->prefix . 'courseNforums', $CFG->prefix . 'grade_grades_with_outcome_counts', $CFG->prefix . 'grade_grades_with_outcomes_ext', $CFG->prefix . 'GradesListing4Transcript', $CFG->prefix . 'GroupsNMembers', $CFG->prefix . 'LoginDurationByUserNDate', $CFG->prefix . 'LoginDurationbyUserNDate1', $CFG->prefix . 'LoginDurationByUserNDate1Ext', $CFG->prefix . 'LoginDurationByUserNDateExt', $CFG->prefix . 'LogSummaryWithGroups', $CFG->prefix . 'LogwDateSummary', $CFG->prefix . 'moodleLog', $CFG->prefix . 'moodleLogwDate', $CFG->prefix . 'Role2RoleAssignments', $CFG->prefix . 'Role2RoleAssignments5', $CFG->prefix . 'SiteWideTimeStats', $CFG->prefix . 'testweekdayCalc', $CFG->prefix . 'Top5ForumUserTest', $CFG->prefix . 'UserExt'); // Must use direct PHP database commands since Moodle does not know about these tables. if ($CFG->dbfamily == 'mysql') { $db = mysqli_connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass); mysqli_select_db($db, $CFG->dbname); foreach ($viewtables as $viewtable) { $sql = "DROP VIEW IF EXISTS {$viewtable}"; mysqli_query($db, $sql); } mysqli_close($db); } else { if ($CFG->dbfamily == 'postgres') { $db = pg_connect('host=' . $CFG->dbhost . ' dbname=' . $CFG->dbname . ' user='******' password='******'elis_scheduled_tasks' => 'local_eliscore_sched_tasks', 'elis_workflow_instances' => 'local_eliscore_wkflow_inst', 'elis_field' => 'local_eliscore_field', 'elis_field_categories' => 'local_eliscore_field_cats', 'elis_field_contextlevels' => 'local_eliscore_field_clevels', 'elis_field_category_contexts' => 'local_eliscore_fld_cat_ctx', 'elis_field_data_text' => 'local_eliscore_fld_data_text', 'elis_field_data_int' => 'local_eliscore_fld_data_int', 'elis_field_data_num' => 'local_eliscore_fld_data_num', 'elis_field_data_char' => 'local_eliscore_fld_data_char', 'elis_field_owner' => 'local_eliscore_field_owner'); foreach ($tablemap as $oldtable => $newtable) { $oldtableobj = new xmldb_table($oldtable); if ($dbman->table_exists($oldtableobj)) { $newtableobj = new xmldb_table($newtable); $dbman->drop_table($newtableobj); $dbman->rename_table($oldtableobj, $newtable); } } // Upgrade step that had to be differred for new tables if ($result && $oldversion !== false && $oldversion < 2012091900) { // clear out duplicate default values from elis_field_data tables $tables = array('local_eliscore_fld_data_char', 'local_eliscore_fld_data_int', 'local_eliscore_fld_data_num', 'local_eliscore_fld_data_text'); foreach ($tables as $data_table) { $table = new xmldb_table($data_table); $dbman->rename_table($table, 'old_' . $data_table); $dbman->install_one_table_from_xmldb_file("{$CFG->dirroot}/local/eliscore/db/install.xml", $data_table); $DB->execute("INSERT INTO {{$data_table}} (contextid, fieldid, data) SELECT DISTINCT contextid, fieldid, data FROM {old_{$data_table}}"); $table = new xmldb_table('old_' . $data_table); $dbman->drop_table($table); } } // Migrate language strings $migrator = new \local_eliscore\install\migration\migrator('elis_core', 'local_eliscore'); $migrator->migrate_language_strings(); // Copy any settings from old plugin $oldconfig = get_config('elis_core'); foreach ($oldconfig as $name => $value) { set_config($name, $value, 'local_eliscore'); } unset_all_config_for_plugin('elis_core'); return $result; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2014 onwards Remote-Learner.net Inc (http://www.remote-learner.net) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package repository_elisfiles * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net) * */ function xmldb_repository_elisfiles_install() { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); // Run upgrade steps from old plugin if applicable $oldversion = get_config('repository_elis_files', 'version'); if ($oldversion !== false) { require_once($CFG->dirroot.'/repository/elisfiles/lib/lib.php'); if ($oldversion < 2011110301) { $errors = false; $auths = elis_files_nopasswd_auths(); $authlist = "'". implode("', '", $auths) ."'"; $users = $DB->get_records_select('user', "auth IN ({$authlist})", array(), 'id, auth'); if (!empty($users)) { foreach ($users as $user) { $user = get_complete_user_data('id', $user->id); $migrate_ok = elis_files_user_created($user); if (!$migrate_ok) { $errors = true; // error_log("xmldb_block_elis_files_upgrade({$oldversion}) - failed migrating user ({$user->id}) to Alfresco."); } } } if (!$errors) { set_config('initialized', 1, ELIS_files::$plugin_name); } } if ($result && $oldversion < 2012042300) { //check that elis_files_organization_store exists and repository_elisfiles_userset does not exist if ($dbman->table_exists('elis_files_organization_store') && !$dbman->table_exists('elis_files_userset_store')) { $original_table = new xmldb_table('elis_files_organization_store'); //rename table $dbman->rename_table($original_table, 'elis_files_userset_store'); $new_table = new xmldb_table('elis_files_userset_store'); //drop the keys $original_uuid_index = new xmldb_index('elisfileorgastor_orguu_uix', XMLDB_INDEX_UNIQUE, array('organizationid', 'uuid')); $original_index = new xmldb_index('elisfileorgastor_org_ix', XMLDB_INDEX_NOTUNIQUE, array('organizationid')); $dbman->drop_index($new_table, $original_uuid_index); $dbman->drop_index($new_table, $original_index); //rename field $organization = new xmldb_field('organizationid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0); $dbman->rename_field($new_table, $organization, 'usersetid'); //add the keys $new_uuid_index = new xmldb_index('elisfileuserstor_useuu_uix', XMLDB_INDEX_UNIQUE, array('usersetid', 'uuid')); $new_index = new xmldb_index('elisfileuserstor_use_ix', XMLDB_INDEX_NOTUNIQUE, array('usersetid')); $dbman->add_index($new_table, $new_uuid_index); $dbman->add_index($new_table, $new_index); } } if ($result && $oldversion < 2012042500) { defined('ELIS_FILES_BROWSE_USERSET_FILES') or define('ELIS_FILES_BROWSE_USERSET_FILES', 60); // ELIS-4676 ELIS UserSet Files is no longer valid, so change to default of ELIS User Files $select = "plugin = 'elis_files' AND name = 'default_browse'"; if ($record = $DB->get_record_select('config_plugins', $select)) { require_once($CFG->dirroot.'/repository/elisfiles/lib/ELIS_files.php'); $int_value = (int)$record->value; $valid_values = array( ELIS_FILES_BROWSE_SITE_FILES, ELIS_FILES_BROWSE_SHARED_FILES, ELIS_FILES_BROWSE_COURSE_FILES, ELIS_FILES_BROWSE_USER_FILES ); if (!in_array($int_value, $valid_values)) { $record->value = ELIS_FILES_BROWSE_USER_FILES; $DB->update_record('config_plugins', $record); } } } if ($result && $oldversion < 2012050200) { // Check for any plug-in settings using an incorrect plug-in name "ELIS_files" instead of "elis_files" if ($pcfgs = $DB->get_records('config_plugins', array('plugin' => 'ELIS_files'))) { foreach ($pcfgs as $pcfg) { $pcfg->plugin = 'elis_files'; $DB->update_record('config_plugins', $pcfg); } } } /* * This upgrade step removes any possible stale data in the repository_elisfiles_userset and * repository_elisfiles_course that not longer have relevant courses or user sets */ if ($result && $oldversion < 2012083000) { $haveuserset = false; if (file_exists($CFG->dirroot.'/local/elisprogram/lib/data/userset.class.php')) { require_once($CFG->dirroot.'/local/elisprogram/lib/data/userset.class.php'); $haveuserset = $dbman->table_exists(userset::TABLE); } $sql = 'DELETE FROM {elis_files_userset_store}'; if ($haveuserset) { $sql .= ' WHERE NOT EXISTS (SELECT * FROM {'.userset::TABLE.'} WHERE {elis_files_userset_store}.usersetid = {'.userset::TABLE.'}.id)'; } $DB->execute($sql); $sql = 'DELETE FROM {elis_files_course_store} WHERE NOT EXISTS (SELECT * FROM {course} WHERE {elis_files_course_store}.courseid = {course}.id)'; $DB->execute($sql); } /* * This upgrade step removes backslashes from category titles in the repository_elisfiles_cats */ if ($result && $oldversion < 2012090400) { require_once($CFG->dirroot.'/repository/elisfiles/ELIS_files_factory.class.php'); // Initialize the repo object. $repo = repository_factory::factory(); $table = 'elis_files_categories'; if ($repo && $dbman->table_exists($table) && $categories = elis_files_get_categories()) { $DB->delete_records($table); // Perform the back-end category refresh $categories = elis_files_get_categories(); $uuids = array(); $repo->process_categories($uuids, $categories); } } // If the pre-ELIS 2 Alfresco plugin was present and enabled on this site, then we need to automatically // enable the ELIS Files plugin $select1 = "name = 'repository' AND ".$DB->sql_compare_text('value')." = 'alfresco'"; $select2 = "name = 'repository_plugins_enabled' AND ".$DB->sql_compare_text('value')." = 'alfresco'"; if ($DB->record_exists_select('config', $select1) && $DB->record_exists_select('config', $select2)) { require_once($CFG->dirroot.'/repository/lib.php'); $elis_files = new repository_type('elisfiles', array(), true); if (!empty($elis_files)) { $elis_files->update_visibility(true); $elis_files->create(); } $DB->delete_records_select('config', "(name = 'repository' OR name = 'repository_plugins_enabled')"); } // ELIS-3677, ELIS-3802 Moodle files is no longer valid, so change to default of ELIS User Files $select = "plugin = 'elis_files' AND name = 'default_browse'"; if ($record = $DB->get_record_select('config_plugins', $select)) { require_once($CFG->dirroot.'/repository/elisfiles/lib/ELIS_files.php'); $int_value = (int)$record->value; $valid_values = array( ELIS_FILES_BROWSE_SITE_FILES, ELIS_FILES_BROWSE_SHARED_FILES, ELIS_FILES_BROWSE_COURSE_FILES, ELIS_FILES_BROWSE_USER_FILES ); if (!in_array($int_value, $valid_values)) { $record->value = ELIS_FILES_BROWSE_USER_FILES; $DB->update_record('config_plugins', $record); } } $ignoreresult = elis_files_update_references_in_database(); } // Convert old tables to new static $tablemap = array( 'elis_files_categories' => 'repository_elisfiles_cats', 'elis_files_course_store' => 'repository_elisfiles_course', 'elis_files_userset_store' => 'repository_elisfiles_userset' ); foreach ($tablemap as $oldtable => $newtable) { $oldtableobj = new xmldb_table($oldtable); if ($dbman->table_exists($oldtableobj)) { $newtableobj = new xmldb_table($newtable); $dbman->drop_table($newtableobj); $dbman->rename_table($oldtableobj, $newtable); } } // Migrate capabilities $oldcapprefix = 'repository/elis_files'; $newcapprefix = 'repository/elisfiles'; $sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?'; $params = array($oldcapprefix.'%'); $rolecaps = $DB->get_recordset_sql($sql, $params); foreach ($rolecaps as $rolecaprec) { $updaterec = new stdClass; $updaterec->id = $rolecaprec->id; $updaterec->capability = str_replace($oldcapprefix, $newcapprefix, $rolecaprec->capability); $DB->update_record('role_capabilities', $updaterec); } $sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?'; $caps = $DB->get_recordset_sql($sql, $params); foreach ($caps as $cap) { $cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name); $cap->component = str_replace('repository_elis_files', 'repository_elisfiles', $cap->component); $DB->update_record('capabilities', $cap); } // Migrate language strings $migrator = new \local_eliscore\install\migration\migrator('repository_elis_files', 'repository_elisfiles'); $migrator->migrate_language_strings(); // Copy any settings from old plugin $oldconfig = get_config('elis_files'); foreach ($oldconfig as $name => $value) { set_config($name, $value, 'elisfiles'); } unset_all_config_for_plugin('elis_files'); unset_all_config_for_plugin('repository_elis_files'); // Update repository table $sql = 'UPDATE {repository} SET type = "elisfiles" WHERE type = "elis_files"'; $DB->execute($sql); return $result; }