コード例 #1
0
ファイル: badgeslib_test.php プロジェクト: rwijaya/moodle
    protected function setUp() {
        global $DB, $CFG;
        $this->resetAfterTest(true);

        unset_config('noemailever');

        $CFG->enablecompletion = true;

        $user = $this->getDataGenerator()->create_user();

        $fordb = new stdClass();
        $fordb->id = null;
        $fordb->name = "Test badge";
        $fordb->description = "Testing badges";
        $fordb->timecreated = time();
        $fordb->timemodified = time();
        $fordb->usercreated = $user->id;
        $fordb->usermodified = $user->id;
        $fordb->issuername = "Test issuer";
        $fordb->issuerurl = "http://issuer-url.domain.co.nz";
        $fordb->issuercontact = "*****@*****.**";
        $fordb->expiredate = null;
        $fordb->expireperiod = null;
        $fordb->type = BADGE_TYPE_SITE;
        $fordb->courseid = null;
        $fordb->messagesubject = "Test message subject";
        $fordb->message = "Test message body";
        $fordb->attachment = 1;
        $fordb->notification = 0;
        $fordb->status = BADGE_STATUS_INACTIVE;

        $this->badgeid = $DB->insert_record('badge', $fordb, true);

        // Create a course with activity and auto completion tracking.
        $this->course = $this->getDataGenerator()->create_course(array('enablecompletion' => true));
        $this->user = $this->getDataGenerator()->create_user();
        $studentrole = $DB->get_record('role', array('shortname' => 'student'));
        $this->assertNotEmpty($studentrole);

        // Get manual enrolment plugin and enrol user.
        require_once($CFG->dirroot.'/enrol/manual/locallib.php');
        $manplugin = enrol_get_plugin('manual');
        $maninstance = $DB->get_record('enrol', array('courseid' => $this->course->id, 'enrol' => 'manual'), '*', MUST_EXIST);
        $manplugin->enrol_user($maninstance, $this->user->id, $studentrole->id);
        $this->assertEquals(1, $DB->count_records('user_enrolments'));

        $completionauto = array('completion' => COMPLETION_TRACKING_AUTOMATIC);
        $this->module = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id), $completionauto);

        // Build badge and criteria.
        $fordb->type = BADGE_TYPE_COURSE;
        $fordb->courseid = $this->course->id;
        $fordb->status = BADGE_STATUS_ACTIVE;

        $this->coursebadge = $DB->insert_record('badge', $fordb, true);
        $this->assertion = new stdClass();
        $this->assertion->badge = '{"uid":"%s","recipient":{"identity":"%s","type":"email","hashed":true,"salt":"%s"},"badge":"%s","verify":{"type":"hosted","url":"%s"},"issuedOn":"%d","evidence":"%s"}';
        $this->assertion->class = '{"name":"%s","description":"%s","image":"%s","criteria":"%s","issuer":"%s"}';
        $this->assertion->issuer = '{"name":"%s","url":"%s","email":"%s"}';
    }
コード例 #2
0
function xmldb_theme_formal_white_install()
{
    // We need here to check whether or not the theme has been installed.
    // If it has been installed then we need to change the name of the settings to the new names.
    // If it is not installed it won't have any settings yet and we won't need to worry about this.
    $currentsetting = get_config('theme_formal_white');
    if (!empty($currentsetting)) {
        // Remove the settings that are no longer used by this theme
        // Remove regionwidth
        unset_config('regionwidth', 'theme_formal_white');
        // Remove alwayslangmenu
        unset_config('alwayslangmenu', 'theme_formal_white');
        // previous releases of formal_white them were not equipped with version number
        // so I can not know if a theme specific variable exists or not.
        // This is the reason why I try to use them both.
        if (!empty($currentsetting->backgroundcolor)) {
            // Create a new config setting called lblockcolumnbgc and give it backgroundcolor's value.
            set_config('lblockcolumnbgc', $currentsetting->backgroundcolor, 'theme_formal_white');
            // Remove backgroundcolor
            unset_config('backgroundcolor', 'theme_formal_white');
        } elseif (!empty($currentsetting->blockcolumnbgc)) {
            // Create a new config setting called lblockcolumnbgc and give it blockcolumnbgc's value.
            set_config('lblockcolumnbgc', $currentsetting->blockcolumnbgc, 'theme_formal_white');
            // Remove blockcolumnbgc
            unset_config('blockcolumnbgc', 'theme_formal_white');
        }
    }
    return true;
}
コード例 #3
0
ファイル: install.php プロジェクト: nigeldaley/moodle
function xmldb_tool_bloglevelupgrade_install()
{
    global $CFG, $OUTPUT;
    // this is a hack - admins were long ago instructed to upgrade blog levels,
    // the problem is that blog is not supposed to be course level activity!!
    if (!empty($CFG->bloglevel_upgrade_complete)) {
        // somebody already upgrades, we do not need this any more
        unset_config('bloglevel_upgrade_complete');
        return;
    }
    if (!isset($CFG->bloglevel)) {
        // fresh install?
        return;
    }
    if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
        // inform admins that some settings require attention after upgrade
        $site = get_site();
        $a = new StdClass();
        $a->sitename = $site->fullname;
        $a->fixurl = "{$CFG->wwwroot}/{$CFG->admin}/tool/bloglevelupgrade/index.php";
        $subject = get_string('bloglevelupgrade', 'tool_bloglevelupgrade');
        $description = get_string('bloglevelupgradedescription', 'tool_bloglevelupgrade', $a);
        // can not use messaging here because it is not configured yet!
        upgrade_log(UPGRADE_LOG_NOTICE, null, $subject, $description);
        set_config('tool_bloglevelupgrade_pending', 1);
        echo $OUTPUT->notification($description);
    }
}
コード例 #4
0
function xmldb_enrol_license_install()
{
    global $CFG, $DB;
    // Migrate welcome message.
    if (isset($CFG->sendcoursewelcomemessage)) {
        // New course default.
        set_config('sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, 'enrol_license');
        // Each instance has different setting now.
        $DB->set_field('enrol', 'customint4', $CFG->sendcoursewelcomemessage, array('enrol' => 'license'));
        unset_config('sendcoursewelcomemessage');
    }
    // Migrate long-time-no-see feature settings.
    if (isset($CFG->longtimenosee)) {
        $nosee = $CFG->longtimenosee * 3600 * 24;
        set_config('longtimenosee', $nosee, 'enrol_license');
        $DB->set_field('enrol', 'customint2', $nosee, array('enrol' => 'license'));
        unset_config('longtimenosee');
    }
    // Enable by default on the site.
    $enabledenrols = explode(',', $CFG->enrol_plugins_enabled);
    if (!in_array('license', $enabledenrols)) {
        $enabledenrols[] = 'license';
        set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
    }
}
コード例 #5
0
/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_filter_texwjax_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2013120300) {
        $settings = array('density', 'latexbackground', 'convertformat', 'pathlatex', 'convertformat', 'pathconvert', 'pathdvips', 'latexpreamble');
        // Move tex settings to config_pluins and delete entries from the config table.
        foreach ($settings as $setting) {
            $existingkey = 'filter_texwjax_' . $setting;
            if (array_key_exists($existingkey, $CFG)) {
                set_config($setting, $CFG->{$existingkey}, 'filter_texwjax');
                unset_config($existingkey);
            }
        }
        upgrade_plugin_savepoint(true, 2013120300, 'filter', 'texwjax');
    }
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
コード例 #6
0
/**
 * Upgrade code for the section links block.
 *
 * @global moodle_database $DB
 * @param int $oldversion
 * @param object $block
 */
function xmldb_block_section_links_upgrade($oldversion, $block)
{
    global $DB;
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2013012200.0) {
        // The section links block used to use its own crazy plugin name.
        // Here we are converting it to the proper component name.
        $oldplugin = 'blocks/section_links';
        $newplugin = 'block_section_links';
        // Use the proper API here... thats what we should be doing as it ensures any caches etc are cleared
        // along the way!
        // It may be quicker to just write an SQL statement but that would be reckless.
        $config = get_config($oldplugin);
        if (!empty($config)) {
            foreach ($config as $name => $value) {
                set_config($name, $value, $newplugin);
                unset_config($name, $oldplugin);
            }
        }
        // Main savepoint reached.
        upgrade_block_savepoint(true, 2013012200.0, 'section_links');
    }
    // Moodle v2.5.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
コード例 #7
0
function xmldb_theme_formal_white_upgrade($oldversion)
{
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2012051503) {
        $currentsetting = get_config('theme_formal_white');
        if (isset($currentsetting->displaylogo)) {
            // useless but safer
            // Create a new config setting called headercontent and give it the current displaylogo value.
            set_config('headercontent', $currentsetting->displaylogo, 'theme_formal_white');
            unset_config('displaylogo', 'theme_formal_white');
        }
        if (isset($currentsetting->logo)) {
            // useless but safer
            // Create a new config setting called headercontent and give it the current displaylogo value.
            set_config('customlogourl', $currentsetting->logo, 'theme_formal_white');
            unset_config('logo', 'theme_formal_white');
        }
        if (isset($currentsetting->frontpagelogo)) {
            // useless but safer
            // Create a new config setting called headercontent and give it the current displaylogo value.
            set_config('frontpagelogourl', $currentsetting->frontpagelogo, 'theme_formal_white');
            unset_config('frontpagelogo', 'theme_formal_white');
        }
        upgrade_plugin_savepoint(true, 2012051503, 'theme', 'formal_white');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
コード例 #8
0
ファイル: upgrade.php プロジェクト: esyacelga/sisadmaca
/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_filter_mediaplugin_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    if ($oldversion < 2011030900) {
        unset_config('filter_mediaplugin_enable_img');
        // migrated to filter_urltolink
        unset_config('filter_mediaplugin_enable_ram');
        // --> rm
        unset_config('filter_mediaplugin_enable_rpm');
        // --> rm
        unset_config('filter_mediaplugin_enable_ogg');
        // --> html5audio
        unset_config('filter_mediaplugin_enable_ogv');
        // --> html5video
        unset_config('filter_mediaplugin_enable_avi');
        // --> wmp
        unset_config('filter_mediaplugin_enable_wmv');
        // --> wmp
        unset_config('filter_mediaplugin_enable_mov');
        // --> qt
        unset_config('filter_mediaplugin_enable_mpg');
        // --> qt
        upgrade_plugin_savepoint(true, 2011030900, 'filter', 'mediaplugin');
    }
    return true;
}
コード例 #9
0
ファイル: upgrade.php プロジェクト: Jtgadbois/Pedadida
/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_filter_mediaplugin_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011121200) {
        // Move all the media enable setttings that are now handled by core media renderer.
        foreach (array('html5video', 'html5audio', 'mp3', 'flv', 'wmp', 'qt', 'rm', 'youtube', 'vimeo', 'swf') as $type) {
            $existingkey = 'filter_mediaplugin_enable_' . $type;
            if (array_key_exists($existingkey, $CFG)) {
                set_config('core_media_enable_' . $type, $CFG->{$existingkey});
                unset_config($existingkey);
            }
        }
        // Override setting for html5 to turn it on (previous default was off; because
        // of changes in the way fallbacks are handled, this is now unlikely to cause
        // a problem, and is required for mobile a/v support on non-Flash devices, so
        // this change is basically needed in order to maintain existing behaviour).
        set_config('core_media_enable_html5video', 1);
        set_config('core_media_enable_html5audio', 1);
        upgrade_plugin_savepoint(true, 2011121200, 'filter', 'mediaplugin');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
コード例 #10
0
function xmldb_enrol_leap_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2012100702) {
        // Set default expiry threshold to 1 day.
        $DB->execute("UPDATE {enrol} SET expirythreshold = 86400 WHERE enrol = 'leap' AND expirythreshold = 0");
        upgrade_plugin_savepoint(true, 2012100702, 'enrol', 'leap');
    }
    if ($oldversion < 2012101400) {
        // Delete obsoleted settings, now using expiry* prefix to make them more consistent.
        unset_config('notifylast', 'enrol_leap');
        unset_config('notifyhour', 'enrol_leap');
        upgrade_plugin_savepoint(true, 2012101400, 'enrol', 'leap');
    }
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
コード例 #11
0
ファイル: upgrade.php プロジェクト: evltuma/moodle
function xmldb_editor_tinymce_upgrade($oldversion)
{
    global $CFG, $DB;
    if ($oldversion < 2014062900) {
        // We only want to delete DragMath from the customtoolbar setting if the directory no longer exists. If
        // the directory is present then it means it has been restored, so do not remove any settings.
        if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) {
            // Remove the DragMath plugin from the 'customtoolbar' setting (if it exists) as it has been removed.
            $currentorder = get_config('editor_tinymce', 'customtoolbar');
            $newtoolbarrows = array();
            $currenttoolbarrows = explode("\n", $currentorder);
            foreach ($currenttoolbarrows as $currenttoolbarrow) {
                $currenttoolbarrow = implode(',', array_diff(str_getcsv($currenttoolbarrow), array('dragmath')));
                $newtoolbarrows[] = $currenttoolbarrow;
            }
            $neworder = implode("\n", $newtoolbarrows);
            unset_config('customtoolbar', 'editor_tinymce');
            set_config('customtoolbar', $neworder, 'editor_tinymce');
        }
        upgrade_plugin_savepoint(true, 2014062900, 'editor', 'tinymce');
    }
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
コード例 #12
0
ファイル: upgrade.php プロジェクト: ajv/Offline-Caching
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;
}
コード例 #13
0
ファイル: upgrade.php プロジェクト: nmicha/moodle
/**
 * @global moodle_database $DB
 * @param int $oldversion
 * @return bool
 */
function xmldb_scorm_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2012032100) {
        unset_config('updatetime', 'scorm');
        upgrade_mod_savepoint(true, 2012032100, 'scorm');
    }
    // Adding completion fields to scorm table
    if ($oldversion < 2012032101) {
        $table = new xmldb_table('scorm');
        $field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        $field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_mod_savepoint(true, 2012032101, 'scorm');
    }
    return true;
}
コード例 #14
0
ファイル: theme.php プロジェクト: EmmanuelYupit/educursos
 /**
  * Pre-uninstall hook.
  *
  * This is intended for disabling of plugin, some DB table purging, etc.
  *
  * NOTE: to be called from uninstall_plugin() only.
  * @private
  */
 public function uninstall_cleanup()
 {
     global $DB;
     $DB->set_field('course', 'theme', '', array('theme' => $this->name));
     $DB->set_field('course_categories', 'theme', '', array('theme' => $this->name));
     $DB->set_field('user', 'theme', '', array('theme' => $this->name));
     $DB->set_field('mnet_host', 'theme', '', array('theme' => $this->name));
     if (get_config('core', 'thememobile') === $this->name) {
         unset_config('thememobile');
     }
     if (get_config('core', 'themetablet') === $this->name) {
         unset_config('themetablet');
     }
     if (get_config('core', 'themelegacy') === $this->name) {
         unset_config('themelegacy');
     }
     $themelist = get_config('core', 'themelist');
     if (!empty($themelist)) {
         $themes = explode(',', $themelist);
         $key = array_search($this->name, $themes);
         if ($key !== false) {
             unset($themes[$key]);
             set_config('themelist', implode(',', $themes));
         }
     }
     parent::uninstall_cleanup();
 }
コード例 #15
0
/**
 * @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;
}
コード例 #16
0
ファイル: upgrade.php プロジェクト: vuchannguyen/web
function xmldb_block_search_upgrade($oldversion)
{
    global $CFG, $DB;
    require 'upgradelib.php';
    $result = TRUE;
    $dbman = $DB->get_manager();
    if ($oldversion < 2010101800) {
        // See MDL-24374
        // Changing type of field docdate on table block_search_documents to int
        // Changing type of field updated on table block_search_documents to int
        $table = new xmldb_table('block_search_documents');
        $field_docdate_new = new xmldb_field('docdate_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'docdate');
        $field_updated_new = new xmldb_field('updated_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'updated');
        $field_docdate_old = new xmldb_field('docdate');
        $field_updated_old = new xmldb_field('updated');
        // Conditionally launch add temporary fields
        if (!$dbman->field_exists($table, $field_docdate_new)) {
            $dbman->add_field($table, $field_docdate_new);
        }
        if (!$dbman->field_exists($table, $field_updated_new)) {
            $dbman->add_field($table, $field_updated_new);
        }
        $sql = "SELECT id, docdate, updated FROM {block_search_documents}";
        $search_documents = $DB->get_records_sql($sql);
        if ($search_documents) {
            foreach ($search_documents as $sd) {
                $sd->docdate_new = convert_datetime_upgrade($sd->docdate);
                $sd->updated_new = convert_datetime_upgrade($sd->updated);
                $DB->update_record('block_search_documents', $sd);
            }
        }
        // Conditionally launch drop the old fields
        if ($dbman->field_exists($table, $field_docdate_old)) {
            $dbman->drop_field($table, $field_docdate_old);
        }
        if ($dbman->field_exists($table, $field_updated_old)) {
            $dbman->drop_field($table, $field_updated_old);
        }
        //rename the new fields to the original field names.
        $dbman->rename_field($table, $field_docdate_new, 'docdate');
        $dbman->rename_field($table, $field_updated_new, 'updated');
        // search savepoint reached
        upgrade_block_savepoint(true, 2010101800, 'search');
    }
    if ($oldversion < 2010110900) {
        unset_config('block_search_text');
        unset_config('block_search_button');
        upgrade_block_savepoint(true, 2010110900, 'search');
    }
    if ($oldversion < 2010111100) {
        // set block to hidden if global search is disabled.
        if ($CFG->enableglobalsearch != 1) {
            $DB->set_field('block', 'visible', 0, array('name' => 'search'));
            // Hide block
        }
        upgrade_block_savepoint(true, 2010111100, 'search');
    }
    return $result;
}
コード例 #17
0
/**
 * uninstall online judge
 *
 * @package   local_onlinejudge
 * @copyright 2011 Sun Zhigang (http://sunner.cn)
 * @author    Sun Zhigang
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_local_onlinejudge_uninstall()
{
    unset_config('maxmemlimit', 'local_onlinejudge');
    unset_config('maxcpulimit', 'local_onlinejudge');
    unset_config('ideonedelay', 'local_onlinejudge');
    $fs = get_file_storage();
    return $fs->delete_area_files(get_context_instance(CONTEXT_SYSTEM)->id, 'local_onlinejudge');
}
コード例 #18
0
ファイル: upgrade.php プロジェクト: r007/PMoodle
function question_remove_rqp_qtype_config_string()
{
    global $CFG;
    $result = true;
    // An earlier, buggy version of the previous function missed out the unset_config call.
    if (!empty($CFG->qtype_rqp_version) && !is_dir($CFG->dirroot . '/question/type/rqp')) {
        $result = $result && unset_config('qtype_rqp_version');
    }
    return $result;
}
コード例 #19
0
/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_local_sandbox_upgrade($oldversion)
{
    if ($oldversion < 2014051200) {
        echo html_writer::tag('div', get_string('upgrade_notice_2014051200', 'local_sandbox'), array('class' => 'alert alert-info'));
        unset_config('cronruntimehour', 'local_sandbox');
        unset_config('cronruntimemin', 'local_sandbox');
        unset_config('cronrunday', 'local_sandbox');
        upgrade_plugin_savepoint(true, 2014051200, 'local', 'sandbox');
    }
    return true;
}
コード例 #20
0
ファイル: upgrade.php プロジェクト: JP-Git/moodle
function xmldb_editor_tinymce_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2012083100) {
        // Reset redesigned editor toolbar setting.
        unset_config('customtoolbar', 'editor_tinymce');
        upgrade_plugin_savepoint(true, 2012083100, 'editor', 'tinymce');
    }
    return true;
}
コード例 #21
0
function xmldb_webex_install()
{
    global $CFG;
    // migrate settings if present
    if (!empty($CFG->resource_secretphrase)) {
        set_config('secretphrase', $CFG->resource_secretphrase, 'webex');
    }
    unset_config('resource_secretphrase');
    // Upgrade from old resource module type if needed
    require_once "{$CFG->dirroot}/mod/webex/db/upgradelib.php";
    webex_20_migrate();
}
コード例 #22
0
ファイル: theme.php プロジェクト: tyleung/CMPUT401MoodleExams
 /**
  * Pre-uninstall hook.
  *
  * This is intended for disabling of plugin, some DB table purging, etc.
  *
  * NOTE: to be called from uninstall_plugin() only.
  * @private
  */
 public function uninstall_cleanup()
 {
     global $DB;
     $DB->set_field('course', 'theme', '', array('theme' => $this->name));
     $DB->set_field('course_categories', 'theme', '', array('theme' => $this->name));
     $DB->set_field('user', 'theme', '', array('theme' => $this->name));
     $DB->set_field('mnet_host', 'theme', '', array('theme' => $this->name));
     unset_config('thememobile');
     unset_config('themetablet');
     unset_config('themelegacy');
     parent::uninstall_cleanup();
 }
コード例 #23
0
    public function test_message_get_providers_for_user() {
        global $CFG, $DB;

        $this->resetAfterTest(true);

        $generator = $this->getDataGenerator();

        // Create a course category and course
        $cat = $generator->create_category(array('parent' => 0));
        $course = $generator->create_course(array('category' => $cat->id));
        $quiz = $generator->create_module('quiz', array('course' => $course->id));
        $user = $generator->create_user();

        $coursecontext = context_course::instance($course->id);
        $quizcontext = context_module::instance($quiz->cmid);
        $frontpagecontext = context_course::instance(SITEID);

        $studentrole = $DB->get_record('role', array('shortname' => 'student'));

        // The user is a student in a course, and has the capability for quiz
        // confirmation emails in one quiz in that course.
        role_assign($studentrole->id, $user->id, $coursecontext->id);
        assign_capability('mod/quiz:emailconfirmsubmission', CAP_ALLOW, $studentrole->id, $quizcontext->id);

        // Give this message type to the front page role.
        assign_capability('mod/quiz:emailwarnoverdue', CAP_ALLOW, $CFG->defaultfrontpageroleid, $frontpagecontext->id);

        $providers = message_get_providers_for_user($user->id);
        $this->assertTrue($this->message_type_present('mod_forum', 'posts', $providers));
        $this->assertTrue($this->message_type_present('mod_quiz', 'confirmation', $providers));
        $this->assertTrue($this->message_type_present('mod_quiz', 'attempt_overdue', $providers));
        $this->assertFalse($this->message_type_present('mod_quiz', 'submission', $providers));

        // A user is a student in a different course, they should not get confirmation.
        $course2 = $generator->create_course(array('category' => $cat->id));
        $user2 = $generator->create_user();
        $coursecontext2 = context_course::instance($course2->id);
        role_assign($studentrole->id, $user2->id, $coursecontext2->id);
        accesslib_clear_all_caches_for_unit_testing();
        $providers = message_get_providers_for_user($user2->id);
        $this->assertTrue($this->message_type_present('mod_forum', 'posts', $providers));
        $this->assertFalse($this->message_type_present('mod_quiz', 'confirmation', $providers));

        // Now remove the frontpage role id, and attempt_overdue message should go away.
        unset_config('defaultfrontpageroleid');
        accesslib_clear_all_caches_for_unit_testing();

        $providers = message_get_providers_for_user($user->id);
        $this->assertTrue($this->message_type_present('mod_quiz', 'confirmation', $providers));
        $this->assertFalse($this->message_type_present('mod_quiz', 'attempt_overdue', $providers));
        $this->assertFalse($this->message_type_present('mod_quiz', 'submission', $providers));
    }
コード例 #24
0
ファイル: upgradelib.php プロジェクト: evltuma/moodle
/**
 * Migrate spell related settings from tinymce.
 */
function tinymce_spellchecker_migrate_settings()
{
    $engine = get_config('editor_tinymce', 'spellengine');
    if ($engine !== false) {
        set_config('spellengine', $engine, 'tinymce_spellchecker');
        unset_config('spellengine', 'editor_tinymce');
    }
    $list = get_config('editor_tinymce', 'spelllanguagelist');
    if ($list !== false) {
        set_config('spelllanguagelist', $list, 'tinymce_spellchecker');
        unset_config('spelllanguagelist', 'editor_tinymce');
    }
}
コード例 #25
0
function xmldb_enrol_database_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    // fix leftovers after incorrect 2.x upgrade in install.php
    if ($oldversion < 2010073101) {
        unset_config('enrol_db_localrolefield');
        unset_config('enrol_db_remoterolefield');
        unset_config('enrol_db_disableunenrol');
        upgrade_plugin_savepoint(true, 2010073101, 'enrol', 'database');
    }
    return true;
}
コード例 #26
0
ファイル: configuration.php プロジェクト: adamboardman/Elgg
/**
 * Sets a configuration value
 *
 * @param string $name The name of the configuration value
 * @param string $value Its value
 * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)
 * @return 0
 * @todo The config table doens't have numeric primary keys so insert_data returns 0.
 */
function set_config($name, $value, $site_guid = 0)
{
    global $CONFIG;
    // Unset existing
    unset_config($name, $site_guid);
    $site_guid = (int) $site_guid;
    if ($site_guid == 0) {
        $site_guid = (int) $CONFIG->site_id;
    }
    $CONFIG->{$name} = $value;
    $value = sanitise_string(serialize($value));
    return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}");
}
コード例 #27
0
ファイル: upgrade.php プロジェクト: Jtgadbois/Pedadida
function xmldb_editor_tinymce_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2012083100) {
        // Reset redesigned editor toolbar setting.
        unset_config('customtoolbar', 'editor_tinymce');
        upgrade_plugin_savepoint(true, 2012083100, 'editor', 'tinymce');
    }
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
コード例 #28
0
/**
 * Database log store upgrade.
 *
 * @package    logstore_database
 * @copyright  2014 onwards Ankit Agarwal <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_logstore_database_upgrade($oldversion)
{
    if ($oldversion < 2014041700) {
        // Clean up old config.
        unset_config('excludelevels', 'logstore_database');
        unset_config('excludeactions', 'logstore_database');
        // Savepoint reached.
        upgrade_plugin_savepoint(true, 2014041700, 'logstore', 'database');
    }
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
コード例 #29
0
/**
 * Upgrade code for the section links block.
 *
 * @param int $oldversion
 * @return bool
 */
function xmldb_block_filtered_course_list_upgrade($oldversion)
{
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this.
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this.
    // Moodle v2.5.0 release upgrade line
    // Put any upgrade step following this.
    if ($oldversion < 2014010601) {
        $oldfiltertype = get_config('moodle', 'block_filtered_course_list/filtertype');
        if ($oldfiltertype == 'term') {
            set_config('block_filtered_course_list/filtertype', 'shortname');
        }
        $oldtermcurrent = get_config('moodle', 'block_filtered_course_list_termcurrent');
        if (!empty($oldtermcurrent)) {
            set_config('block_filtered_course_list_currentshortname', $oldtermcurrent);
            unset_config('block_filtered_course_list_termcurrent');
        }
        $oldtermfuture = get_config('moodle', 'block_filtered_course_list_termfuture');
        if (!empty($oldtermfuture)) {
            set_config('block_filtered_course_list_futureshortname', $oldtermfuture);
            unset_config('block_filtered_course_list_termfuture');
        }
        // Main savepoint reached.
        upgrade_block_savepoint(true, 2014010601, 'filtered_course_list');
    }
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2015102002) {
        $fclsettings = array('filtertype', 'hideallcourseslink', 'hidefromguests', 'hideothercourses', 'useregex', 'currentshortname', 'currentexpanded', 'futureshortname', 'futureexpanded', 'labelscount', 'categories', 'adminview', 'maxallcourse', 'collapsible');
        $customrubrics = array('customlabel', 'customshortname', 'labelexpanded');
        foreach ($fclsettings as $name) {
            $value = get_config('moodle', 'block_filtered_course_list_' . $name);
            set_config($name, $value, 'block_filtered_course_list');
            unset_config('block_filtered_course_list_' . $name);
        }
        for ($i = 1; $i <= 10; $i++) {
            foreach ($customrubrics as $setting) {
                $name = $setting . $i;
                $value = get_config('moodle', 'block_filtered_course_list_' . $name);
                if (!empty($value)) {
                    set_config($name, $value, 'block_filtered_course_list');
                    unset_config('block_filtered_course_list_' . $name);
                }
            }
        }
        // Main savepoint reached.
        upgrade_block_savepoint(true, 2015102002, 'filtered_course_list');
    }
    return true;
}
コード例 #30
0
ファイル: upgrade.php プロジェクト: kevin-bruton/marsupial
function xmldb_block_my_books_upgrade($oldversion = 0)
{
    global $CFG, $DB;
    if ($oldversion < 2014111100) {
        set_config('viewer_opening', $CFG->mybooks_viewer_opening, 'mybooks');
        unset_config('mybooks_viewer_opening');
        set_config('width', $CFG->mybooks_width, 'mybooks');
        unset_config('mybooks_width');
        set_config('height', $CFG->mybooks_height, 'mybooks');
        unset_config('mybooks_height');
        set_config('activity_opening', $CFG->mybooks_activity_opening, 'mybooks');
        unset_config('mybooks_activity_opening');
        set_config('scrollbars', $CFG->mybooks_scrollbars, 'mybooks');
        unset_config('mybooks_scrollbars');
        set_config('menubar', $CFG->mybooks_menubar, 'mybooks');
        unset_config('mybooks_menubar');
        set_config('toolbar', $CFG->mybooks_toolbar, 'mybooks');
        unset_config('mybooks_toolbar');
        set_config('status', $CFG->mybooks_status, 'mybooks');
        unset_config('mybooks_status');
        set_config('addkey', $CFG->mybooks_addkey, 'mybooks');
        unset_config('mybooks_addkey');
        unset_config('mybooks_directories');
        unset_config('mybooks_resizable');
        unset_config('mybooks_location');
        upgrade_block_savepoint(true, 2014111100, 'my_books');
    }
    if ($oldversion < 2015051900) {
        unset_config('resizable', 'mybooks');
        unset_config('directories', 'mybooks');
        unset_config('location', 'mybooks');
        $DB->set_field('rcontent', 'frame', 0, array('course' => SITEID));
        upgrade_block_savepoint(true, 2015051900, 'my_books');
    }
    if ($oldversion < 2015111700) {
        unset_config('status', 'mybooks');
        unset_config('toolbar', 'mybooks');
        unset_config('menubar', 'mybooks');
        unset_config('scrollbars', 'mybooks');
        unset_config('activity_opening', 'mybooks');
        unset_config('height', 'mybooks');
        unset_config('width', 'mybooks');
        $popupoptions = "scrollbars=1,menubar=0,toolbar=1,status=1,height=800,width=600";
        $DB->set_field('rcontent', 'popup', 0, array('course' => SITEID));
        $DB->set_field('rcontent', 'popup_options', $popupoptions, array('course' => SITEID));
        $DB->set_field('rcontent', 'width', 800, array('course' => SITEID));
        $DB->set_field('rcontent', 'height', 600, array('course' => SITEID));
        upgrade_block_savepoint(true, 2015111700, 'my_books');
    }
    return true;
}