function xmldb_assignment_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2007072200) { require_once $CFG->dirroot . '/mod/assignment/lib.php'; // too much debug output $db->debug = false; assignment_update_grades(); $db->debug = true; } if ($result && $oldversion < 2007091900) { /// MDL-11268 /// Changing nullability of field data1 on table assignment_submissions to null $table = new XMLDBTable('assignment_submissions'); $field = new XMLDBField('data1'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'numfiles'); /// Launch change of nullability for field data1 $result = $result && change_field_notnull($table, $field); /// Changing nullability of field data2 on table assignment_submissions to null $field = new XMLDBField('data2'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'data1'); /// Launch change of nullability for field data2 $result = $result && change_field_notnull($table, $field); } return $result; }
function xmldb_ezproxy_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 < 2009042403) { /// Rebuild the course cache of every course which uses one of these modules in it to get /// the new link. if ($courseids = get_records_menu('ezproxy', '', '', 'course ASC', 'id, course')) { /// Just get the unique course ID values. $courseids = array_unique(array_values($courseids)); if (!empty($courseids)) { require_once $CFG->dirroot . '/course/lib.php'; foreach ($courseids as $courseid) { rebuild_course_cache($courseid); // Does not return a bool } } } } if ($result && $oldversion < 2009042404) { $table = new XMLDBTable('ezproxy'); $field = new XMLDBField('serverurl'); $field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, '', 'name'); $result = change_field_type($table, $field); } return $result; }
function xmldb_forum_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 /// } if ($result && $oldversion < 2007072200) { require_once $CFG->dirroot . '/mod/forum/lib.php'; // too much debug output $db->debug = false; forum_update_grades(); $db->debug = true; } if ($result && $oldversion < 2007101000) { /// Define field timemodified to be added to forum_queue $table = new XMLDBTable('forum_queue'); $field = new XMLDBField('timemodified'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'postid'); /// Launch add field timemodified $result = $result && add_field($table, $field); } return $result; }
function xmldb_groupselect_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2009020600) { /// Define field signuptype to be added to groupselect $table = new XMLDBTable('groupselect'); $field = new XMLDBField('signuptype'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'intro'); $result = $result && add_field($table, $field); /// Define field timecreated to be added to groupselect $table = new XMLDBTable('groupselect'); $field = new XMLDBField('timecreated'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timedue'); $result = $result && add_field($table, $field); } if ($result && $oldversion < 2009030500) { /// Define field targetgrouping to be added to groupselect $table = new XMLDBTable('groupselect'); $field = new XMLDBField('targetgrouping'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); $result = $result && add_field($table, $field); } return $result; }
function xmldb_qtype_dragdrop_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 /// } // Add a field so that question authors can choose in how many columns // the drag and drop media is arranged. if ($result && $oldversion < 2008060501) { $table = new XMLDBTable('question_dragdrop'); $field = new XMLDBField('arrangemedia'); $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'feedbackmissed'); $result = $result && add_field($table, $field); } // Add a field so that question authors can choose where to place the media // below or right beside the background. if ($result && $oldversion < 2008060502) { $table = new XMLDBTable('question_dragdrop'); $field = new XMLDBField('placemedia'); $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'arrangemedia'); $result = $result && add_field($table, $field); } return $result; }
function xmldb_assignment_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2007091900) { /// MDL-11268 /// Changing nullability of field data1 on table assignment_submissions to null $table = new XMLDBTable('assignment_submissions'); $field = new XMLDBField('data1'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'numfiles'); /// Launch change of nullability for field data1 $result = $result && change_field_notnull($table, $field); /// Changing nullability of field data2 on table assignment_submissions to null $field = new XMLDBField('data2'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'data1'); /// Launch change of nullability for field data2 $result = $result && change_field_notnull($table, $field); } if ($result && $oldversion < 2007091902) { // add draft tracking default to existing upload assignments $sql = "UPDATE {$CFG->prefix}assignment SET var4=1 WHERE assignmenttype='upload'"; $result = execute_sql($sql); } //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2007101511) { notify('Processing assignment grades, this may take a while if there are many assignments...', 'notifysuccess'); // change grade typo to text if no grades MDL-13920 require_once $CFG->dirroot . '/mod/assignment/lib.php'; // too much debug output $db->debug = false; assignment_update_grades(); $db->debug = true; } return $result; }
function xmldb_block_file_manager_upgrade($oldversion = 0) { /// This function does anything necessary to upgrade /// older versions to match current functionality $result = true; if ($result && $oldversion < 2008061700) { /// Define field ownertype to be added to fmanager_link $table = new XMLDBTable('fmanager_link'); $field = new XMLDBField('ownertype'); $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner'); /// Launch add field ownertype $result = $result && add_field($table, $field); /// Define field ownertype to be added to fmanager_categories $table = new XMLDBTable('fmanager_categories'); $field = new XMLDBField('ownertype'); $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner'); /// Launch add field ownertype $result = $result && add_field($table, $field); /// Define field ownertype to be added to fmanager_folders $table = new XMLDBTable('fmanager_folders'); $field = new XMLDBField('ownertype'); $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner'); /// Launch add field ownertype $result = $result && add_field($table, $field); /// Define field ownertype to be added to fmanager_shared $table = new XMLDBTable('fmanager_shared'); $field = new XMLDBField('ownertype'); $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'owner'); /// Launch add field ownertype $result = $result && add_field($table, $field); } return $result; }
function xmldb_ilpconcern_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; /// And upgrade begins here. For each one, you'll need one if ($result && $oldversion < 2008072501) { /// Define field courserelated to be added to ilptarget_posts $table = new XMLDBTable('ilpconcern_posts'); $field = new XMLDBField('courserelated'); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'course'); /// Launch add field courserelated $result = $result && add_field($table, $field); $field = new XMLDBField('targetcourse'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courserelated'); /// Launch add field targetcourse $result = $result && add_field($table, $field); } if ($result && $oldversion < 2008072200) { /// Define field course to be added to ilptarget_posts $table = new XMLDBTable('ilpconcern_status'); $field = new XMLDBField('modifiedbyuser'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'modified'); /// Launch add field course $result = $result && add_field($table, $field); } if ($result && $oldversion < 2008052800) { /// Define field course to be added to ilptarget_posts $table = new XMLDBTable('ilpconcern_posts'); $field = new XMLDBField('course'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'setbyuserid'); /// Launch add field course $result = $result && add_field($table, $field); } return $result; }
function xmldb_artefact_comment_upgrade($oldversion = 0) { $success = true; if ($oldversion < 2011011201) { $table = new XMLDBTable('artefact_comment_comment'); $field = new XMLDBField('rating'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED); $success = $success && add_field($table, $field); } if ($oldversion < 2013072400) { $table = new XMLDBTable('artefact_comment_comment'); $field = new XMLDBField('lastcontentupdate'); $field->setAttributes(XMLDB_TYPE_DATETIME); $success = $success && add_field($table, $field); $success = $success && execute_sql('update {artefact_comment_comment} acc set lastcontentupdate = ( select a.mtime from {artefact} a where a.id = acc.artefact )'); } if ($oldversion < 2015081000) { // Set default maxindent for threaded comments set_config_plugin('artefact', 'comment', 'maxindent', 5); } return $success; }
function xmldb_wwassignment_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 /// } //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2008092818) { //Define field grade to be added to wwassignment $table = new XMLDBTable('wwassignment'); $field = new XMLDBField('grade'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'webwork_set'); /// Launch add field grade $result = $result && add_field($table, $field); /// Define field timemodified to be added to wwassignment $table = new XMLDBTable('wwassignment'); $field = new XMLDBField('timemodified'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grade'); /// Launch add field timemodified to wwassignment_bridge $result = $result && add_field($table, $field); //notify('Processing assignment grades, this may take a while if there are many assignments...', 'notifysuccess'); // change grade typo to text if no grades MDL-13920 //require_once $CFG->dirroot.'/mod/wwassignment/lib.php'; // too much debug output //$db->debug = false; //wwassignment_update_grades(); //$db->debug = true; } return $result; }
function xmldb_block_accessibility_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 < 2009082500) { /// Define field colourscheme to be added to accessibility $table = new XMLDBTable('accessibility'); $field = new XMLDBField('colourscheme'); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null, 'fontsize'); /// Launch add field colourscheme $result = $result && add_field($table, $field); } 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 && change_field_type($table, $field); } return $result; }
function xmldb_artefact_resume_upgrade($oldversion = 0) { $status = true; if ($oldversion < 2009122100) { $table = new XMLDBTable('artefact_resume_employmenthistory'); $field = new XMLDBField('employeraddress'); $field->setAttributes(XMLDB_TYPE_TEXT); add_field($table, $field); $table = new XMLDBTable('artefact_resume_educationhistory'); $field = new XMLDBField('institutionaddress'); $field->setAttributes(XMLDB_TYPE_TEXT); add_field($table, $field); } if ($oldversion < 2010020300) { $table = new XMLDBTable('artefact_resume_educationhistory'); $field = new XMLDBField('qualtype'); $field->setAttributes(XMLDB_TYPE_TEXT); change_field_notnull($table, $field); $table = new XMLDBTable('artefact_resume_educationhistory'); $field = new XMLDBField('qualname'); $field->setAttributes(XMLDB_TYPE_TEXT); change_field_notnull($table, $field); } if ($oldversion < 2013071300) { $table = new XMLDBTable('artefact_resume_book'); $field = new XMLDBField('url'); $field->setAttributes(XMLDB_TYPE_TEXT); add_field($table, $field); } if ($oldversion < 2013072900) { execute_sql("UPDATE {blocktype_installed_category} SET category = 'internal' WHERE category = 'resume'"); } return $status; }
function xmldb_block_task_list_upgrade($oldversion = 0) { $result = true; if ($result and $oldversion < 2007011501) { /// Define field format to be added to block_task_list $table = new XMLDBTable('block_task_list'); $field = new XMLDBField('format'); $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'name'); /// Launch add field format $result = $result and add_field($table, $field); } if ($result and $oldversion < 2007011503) { /// Manually remove bad capabilities $result = $result and delete_records('capabilities', 'name', 'block/tast_list:manage'); $result = $result and delete_records('capabilities', 'name', 'block/tast_list:checkofftasks'); } if ($result and $oldversion < 2007011505) { //TODO: The info field might be able to be removed, as it doesn't seem to be used anywhere, but in the meantime, change it to allow nulls /// Changing nullability of field info on table block_task_list to allow null $table = new XMLDBTable('block_task_list'); $field = new XMLDBField('info'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'checked'); /// Launch change of nullability for field info $result = $result && change_field_notnull($table, $field); } return $result; }
function xmldb_ilptarget_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2008052906) { /// Define field name to be added to ilptarget_posts $table = new XMLDBTable('ilptarget_posts'); $field = new XMLDBField('name'); $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'data2'); /// Launch add field name $result = $result && add_field($table, $field); } if ($result && $oldversion < 2008052904) { /// Define field courserelated to be added to ilptarget_posts $table = new XMLDBTable('ilptarget_posts'); $field = new XMLDBField('courserelated'); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'course'); /// Launch add field courserelated $result = $result && add_field($table, $field); $field = new XMLDBField('targetcourse'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courserelated'); /// Launch add field targetcourse $result = $result && add_field($table, $field); } if ($result && $oldversion < 2008052902) { /// Define field course to be added to ilptarget_posts $table = new XMLDBTable('ilptarget_posts'); $field = new XMLDBField('course'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'setbyuserid'); /// Launch add field course $result = $result && add_field($table, $field); } return $result; }
/** * Database upgrade script for the custom SQL report. * * @package report_customsql * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_report_customsql_upgrade($oldversion = 0) { global $CFG, $db; $result = true; if ($result && $oldversion < 2009102802) { /// Define field runable to be added to report_customsql_queries $table = new XMLDBTable('report_customsql_queries'); $field = new XMLDBField('runable'); $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'manual', 'lastexecutiontime'); /// Launch add field runable $result = $result && add_field($table, $field); } if ($result && $oldversion < 2009102900) { /// Define field singlerow to be added to report_customsql_queries $table = new XMLDBTable('report_customsql_queries'); $field = new XMLDBField('singlerow'); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'runable'); /// Launch add field singlerow $result = $result && add_field($table, $field); } if ($result && $oldversion < 2009103000) { /// Changing the default of field lastrun on table report_customsql_queries to 0 $table = new XMLDBTable('report_customsql_queries'); $field = new XMLDBField('lastrun'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'capability'); /// Launch change of default for field lastrun $result = $result && change_field_default($table, $field); } return $result; }
function xmldb_block_student_gradeviewer_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2010070912) { /// Define field opt to be dropped from block_teacher_referral_opt $table = new XMLDBTable('block_teacher_referral_opt'); // First let's drop the index $index = new XMLDBIndex('bloc_tea_usesec_uix'); $index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'sectionsid')); $failing_field = new XMLDBField('failing'); $lagging_field = new XMLDBField('lagging'); $usersid_field = new XMLDBField('usersid'); /// Launch drop field opt $result = $result && drop_index($table, $index) && drop_field($table, $usersid_field) && drop_field($table, $lagging_field) && drop_field($table, $failing_field); // Add the following fields $fields = array('sectionsid', 'primary_instructor', 'non_primary_instructor', 'student', 'non_primary_control'); foreach (range(1, count($fields) - 1) as $index) { $field = new XMLDBField($fields[$index]); $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $fields[$index - 1]); $result = $result && add_field($table, $field); } $index = new XMLDBIndex('bloc_tea_usesec_uix'); $index->setAttributes(XMLDB_INDEX_UNIQUE, array('sectionsid')); $result = $result && add_index($table, $index); } return $result; }
function xmldb_search_elasticsearch_upgrade($oldversion = 0) { if ($oldversion < 2015012800) { // Adding indices on the table search_elasticsearch_queue $table = new XMLDBTable('search_elasticsearch_queue'); $index = new XMLDBIndex('itemidix'); $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('itemid')); add_index($table, $index); } if ($oldversion < 2015060900) { log_debug('Add "status" and "lastprocessed" columns to search_elasticsearch_queue table'); $table = new XMLDBTable('search_elasticsearch_queue'); $field = new XMLDBField('status'); $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, 0); add_field($table, $field); $table = new XMLDBTable('search_elasticsearch_queue'); $field = new XMLDBField('lastprocessed'); $field->setAttributes(XMLDB_TYPE_DATETIME); add_field($table, $field); $table = new XMLDBTable('search_elasticsearch_queue'); $index = new XMLDBIndex('statusix'); $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('status')); add_index($table, $index); } if ($oldversion < 2015072700) { log_debug('Adding ability to search by "Text" blocks in elasticsearch'); // Need to add the 'block_instance' to the default types to index for elasticsearch // Note: the $cfg->plugin_search_elasticsearch_types can be overriding this // We don't want to run the re-indexing now as that will take ages for large sites // It should be run from the Extensions -> Elasticsearch -> Configuration page if ($types = get_field('search_config', 'value', 'plugin', 'elasticsearch', 'field', 'types')) { $types = explode(',', $types); if (!in_array('block_instance', $types)) { $types[] = 'block_instance'; } $types = implode(',', $types); update_record('search_config', array('value' => $types), array('plugin' => 'elasticsearch', 'field' => 'types')); log_warn(get_string('newindextype', 'search.elasticsearch', 'block_instance'), true, false); } } if ($oldversion < 2015100800) { log_debug('Adding ability to search by collection in elasticsearch'); // The code for this existed since the beginning but 'collection' was not // added to the $cfg->plugin_search_elasticsearch_types // We don't want to run the re-indexing now as that will take ages for large sites // It should be run from the Extensions -> Elasticsearch -> Configuration page if ($types = get_field('search_config', 'value', 'plugin', 'elasticsearch', 'field', 'types')) { $types = explode(',', $types); if (!in_array('collection', $types)) { $types[] = 'collection'; } $types = implode(',', $types); update_record('search_config', array('value' => $types), array('plugin' => 'elasticsearch', 'field' => 'types')); log_warn(get_string('newindextype', 'search.elasticsearch', 'collection'), true, false); } } return true; }
function xmldb_hotquestion_upgrade($oldversion = 0) { global $CFG, $DB; $result = true; //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2007040100) { /// Define field course to be added to hotquestion $table = new XMLDBTable('hotquestion'); $field = new XMLDBField('course'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id'); /// Launch add field course $result = $result && $table->add_field($field); /// Define field intro to be added to hotquestion $field = new xmldb_field('intro'); $field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'name'); /// Launch add field intro $result = $result && $table->add_field($field); /// Define field introformat to be added to hotquestion $field = new xmldb_field('introformat'); $field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Launch add field introformat $result = $result && $table->add_field($field); } if ($result && $oldversion < 2007040101) { /// Define field timecreated to be added to hotquestion $table = new xmldb_table('hotquestion'); $field = new xmldb_field('timecreated'); $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'introformat'); /// Launch add field timecreated $result = $result && $table->add_field($field); $field = new xmldb_field('timemodified'); $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated'); /// Launch add field timemodified $result = $result && $table->add_field($table, $field); /// Define index course (not unique) to be added to hotquestion $result = $result && $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course')); } if ($result && $oldversion < 2007040200) { /// Add some actions to get them properly displayed in the logs $rec = new stdClass(); $rec->module = 'hotquestion'; $rec->action = 'add'; $rec->mtable = 'hotquestion'; $rec->filed = 'name'; /// Insert the add action in log_display $result = $DB->insert_record('log_display', $rec); /// Now the update action $rec->action = 'update'; $result = $DB->insert_record('log_display', $rec); /// Now the view action $rec->action = 'view'; $result = $DB->insert_record('log_display', $rec); } //===== 2.0 upgrade start here ======// return $result; }
function xmldb_interaction_forum_upgrade($oldversion = 0) { if ($oldversion < 2009062300) { foreach (array('topic', 'forum') as $type) { log_debug("Subscription upgrade for {$type}s"); // Add missing primary key to the subscription tables // Step 1: remove duplicates if ($dupes = get_records_sql_array(' SELECT "user", ' . $type . ', COUNT(*) FROM {interaction_forum_subscription_' . $type . '} GROUP BY "user", ' . $type . ' HAVING COUNT(*) > 1', array())) { // We found duplicate subscriptions to a topic/forum foreach ($dupes as $dupe) { log_debug("interaction.forum: Removing duplicate {$type} subscription for {$dupe->user}"); delete_records('interaction_forum_subscription_' . $type, 'user', $dupe->user, $type, $dupe->{$type}); insert_record('interaction_forum_subscription_' . $type, (object) array('user' => $dupe->user, $type => $dupe->{$type})); } } // Step 2: add the actual key $table = new XMLDBTable('interaction_forum_subscription_' . $type); $key = new XMLDBKey('primary'); $key->setAttributes(XMLDB_KEY_PRIMARY, array('user', $type)); add_key($table, $key); // Add a 'key' column, used for unsubscriptions $field = new XMLDBField('key'); $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, null); add_field($table, $field); $key = new XMLDBKey('keyuk'); $key->setAttributes(XMLDB_KEY_UNIQUE, array('key')); add_key($table, $key); // Populate the key column if ($records = get_records_array('interaction_forum_subscription_' . $type, '', '', '', '"user", ' . $type)) { foreach ($records as $where) { $new = (object) array('user' => $where->user, $type => $where->{$type}, 'key' => dechex(mt_rand())); update_record('interaction_forum_subscription_' . $type, $new, $where); } } // Now make the key column not null $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, XMLDB_NOTNULL); change_field_notnull($table, $field); } } if ($oldversion < 2009081700) { if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) { insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30)); } } if ($oldversion < 2009081800) { $subscription = (object) array('plugin' => 'forum', 'event' => 'creategroup', 'callfunction' => 'create_default_forum'); ensure_record_exists('interaction_event_subscription', $subscription, $subscription); } return true; }
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; }
function xmldb_blocktype_externalfeed_upgrade($oldversion = 0) { if ($oldversion < 2008042100) { // Add the 'image' column so that information about a feed's image can // be stored $table = new XMLDBTable('blocktype_externalfeed_data'); $field = new XMLDBField('image'); $field->setAttributes(XMLDB_TYPE_TEXT); add_field($table, $field); } return true; }
function xmldb_exercise_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2007110500) { $table = new XMLDBTable('exercise_submissions'); $field = new XMLDBField('late'); $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'isexercise'); $result = $result && add_field($table, $field); } return $result; }
function xmldb_nanogong_upgrade($oldversion = 0) { $result = true; if ($result && $oldversion < 2010012500) { // Add maxduration field $table = new XMLDBTable('nanogong'); $field = new XMLDBField('maxduration'); $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '300', 'color'); $result = $result && add_field($table, $field); } return $result; }
function xmldb_forum_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 /// } if ($result && $oldversion < 2007101000) { /// Define field timemodified to be added to forum_queue $table = new XMLDBTable('forum_queue'); $field = new XMLDBField('timemodified'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'postid'); /// Launch add field timemodified $result = $result && add_field($table, $field); } //===== 1.9.0 upgrade line ======// if ($result and $oldversion < 2007101511) { notify('Processing forum grades, this may take a while if there are many forums...', 'notifysuccess'); //MDL-13866 - send forum ratins to gradebook again require_once $CFG->dirroot . '/mod/forum/lib.php'; // too much debug output $db->debug = false; forum_update_grades(); $db->debug = true; } if ($result && $oldversion < 2007101512) { /// Cleanup the forum subscriptions notify('Removing stale forum subscriptions', 'notifysuccess'); $roles = get_roles_with_capability('moodle/course:view', CAP_ALLOW); $roles = array_keys($roles); $roles = implode(',', $roles); $sql = "SELECT fs.userid, f.id AS forumid\n FROM {$CFG->prefix}forum f\n JOIN {$CFG->prefix}course c ON c.id = f.course\n JOIN {$CFG->prefix}context ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = " . CONTEXT_COURSE . ")\n JOIN {$CFG->prefix}forum_subscriptions fs ON fs.forum = f.id\n LEFT JOIN {$CFG->prefix}role_assignments ra ON (ra.contextid = ctx.id AND ra.userid = fs.userid AND ra.roleid IN ({$roles}))\n WHERE ra.id IS NULL"; if ($rs = get_recordset_sql($sql)) { $db->debug = false; while ($remove = rs_fetch_next_record($rs)) { delete_records('forum_subscriptions', 'userid', $remove->userid, 'forum', $remove->forumid); echo '.'; } $db->debug = true; rs_close($rs); } } if ($result && $oldversion < 2007101513) { delete_records('forum_ratings', 'post', 0); /// Clean existing wrong rates. MDL-18227 } return $result; }
function xmldb_map_upgrade($oldversion = 0) { $result = true; if ($result && $oldversion < 2008110601) { /// Define field provider to be added to map $table = new XMLDBTable('map'); $field = new XMLDBField('provider'); $field->setAttributes(XMLDB_TYPE_CHAR, '25', null, null, null, null, null, null, 'timemodified'); /// Launch add field provider $result = $result && add_field($table, $field); } return $result; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage core * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ function xmldb_elis_core_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2011030402) { /*********************************************************************** * Replace plugintype and pluginname with plugin field **********************************************************************/ /// Define field plugin to be added to elis_scheduled_tasks $table = new XMLDBTable('elis_scheduled_tasks'); $field = new XMLDBField('plugin'); $field->setAttributes(XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null, 'id'); /// Launch add field plugin $result = $result && add_field($table, $field); /// Define index plugin_idx (not unique) to be dropped form elis_scheduled_tasks $index = new XMLDBIndex('plugin_idx'); $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugintype', 'pluginname', 'taskname')); /// Launch drop index plugin_idx $result = $result && drop_index($table, $index); /// Define index plugin_idx (not unique) to be added to elis_scheduled_tasks $index = new XMLDBIndex('plugin_idx'); $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugin', 'taskname')); /// Launch add index plugin_idx $result = $result && add_index($table, $index); /// Define field plugin to be dropped from elis_scheduled_tasks $field = new XMLDBField('plugintype'); /// Launch drop field plugin $result = $result && drop_field($table, $field); /// Define field plugin to be dropped from elis_scheduled_tasks $field = new XMLDBField('pluginname'); /// Launch drop field plugin $result = $result && drop_field($table, $field); /*********************************************************************** * Change callfunction from text to char **********************************************************************/ /// Changing type of field callfunction on table elis_scheduled_tasks to char $field = new XMLDBField('callfunction'); $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'callfile'); /// Launch change of type for field callfunction $result = $result && change_field_type($table, $field); } if ($result && $oldversion < 2011030403) { /// Define field startdate to be added to elis_scheduled_tasks $table = new XMLDBTable('elis_scheduled_tasks'); $field = new XMLDBField('startdate'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'runsremaining'); /// Launch add field startdate $result = $result && add_field($table, $field); } return $result; }
function xmldb_lesson_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2006091802) { /// Changing nullability of field response on table lesson_answers to null $table = new XMLDBTable('lesson_answers'); $field = new XMLDBField('response'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'answer'); /// Launch change of nullability for field response $result = $result && change_field_notnull($table, $field); } if ($result && $oldversion < 2006091803) { /// Changing nullability of field useranswer on table lesson_attempts to null $table = new XMLDBTable('lesson_attempts'); $field = new XMLDBField('useranswer'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'correct'); /// Launch change of nullability for field useranswer $result = $result && change_field_notnull($table, $field); } if ($result && $oldversion < 2007020201) { /// Changing nullability of field answer on table lesson_answers to null $table = new XMLDBTable('lesson_answers'); $field = new XMLDBField('answer'); $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'timemodified'); /// Launch change of nullability for field answer $result = $result && change_field_notnull($table, $field); } //===== 1.9.0 upgrade line ======// if ($result && $oldversion < 2007072201) { $table = new XMLDBTable('lesson'); $field = new XMLDBField('usegrademax'); $field2 = new XMLDBField('usemaxgrade'); /// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177 if (field_exists($table, $field) && !field_exists($table, $field2)) { /// Set field specs $field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'ongoing'); /// Launch rename field usegrademax to usemaxgrade $result = $result && rename_field($table, $field, 'usemaxgrade'); } } if ($result && $oldversion < 2008112601) { require_once $CFG->dirroot . '/mod/lesson/lib.php'; // too much debug output $db->debug = false; lesson_update_grades(); $db->debug = true; } return $result; }
function xmldb_chat_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2007012100) { /// Changing precision of field lang on table chat_users to (30) $table = new XMLDBTable('chat_users'); $field = new XMLDBField('lang'); $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'course'); /// Launch change of precision for field lang $result = $result && change_field_precision($table, $field); } return $result; }
function xmldb_voicepodcaster_upgrade($oldversion = 0) { $result = true; //we create the default table voicetools to match the moodle requirment if ($oldversion < 2009082500) { $table = new XMLDBTable('voicepodcaster_resources'); /// Adding fields to table voicetools $field = new XMLDBField('gradeid'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, -1); /// Launch create table for termreview_alis $result = $result && add_field($table, $field); } return $result; }
function xmldb_bookmarks_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($oldversion < 2008062001) { $table = new XMLDBTable("bookmarks"); $field = new XMLDBField("intro"); $field->setAttributes(XMLDB_TYPE_TEXT, small, null, true, null, null, null, "", null); change_field_default($table, $field); change_field_type($table, $field); change_field_notnull($table, $field); } return $result; }