/** * Upgrade code for the recent activity block. * * @global moodle_database $DB * @param int $oldversion * @param object $block */ function xmldb_block_recent_activity_upgrade($oldversion, $block) { global $CFG, $DB; $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes if ($oldversion < 2014012000) { // Define table block_recent_activity to be created. $table = new xmldb_table('block_recent_activity'); // Adding fields to table block_recent_activity. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('cmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('action', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null); $table->add_field('modname', XMLDB_TYPE_CHAR, '20', null, null, null, null); // Adding keys to table block_recent_activity. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Adding indexes to table block_recent_activity. $table->add_index('coursetime', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'timecreated')); // Conditionally launch create table for block_recent_activity. if (!$dbman->table_exists($table)) { $dbman->create_table($table); // Insert dummy log record for each existing course to notify that their logs need to be migrated. $DB->execute('INSERT INTO {block_recent_activity} (timecreated, userid, courseid, cmid, action) ' . 'SELECT ?, 0, id, 0, 3 FROM {course}', array(time())); } // Recent_activity savepoint reached. upgrade_block_savepoint(true, 2014012000, 'recent_activity'); } // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Upgrade the block_rss_client database. * * @param int $oldversion The version number of the plugin that was installed. * @return boolean */ function xmldb_block_rss_client_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); if ($oldversion < 2015071700) { // Support for skipping RSS feeds for a while when they fail. $table = new xmldb_table('block_rss_client'); // How many seconds we are currently ignoring this RSS feed for (due to an error). $field = new xmldb_field('skiptime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'url'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // When to next update this RSS feed. $field = new xmldb_field('skipuntil', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'skiptime'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_block_savepoint(true, 2015071700, 'rss_client'); } // 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; }
function xmldb_block_rcommon_upgrade($oldversion) { global $DB, $OUTPUT; if ($oldversion < 2014070300) { $local_version = $DB->get_field('config_plugins', 'value', array('name' => 'version', 'plugin' => 'local_rcommon')); if (!$local_version) { //Local not installed try { $version = $DB->get_field('block', 'version', array('name' => 'rcommon')); } catch (Exception $e) { $version = false; } if (!$version) { $version = $DB->get_field('config_plugins', 'value', array('name' => 'version', 'plugin' => 'block_rcommon')); } if ($version) { $new_version = new StdClass(); $new_version->name = 'version'; $new_version->plugin = 'local_rcommon'; $new_version->value = $version; $DB->insert_record('config_plugins', $new_version); } } // Savepoint reached. upgrade_block_savepoint(true, 2014070300, 'rcommon'); } echo $OUTPUT->notification('Now you can uninstall block/rcommon by erasing the directory', 'notifysuccess'); return true; }
/** * This function is run when the plugin have to be updated * @global stdClass $CFG * @global moodle_database $DB * @param int $oldversion The older version of the plugin installed on the moodle * @return boolean True if the update passed successfully */ function xmldb_block_tts_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2012101800) { // Define table block_tts to be renamed to NEWNAMEGOESHERE $table = new xmldb_table('tts'); $table2 = new xmldb_table('tts_lexicon'); // Launch rename table for block_tts $dbman->rename_table($table, 'block_tts'); $dbman->rename_table($table2, 'block_tts_lexicon'); // tts savepoint reached upgrade_block_savepoint(true, 2012101800, 'tts'); } if ($oldversion < 2012102900) { // Correction on the wrong table name upgrade_block_savepoint(true, 2012102900, 'tts'); } if ($oldversion < 2012110500) { // Fixed language string issue upgrade_block_savepoint(true, 2012110500, 'tts'); } if ($oldversion < 2012121000) { //Update logo for Moodle 2.4 upgrade_block_savepoint(true, 2012121000, 'tts'); } if ($oldversion < 2012121400) { //Update capabilities for Moodle 2.4 upgrade_block_savepoint(true, 2012121400, 'tts'); } return true; }
/** * * @since 2.0 * @package blocks * @copyright 2011 Dustin Durand * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_block_roomscheduler_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); if ($oldversion < 2011150301) { $timenow = time(); $sysctx = get_context_instance(CONTEXT_SYSTEM); /// Fully setup the Elluminate Moderator role. if (!($mrole = $DB->get_record('role', array('shortname' => 'roomschedulermanager')))) { if ($rid = create_role(get_string('roomschedulermanager', 'block_roomscheduler'), 'roomschedulemanager', get_string('roomschedulermanagerdescription', 'block_roomscheduler'))) { $mrole = $DB->get_record('role', array('id' => $rid)); assign_capability('block/roomscheduler:manage', CAP_ALLOW, $mrole->id, $sysctx->id); set_role_contextlevels($mrole->id, array(CONTEXT_SYSTEM)); } else { $mrole = $DB->get_record('role', array('shortname' => 'roomschedulermanager')); set_role_contextlevels($mrole->id, array(CONTEXT_SYSTEM)); } } upgrade_block_savepoint(true, 2011150301, 'roomscheduler'); } if ($oldversion < 2011140315) { // Define field reservable to be added to roomscheduler_rooms $table = new xmldb_table('roomscheduler_rooms'); $field = new xmldb_field('reservable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'active'); // Conditionally launch add field reservable if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_block_savepoint(true, 2011140315, 'roomscheduler'); } return true; }
/** * * @param int $oldversion * @param object $block */ function xmldb_block_iomad_approve_access_upgrade($oldversion) { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); if ($oldversion < 2013061100) { // Define field companyid to be added to block_iomad_approve_access. $table = new xmldb_table('block_iomad_approve_access'); $field = new xmldb_field('companyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'userid'); // Conditionally launch add field companyid. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Iomad_approve_access savepoint reached. upgrade_block_savepoint(true, 2013061100, 'iomad_approve_access'); } if ($oldversion < 2013071000) { // Define field activityid to be added to block_iomad_approve_access. $table = new xmldb_table('block_iomad_approve_access'); $field = new xmldb_field('activityid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); // Conditionally launch add field activityid. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Iomad_approve_access savepoint reached. upgrade_block_savepoint(true, 2013071000, 'iomad_approve_access'); } return true; }
/** * * @param int $oldversion * @param object $block */ function xmldb_block_community_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2010042701) { /// Define table block_community to be created $table = new xmldb_table('block_community'); /// Adding fields to table block_community $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('coursename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('coursedescription', XMLDB_TYPE_TEXT, 'big', null, null, null, null); $table->add_field('courseurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); $table->add_field('imageurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); /// Adding keys to table block_community $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); /// Conditionally launch create table for block_community if (!$dbman->table_exists($table)) { $dbman->create_table($table); } /// community savepoint reached upgrade_block_savepoint(true, 2010042701, 'community'); } return true; }
/** * Upgrade code for the section links block. * * @global moodle_database $DB * @param int $oldversion * @param object $block */ function xmldb_block_section_links_upgrade($oldversion, $block) { global $DB; // 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 if ($oldversion < 2013012200.0) { // The section links block used to use its own crazy plugin name. // Here we are converting it to the proper component name. $oldplugin = 'blocks/section_links'; $newplugin = 'block_section_links'; // Use the proper API here... thats what we should be doing as it ensures any caches etc are cleared // along the way! // It may be quicker to just write an SQL statement but that would be reckless. $config = get_config($oldplugin); if (!empty($config)) { foreach ($config as $name => $value) { set_config($name, $value, $newplugin); unset_config($name, $oldplugin); } } // Main savepoint reached. upgrade_block_savepoint(true, 2013012200.0, 'section_links'); } // 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. return true; }
/** * * @param int $oldversion * @param object $block */ function xmldb_block_html_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2010071900) { $params = array(); $sql = "SELECT * FROM {block_instances} b WHERE b.blockname = :blockname"; $params['blockname'] = 'html'; $rs = $DB->get_recordset_sql($sql, $params); foreach ($rs as $record) { $config = unserialize(base64_decode($record->configdata)); if (!empty($config) && is_object($config)) { if (!empty($config->text) && is_array($config->text)) { // fix bad data $data = clone $config; $config->text = $data->text['text']; $config->format = $data->text['format']; $record->configdata = base64_encode(serialize($config)); $DB->update_record('block_instances', $record); } else { if (empty($config->format)) { // add format parameter to 1.9 $config->format = FORMAT_HTML; $record->configdata = base64_encode(serialize($config)); $DB->update_record('block_instances', $record); } } } } $rs->close(); /// html block savepoint reached upgrade_block_savepoint(true, 2010071900, 'html'); } return true; }
/** * Handles upgrading instances of this block. * * @param int $oldversion * @param object $block */ function xmldb_block_completionstatus_upgrade($oldversion, $block) { global $DB; // Moodle v2.4.0 release upgrade line // Put any upgrade step following this. if ($oldversion < 2012112901) { // Get the instances of this block. if ($blocks = $DB->get_records('block_instances', array('blockname' => 'completionstatus', 'pagetypepattern' => 'my-index'))) { // Loop through and remove them from the My Moodle page. foreach ($blocks as $block) { blocks_delete_instance($block); } } // Savepoint reached. upgrade_block_savepoint(true, 2012112901, 'completionstatus'); } // 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; }
/** * Upgrade the calendar_month block * @param int $oldversion * @param object $block */ function xmldb_block_calendar_month_upgrade($oldversion, $block) { global $DB; if ($oldversion < 2014062600) { // Add this block the default blocks on /my. $blockname = 'calendar_month'; // Do not try to add the block if we cannot find the default my_pages entry. // Private => 1 refers to MY_PAGE_PRIVATE. if ($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => 1))) { $page = new moodle_page(); $page->set_context(context_system::instance()); // Check to see if this block is already on the default /my page. $criteria = array('blockname' => $blockname, 'parentcontextid' => $page->context->id, 'pagetypepattern' => 'my-index', 'subpagepattern' => $systempage->id); if (!$DB->record_exists('block_instances', $criteria)) { // Add the block to the default /my. $page->blocks->add_region(BLOCK_POS_RIGHT); $page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index', $systempage->id); } } upgrade_block_savepoint(true, 2014062600, $blockname); } // 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; }
function xmldb_block_search_upgrade($oldversion) { global $CFG, $DB; require 'upgradelib.php'; $result = TRUE; $dbman = $DB->get_manager(); if ($oldversion < 2010101800) { // See MDL-24374 // Changing type of field docdate on table block_search_documents to int // Changing type of field updated on table block_search_documents to int $table = new xmldb_table('block_search_documents'); $field_docdate_new = new xmldb_field('docdate_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'docdate'); $field_updated_new = new xmldb_field('updated_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'updated'); $field_docdate_old = new xmldb_field('docdate'); $field_updated_old = new xmldb_field('updated'); // Conditionally launch add temporary fields if (!$dbman->field_exists($table, $field_docdate_new)) { $dbman->add_field($table, $field_docdate_new); } if (!$dbman->field_exists($table, $field_updated_new)) { $dbman->add_field($table, $field_updated_new); } $sql = "SELECT id, docdate, updated FROM {block_search_documents}"; $search_documents = $DB->get_records_sql($sql); if ($search_documents) { foreach ($search_documents as $sd) { $sd->docdate_new = convert_datetime_upgrade($sd->docdate); $sd->updated_new = convert_datetime_upgrade($sd->updated); $DB->update_record('block_search_documents', $sd); } } // Conditionally launch drop the old fields if ($dbman->field_exists($table, $field_docdate_old)) { $dbman->drop_field($table, $field_docdate_old); } if ($dbman->field_exists($table, $field_updated_old)) { $dbman->drop_field($table, $field_updated_old); } //rename the new fields to the original field names. $dbman->rename_field($table, $field_docdate_new, 'docdate'); $dbman->rename_field($table, $field_updated_new, 'updated'); // search savepoint reached upgrade_block_savepoint(true, 2010101800, 'search'); } if ($oldversion < 2010110900) { unset_config('block_search_text'); unset_config('block_search_button'); upgrade_block_savepoint(true, 2010110900, 'search'); } if ($oldversion < 2010111100) { // set block to hidden if global search is disabled. if ($CFG->enableglobalsearch != 1) { $DB->set_field('block', 'visible', 0, array('name' => 'search')); // Hide block } upgrade_block_savepoint(true, 2010111100, 'search'); } return $result; }
function xmldb_block_oppia_mobile_export_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); if ($oldversion < 2013111402) { // block savepoint reached upgrade_block_savepoint(true, 2013111402, 'oppia_mobile_export'); } if ($oldversion < 2014032100) { // Define table block_oppia_mobile_server to be created. $table = new xmldb_table('block_oppia_mobile_server'); // Adding fields to table block_oppia_mobile_server. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('servername', XMLDB_TYPE_CHAR, '50', null, null, null, ''); $table->add_field('url', XMLDB_TYPE_CHAR, '50', null, null, null, ''); $table->add_field('moodleuserid', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); $table->add_field('username', XMLDB_TYPE_CHAR, '50', null, null, null, ''); $table->add_field('apikey', XMLDB_TYPE_CHAR, '50', null, null, null, ''); $table->add_field('defaultserver', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); // Adding keys to table block_oppia_mobile_server. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_oppia_mobile_server. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Blocks savepoint reached. upgrade_plugin_savepoint(true, 2014032100, 'error', 'blocks'); } if ($oldversion < 2015021802) { // Changing type of field value on table block_oppia_mobile_config to text. $table = new xmldb_table('block_oppia_mobile_config'); $field = new xmldb_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name'); // Launch change of type for field value. $dbman->change_field_type($table, $field); // Blocks savepoint reached. upgrade_plugin_savepoint(true, 2015021802, 'error', 'blocks'); } if ($oldversion < 2016021500) { // Add the field serverid to table block_oppia_mobile_config $table = new xmldb_table('block_oppia_mobile_config'); if (!$dbman->field_exists($table, 'serverid')) { $field = new xmldb_field('serverid', XMLDB_TYPE_TEXT, null, null, null, null, null, 'value'); $dbman->add_field($table, $field); } // Blocks savepoint reached. upgrade_plugin_savepoint(true, 2016021500, 'error', 'blocks'); } if ($oldversion < 2016041301) { //Update the size for field value to support longer tag values $table = new xmldb_table('block_oppia_mobile_config'); $field = new xmldb_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name'); // Launch change of type for field value. $dbman->change_field_type($table, $field); // Blocks savepoint reached. upgrade_plugin_savepoint(true, 2016041301, 'error', 'blocks'); } return true; }
/** * This is the upgrade script for the project. * * @package block_nurs_navigation * @category block * @copyright 2012 Craig Jamieson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_block_nurs_navigation_upgrade($oldversion = 0) { global $DB; $dbman = $DB->get_manager(); $result = true; // June 17, 2013 version changed the way that contexts are stored in the files table. if ($oldversion < 2013061706) { $query = "SELECT * FROM {nurs_navigation} WHERE courseid <> 1"; $records = $DB->get_records_sql($query); $fs = get_file_storage(); foreach ($records as $record) { $coursecontext = context_course::instance($record->courseid); // Explicit check here since sometimes there are old nurs_navigation records that point to deleted courses. if (isset($coursecontext->id)) { $params = array($coursecontext->id, 'nurs_navigation'); $query = "SELECT * FROM {block_instances} WHERE parentcontextid = ? AND blockname = ?"; $block = $DB->get_record_sql($query, $params, IGNORE_MULTIPLE); $blockcontext = context_block::instance($block->id); // This can return multiple records because of how the multiple file terminator works. $filerecords = $DB->get_records('files', array('contextid' => $coursecontext->id, 'itemid' => $record->fileid)); foreach ($filerecords as $filerecord) { $filerecord->contextid = $blockcontext->id; // Path hash must be updated as well with a context change. $filerecord->pathnamehash = $fs->get_pathname_hash($filerecord->contextid, BNN_BLOCK_SAVE_COMPONENT, BNN_BLOCK_SAVE_AREA, $filerecord->itemid, $filerecord->filepath, $filerecord->filename); $DB->update_record('files', $filerecord); } } } } // Create the second table. if ($oldversion < 2012110200) { // Define table nurs_navigation_settings to be created. $table = new xmldb_table('nurs_navigation_settings'); // Adding fields to table nurs_navigation_settings. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('courseid', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null); $table->add_field('sectionname', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null); $table->add_field('disableicon', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null); $table->add_field('customlabel', XMLDB_TYPE_TEXT, 'big', null, null, null, null); // Adding keys to table nurs_navigation_settings. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for nurs_navigation_settings. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Define field disableicon to be dropped from nurs_navigation. $table = new xmldb_table('nurs_navigation'); $field = new xmldb_field('disableicon'); // Conditionally launch drop field courseid. if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } // Update savepoint. upgrade_block_savepoint(true, 2012110200, 'nurs_navigation'); } return $result; }
function xmldb_block_panopto_upgrade($oldversion = 0) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2014121502) { // Add db fields for servername and application key per course. if (isset($CFG->block_panopto_server_name)) { $oldservername = $CFG->block_panopto_server_name; } if (isset($CFG->block_panopto_application_key)) { $oldappkey = $CFG->block_panopto_application_key; } // Define field panopto_server to be added to block_panopto_foldermap. $table = new xmldb_table('block_panopto_foldermap'); $field = new xmldb_field('panopto_server', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'panopto_id'); // Conditionally launch add field panopto_server. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); if (isset($oldservername)) { $DB->set_field('block_panopto_foldermap', 'panopto_server', $oldservername, null); } } // Define field panopto_app_key to be added to block_panopto_foldermap. $table = new xmldb_table('block_panopto_foldermap'); $field = new xmldb_field('panopto_app_key', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'panopto_server'); // Conditionally launch add field panopto_app_key. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); if (isset($oldappkey)) { $DB->set_field('block_panopto_foldermap', 'panopto_app_key', $oldappkey, null); } } // Panopto savepoint reached. upgrade_block_savepoint(true, 2014121502, 'panopto'); } if ($oldversion < 2015012901) { // Define field publisher_mapping to be added to block_panopto_foldermap. $table = new xmldb_table('block_panopto_foldermap'); $field = new xmldb_field('publisher_mapping', XMLDB_TYPE_CHAR, '20', null, null, null, '1', 'panopto_app_key'); // Conditionally launch add field publisher_mapping. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Define field creator_mapping to be added to block_panopto_foldermap. $table = new xmldb_table('block_panopto_foldermap'); $field = new xmldb_field('creator_mapping', XMLDB_TYPE_CHAR, '20', null, null, null, '3,4', 'publisher_mapping'); // Conditionally launch add field creator_mapping. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Panopto savepoint reached. upgrade_block_savepoint(true, 2015012901, 'panopto'); } return true; }
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; }
function xmldb_block_taskchain_navigation_upgrade($oldversion = 0) { global $CFG, $DB; $result = true; $newversion = 2014051601; if ($oldversion < $newversion) { update_capabilities('block/taskchain_navigation'); upgrade_block_savepoint($result, "{$newversion}", 'taskchain_navigation'); } return $result; }
function xmldb_block_accessibility_upgrade($oldversion = 0) { global $CFG, $THEME, $DB; $dbman = $DB->get_manager(); $result = true; // And upgrade begins here. For each one, you'll need one // block of code similar to the next one. Please, delete // this comment lines once this file start handling proper // upgrade code. if ($result && $oldversion < 2009071000) { // Changing type of field fontsize on table accessibility to number $table = new XMLDBTable('accessibility'); $field = new XMLDBField('fontsize'); $field->setAttributes(XMLDB_TYPE_NUMBER, '4, 1', XMLDB_UNSIGNED, null, null, null, null, null, 'userid'); // Launch change of type for field fontsize $result = $result && $dbman->change_field_type($table, $field); upgrade_block_savepoint(true, 2009071000, 'accessibility'); } if ($result && $oldversion < 2009082500) { // Define field colourscheme to be added to accessibility $table = new xmldb_table('accessibility'); $field = new xmldb_field('colourscheme', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null, 'fontsize'); // Launch add field colourschemea if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_block_savepoint(true, 2009082500, 'accessibility'); } if ($oldversion < 2010121500) { // Define field autoload_atbar to be added to accessibility $table = new xmldb_table('accessibility'); $cs = new xmldb_field('colourscheme', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null, 'fontsize'); $field = new xmldb_field('autoload_atbar', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'colourscheme'); if (!$dbman->field_exists($table, $cs)) { $dbman->add_field($table, $cs); } // Conditionally launch add field autoload_atbar if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // accessibility savepoint reached upgrade_block_savepoint(true, 2010121500, 'accessibility'); } if ($oldversion < 2011122000) { // Define table accessibility to be renamed to block_accessibility $table = new xmldb_table('accessibility'); // Launch rename table for accessibility $dbman->rename_table($table, 'block_accessibility'); // accessibility savepoint reached upgrade_block_savepoint(true, 2011122000, 'accessibility'); } return $result; }
/** * Upgrades openveo block depending on actual version. * * For version older than 2016021500 : * Media ids generated by OpenVeo can contains characters, not only digits, thus the table field "videoid" needs to * store Strings and not Integers. * * @package block_openveo_videos * @copyright 2015, veo-labs <*****@*****.**> * @license TODO */ function xmldb_block_openveo_videos_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); /// Change the type of the field "videoid" from Integer to String if ($oldversion < 2016021500) { $table = new xmldb_table('block_openveo_videos'); $field = new xmldb_field('videoid', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null); $dbman->change_field_type($table, $field); upgrade_block_savepoint(true, 2016021500, 'openveo_videos'); } return true; }
function xmldb_block_my_books_upgrade($oldversion = 0) { global $CFG, $DB; if ($oldversion < 2014111100) { set_config('viewer_opening', $CFG->mybooks_viewer_opening, 'mybooks'); unset_config('mybooks_viewer_opening'); set_config('width', $CFG->mybooks_width, 'mybooks'); unset_config('mybooks_width'); set_config('height', $CFG->mybooks_height, 'mybooks'); unset_config('mybooks_height'); set_config('activity_opening', $CFG->mybooks_activity_opening, 'mybooks'); unset_config('mybooks_activity_opening'); set_config('scrollbars', $CFG->mybooks_scrollbars, 'mybooks'); unset_config('mybooks_scrollbars'); set_config('menubar', $CFG->mybooks_menubar, 'mybooks'); unset_config('mybooks_menubar'); set_config('toolbar', $CFG->mybooks_toolbar, 'mybooks'); unset_config('mybooks_toolbar'); set_config('status', $CFG->mybooks_status, 'mybooks'); unset_config('mybooks_status'); set_config('addkey', $CFG->mybooks_addkey, 'mybooks'); unset_config('mybooks_addkey'); unset_config('mybooks_directories'); unset_config('mybooks_resizable'); unset_config('mybooks_location'); upgrade_block_savepoint(true, 2014111100, 'my_books'); } if ($oldversion < 2015051900) { unset_config('resizable', 'mybooks'); unset_config('directories', 'mybooks'); unset_config('location', 'mybooks'); $DB->set_field('rcontent', 'frame', 0, array('course' => SITEID)); upgrade_block_savepoint(true, 2015051900, 'my_books'); } if ($oldversion < 2015111700) { unset_config('status', 'mybooks'); unset_config('toolbar', 'mybooks'); unset_config('menubar', 'mybooks'); unset_config('scrollbars', 'mybooks'); unset_config('activity_opening', 'mybooks'); unset_config('height', 'mybooks'); unset_config('width', 'mybooks'); $popupoptions = "scrollbars=1,menubar=0,toolbar=1,status=1,height=800,width=600"; $DB->set_field('rcontent', 'popup', 0, array('course' => SITEID)); $DB->set_field('rcontent', 'popup_options', $popupoptions, array('course' => SITEID)); $DB->set_field('rcontent', 'width', 800, array('course' => SITEID)); $DB->set_field('rcontent', 'height', 600, array('course' => SITEID)); upgrade_block_savepoint(true, 2015111700, 'my_books'); } return true; }
function xmldb_block_navbuttons_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); if ($oldversion < 2012070202) { // Define table navbuttons to be created $table = new xmldb_table('navbuttons'); // Adding fields to table navbuttons $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('enabled', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('backgroundcolour', XMLDB_TYPE_CHAR, '20', null, null, null, '#6666cc'); $table->add_field('customusebackground', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('homebuttonshow', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('homebuttontype', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('firstbuttonshow', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('firstbuttontype', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '2'); $table->add_field('prevbuttonshow', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('nextbuttonshow', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('lastbuttonshow', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('lastbuttontype', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '2'); $table->add_field('extra1show', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('extra1link', XMLDB_TYPE_TEXT, 'medium', null, null, null, null); $table->add_field('extra1title', XMLDB_TYPE_TEXT, 'small', null, null, null, null); $table->add_field('extra1openin', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); $table->add_field('extra2show', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('extra2link', XMLDB_TYPE_TEXT, 'medium', null, null, null, null); $table->add_field('extra2title', XMLDB_TYPE_TEXT, 'small', null, null, null, null); $table->add_field('extra2openin', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1'); // Adding keys to table navbuttons $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for navbuttons if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // navbuttons savepoint reached upgrade_block_savepoint(true, 2012070202, 'navbuttons'); } if ($oldversion < 2014070601) { // Define field buttonstype to be added to navbuttons. $table = new xmldb_table('navbuttons'); $field = new xmldb_field('buttonstype', XMLDB_TYPE_CHAR, '6', null, XMLDB_NOTNULL, null, 'icon', 'enabled'); // Conditionally launch add field buttonstype. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Navbuttons savepoint reached. upgrade_block_savepoint(true, 2014070601, 'navbuttons'); } return true; }
/** * Upgrade code for the section links block. * * @param int $oldversion * @return bool */ function xmldb_block_filtered_course_list_upgrade($oldversion) { // 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. if ($oldversion < 2014010601) { $oldfiltertype = get_config('moodle', 'block_filtered_course_list/filtertype'); if ($oldfiltertype == 'term') { set_config('block_filtered_course_list/filtertype', 'shortname'); } $oldtermcurrent = get_config('moodle', 'block_filtered_course_list_termcurrent'); if (!empty($oldtermcurrent)) { set_config('block_filtered_course_list_currentshortname', $oldtermcurrent); unset_config('block_filtered_course_list_termcurrent'); } $oldtermfuture = get_config('moodle', 'block_filtered_course_list_termfuture'); if (!empty($oldtermfuture)) { set_config('block_filtered_course_list_futureshortname', $oldtermfuture); unset_config('block_filtered_course_list_termfuture'); } // Main savepoint reached. upgrade_block_savepoint(true, 2014010601, 'filtered_course_list'); } // Moodle v2.6.0 release upgrade line. // Put any upgrade step following this. if ($oldversion < 2015102002) { $fclsettings = array('filtertype', 'hideallcourseslink', 'hidefromguests', 'hideothercourses', 'useregex', 'currentshortname', 'currentexpanded', 'futureshortname', 'futureexpanded', 'labelscount', 'categories', 'adminview', 'maxallcourse', 'collapsible'); $customrubrics = array('customlabel', 'customshortname', 'labelexpanded'); foreach ($fclsettings as $name) { $value = get_config('moodle', 'block_filtered_course_list_' . $name); set_config($name, $value, 'block_filtered_course_list'); unset_config('block_filtered_course_list_' . $name); } for ($i = 1; $i <= 10; $i++) { foreach ($customrubrics as $setting) { $name = $setting . $i; $value = get_config('moodle', 'block_filtered_course_list_' . $name); if (!empty($value)) { set_config($name, $value, 'block_filtered_course_list'); unset_config('block_filtered_course_list_' . $name); } } } // Main savepoint reached. upgrade_block_savepoint(true, 2015102002, 'filtered_course_list'); } return true; }
function xmldb_local_iomad_settings_upgrade($oldversion) { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); if ($oldversion < 2011110201) { // Define fields to be added to certificate. $table = new xmldb_table('certificate'); $field = new xmldb_field('serialnumberformat', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'timemodified'); // Conditionally launch add field. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $field = new xmldb_field('reset_sequence', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, 'serialnumberformat'); // Conditionally launch add field. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $field = new xmldb_field('customtext2', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'reset_sequence'); // Conditionally launch add field. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $field = new xmldb_field('customtext3', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'customtext2'); // Conditionally launch add field. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Iomad savepoint reached. upgrade_block_savepoint(true, 2011110201, 'iomad_settings'); } if ($oldversion < 2011110300) { $table = new xmldb_table('certificate_serialnumber'); $index = new xmldb_index('certificate_year_sequenceno_unique', XMLDB_INDEX_UNIQUE, array('certificateid', 'year', 'sequenceno')); if ($dbman->index_exists($table, $index)) { $dbman->drop_index($table, $index); } if ($dbman->field_exists($table, 'year')) { $field = new xmldb_field('year', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'timecreated'); $dbman->rename_field($table, $field, 'sequence'); } $field = new xmldb_field('sequence', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'timecreated'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } else { $dbman->change_field_precision($table, $field); } $index = new xmldb_index('certificate_sequence_sequenceno_unique', XMLDB_INDEX_UNIQUE, array('certificateid', 'sequence', 'sequenceno')); } return $result; }
/** * As of the implementation of this block and the general navigation code * in Moodle 2.0 the body of immediate upgrade work for this block and * settings is done in core upgrade {@see lib/db/upgrade.php} * * There were several reasons that they were put there and not here, both becuase * the process for the two blocks was very similar and because the upgrade process * was complex due to us wanting to remvoe the outmoded blocks that this * block was going to replace. * * @global moodle_database $DB * @param int $oldversion * @param object $block */ function xmldb_block_settings_upgrade($oldversion, $block) { global $DB; // Implemented at 2009082800 if ($oldversion < 2010091400) { $sql = "SELECT bp.id FROM {block_instances} bi\n LEFT JOIN {block_positions} bp ON bp.blockinstanceid=bi.id\n WHERE bi.blockname='settings' AND bp.visible=0"; $blockpositions = $DB->get_records_sql($sql); if ($blockpositions) { foreach ($blockpositions as $bp) { $bp->visible = 1; $DB->update_record('block_positions', $bp); } } upgrade_block_savepoint(true, 2010091400, 'settings'); } return true; }
/** * Handles upgrading instances of this block. * * @param int $oldversion * @param object $block */ function xmldb_block_spedcompletion_upgrade($oldversion, $block) { global $DB; // 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 < 2014090900) { // Savepoint reached. upgrade_block_savepoint(true, 2014090900, 'spedcompletion'); } if ($oldversion < 2014100700) { $dbman = $DB->get_manager(); $index = new xmldb_index('completionsent', XMLDB_INDEX_NOTUNIQUE, array('completionsent')); $table = new xmldb_table('spedcompletion'); // Conditionally launch drop index completionsent. if ($dbman->index_exists($table, $index)) { $dbman->drop_index($table, $index); } // Define field completionsent to be dropped from spedcompletion. $field = new xmldb_field('completionsent'); // Conditionally launch drop field completionsent. if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } $field = new xmldb_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'userid'); // Launch rename field courseid. $dbman->rename_field($table, $field, 'course'); $index = new xmldb_index('course', XMLDB_INDEX_NOTUNIQUE, array('course')); // Conditionally launch add index completionsent. if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } $index = new xmldb_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid')); // Conditionally launch add index completionsent. if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } // Savepoint reached. upgrade_block_savepoint(true, 2014100700, 'spedcompletion'); } return true; }
/** * Version details * * @package block * @subpackage block_my_enrolled_courses * @copyright Dualcube (http://dualcube.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_block_my_enrolled_courses_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2014102202) { $table = new xmldb_table('block_myenrolledcoursesorder'); $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('courseorder', XMLDB_TYPE_TEXT, 'long', null, XMLDB_NOTNULL, null, null); $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid')); if (!$dbman->table_exists($table)) { $dbman->create_table($table); } upgrade_block_savepoint(true, 2014102202, 'my_enrolled_courses'); } return true; }
function xmldb_block_course_message_upgrade($oldversion = 0) { global $DB; $dbman = $DB->get_manager(); $result = true; // July 7, 2014 version added the carbon copy field. if ($oldversion < 2014070700) { $table = new xmldb_table('course_message_mails'); $field = new xmldb_field('carboncopy', XMLDB_TYPE_TEXT, 'big', null, null, null, 'attachment'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Force cache purge. purge_all_caches(); // Update savepoint. upgrade_block_savepoint(true, 2014062600, 'course_message'); } return $result; }
/** * As of the implementation of this block and the general navigation code * in Moodle 2.0 the body of immediate upgrade work for this block and * settings is done in core upgrade {@see lib/db/upgrade.php} * * There were several reasons that they were put there and not here, both becuase * the process for the two blocks was very similar and because the upgrade process * was complex due to us wanting to remvoe the outmoded blocks that this * block was going to replace. * * @global moodle_database $DB * @param int $oldversion * @param object $block */ function xmldb_block_navigation_upgrade($oldversion, $block) { global $DB; // Implemented at 2009082800 if ($oldversion < 2010091400) { $sql = "SELECT bp.id FROM {block_instances} bi \n LEFT JOIN {block_positions} bp ON bp.blockinstanceid=bi.id\n WHERE bi.blockname='navigation' AND bp.visible=0"; $blockpositions = $DB->get_records_sql($sql); if ($blockpositions) { foreach ($blockpositions as $bp) { $bp->visible = 1; $DB->update_record('block_positions', $bp); } } upgrade_block_savepoint(true, 2010091400, 'navigation'); } // Moodle v2.1.0 release upgrade line // Put any upgrade step following this return true; }
/** * Upgrade the badges block * @param int $oldversion * @param object $block */ function xmldb_block_badges_upgrade($oldversion, $block) { global $DB; if ($oldversion < 2014062600) { // Add this block the default blocks on /my. $blockname = 'badges'; $page = new moodle_page(); $page->set_context(context_system::instance()); // Check to see if this block is already on the default /my page. $criteria = array('blockname' => $blockname, 'parentcontextid' => $page->context->id, 'pagetypepattern' => 'my-index'); if (!$DB->record_exists('block_instances', $criteria)) { // Add the block to the default /my. $page->blocks->add_region(BLOCK_POS_RIGHT); $page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index'); } upgrade_block_savepoint(true, 2014062600, $blockname); } return true; }
/** * * @param int $oldversion * @param object $block */ function xmldb_block_iomad_company_admin_upgrade($oldversion) { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); if ($oldversion < 2014041200) { // Check if there is an instance of the company select block on the dashboard. if ($DB->get_record('block_instances', array('blockname' => 'iomad_company_selector', 'pagetypepattern' => 'local-iomad-dashboard-index'))) { $DB->delete_records('block_instances', array('blockname' => 'iomad_company_selector', 'pagetypepattern' => 'local-iomad-dashboard-index')); } // Iomad_company_admin savepoint reached. upgrade_block_savepoint(true, 2014041200, 'iomad_company_admin'); } // add new role capability if ($oldversion < 2014041201) { $systemcontext = context_system::instance(); $clientadministrator = $DB->get_record('role', array('shortname' => 'clientadministrator'), '*', MUST_EXIST); assign_capability('block/iomad_company_admin:restrict_capabilities', CAP_ALLOW, $clientadministrator->id, $systemcontext->id); } return true; }