function xmldb_enrol_guest_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); // Moodle v2.2.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2011112901) { // convert all null passwords to empty strings $DB->set_field('enrol', 'password', '', array('enrol' => 'guest', 'password' => null)); upgrade_plugin_savepoint(true, 2011112901, 'enrol', 'guest'); } // Moodle v2.3.0 release upgrade line // Put any upgrade step following this // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.9.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Upgrade function. * * @param int $oldversion the version we are upgrading from. * @return bool result */ function xmldb_portfolio_boxnet_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2013110602) { require_once $CFG->libdir . '/portfoliolib.php'; require_once $CFG->dirroot . '/portfolio/boxnet/db/upgradelib.php'; $existing = $DB->get_record('portfolio_instance', array('plugin' => 'boxnet'), '*', IGNORE_MULTIPLE); if ($existing) { // Only disable or message the admins when the portfolio hasn't been set for APIv2. $instance = portfolio_instance($existing->id, $existing); if ($instance->get_config('clientid') === null && $instance->get_config('clientsecret') === null) { // Disable Box.net. $instance->set('visible', 0); $instance->save(); // Message the admins. portfolio_boxnet_admin_upgrade_notification(); } } upgrade_plugin_savepoint(true, 2013110602, 'portfolio', 'boxnet'); } // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.9.0 release upgrade line. // Put any upgrade step following this. return true; }
function xmldb_enrol_flatfile_upgrade($oldversion) { global $CFG, $DB; $result = TRUE; $dbman = $DB->get_manager(); if ($oldversion < 2010091400) { // Define table enrol_flatfile to be created $table = new xmldb_table('enrol_flatfile'); // Adding fields to table enrol_flatfile $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('action', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null); $table->add_field('roleid', 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('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('timestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('timeend', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); // Adding keys to table enrol_flatfile $table->add_key('id', XMLDB_KEY_PRIMARY, array('id')); $table->add_key('courseid-id', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id')); $table->add_key('userid-id', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); $table->add_key('roleid-id', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id')); // Conditionally launch create table for enrol_flatfile if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // flatfile savepoint reached upgrade_plugin_savepoint(true, 2010091400, 'enrol', 'flatfile'); } return $result; }
function xmldb_theme_formal_white_upgrade($oldversion) { // Moodle v2.2.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2012051503) { $currentsetting = get_config('theme_formal_white'); if (isset($currentsetting->displaylogo)) { // useless but safer // Create a new config setting called headercontent and give it the current displaylogo value. set_config('headercontent', $currentsetting->displaylogo, 'theme_formal_white'); unset_config('displaylogo', 'theme_formal_white'); } if (isset($currentsetting->logo)) { // useless but safer // Create a new config setting called headercontent and give it the current displaylogo value. set_config('customlogourl', $currentsetting->logo, 'theme_formal_white'); unset_config('logo', 'theme_formal_white'); } if (isset($currentsetting->frontpagelogo)) { // useless but safer // Create a new config setting called headercontent and give it the current displaylogo value. set_config('frontpagelogourl', $currentsetting->frontpagelogo, 'theme_formal_white'); unset_config('frontpagelogo', 'theme_formal_white'); } upgrade_plugin_savepoint(true, 2012051503, 'theme', 'formal_white'); } // Moodle v2.3.0 release upgrade line // Put any upgrade step following this // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_portfolio_picasa_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2012053000) { // Delete old user preferences containing authsub tokens. $DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey_picasa')); upgrade_plugin_savepoint(true, 2012053000, 'portfolio', 'picasa'); } if ($oldversion < 2012053001) { $existing = $DB->get_record('portfolio_instance', array('plugin' => 'picasa'), '*', IGNORE_MISSING); if ($existing) { portfolio_picasa_admin_upgrade_notification(); } upgrade_plugin_savepoint(true, 2012053001, 'portfolio', 'picasa'); } // Moodle v2.3.0 release upgrade line // Put any upgrade step following this return true; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_filter_texwjax_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.3.0 release upgrade line // Put any upgrade step following this // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. if ($oldversion < 2013120300) { $settings = array('density', 'latexbackground', 'convertformat', 'pathlatex', 'convertformat', 'pathconvert', 'pathdvips', 'latexpreamble'); // Move tex settings to config_pluins and delete entries from the config table. foreach ($settings as $setting) { $existingkey = 'filter_texwjax_' . $setting; if (array_key_exists($existingkey, $CFG)) { set_config($setting, $CFG->{$existingkey}, 'filter_texwjax'); unset_config($existingkey); } } upgrade_plugin_savepoint(true, 2013120300, 'filter', 'texwjax'); } // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * EditPDF upgrade code * @param int $oldversion * @return bool */ function xmldb_assignfeedback_editpdf_upgrade($oldversion) { global $CFG; if ($oldversion < 2013110800) { // Check that no stamps where uploaded. $fs = get_file_storage(); $stamps = $fs->get_area_files(context_system::instance()->id, 'assignfeedback_editpdf', 'stamps', 0, "filename", false); // Add default stamps. if (empty($stamps)) { // List of default stamps. $defaultstamps = array('smile.png', 'sad.png', 'tick.png', 'cross.png'); // Stamp file object. $filerecord = new stdClass(); $filerecord->component = 'assignfeedback_editpdf'; $filerecord->contextid = context_system::instance()->id; $filerecord->userid = get_admin()->id; $filerecord->filearea = 'stamps'; $filerecord->filepath = '/'; $filerecord->itemid = 0; // Add all default stamps. foreach ($defaultstamps as $stamp) { $filerecord->filename = $stamp; $fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/mod/assign/feedback/editpdf/pix/' . $filerecord->filename); } } upgrade_plugin_savepoint(true, 2013110800, 'assignfeedback', 'editpdf'); } // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * EditPDF upgrade code * @param int $oldversion * @return bool */ function xmldb_assignfeedback_editpdf_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.9.0 release upgrade line. // Put any upgrade step following this. // Moodle v3.0.0 release upgrade line. // Put any upgrade step following this. if ($oldversion < 2016021600) { // Define table assignfeedback_editpdf_queue to be created. $table = new xmldb_table('assignfeedback_editpdf_queue'); // Adding fields to table assignfeedback_editpdf_queue. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('submissionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('submissionattempt', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table assignfeedback_editpdf_queue. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for assignfeedback_editpdf_queue. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Editpdf savepoint reached. upgrade_plugin_savepoint(true, 2016021600, 'assignfeedback', 'editpdf'); } // Moodle v3.1.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Language customization report upgrades * * @package report * @subpackage customlang * @copyright 2010 David Mudrak <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_report_customlang_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); $result = true; /** * Use proper plugin prefix for tables */ if ($oldversion < 2010111200) { if ($dbman->table_exists('customlang')) { $dbman->rename_table(new xmldb_table('customlang'), 'report_customlang'); } if ($dbman->table_exists('customlang_components')) { $dbman->rename_table(new xmldb_table('customlang_components'), 'report_customlang_components'); } upgrade_plugin_savepoint(true, 2010111200, 'report', 'customlang'); } /** * Regenerate the foreign key after the tables rename */ if ($oldversion < 2010111500) { $table = new xmldb_table('report_customlang'); $oldkey = new xmldb_key('fk_component', XMLDB_KEY_FOREIGN, array('componentid'), 'customlang_components', array('id')); $newkey = new xmldb_key('fk_component', XMLDB_KEY_FOREIGN, array('componentid'), 'report_customlang_components', array('id')); $dbman->drop_key($table, $oldkey); $dbman->add_key($table, $newkey); upgrade_plugin_savepoint(true, 2010111500, 'report', 'customlang'); } return $result; }
function xmldb_editor_tinymce_upgrade($oldversion) { global $CFG, $DB; if ($oldversion < 2014062900) { // We only want to delete DragMath from the customtoolbar setting if the directory no longer exists. If // the directory is present then it means it has been restored, so do not remove any settings. if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) { // Remove the DragMath plugin from the 'customtoolbar' setting (if it exists) as it has been removed. $currentorder = get_config('editor_tinymce', 'customtoolbar'); $newtoolbarrows = array(); $currenttoolbarrows = explode("\n", $currentorder); foreach ($currenttoolbarrows as $currenttoolbarrow) { $currenttoolbarrow = implode(',', array_diff(str_getcsv($currenttoolbarrow), array('dragmath'))); $newtoolbarrows[] = $currenttoolbarrow; } $neworder = implode("\n", $newtoolbarrows); unset_config('customtoolbar', 'editor_tinymce'); set_config('customtoolbar', $neworder, 'editor_tinymce'); } upgrade_plugin_savepoint(true, 2014062900, 'editor', 'tinymce'); } // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.9.0 release upgrade line. // Put any upgrade step following this. // Moodle v3.0.0 release upgrade line. // Put any upgrade step following this. // Moodle v3.1.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Performs upgrade of the database structure and data * * @param int $oldversion the version we are upgrading from * @return bool true */ function xmldb_workshopform_comments_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); if ($oldversion < 2010091700) { // clean up orphaned dimensions $orphans = $DB->get_records_sql("SELECT d.id FROM {workshopform_comments} d LEFT JOIN {workshop} w ON d.workshopid = w.id WHERE w.id IS NULL"); if (!empty($orphans)) { echo $OUTPUT->notification('Orphaned assessment form elements found - cleaning...'); $DB->delete_records_list('workshopform_comments', 'id', array_keys($orphans)); } upgrade_plugin_savepoint(true, 2010091700, 'workshopform', 'comments'); } // Moodle v2.1.0 release upgrade line // Put any upgrade step following this // Moodle v2.2.0 release upgrade line // Put any upgrade step following this return true; }
function xmldb_tinymce_spellchecker_upgrade($oldversion) { global $CFG, $DB; require_once __DIR__ . '/upgradelib.php'; $dbman = $DB->get_manager(); if ($oldversion < 2012051800) { tinymce_spellchecker_migrate_settings(); upgrade_plugin_savepoint(true, 2012051800, 'tinymce', 'spellchecker'); } // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.9.0 release upgrade line. // Put any upgrade step following this. // Moodle v3.0.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_repository_onenote_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2014103001) { // Define table repository_onenote to be created. $table = new xmldb_table('repository_onenote'); // Adding fields to table repository_onenote. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); // Adding keys to table repository_onenote. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for repository_onenote. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Onenote savepoint reached. upgrade_plugin_savepoint(true, 2014103001, 'repository', 'onenote'); } // Moodle v2.3.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.4.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Custom authentication for WHIA project * * Upgrade script * * @package auth_whia * @author Bevan Holman <*****@*****.**>, Pukunui * @copyright 2015 onwards, Pukunui * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_auth_whia_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); /// Add a new table mdl_auth_whia_domain to plugin if ($oldversion < 2016020802) { // Define table auth_rsa_cpdlog to be created. $table = new xmldb_table('auth_whia_domain'); // Adding fields to table auth_rsa_cpdlog. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('name', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); // Adding keys to table auth_rsa_cpdlog. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for auth_rsa_cpdlog. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // WHIA savepoint reached. upgrade_plugin_savepoint(true, 2016020802, 'auth', 'whia'); } if ($oldversion < 2016020813) { // Define field cohortid to be added to auth_whia_domain. $table = new xmldb_table('auth_whia_domain'); $field = new xmldb_field('cohortid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'name'); // Conditionally launch add field cohortid. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Monitor savepoint reached. upgrade_plugin_savepoint(true, 2016020813, 'auth', 'whia'); } return true; }
function xmldb_local_enrolmentreminder_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2014051501) { // Define field leadtime to be added to enrolmentreminder. $table = new xmldb_table('enrolmentreminder'); $field = new xmldb_field('leadtime', XMLDB_TYPE_INTEGER, '7', null, XMLDB_NOTNULL, null, '259200', 'tmpltext'); // Conditionally launch add field leadtime. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Enrolmentreminder savepoint reached. upgrade_plugin_savepoint(true, '2014051501', 'local', 'enrolmentreminder'); } if ($oldversion < 2014072201) { // Changing type of field tmpltext on table enrolmentreminder to text. $table = new xmldb_table('enrolmentreminder'); $field = new xmldb_field('tmpltext', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'courseid'); // Launch change of type for field tmpltext. $dbman->change_field_type($table, $field); // Enrolmentreminder savepoint reached. upgrade_plugin_savepoint(true, 2014072201, 'local', 'enrolmentreminder'); } return true; }
function xmldb_block_configurable_reports_upgrade($oldversion) { global $DB, $CFG; $dbman = $DB->get_manager(); if ($oldversion < 2011040103) { $table = new xmldb_table('block_configurable_reports_report'); $dbman->rename_table($table, 'block_configurable_reports'); upgrade_plugin_savepoint(true, 2011040103, 'block', 'configurable_reports'); } if ($oldversion < 2011040106) { $table = new xmldb_table('block_configurable_reports'); $field = new xmldb_field('global', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '0', null); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $field = new xmldb_field('lastexecutiontime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0', null); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $field = new xmldb_field('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0', null); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_plugin_savepoint(true, 2011040106, 'block', 'configurable_reports'); } if ($oldversion < 2011040115) { $table = new xmldb_table('block_configurable_reports'); $field = new xmldb_field('remote', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0', null); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_plugin_savepoint(true, 2011040115, 'block', 'configurable_reports'); } return true; }
/** * Runs any upgrade needed to upgrade from $oldversion to the current version * * @param int $oldversion */ function xmldb_local_progressreview_upgrade($oldversion = 0) { global $DB; $dbman = $DB->get_manager(); if ($oldversion < 2012012700) { // Define field homeworkstart to be added to progressreview_session $table = new xmldb_table('progressreview_session'); $field = new xmldb_field('homeworkstart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'scale_behaviour'); // Conditionally launch add field homeworkstart if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // progressreview savepoint reached upgrade_plugin_savepoint(true, 2012012700, 'local', 'progressreview'); } if ($oldversion < 2012041700) { // Define field deadline_active to be added to progressreview_session $table = new xmldb_table('progressreview_session'); $field = new xmldb_field('deadline_active', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'deadline_tutor'); // Conditionally launch add field deadline_active if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // progressreview savepoint reached upgrade_plugin_savepoint(true, 2012041700, 'local', 'progressreview'); } }
/** * Upgrade code for the essay question type. * @param int $oldversion the version we are upgrading from. */ function xmldb_qtype_essay_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2011031000) { // Define table qtype_essay_options to be created $table = new xmldb_table('qtype_essay_options'); // Adding fields to table qtype_essay_options $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('responseformat', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, 'editor'); $table->add_field('responsefieldlines', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '15'); $table->add_field('attachments', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0'); $table->add_field('graderinfo', XMLDB_TYPE_TEXT, 'small', null, null, null, null); $table->add_field('graderinfoformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); // Adding keys to table qtype_essay_options $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); $table->add_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id')); // Conditionally launch create table for qtype_essay_options if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // essay savepoint reached upgrade_plugin_savepoint(true, 2011031000, 'qtype', 'essay'); } if ($oldversion < 2011060300) { // Insert a row into the qtype_essay_options table for each existing essay question. $DB->execute("\n INSERT INTO {qtype_essay_options} (questionid, responseformat,\n responsefieldlines, attachments, graderinfo, graderinfoformat)\n SELECT q.id, 'editor', 15, 0, '', " . FORMAT_MOODLE . "\n FROM {question} q\n WHERE q.qtype = 'essay'\n AND NOT EXISTS (\n SELECT 'x'\n FROM {qtype_essay_options} qeo\n WHERE qeo.questionid = q.id)"); // essay savepoint reached upgrade_plugin_savepoint(true, 2011060300, 'qtype', 'essay'); } // Moodle v2.1.0 release upgrade line // Put any upgrade step following this return true; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_repository_dropbox_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.3.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2012080702) { // Set the default value for dropbox_cachelimit $value = get_config('dropbox', 'dropbox_cachelimit'); if (empty($value)) { set_config('dropbox_cachelimit', 1024*1024, 'dropbox'); } upgrade_plugin_savepoint(true, 2012080702, 'repository', 'dropbox'); } // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * MOODLE VERSION INFORMATION * * * @package local * @copyright Renzo Tassara Miller (rtassara@alumnos.uai.cl) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_local_fitness_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2015060210) { // Define table local_fitness to be created. $table = new xmldb_table('local_fitness'); // Adding fields to table local_fitness. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('nombre', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null); $table->add_field('apellido', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null); $table->add_field('email', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); $table->add_field('talla', XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, null); $table->add_field('peso', XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, null); $table->add_field('imc', XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, null); $table->add_field('sumamm', XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, null); $table->add_field('grasa', XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, null); $table->add_field('sitandreachr', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); $table->add_field('sitandreachl', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); $table->add_field('trunklift', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); $table->add_field('abd', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); $table->add_field('pushup', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); $table->add_field('pacerlvl', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); $table->add_field('vo2max', XMLDB_TYPE_NUMBER, '6, 2', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_fitness. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for local_fitness. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Fitness savepoint reached. upgrade_plugin_savepoint(true, 2015060210, 'local', 'fitness'); } }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_filter_mediaplugin_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2011121200) { // Move all the media enable setttings that are now handled by core media renderer. foreach (array('html5video', 'html5audio', 'mp3', 'flv', 'wmp', 'qt', 'rm', 'youtube', 'vimeo', 'swf') as $type) { $existingkey = 'filter_mediaplugin_enable_' . $type; if (array_key_exists($existingkey, $CFG)) { set_config('core_media_enable_' . $type, $CFG->{$existingkey}); unset_config($existingkey); } } // Override setting for html5 to turn it on (previous default was off; because // of changes in the way fallbacks are handled, this is now unlikely to cause // a problem, and is required for mobile a/v support on non-Flash devices, so // this change is basically needed in order to maintain existing behaviour). set_config('core_media_enable_html5video', 1); set_config('core_media_enable_html5audio', 1); upgrade_plugin_savepoint(true, 2011121200, 'filter', 'mediaplugin'); } // Moodle v2.3.0 release upgrade line // Put any upgrade step following this // Moodle v2.4.0 release upgrade line // Put any upgrade step following this return true; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_portfolio_googledocs_upgrade($oldversion) { global $CFG, $DB; require_once __DIR__ . '/upgradelib.php'; $dbman = $DB->get_manager(); if ($oldversion < 2012053000) { // Delete old user preferences containing authsub tokens. $DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey')); upgrade_plugin_savepoint(true, 2012053000, 'portfolio', 'googledocs'); } if ($oldversion < 2012053001) { $existing = $DB->get_record('portfolio_instance', array('plugin' => 'googledocs'), '*', IGNORE_MULTIPLE); if ($existing) { portfolio_googledocs_admin_upgrade_notification(); } upgrade_plugin_savepoint(true, 2012053001, 'portfolio', 'googledocs'); } // Moodle v2.3.0 release upgrade line // Put any upgrade step following this // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. return true; }
function xmldb_enrol_self_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); // Moodle v2.3.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2012101400) { // Set default expiry threshold to 1 day. $DB->execute("UPDATE {enrol} SET expirythreshold = 86400 WHERE enrol = 'self' AND expirythreshold = 0"); upgrade_plugin_savepoint(true, 2012101400, 'enrol', 'self'); } if ($oldversion < 2012120600) { // Enable new self enrolments everywhere. $DB->execute("UPDATE {enrol} SET customint6 = 1 WHERE enrol = 'self'"); upgrade_plugin_savepoint(true, 2012120600, 'enrol', 'self'); } // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. if ($oldversion < 2013112100) { // Set customint1 (group enrolment key) to 0 if it was not set (null). $DB->execute("UPDATE {enrol} SET customint1 = 0 WHERE enrol = 'self' AND customint1 IS NULL"); upgrade_plugin_savepoint(true, 2013112100, 'enrol', 'self'); } // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * upgrade this attendance instance - this function could be skipped but it will be needed later * @param int $oldversion The old version of the attendance module * @return bool */ function xmldb_attendance_upgrade($oldversion = 0) { global $CFG, $THEME, $DB; $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. $result = true; if ($oldversion < 2013082902) { // Replace values that reference old module "attforblock" to "attendance". $sql = "UPDATE {grade_items}\n SET itemmodule = 'attendance'\n WHERE itemmodule = 'attforblock'"; $DB->execute($sql); $sql = "UPDATE {grade_items_history}\n SET itemmodule = 'attendance'\n WHERE itemmodule = 'attforblock'"; $DB->execute($sql); /* * The user's custom capabilities need to be preserved due to the module renaming. * Capabilities with a modifierid = 0 value are installed by default. * Only update the user's custom capabilities where modifierid is not zero. */ $sql = $DB->sql_like('capability', '?') . ' AND modifierid <> 0'; $rs = $DB->get_recordset_select('role_capabilities', $sql, array('%mod/attforblock%')); foreach ($rs as $cap) { $renamedcapability = str_replace('mod/attforblock', 'mod/attendance', $cap->capability); $exists = $DB->record_exists('role_capabilities', array('roleid' => $cap->roleid, 'capability' => $renamedcapability)); if (!$exists) { $DB->update_record('role_capabilities', array('id' => $cap->id, 'capability' => $renamedcapability)); } } // Delete old role capabilities. $sql = $DB->sql_like('capability', '?'); $DB->delete_records_select('role_capabilities', $sql, array('%mod/attforblock%')); // Delete old capabilities. $DB->delete_records_select('capabilities', 'component = ?', array('mod_attforblock')); upgrade_plugin_savepoint($result, 2013082902, 'mod', 'attendance'); } return $result; }
/** * Upgrade the local_msaccount plugin. * * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_local_msaccount_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2014111702) { // Define table to be created. $table = new xmldb_table('msaccount_refresh_tokens'); // Adding fields to table. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('user_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null); $table->add_field('refresh_token', XMLDB_TYPE_CHAR, '500', null, null, null, null); // Adding keys to table. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Create table. if ($dbman->table_exists($table)) { $dbman->drop_table($table); } $dbman->create_table($table); // Msaccount savepoint reached. upgrade_plugin_savepoint(true, 2014111702, 'local', 'msaccount'); } // Moodle v2.3.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.4.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Upgrade code for the multi-answer question type. * @param int $oldversion the version we are upgrading from. */ function xmldb_qtype_multianswer_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2008050800) { //hey - no functions here in this file !!!!!!! $rs = $DB->get_recordset_sql("SELECT q.id, q.category, qma.sequence FROM {question} q JOIN {question_multianswer} qma ON q.id = qma.question"); foreach ($rs as $q) { if (!empty($q->sequence)) { $DB->execute("UPDATE {question} SET parent = ?, category = ? WHERE id IN ($q->sequence) AND parent <> 0", array($q->id, $q->category)); } } $rs->close(); /// multianswer savepoint reached upgrade_plugin_savepoint(true, 2008050800, 'qtype', 'multianswer'); } // Moodle v2.1.0 release upgrade line // Put any upgrade step following this // Moodle v2.2.0 release upgrade line // Put any upgrade step following this return true; }
/** * This file keeps track of upgrades to the wiki module * * 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 installation to the current version. * * @package mod-wiki-2.0 * @copyrigth 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu * @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu * * @author Jordi Piguillem * * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * */ function xmldb_wiki_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); // Moodle v2.2.0 release upgrade line // Put any upgrade step following this // Moodle v2.3.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2012061701) { // Drop all legacy upgrade tables, not used anymore. $table = new xmldb_table('wiki_entries_old'); if ($dbman->table_exists('wiki_entries_old')) { $dbman->drop_table($table); } $table = new xmldb_table('wiki_locks_old'); if ($dbman->table_exists('wiki_locks_old')) { $dbman->drop_table($table); } $table = new xmldb_table('wiki_pages_old'); if ($dbman->table_exists('wiki_pages_old')) { $dbman->drop_table($table); } upgrade_plugin_savepoint(true, 2012061701, 'mod', 'wiki'); } // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Upgrade the plugin. * * @param int $oldversion * @return bool always true */ function xmldb_tool_monitor_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); if ($oldversion < 2014102000) { // Define field lastnotificationsent to be added to tool_monitor_subscriptions. $table = new xmldb_table('tool_monitor_subscriptions'); $field = new xmldb_field('lastnotificationsent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'timecreated'); // Conditionally launch add field lastnotificationsent. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Monitor savepoint reached. upgrade_plugin_savepoint(true, 2014102000, 'tool', 'monitor'); } // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.9.0 release upgrade line. // Put any upgrade step following this. // Moodle v3.0.0 release upgrade line. // Put any upgrade step following this. // Moodle v3.1.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_repository_googledocs_upgrade($oldversion) { global $CFG, $DB; require_once __DIR__ . '/upgradelib.php'; $dbman = $DB->get_manager(); if ($oldversion < 2012051400) { // Delete old user preferences containing authsub tokens. $DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey')); upgrade_plugin_savepoint(true, 2012051400, 'repository', 'googledocs'); } if ($oldversion < 2012053000) { require_once $CFG->dirroot . '/repository/lib.php'; $existing = $DB->get_record('repository', array('type' => 'googledocs'), '*', IGNORE_MULTIPLE); if ($existing) { $googledocsplugin = new repository_type('googledocs', array(), true); $googledocsplugin->delete(); repository_googledocs_admin_upgrade_notification(); } upgrade_plugin_savepoint(true, 2012053000, 'repository', 'googledocs'); } // Moodle v2.3.0 release upgrade line // Put any upgrade step following this // Moodle v2.4.0 release upgrade line // Put any upgrade step following this // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. return true; }
function xmldb_local_rcommon_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2015051300) { require_once $CFG->dirroot . '/local/rcommon/locallib.php'; if (isset($CFG->isagora) && $CFG->isagora) { if (isset($CFG->ismarsupial) && $CFG->ismarsupial) { $enable = 1; } else { $enable = 0; } set_marsupial_state($enable); } else { set_marsupial_state(1); } upgrade_plugin_savepoint(true, 2015051300, 'local', 'rcommon'); } if ($oldversion < 2015051901) { // Delete duplicated credentials $creds = $DB->get_records_sql('SELECT id, isbn, euserid, credentials FROM {rcommon_user_credentials} ORDER BY isbn, euserid'); $lastcred = false; foreach ($creds as $cred) { if (!empty($cred->credentials)) { if ($lastcred && $cred->isbn == $lastcred->isbn && $cred->euserid == $lastcred->euserid && $cred->credentials == $lastcred->credentials) { $DB->delete_records('rcommon_user_credentials', array('id' => $cred->id)); } $lastcred = $cred; } } upgrade_plugin_savepoint(true, 2015051901, 'local', 'rcommon'); } return true; }