/** * xmldb_lti_upgrade is the function that upgrades * the lti module database when is needed * * This function is automaticly called when version number in * version.php changes. * * @param int $oldversion New old version number. * * @return boolean */ function xmldb_lti_upgrade($oldversion) { global $CFG, $DB; $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 // 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. if ($oldversion < 2014060201) { // Changing type of field grade on table lti to int. $table = new xmldb_table('lti'); $field = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '100', 'instructorchoiceacceptgrades'); // Launch change of type for field grade. $dbman->change_field_type($table, $field); // Lti savepoint reached. upgrade_mod_savepoint(true, 2014060201, 'lti'); } return true; }
/** * xmldb_scormcloud_upgrade * * @param int $oldversion * @return bool */ function xmldb_scormcloud_upgrade($oldversion) { global $DB; global $CFG; $dbman = $DB->get_manager(); $module = new stdClass(); require $CFG->dirroot . '/mod/scormcloud/version.php'; $result = true; if ($result && $oldversion < 2011100700) { $table = new xmldb_table('scormcloud'); $field = new xmldb_field('cloudid', XMLDB_TYPE_CHAR, '255', null, 'XMLDB_NULL', null, null, 'id'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $rs = $DB->get_recordset('scormcloud'); foreach ($rs as $record) { if (!isset($record->cloudid) || empty($record->cloudid)) { $record->cloudid = $record->id; $DB->update_record('scormcloud', $record, true); } } $rs->close(); $field->setNotNull(); $dbman->change_field_notnull($table, $field); } upgrade_mod_savepoint($result, $module->version, 'scormcloud'); return $result; }
function xmldb_trainingevent_upgrade($oldversion) { global $CFG, $DB; $result = true; $dbman = $DB->get_manager(); if ($oldversion < 2011111701) { // Define table trainingevent_users to be created. $table = new xmldb_table('trainingevent_users'); // Adding fields to table trainingevent_users. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('userid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); $table->add_field('trainingeventid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null); // Adding keys to table trainingevent_users. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for trainingevent_users. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Label savepoint reached. upgrade_mod_savepoint(true, 2011111701, 'trainingevent'); } if ($oldversion < 2014012301) { // Define field approvaltype to be added to trainingevent. $table = new xmldb_table('trainingevent'); $field = new xmldb_field('approvaltype', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'classroomid'); // Conditionally launch add field approvaltype. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Trainingevent savepoint reached. upgrade_mod_savepoint(true, 2014012301, 'trainingevent'); } return $result; }
function xmldb_survey_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); //===== 1.9.0 upgrade line ======// if ($oldversion < 2009042002) { /// Define field introformat to be added to survey $table = new xmldb_table('survey'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro'); /// Conditionally launch add field introformat if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // conditionally migrate to html format in intro if ($CFG->texteditors !== 'textarea') { $rs = $DB->get_recordset('survey', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat'); foreach ($rs as $s) { $s->intro = text_to_html($s->intro, false, false, true); $s->introformat = FORMAT_HTML; $DB->update_record('survey', $s); upgrade_set_timeout(); } $rs->close(); } /// survey savepoint reached upgrade_mod_savepoint(true, 2009042002, 'survey'); } return true; }
function xmldb_choice_upgrade($oldversion) { global $CFG, $DB; $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 // 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. if ($oldversion < 2014051201) { // Define field allowmultiple to be added to choice. $table = new xmldb_table('choice'); $field = new xmldb_field('allowmultiple', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'allowupdate'); // Conditionally launch add field allowmultiple. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Choice savepoint reached. upgrade_mod_savepoint(true, 2014051201, 'choice'); } // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. return true; }
/** * Performs upgrade of the database structure and data * * Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade, * there are significant database changes. * * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_workshop_upgrade($oldversion) { global $CFG, $DB; // 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. $dbman = $DB->get_manager(); if ($oldversion < 2016022200) { // Add field submissionfiletypes to the table workshop. $table = new xmldb_table('workshop'); $field = new xmldb_field('submissionfiletypes', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'nattachments'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Add field overallfeedbackfiletypes to the table workshop. $field = new xmldb_field('overallfeedbackfiletypes', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'overallfeedbackfiles'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_mod_savepoint(true, 2016022200, 'workshop'); } // Moodle v3.1.0 release upgrade line. // Put any upgrade step following this. return true; }
function xmldb_choicegroup_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2013070900) { if ($oldversion < 2012042500) { /// remove the no longer needed choicegroup_answers DB table $choicegroup_answers = new xmldb_table('choicegroup_answers'); $dbman->drop_table($choicegroup_answers); /// change the choicegroup_options.text (text) field as choicegroup_options.groupid (int) $choicegroup_options = new xmldb_table('choicegroup_options'); $field_text = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'choicegroupid'); $field_groupid = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'choicegroupid'); $dbman->rename_field($choicegroup_options, $field_text, 'groupid'); $dbman->change_field_type($choicegroup_options, $field_groupid); } // Define table choicegroup to be created $table = new xmldb_table('choicegroup'); // Adding fields to table choicegroup $newField = $table->add_field('multipleenrollmentspossible', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0'); $dbman->add_field($table, $newField); upgrade_mod_savepoint(true, 2013070900, 'choicegroup'); } if ($oldversion < 2015022301) { $table = new xmldb_table('choicegroup'); // Adding field to table choicegroup $newField = $table->add_field('sortgroupsby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); if (!$dbman->field_exists($table, $newField)) { $dbman->add_field($table, $newField); } upgrade_mod_savepoint(true, 2015022301, 'choicegroup'); } return true; }
function xmldb_survey_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. // 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. if ($oldversion < 2016061400) { // Define field completionsubmit to be added to survey. $table = new xmldb_table('survey'); $field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'questions'); // Conditionally launch add field completionsubmit. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Survey savepoint reached. upgrade_mod_savepoint(true, 2016061400, 'survey'); } return true; }
function xmldb_label_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); $result = true; //===== 1.9.0 upgrade line ======// if ($oldversion < 2007101510) { $sql = "UPDATE {log_display} SET mtable = 'label' WHERE module = 'label'"; $result = $DB->execute($sql); upgrade_mod_savepoint($result, 2007101510, 'label'); } if ($result && $oldversion < 2009042200) { /// Rename field content on table label to intro $table = new xmldb_table('label'); $field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name'); /// Launch rename field content $dbman->rename_field($table, $field, 'intro'); /// label savepoint reached upgrade_mod_savepoint($result, 2009042200, 'label'); } if ($result && $oldversion < 2009042201) { /// Define field introformat to be added to label $table = new xmldb_table('label'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '4', 'intro'); /// Launch add field introformat $dbman->add_field($table, $field); /// label savepoint reached upgrade_mod_savepoint($result, 2009042201, 'label'); } return $result; }
function xmldb_label_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); //===== 1.9.0 upgrade line ======// if ($oldversion < 2009042200) { /// Rename field content on table label to intro $table = new xmldb_table('label'); $field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name'); /// Launch rename field content $dbman->rename_field($table, $field, 'intro'); /// label savepoint reached upgrade_mod_savepoint(true, 2009042200, 'label'); } if ($oldversion < 2009042201) { /// Define field introformat to be added to label $table = new xmldb_table('label'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '0', 'intro'); /// Launch add field introformat $dbman->add_field($table, $field); // all existing lables in 1.9 are in HTML format $DB->set_field('label', 'introformat', FORMAT_HTML, array()); /// label savepoint reached upgrade_mod_savepoint(true, 2009042201, 'label'); } // Moodle v2.1.0 release upgrade line // Put any upgrade step following this return true; }
function xmldb_glossary_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. if ($oldversion < 2015060200) { // Define field showtabs to be added to glossary_formats. $table = new xmldb_table('glossary_formats'); $field = new xmldb_field('showtabs', XMLDB_TYPE_CHAR, '100', null, null, null, null, 'showgroup'); // Conditionally launch add field showtabs. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Glossary savepoint reached. upgrade_mod_savepoint(true, 2015060200, 'glossary'); } // 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_assignment_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) { // Fixed/updated numfiles field in assignment_submissions table to count the actual // number of files has been uploaded when sendformarking is disabled upgrade_set_timeout(600); // increase excution time for in large sites $fs = get_file_storage(); // Fetch the moduleid for use in the course_modules table $moduleid = $DB->get_field('modules', 'id', array('name' => 'assignment'), MUST_EXIST); $selectcount = 'SELECT COUNT(s.id) '; $select = 'SELECT s.id, cm.id AS cmid '; $query = 'FROM {assignment_submissions} s JOIN {assignment} a ON a.id = s.assignment JOIN {course_modules} cm ON a.id = cm.instance AND cm.module = :moduleid WHERE assignmenttype = :assignmenttype'; $params = array('moduleid' => $moduleid, 'assignmenttype' => 'upload'); $countsubmissions = $DB->count_records_sql($selectcount.$query, $params); $submissions = $DB->get_recordset_sql($select.$query, $params); $pbar = new progress_bar('assignmentupgradenumfiles', 500, true); $i = 0; foreach ($submissions as $sub) { $i++; if ($context = context_module::instance($sub->cmid)) { $sub->numfiles = count($fs->get_area_files($context->id, 'mod_assignment', 'submission', $sub->id, 'sortorder', false)); $DB->update_record('assignment_submissions', $sub); } $pbar->update($i, $countsubmissions, "Counting files of submissions ($i/$countsubmissions)"); } $submissions->close(); // assignment savepoint reached upgrade_mod_savepoint(true, 2012061701, 'assignment'); } // 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; }
function xmldb_mediaboard_upgrade($oldversion = 0) { global $CFG, $THEME, $DB; $result = true; $dbman = $DB->get_manager(); if ($oldversion < 2015030200) { // Define table assign_user_mapping to be created. $table = new xmldb_table('mediaboard_likes'); // Adding fields to table assign_user_mapping. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('instance', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); $table->add_field('fileid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); $table->add_field('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); // Adding keys to table assign_user_mapping. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); $table->add_key('user', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); // Conditionally launch create table for assign_user_mapping. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Assign savepoint reached. upgrade_mod_savepoint(true, 2015030200, 'mediaboard'); } return $result; }
/** * Execute recordingsbn upgrade from the given old version * * @param int $oldversion * @return bool */ function xmldb_recordingsbn_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes if ($oldversion < 2012040200) { // Define field intro to be droped from recordingsbn $table = new xmldb_table('recordingsbn'); $field = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'name'); // Drop field intro if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field, $continue = true, $feedback = true); } // Define field introformat to be droped from recordingsbn $table = new xmldb_table('recordingsbn'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro'); // Add field introformat if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field, $continue = true, $feedback = true); } // Once we reach this point, we can store the new version and consider the module // upgraded to the version 2012040200 so the next time this block is skipped upgrade_mod_savepoint(true, 2012040200, 'recordingsbn'); } // Final return of upgrade result (true, all went good) to Moodle. return true; }
function xmldb_glossary_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 < 2012022000) { // Define field approvaldisplayformat to be added to glossary $table = new xmldb_table('glossary'); $field = new xmldb_field('approvaldisplayformat', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'default', 'defaultapproval'); // Conditionally launch add field approvaldisplayformat if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // glossary savepoint reached upgrade_mod_savepoint(true, 2012022000, 'glossary'); } // 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. return true; }
function xmldb_opencast_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2013120100) { // Define fields to be added to table opencast $table = new xmldb_table('opencast'); $field1 = new xmldb_field('userupload', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'inviting'); $field2 = new xmldb_field('userupload_maxfilesize', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'userupload'); // Conditionally launch add fields if (!$dbman->field_exists($table, $field1)) { $dbman->add_field($table, $field1); } if (!$dbman->field_exists($table, $field2)) { $dbman->add_field($table, $field2); } upgrade_mod_savepoint(true, 2013120100, 'mod', 'opencast'); } if ($oldversion < 2013121600) { $table2 = new xmldb_table('opencast_uploadedclip'); if (!$dbman->table_exists($table2)) { $dbman->install_one_table_from_xmldb_file($CFG->dirroot . '/mod/opencast/db/install.xml', 'opencast_uploadedclip'); } upgrade_mod_savepoint(true, 2013121600, 'mod', 'opencast'); } if ($oldversion < 2015070100) { // Define table matrix to be created $table = new xmldb_table('opencast'); // Adding fields to table matrix $newField = $table->add_field('allow_annotations', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1'); $dbman->add_field($table, $newField); upgrade_plugin_savepoint(true, 2015070100, 'mod', 'opencast'); } return true; }
function xmldb_customlabel_upgrade($oldversion = 0) { global $CFG, $THEME, $DB; $result = true; $dbman = $DB->get_manager(); //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2012062401) { // Define field fallbacktype to be added to customlabel. $table = new xmldb_table('customlabel'); $field = new xmldb_field('fallbacktype'); $field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'labelclass'); // Launch add field parent. $result = $result || $dbman->add_field($table, $field); // customlabel savepoint reached. upgrade_mod_savepoint($result, 2012062401, 'customlabel'); } if ($result && $oldversion < 2013041802) { // Regenerates all contents to match template changes. $sql = "\n SELECT DISTINCT\n c.id,\n c.shortname,\n c.fullname,\n c.idnumber,\n c.summary,\n c.category,\n c.summaryformat\n FROM\n {course} c,\n {course_modules} cm,\n {modules} m\n WHERE\n c.id = cm.course AND\n cm.module = m.id AND\n m.name = 'customlabel'\n "; $courses = $DB->get_records_sql($sql); if ($courses) { echo '<pre>'; foreach ($courses as $c) { customlabel_course_preprocess_filepickers($c); customlabel_course_regenerate($c, 'all'); } echo '</pre>'; } upgrade_mod_savepoint($result, 2013041802, 'customlabel'); } return $result; }
function xmldb_openmeetings_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); $result = true; if ($oldversion < 20111001) { // Define field allow_recording to be added to openmeetings $table = new xmldb_table('openmeetings'); $field = new xmldb_field('allow_recording', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'room_recording_id'); // Conditionally launch add field allow_recording if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // openmeetings savepoint reached upgrade_mod_savepoint(true, 20111001, 'openmeetings'); } if ($oldversion < 20111002) { // Define field introformat to be dropped from openmeetings $table = new xmldb_table('openmeetings'); $field = new xmldb_field('introformat'); // Conditionally launch drop field introformat if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } // openmeetings savepoint reached upgrade_mod_savepoint(true, 20111002, 'openmeetings'); } if ($oldversion == 20111002) { //$result = false; //nothing to upgrade here } return $result; }
function xmldb_label_upgrade($oldversion) { global $CFG, $DB; $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 // Moodle v2.4.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2013021400) { // find all courses that contain labels and reset their cache $modid = $DB->get_field_sql("SELECT id FROM {modules} WHERE name=?", array('label')); if ($modid) { $courses = $DB->get_fieldset_sql('SELECT DISTINCT course ' . 'FROM {course_modules} WHERE module=?', array($modid)); foreach ($courses as $courseid) { rebuild_course_cache($courseid, true); } } // label savepoint reached upgrade_mod_savepoint(true, 2013021400, 'label'); } // 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; }
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 < 2014072200) { // 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_mod_savepoint(true, 2014072200, 'enrolmentreminder'); } return true; }
/** * xmldb_pcast_upgrade * * @param int $oldversion * @return bool */ function xmldb_pcast_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $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 < YYYYMMDD00) { //New version in version.php /// $result = result of "/lib/ddllib.php" function calls /// } /// RatingArea Upgrade if ($oldversion < 2011080700) { // rating.component and rating.ratingarea have now been added as mandatory fields. // Presently you can only rate data entries so component = 'mod_pcast' and ratingarea = 'episode' // for all ratings with a pcast context. // We want to update all ratings that belong to a glossary context and don't already have a // component set. // This could take a while reset upgrade timeout to 5 min upgrade_set_timeout(60 * 20); $sql = "UPDATE {rating}\n SET component = 'mod_pcast', ratingarea = 'episode'\n WHERE contextid IN (\n SELECT ctx.id\n FROM {context} ctx\n JOIN {course_modules} cm ON cm.id = ctx.instanceid\n JOIN {modules} m ON m.id = cm.module\n WHERE ctx.contextlevel = 70 AND\n m.name = 'pcast'\n ) AND component = 'unknown'"; $DB->execute($sql); upgrade_mod_savepoint(true, 2011080700, 'pcast'); } /// Final return of upgrade result (true/false) to Moodle. Must be /// always the last line in the script return true; }
/** * Book module upgrade task * * @param int $oldversion the version we are upgrading from * @return bool always true */ function xmldb_book_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. if ($oldversion < 2014111800) { // Define field navstyle to be added to book. $table = new xmldb_table('book'); $field = new xmldb_field('navstyle', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '1', 'numbering'); // Conditionally launch add field navstyle. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Book savepoint reached. upgrade_mod_savepoint(true, 2014111800, 'book'); } // 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; }
/** * @global moodle_database $DB * @param int $oldversion * @return bool */ function xmldb_scorm_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.2.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2012032100) { unset_config('updatetime', 'scorm'); upgrade_mod_savepoint(true, 2012032100, 'scorm'); } // Adding completion fields to scorm table if ($oldversion < 2012032101) { $table = new xmldb_table('scorm'); $field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } upgrade_mod_savepoint(true, 2012032101, 'scorm'); } return true; }
function xmldb_lesson_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); $result = true; //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2007072201) { $table = new xmldb_table('lesson'); $field = new xmldb_field('usegrademax'); $field2 = new xmldb_field('usemaxgrade'); /// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177 if ($dbman->field_exists($table, $field) && !$dbman->field_exists($table, $field2)) { /// Set field specs $field->set_attributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'ongoing'); /// Launch rename field usegrademax to usemaxgrade $dbman->rename_field($table, $field, 'usemaxgrade'); } upgrade_mod_savepoint($result, 2007072201, 'lesson'); } if ($result && $oldversion < 2008112601) { require_once $CFG->dirroot . '/mod/lesson/lib.php'; lesson_upgrade_grades(); upgrade_mod_savepoint($result, 2008112601, 'lesson'); } return $result; }
function xmldb_folder_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. // 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. // Add showdownloadfolder option. if ($oldversion < 2016020201) { $table = new xmldb_table('folder'); $field = new xmldb_field('showdownloadfolder', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'showexpanded'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field, 'showdownloadfolder'); } upgrade_mod_savepoint(true, 2016020201, 'folder'); } // Moodle v3.1.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v3.2.0 release upgrade line. // Put any upgrade step following this. return true; }
function xmldb_resource_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); $result = true; //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2009042000) { /// Rename field summary on table resource to intro $table = new xmldb_table('resource'); $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'reference'); /// Launch rename field summary $dbman->rename_field($table, $field, 'intro'); /// resource savepoint reached upgrade_mod_savepoint($result, 2009042000, 'resource'); } if ($result && $oldversion < 2009042001) { /// Define field introformat to be added to resource $table = new xmldb_table('resource'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro'); /// Launch add field introformat $dbman->add_field($table, $field); /// set format to current $DB->set_field('resource', 'introformat', FORMAT_MOODLE, array()); /// resource savepoint reached upgrade_mod_savepoint($result, 2009042001, 'resource'); } return $result; }
function xmldb_choice_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); $result = true; //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2009042000) { /// Rename field text on table choice to NEWNAMEGOESHERE $table = new xmldb_table('choice'); $field = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name'); /// Launch rename field text $dbman->rename_field($table, $field, 'intro'); /// choice savepoint reached upgrade_mod_savepoint($result, 2009042000, 'choice'); } if ($result && $oldversion < 2009042001) { /// Rename field format on table choice to NEWNAMEGOESHERE $table = new xmldb_table('choice'); $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro'); /// Launch rename field format $dbman->rename_field($table, $field, 'introformat'); /// choice savepoint reached upgrade_mod_savepoint($result, 2009042001, 'choice'); } return $result; }
/** * Execute studyplan upgrade from the given old version * * @param int $oldversion * @return bool */ function xmldb_studyplan_upgrade($oldversion) { global $DB; $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes if ($oldversion < 2014071400) { // Change field 'name' column to default null $table = new xmldb_table('studyplan'); $field = new xmldb_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'quiz'); // apply the change if the field is here to fix if ($dbman->field_exists($table, $field)) { $dbman->change_field_type($table, $field); } upgrade_mod_savepoint(true, 2014071400, 'studyplan'); } if ($oldversion < 2014080700) { // Create the studyplan_progress table if (!$dbman->table_exists('studyplan_progress')) { $table = new xmldb_table('studyplan_progress'); $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('studyplan', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id'); $table->add_field('user', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'studyplan'); $table->add_field('percent', XMLDB_TYPE_NUMBER, '10,5', null, XMLDB_NOTNULL, null, '0', 'user'); $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'percent'); $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timecreated'); $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); $table->add_index('studyplan', XMLDB_INDEX_NOTUNIQUE, array('studyplan')); $table->add_index('user', XMLDB_INDEX_NOTUNIQUE, array('user')); $dbman->create_table($table); } upgrade_mod_savepoint(true, 2014080700, 'studyplan'); } return true; }
/** * Upgrade logic. * * Authors: * Fred Dixon (ffdixon [at] blindsidenetworks [dt] com) * Jesus Federico (jesus [at] blindsidenetworks [dt] com) * * @package mod_bigbluebuttonbn * @copyright 2010-2012 Blindside Networks * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later */ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) { global $CFG, $THEME, $DB; $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes $result = true; if ($result && $oldversion < 2012040200) { // Define field intro to be droped from bigbluebuttonbn $table = new xmldb_table('bigbluebuttonbn'); $field = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'name'); // Drop field intro if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field, $continue = true, $feedback = true); } // Define field introformat to be droped from bigbluebuttonbn $table = new xmldb_table('bigbluebuttonbn'); $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro'); // Drop field introformat if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field, $continue = true, $feedback = true); } // Once we reach this point, we can store the new version and consider the module // upgraded to the version 2012040200 so the next time this block is skipped upgrade_mod_savepoint(true, 2012040200, 'bigbluebuttonbn'); } return $result; }
function xmldb_url_upgrade($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.1.0 release upgrade line // Put any upgrade step following this if ($oldversion < 2011092800) { // Changing nullability of field externalurl on table urls to not-null $table = new xmldb_table('url'); $field = new xmldb_field('externalurl', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'introformat'); $DB->set_field_select('url', 'externalurl', $DB->sql_empty(), 'externalurl IS NULL'); // Launch change of nullability for field =externalurl $dbman->change_field_notnull($table, $field); // url savepoint reached upgrade_mod_savepoint(true, 2011092800, 'url'); } // Moodle v2.2.0 release upgrade line // Put any upgrade step following this return true; }