Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
/**
 * EditPDF upgrade code
 * @param int $oldversion
 * @return bool
 */
function xmldb_assignfeedback_editpdf_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2016021600) {
        // Define table assignfeedback_editpdf_queue to be created.
        $table = new xmldb_table('assignfeedback_editpdf_queue');
        // Adding fields to table assignfeedback_editpdf_queue.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('submissionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('submissionattempt', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table assignfeedback_editpdf_queue.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for assignfeedback_editpdf_queue.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Editpdf savepoint reached.
        upgrade_plugin_savepoint(true, 2016021600, 'assignfeedback', 'editpdf');
    }
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Exemplo n.º 3
0
/**
 * Upgrade the local_msaccount plugin.
 *
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_local_msaccount_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014111702) {
        // Define table to be created.
        $table = new xmldb_table('msaccount_refresh_tokens');
        // Adding fields to table.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('user_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('refresh_token', XMLDB_TYPE_CHAR, '500', null, null, null, null);
        // Adding keys to table.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Create table.
        if ($dbman->table_exists($table)) {
            $dbman->drop_table($table);
        }
        $dbman->create_table($table);
        // Msaccount savepoint reached.
        upgrade_plugin_savepoint(true, 2014111702, 'local', 'msaccount');
    }
    // Moodle v2.3.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.4.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Exemplo n.º 4
0
/**
 * Custom authentication for WHIA project
 *
 * Upgrade script
 *
 * @package    auth_whia
 * @author     Bevan Holman <*****@*****.**>, Pukunui
 * @copyright  2015 onwards, Pukunui
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_auth_whia_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    /// Add a new table mdl_auth_whia_domain to plugin
    if ($oldversion < 2016020802) {
        // Define table auth_rsa_cpdlog to be created.
        $table = new xmldb_table('auth_whia_domain');
        // Adding fields to table auth_rsa_cpdlog.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('name', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table auth_rsa_cpdlog.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for auth_rsa_cpdlog.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // WHIA savepoint reached.
        upgrade_plugin_savepoint(true, 2016020802, 'auth', 'whia');
    }
    if ($oldversion < 2016020813) {
        // Define field cohortid to be added to auth_whia_domain.
        $table = new xmldb_table('auth_whia_domain');
        $field = new xmldb_field('cohortid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'name');
        // Conditionally launch add field cohortid.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Monitor savepoint reached.
        upgrade_plugin_savepoint(true, 2016020813, 'auth', 'whia');
    }
    return true;
}
Exemplo n.º 5
0
function xmldb_tool_createcourse_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014111000) {
        $table = new xmldb_table('tool_createcourse');
        //Adding fields to table
        $table->add_field('id', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('termcode', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, null, null);
        $table->add_field('suffix', XMLDB_TYPE_CHAR, '4', null, XMLDB_NOTNULL, null, null);
        $table->add_field('categoryid', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null);
        $hidden = new xmldb_field('hidden', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, 'categoryid');
        if (!$dbman->field_exists($table, $hidden)) {
            $dbman->add_field($table, $hidden);
        }
        //Adding keys to table
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        //Adding indices to table tool_createcourse
        $table->add_index('mdl_toolcreate_trm_ix', XMLDB_INDEX_UNIQUE, array('termcode'));
        $table->add_index('mdl_toolcreate_suf_ix', XMLDB_INDEX_UNIQUE, array('suffix'));
        $table->add_index('mdl_toolcreate_cid_ix', XMLDB_INDEX_UNIQUE, array('categoryid'));
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        upgrade_plugin_savepoint(true, 2014111000, 'tool', 'createcourse');
    }
    return true;
}
Exemplo n.º 6
0
function xmldb_qtype_calculated_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    $result = true;
    // MDL-16505.
    if ($result && $oldversion < 2008091700) {
        //New version in version.php
        if (get_config('qtype_datasetdependent', 'version')) {
            $result = $result && unset_config('version', 'qtype_datasetdependent');
        }
        upgrade_plugin_savepoint($result, 2008091700, 'qtype', 'calculated');
    }
    //    let if ($dbman->table_exists()) replace the normal $oldversion test
    //    as in any case the question question_calculated_options should be created
    /// Define table question_calculated_options to be created
    $table = new xmldb_table('question_calculated_options');
    /// Adding fields to table question_calculated_options
    $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
    $table->add_field('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
    $table->add_field('synchronize', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
    /// Adding keys to table question_calculated_options
    $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->add_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
    /// Conditionally launch create table for question_calculated_options
    if (!$dbman->table_exists($table)) {
        $result = $dbman->create_table($table);
    }
    /// calculated savepoint reached
    /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
    ///     $result = result of database_manager methods
    ///     upgrade_plugin_savepoint($result, YYYYMMDD00, 'qtype', 'calculated');
    /// }
    return $result;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
/**
 * @package eclass-local-contextadmin
 * @author joshstagg
 * @copyright Josh Stagg
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_local_contextadmin_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013100813) {
        // Adding fields to table.
        $table = new xmldb_table('cat_role_names');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
        $table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
        $table->add_field('catid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'roleid');
        $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'catid');
        // Add keys to table.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('roleid', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id'));
        $table->add_key('catid', XMLDB_KEY_FOREIGN, array('catid'), 'course_categories', array('id'));
        // Add indices.
        $table->add_index('roleid-catid', XMLDB_INDEX_UNIQUE, array('roleid', 'catid'));
        // Conditionally launch add table.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
            // Main savepoint reached.
            upgrade_plugin_savepoint(true, 2013100813, 'local', 'contextadmin');
        }
    }
}
 public function test_reorder_rows()
 {
     global $DB;
     $dbman = $DB->get_manager();
     $this->resetAfterTest();
     $table = new xmldb_table('test_table');
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $tablename = $table->getName();
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('otherid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('otherdata', XMLDB_TYPE_TEXT, 'big', null, null, null);
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('unique', XMLDB_KEY_UNIQUE, array('otherid', 'sortorder'));
     $dbman->create_table($table);
     // Rows intentionally added in a slightly 'random' order.
     // Note we are testing hat the otherid = 1 rows don't get messed up,
     // as well as testing that the otherid = 2 rows are updated correctly.
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 1, 'otherdata' => 'To become 4'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 2, 'otherdata' => 'To become 1'));
     $DB->insert_record($tablename, array('otherid' => 1, 'sortorder' => 1, 'otherdata' => 'Other 1'));
     $DB->insert_record($tablename, array('otherid' => 1, 'sortorder' => 2, 'otherdata' => 'Other 2'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 3, 'otherdata' => 'To stay at 3'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 4, 'otherdata' => 'To become 2'));
     update_field_with_unique_index($tablename, 'sortorder', array(1 => 4, 2 => 1, 3 => 3, 4 => 2), array('otherid' => 2));
     $this->assertEquals(array(3 => (object) array('id' => 3, 'otherid' => 1, 'sortorder' => 1, 'otherdata' => 'Other 1'), 4 => (object) array('id' => 4, 'otherid' => 1, 'sortorder' => 2, 'otherdata' => 'Other 2')), $DB->get_records($tablename, array('otherid' => 1), 'sortorder'));
     $this->assertEquals(array(2 => (object) array('id' => 2, 'otherid' => 2, 'sortorder' => 1, 'otherdata' => 'To become 1'), 6 => (object) array('id' => 6, 'otherid' => 2, 'sortorder' => 2, 'otherdata' => 'To become 2'), 5 => (object) array('id' => 5, 'otherid' => 2, 'sortorder' => 3, 'otherdata' => 'To stay at 3'), 1 => (object) array('id' => 1, 'otherid' => 2, 'sortorder' => 4, 'otherdata' => 'To become 4')), $DB->get_records($tablename, array('otherid' => 2), 'sortorder'));
 }
Exemplo n.º 10
0
/**
 * Upgrade code for the popup message processor
 *
 * @param int $oldversion The version that we are upgrading from
 */
function xmldb_message_popup_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.
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    $dbman = $DB->get_manager();
    if ($oldversion < 2016052309) {
        // Define table message_popup to be created.
        $table = new xmldb_table('message_popup');
        // Adding fields to table message_popup.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('messageid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('isread', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
        // Adding keys to table message_popup.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table message_popup.
        $table->add_index('messageid-isread', XMLDB_INDEX_UNIQUE, array('messageid', 'isread'));
        // Conditionally launch create table for message_popup.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Popup savepoint reached.
        upgrade_plugin_savepoint(true, 2016052309, 'message', 'popup');
    }
    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');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    //rename config var from maxattempts to maxattempt
    if ($oldversion < 2012061701) {
        $maxattempts = get_config('scorm', 'maxattempts');
        $maxattempts_adv = get_config('scorm', 'maxattempts_adv');
        set_config('maxattempt', $maxattempts, 'scorm');
        set_config('maxattempt_adv', $maxattempts_adv, 'scorm');
        unset_config('maxattempts', 'scorm');
        //remove old setting.
        unset_config('maxattempts_adv', 'scorm');
        //remove old setting.
        upgrade_mod_savepoint(true, 2012061701, 'scorm');
    }
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2015101301) {
        // Define table scorm_scoes_item to be created.
        $table = new xmldb_table('scorm_scoes_item');
        // Adding fields to table scorm_scoes_item.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('scorm_scoes_track_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('field_id', XMLDB_TYPE_CHAR, '255', null, null, null, null);
        $table->add_field('field_text', XMLDB_TYPE_CHAR, '255', null, null, null, null);
        $table->add_field('field_value', XMLDB_TYPE_CHAR, '255', null, null, null, null);
        // Adding keys to table scorm_scoes_item.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for scorm_scoes_item.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Scorm savepoint reached.
        upgrade_mod_savepoint(true, 2015101301, 'scorm');
    }
    return true;
}
Exemplo n.º 12
0
/**
 * This file keeps track of upgrades to
 * the forum module
 *
 * Sometimes, changes between versions involve
 * alterations to database structures and other
 * major things that may break installations.
 *
 * The upgrade function in this file will attempt
 * to perform all the necessary actions to upgrade
 * your older installation to the current version.
 *
 * If there's something it cannot do itself, it
 * will tell you what you need to do.
 *
 * The commands in here will all be database-neutral,
 * using the methods of database_manager class
 *
 * Please do not forget to use upgrade_set_timeout()
 * before any action that may take longer time to finish.
 *
 * @package mod-forum
 * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_forum_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    // Loads ddl manager and xmldb classes.
    // 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 < 2013020500) {
        // Define field displaywordcount to be added to forum.
        $table = new xmldb_table('forum');
        $field = new xmldb_field('displaywordcount', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completionposts');
        // Conditionally launch add field displaywordcount.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Forum savepoint reached.
        upgrade_mod_savepoint(true, 2013020500, 'forum');
    }
    // Forcefully assign mod/forum:allowforcesubscribe to frontpage role, as we missed that when
    // capability was introduced.
    if ($oldversion < 2013021200) {
        // If capability mod/forum:allowforcesubscribe is defined then set it for frontpage role.
        if (get_capability_info('mod/forum:allowforcesubscribe')) {
            assign_legacy_capabilities('mod/forum:allowforcesubscribe', array('frontpage' => CAP_ALLOW));
        }
        // Forum savepoint reached.
        upgrade_mod_savepoint(true, 2013021200, 'forum');
    }
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2013071000) {
        // Define table forum_digests to be created.
        $table = new xmldb_table('forum_digests');
        // Adding fields to table forum_digests.
        $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('forum', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('maildigest', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '-1');
        // Adding keys to table forum_digests.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        $table->add_key('forum', XMLDB_KEY_FOREIGN, array('forum'), 'forum', array('id'));
        $table->add_key('forumdigest', XMLDB_KEY_UNIQUE, array('forum', 'userid', 'maildigest'));
        // Conditionally launch create table for forum_digests.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Forum savepoint reached.
        upgrade_mod_savepoint(true, 2013071000, 'forum');
    }
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Exemplo n.º 13
0
/**
 * 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;
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
function xmldb_voiceshadow_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $DB;
    $result = true;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013030200) {
        $table = new xmldb_table('voiceshadow');
        $field = new xmldb_field('allowmultiple', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'emailteachers');
        // Conditionally launch add field requiresubmissionstatement.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Assign savepoint reached.
        upgrade_mod_savepoint(true, 2013030200, 'voiceshadow');
    }
    if ($oldversion < 2014030200) {
        // Define table assign_user_mapping to be created.
        $table = new xmldb_table('voiceshadow_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, 2014030200, 'voiceshadow');
    }
    if ($oldversion < 2014080400) {
        // Define table assign_user_mapping to be created.
        $table = new xmldb_table('voiceshadow');
        $field = new xmldb_field('gradet', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, '0', 'grade');
        // Conditionally launch add field.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        $field = new xmldb_field('grademethodt', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'default', 'grademethod');
        // Conditionally launch add field.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Assign savepoint reached.
        upgrade_mod_savepoint(true, 2014080400, 'voiceshadow');
    }
    return $result;
}
Exemplo n.º 16
0
/**
 * Upgrade code containing changes to the plugin data table.
 *
 * @package    report_ncccscensus
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @copyright  (C) 2014 Remote Learner.net Inc http://www.remote-learner.net
 */
function xmldb_report_ncccscensus_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014073101) {
        // Define table ncccscensus_reports to be created.
        $table = new xmldb_table('ncccscensus_reports');
        // Adding fields to table ncccscensus_reports.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('batchid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('status', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('filename', XMLDB_TYPE_CHAR, '255', null, null, null, '0');
        $table->add_field('fullfilename', XMLDB_TYPE_CHAR, '255', null, null, null, '0');
        $table->add_field('starttime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('reportstartdate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('reportenddate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        // Adding keys to table ncccscensus_reports.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table ncccscensus_reports.
        $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
        // Conditionally launch create table for ncccscensus_reports.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Define table ncccscensus_batch to be created.
        $table = new xmldb_table('ncccscensus_batch');
        // Adding fields to table ncccscensus_batch.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('status', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('starttime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('zipfile', XMLDB_TYPE_CHAR, '255', null, null, null, '0');
        // Adding keys to table ncccscensus_batch.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table ncccscensus_batch.
        $table->add_index('status', XMLDB_INDEX_NOTUNIQUE, array('status'));
        // Conditionally launch create table for ncccscensus_batch.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Ncccscensus savepoint reached.
        upgrade_plugin_savepoint(true, 2014073101, 'report', 'ncccscensus');
    }
    if ($oldversion < 2014073104.01) {
        // Standardize table names, preventing namespace collisions.
        $dbman->rename_table(new xmldb_table('ncccscensus_reports'), 'report_ncccscensus');
        $dbman->rename_table(new xmldb_table('ncccscensus_batch'), 'report_ncccscensus_batch');
        // Ncccscensus savepoint reached.
        upgrade_plugin_savepoint(true, 2014073104.01, 'report', 'ncccscensus');
    }
    return true;
}
Exemplo n.º 17
0
/**
 * Theme upgrade
 *
 * @package   theme_snap
 * @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_theme_snap_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014080400) {
        if (get_config('core', 'theme') == 'snap') {
            set_config('deadlinestoggle', 0, 'theme_snap');
            set_config('messagestoggle', 0, 'theme_snap');
        }
        upgrade_plugin_savepoint(true, 2014080400, 'theme', 'snap');
    }
    if ($oldversion < 2014090900) {
        if (get_config('core', 'theme') == 'snap') {
            set_config('coursefootertoggle', 0, 'theme_snap');
        }
        upgrade_plugin_savepoint(true, 2014090900, 'theme', 'snap');
    }
    if ($oldversion < 2014110404) {
        theme_snap_process_site_coverimage();
        upgrade_plugin_savepoint(true, 2014110404, 'theme', 'snap');
    }
    if ($oldversion < 2016042900) {
        // Set default value for showing personal menu on login.
        if (get_config('core', 'theme') == 'snap') {
            set_config('personalmenulogintoggle', 0, 'theme_snap');
        }
        // Snap savepoint reached.
        upgrade_plugin_savepoint(true, 2016042900, 'theme', 'snap');
    }
    if ($oldversion < 2016042904) {
        // Define table theme_snap_course_favorites to be created.
        $table = new xmldb_table('theme_snap_course_favorites');
        // Adding fields to table theme_snap_course_favorites.
        $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('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('timefavorited', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table theme_snap_course_favorites.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table theme_snap_course_favorites.
        $table->add_index('userid-courseid', XMLDB_INDEX_UNIQUE, array('userid', 'courseid'));
        // Conditionally launch create table for theme_snap_course_favorites.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Snap savepoint reached.
        upgrade_plugin_savepoint(true, 2016042904, 'theme', 'snap');
    }
    return true;
}
Exemplo n.º 18
0
function xmldb_enrol_flatfile_upgrade($oldversion)
{
    global $CFG, $DB;
    $result = TRUE;
    $dbman = $DB->get_manager();
    if ($oldversion < 2010091400) {
        // Define table enrol_flatfile to be created
        $table = new xmldb_table('enrol_flatfile');
        // Adding fields to table enrol_flatfile
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('action', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null);
        $table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('timestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        $table->add_field('timeend', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        // Adding keys to table enrol_flatfile
        $table->add_key('id', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('courseid-id', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
        $table->add_key('userid-id', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        $table->add_key('roleid-id', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id'));
        // Conditionally launch create table for enrol_flatfile
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // flatfile savepoint reached
        upgrade_plugin_savepoint(true, 2010091400, 'enrol', 'flatfile');
    }
    return $result;
}
Exemplo n.º 19
0
 /**
  * Creates the mock search area temp table.
  */
 public function setup()
 {
     global $DB;
     $dbman = $DB->get_manager();
     // Make our temp table if we need it.
     if (!$dbman->table_exists('temp_mock_search_area')) {
         $table = new \xmldb_table('temp_mock_search_area');
         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
         $table->add_field('timemodified', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, '0');
         $table->add_field('info', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
         $dbman->create_temp_table($table);
     }
 }
Exemplo n.º 20
0
/**
 * Run all Atto upgrade steps between the current DB version and the current version on disk.
 * @param int $oldversion The old version of atto in the DB.
 * @return bool
 */
function xmldb_editor_atto_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014032800) {
        // Make Atto the default.
        $currenteditors = $CFG->texteditors;
        $neweditors = array();
        $list = explode(',', $currenteditors);
        array_push($neweditors, 'atto');
        foreach ($list as $editor) {
            if ($editor != 'atto') {
                array_push($neweditors, $editor);
            }
        }
        set_config('texteditors', implode(',', $neweditors));
        upgrade_plugin_savepoint(true, 2014032800, 'editor', 'atto');
    }
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2014081400) {
        // Define table editor_atto_autosave to be created.
        $table = new xmldb_table('editor_atto_autosave');
        // Adding fields to table editor_atto_autosave.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('elementid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('pagehash', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('drafttext', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
        $table->add_field('draftid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
        $table->add_field('pageinstance', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table editor_atto_autosave.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('autosave_uniq_key', XMLDB_KEY_UNIQUE, array('elementid', 'contextid', 'userid', 'pagehash'));
        // Conditionally launch create table for editor_atto_autosave.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Atto savepoint reached.
        upgrade_plugin_savepoint(true, 2014081400, 'editor', 'atto');
    }
    if ($oldversion < 2014081900) {
        // Define field timemodified to be added to editor_atto_autosave.
        $table = new xmldb_table('editor_atto_autosave');
        $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'pageinstance');
        // Conditionally launch add field timemodified.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Atto savepoint reached.
        upgrade_plugin_savepoint(true, 2014081900, 'editor', 'atto');
    }
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Exemplo n.º 21
0
function xmldb_local_saml_site_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    /// loads ddl manager and xmldb classes
    if ($oldversion < 2015111901) {
        // Define table local_saml_site_rules to be created.
        $table = new xmldb_table('local_saml_site_rules');
        // Adding fields to table local_saml_site_rules.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('local_saml_site_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('rule', XMLDB_TYPE_TEXT, null, null, null, null, null);
        $table->add_field('ruletype', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, '1');
        // Adding keys to table local_saml_site_rules.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table local_saml_site_rules.
        $table->add_index('local_saml_site_id', XMLDB_INDEX_NOTUNIQUE, array('local_saml_site_id'));
        // Conditionally launch create table for local_saml_site_rules.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Define field rule to be dropped from local_saml_site.
        $table = new xmldb_table('local_saml_site');
        $field = new xmldb_field('rule');
        // Conditionally launch drop field rule.
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }
        $field = new xmldb_field('ruletype');
        // Conditionally launch drop field ruletype.
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }
        // Saml_site savepoint reached.
        upgrade_plugin_savepoint(true, 2015111901, 'local', 'saml_site');
    }
    if ($oldversion < 2015122401) {
        // Define field customprofilefield to be added to local_saml_site_rules.
        $table = new xmldb_table('local_saml_site_rules');
        $field = new xmldb_field('customprofilefield', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'ruletype');
        // Conditionally launch add field customprofilefield.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Saml_site savepoint reached.
        upgrade_plugin_savepoint(true, 2015122401, 'local', 'saml_site');
    }
    return true;
}
Exemplo n.º 22
0
/**
 * Stub for upgrade code
 * @param int $oldversion
 * @return bool
 */
function xmldb_assignsubmission_onlinepoodll_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    //Change table name to satisfy Moodle.org plugin submissions component name v table name check
    //ie it checks(or will) check 1st 28 chars of component name matches table name.
    if ($oldversion < 2012112000) {
        $table = new xmldb_table('assignsubmission_onlinepood');
        if ($dbman->table_exists($table)) {
            $dbman->rename_table($table, 'assignsubmission_onlinepoodl', $continue = true, $feedback = true);
        }
        // online PoodLL savepoint reached
        upgrade_plugin_savepoint(true, 2012112000, 'assignsubmission', 'onlinepoodll');
    }
    //add filename field.
    if ($oldversion < 2013120500) {
        $table = new xmldb_table('assignsubmission_onlinepoodl');
        $table->add_field('filename', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
        // online PoodLL savepoint reached
        upgrade_plugin_savepoint(true, 2013120500, 'assignsubmission', 'onlinepoodll');
    }
    return true;
}
Exemplo n.º 23
0
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;
}
Exemplo n.º 24
0
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;
}
Exemplo n.º 25
0
/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_repository_onenote_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014103001) {
        // Define table repository_onenote to be created.
        $table = new xmldb_table('repository_onenote');
        // Adding fields to table repository_onenote.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        // Adding keys to table repository_onenote.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for repository_onenote.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Onenote savepoint reached.
        upgrade_plugin_savepoint(true, 2014103001, 'repository', 'onenote');
    }
    // Moodle v2.3.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.4.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Exemplo n.º 26
0
function xmldb_quiz_overview_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    //===== 1.9.0 upgrade line ======//
    if ($oldversion < 2009091400) {
        /// Define table quiz_question_regrade to be created
        $table = new xmldb_table('quiz_question_regrade');
        /// Adding fields to table quiz_question_regrade
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
        $table->add_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
        $table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        /// Adding keys to table quiz_question_regrade
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Conditionally launch create table for quiz_question_regrade
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        /// overview savepoint reached
        upgrade_plugin_savepoint(true, 2009091400, 'quizreport', 'overview');
    }
    return true;
}
Exemplo n.º 27
0
/**
 * Execute virtualclass upgrade from the given old version
 *
 * @param int $oldversion
 * @return bool
 */
function xmldb_virtualclass_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    // Loads ddl manager and xmldb classes.
    /*
     * 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 ($oldversion < YYYYMMDD00) { //New version in version.php
     * }
     *
     * Lines below (this included)  MUST BE DELETED once you get the first version
     * of your module ready to be installed. They are here only
     * for demonstrative purposes and to show how the virtualclass
     * iself has been upgraded.
     *
     * For each upgrade block, the file virtualclass/version.php
     * needs to be updated . Such change allows Moodle to know
     * that this file has to be processed.
     *
     * To know more about how to write correct DB upgrade scripts it's
     * highly recommended to read information available at:
     *   http://docs.moodle.org/en/Development:XMLDB_Documentation
     * and to play with the XMLDB Editor (in the admin menu) and its
     * PHP generation posibilities.
     *
     * First installation, no update
     */
    /*
     * Finally, return of upgrade result (true, all went good) to Moodle.
     */
    if ($oldversion < 2015072402) {
        // Define table virtualclass_files to virtualclass.
        $table = new xmldb_table('virtualclass_files');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, null);
        $table->add_field('vcid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, null);
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, null);
        $table->add_field('vcsessionkey', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null);
        $table->add_field('vcsessionname', XMLDB_TYPE_CHAR, '225', null, null, null, null, null);
        $table->add_field('numoffiles', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, null);
        $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, null);
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'), null, null);
        // Conditionally launch add table virtualclass_files.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Virtualclass savepoint reached.
        upgrade_mod_savepoint(true, 2015072402, 'virtualclass');
    }
    return true;
}
Exemplo n.º 28
0
/**
 * 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 code for the essay question type.
 * @param int $oldversion the version we are upgrading from.
 */
function xmldb_qtype_essay_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011031000) {
        // Define table qtype_essay_options to be created
        $table = new xmldb_table('qtype_essay_options');
        // Adding fields to table qtype_essay_options
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
        $table->add_field('responseformat', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, 'editor');
        $table->add_field('responsefieldlines', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '15');
        $table->add_field('attachments', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
        $table->add_field('graderinfo', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
        $table->add_field('graderinfoformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        // Adding keys to table qtype_essay_options
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id'));
        // Conditionally launch create table for qtype_essay_options
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // essay savepoint reached
        upgrade_plugin_savepoint(true, 2011031000, 'qtype', 'essay');
    }
    if ($oldversion < 2011060300) {
        // Insert a row into the qtype_essay_options table for each existing essay question.
        $DB->execute("\n                INSERT INTO {qtype_essay_options} (questionid, responseformat,\n                        responsefieldlines, attachments, graderinfo, graderinfoformat)\n                SELECT q.id, 'editor', 15, 0, '', " . FORMAT_MOODLE . "\n                FROM {question} q\n                WHERE q.qtype = 'essay'\n                AND NOT EXISTS (\n                    SELECT 'x'\n                    FROM {qtype_essay_options} qeo\n                    WHERE qeo.questionid = q.id)");
        // essay savepoint reached
        upgrade_plugin_savepoint(true, 2011060300, 'qtype', 'essay');
    }
    // Moodle v2.1.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
/**
 * 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;
}