• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP purge_all_caches函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中purge_all_caches函数的典型用法代码示例。如果您正苦于以下问题:PHP purge_all_caches函数的具体用法?PHP purge_all_caches怎么用?PHP purge_all_caches使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了purge_all_caches函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: xmldb_theme_campus_upgrade

/**
 * Campus theme with the underlying Bootstrap theme.
 *
 * @package    theme
 * @subpackage campus
 * @copyright  © 2014-onwards G J Barnard in respect to modifications of the Clean theme.
 * @copyright  © 2014-onwards Work undertaken for David Bogner of Edulabs.org.
 * @author     G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
 * @author     Based on code originally written by Mary Evans, Bas Brands, Stuart Lamour and David Scotson.
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_theme_campus_upgrade($oldversion = 0)
{
    // Automatic 'Purge all caches'....
    if ($oldversion < 2114121700) {
        purge_all_caches();
    }
    return true;
}
开发者ID:amsibsam,项目名称:moodle3,代码行数:19,代码来源:upgrade.php


示例2: set_marsupial_state

function set_marsupial_state($enable)
{
    global $DB;
    $DB->set_field('modules', 'visible', $enable, array('name' => 'rcontent'));
    $DB->set_field('block', 'visible', $enable, array('name' => 'my_books'));
    $DB->set_field('block', 'visible', $enable, array('name' => 'rgrade'));
    set_config('enabled', $enable, 'rcommon');
    purge_all_caches();
}
开发者ID:kevin-bruton,项目名称:marsupial,代码行数:9,代码来源:locallib.php


示例3: xmldb_block_course_message_upgrade

function xmldb_block_course_message_upgrade($oldversion = 0)
{
    global $DB;
    $dbman = $DB->get_manager();
    $result = true;
    // July 7, 2014 version added the carbon copy field.
    if ($oldversion < 2014070700) {
        $table = new xmldb_table('course_message_mails');
        $field = new xmldb_field('carboncopy', XMLDB_TYPE_TEXT, 'big', null, null, null, 'attachment');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Force cache purge.
        purge_all_caches();
        // Update savepoint.
        upgrade_block_savepoint(true, 2014062600, 'course_message');
    }
    return $result;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:19,代码来源:upgrade.php


示例4: before_scenario

    /**
     * Resets the test environment.
     *
     * @throws coding_exception If here we are not using the test database it should be because of a coding error
     * @BeforeScenario
     */
    public function before_scenario($event) {
        global $DB, $SESSION, $CFG;

        // As many checks as we can.
        if (!defined('BEHAT_TEST') ||
               !defined('BEHAT_SITE_RUNNING') ||
               php_sapi_name() != 'cli' ||
               !behat_util::is_test_mode_enabled() ||
               !behat_util::is_test_site()) {
            throw new coding_exception('Behat only can modify the test database and the test dataroot!');
        }

        $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests';
        $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo;
        try {
            $session = $this->getSession();
        } catch (CurlExec $e) {
            // Exception thrown by WebDriver, so only @javascript tests will be caugth; in
            // behat_util::is_server_running() we already checked that the server is running.
            throw new Exception($driverexceptionmsg);
        } catch (DriverException $e) {
            throw new Exception($driverexceptionmsg);
        } catch (UnknownError $e) {
            // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions.
            $this->throw_unknown_exception($e);
        }


        // We need the Mink session to do it and we do it only before the first scenario.
        if (self::is_first_scenario()) {
            behat_selectors::register_moodle_selectors($session);
        }

        // Reset $SESSION.
        $_SESSION = array();
        $SESSION = new stdClass();
        $_SESSION['SESSION'] =& $SESSION;

        behat_util::reset_database();
        behat_util::reset_dataroot();

        purge_all_caches();
        accesslib_clear_all_caches(true);

        // Reset the nasty strings list used during the last test.
        nasty_strings::reset_used_strings();

        // Assign valid data to admin user (some generator-related code needs a valid user).
        $user = $DB->get_record('user', array('username' => 'admin'));
        \core\session\manager::set_user($user);

        // Reset the browser if specified in config.php.
        if (!empty($CFG->behat_restart_browser_after) && $this->running_javascript()) {
            $now = time();
            if (self::$lastbrowsersessionstart + $CFG->behat_restart_browser_after < $now) {
                $session->restart();
                self::$lastbrowsersessionstart = $now;
            }
        }

        // Start always in the the homepage.
        try {
            // Let's be conservative as we never know when new upstream issues will affect us.
            $session->visit($this->locate_path('/'));
        } catch (UnknownError $e) {
            $this->throw_unknown_exception($e);
        }


        // Checking that the root path is a Moodle test site.
        if (self::is_first_scenario()) {
            $notestsiteexception = new Exception('The base URL (' . $CFG->wwwroot . ') is not a behat test site, ' .
                'ensure you started the built-in web server in the correct directory or your web server is correctly started and set up');
            $this->find("xpath", "//head/child::title[normalize-space(.)='" . behat_util::BEHATSITENAME . "']", $notestsiteexception);

            self::$initprocessesfinished = true;
        }

    }
开发者ID:rwijaya,项目名称:moodle,代码行数:85,代码来源:behat_hooks.php


示例5: uninstall_plugin


//.........这里部分代码省略.........
        if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
            require_once $CFG->dirroot . '/mod/' . $module->name . '/lib.php';
            $uninstallfunction = $module->name . '_uninstall';
            if (function_exists($uninstallfunction)) {
                debugging("{$uninstallfunction}() has been deprecated. Use the plugin's db/uninstall.php instead", DEBUG_DEVELOPER);
                if (!$uninstallfunction()) {
                    echo $OUTPUT->notification('Encountered a problem running uninstall function for ' . $module->name . '!');
                }
            }
        }
    } else {
        if ($type === 'enrol') {
            // NOTE: this is a bit brute force way - it will not trigger events and hooks properly
            // nuke all role assignments
            role_unassign_all(array('component' => $component));
            // purge participants
            $DB->delete_records_select('user_enrolments', "enrolid IN (SELECT id FROM {enrol} WHERE enrol = ?)", array($name));
            // purge enrol instances
            $DB->delete_records('enrol', array('enrol' => $name));
            // tweak enrol settings
            if (!empty($CFG->enrol_plugins_enabled)) {
                $enabledenrols = explode(',', $CFG->enrol_plugins_enabled);
                $enabledenrols = array_unique($enabledenrols);
                $enabledenrols = array_flip($enabledenrols);
                unset($enabledenrols[$name]);
                $enabledenrols = array_flip($enabledenrols);
                if (is_array($enabledenrols)) {
                    set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
                }
            }
        } else {
            if ($type === 'block') {
                if ($block = $DB->get_record('block', array('name' => $name))) {
                    // Inform block it's about to be deleted
                    if (file_exists("{$CFG->dirroot}/blocks/{$block->name}/block_{$block->name}.php")) {
                        $blockobject = block_instance($block->name);
                        if ($blockobject) {
                            $blockobject->before_delete();
                            //only if we can create instance, block might have been already removed
                        }
                    }
                    // First delete instances and related contexts
                    $instances = $DB->get_records('block_instances', array('blockname' => $block->name));
                    foreach ($instances as $instance) {
                        blocks_delete_instance($instance);
                    }
                    // Delete block
                    $DB->delete_records('block', array('id' => $block->id));
                }
            } else {
                if ($type === 'format') {
                    if (($defaultformat = get_config('moodlecourse', 'format')) && $defaultformat !== $name) {
                        $courses = $DB->get_records('course', array('format' => $name), 'id');
                        $data = (object) array('id' => null, 'format' => $defaultformat);
                        foreach ($courses as $record) {
                            $data->id = $record->id;
                            update_course($data);
                        }
                    }
                    $DB->delete_records('course_format_options', array('format' => $name));
                }
            }
        }
    }
    // perform clean-up task common for all the plugin/subplugin types
    //delete the web service functions and pre-built services
    require_once $CFG->dirroot . '/lib/externallib.php';
    external_delete_descriptions($component);
    // delete calendar events
    $DB->delete_records('event', array('modulename' => $pluginname));
    // delete all the logs
    $DB->delete_records('log', array('module' => $pluginname));
    // delete log_display information
    $DB->delete_records('log_display', array('component' => $component));
    // delete the module configuration records
    unset_all_config_for_plugin($pluginname);
    // delete message provider
    message_provider_uninstall($component);
    // delete message processor
    if ($type === 'message') {
        message_processor_uninstall($name);
    }
    // delete the plugin tables
    $xmldbfilepath = $plugindirectory . '/db/install.xml';
    drop_plugin_tables($component, $xmldbfilepath, false);
    if ($type === 'mod' or $type === 'block') {
        // non-frankenstyle table prefixes
        drop_plugin_tables($name, $xmldbfilepath, false);
    }
    // delete the capabilities that were defined by this module
    capabilities_cleanup($component);
    // remove event handlers and dequeue pending events
    events_uninstall($component);
    // Delete all remaining files in the filepool owned by the component.
    $fs = get_file_storage();
    $fs->delete_component_files($component);
    // Finally purge all caches.
    purge_all_caches();
    echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:101,代码来源:adminlib.php


示例6: before_scenario

    /**
     * Resets the test environment.
     *
     * @throws coding_exception If here we are not using the test database it should be because of a coding error
     * @BeforeScenario
     */
    public function before_scenario($event) {
        global $DB, $SESSION, $CFG;

        // As many checks as we can.
        if (!defined('BEHAT_TEST') ||
               !defined('BEHAT_SITE_RUNNING') ||
               php_sapi_name() != 'cli' ||
               !behat_util::is_test_mode_enabled() ||
               !behat_util::is_test_site()) {
            throw new coding_exception('Behat only can modify the test database and the test dataroot!');
        }

        // Avoid some notices / warnings.
        $SESSION = new stdClass();

        behat_util::reset_database();
        behat_util::reset_dataroot();

        purge_all_caches();
        accesslib_clear_all_caches(true);

        // Reset the nasty strings list used during the last test.
        nasty_strings::reset_used_strings();

        // Assing valid data to admin user (some generator-related code needs a valid user).
        $user = $DB->get_record('user', array('username' => 'admin'));
        session_set_user($user);

        // Start always in the the homepage.
        $this->getSession()->visit($this->locate_path('/'));
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:37,代码来源:behat_hooks.php


示例7: db_replace

/**
 * Moved from admin/replace.php so that we can use this in cron
 *
 * @param string $search string to look for
 * @param string $replace string to replace
 * @return bool success or fail
 */
function db_replace($search, $replace)
{
    global $DB, $CFG, $OUTPUT;
    // TODO: this is horrible hack, we should do whitelisting and each plugin should be responsible for proper replacing...
    $skiptables = array('config', 'config_plugins', 'config_log', 'upgrade_log', 'log', 'filter_config', 'sessions', 'events_queue', 'repository_instance_config', 'block_instances', '');
    // Turn off time limits, sometimes upgrades can be slow.
    core_php_time_limit::raise();
    if (!($tables = $DB->get_tables())) {
        // No tables yet at all.
        return false;
    }
    foreach ($tables as $table) {
        if (in_array($table, $skiptables)) {
            // Don't process these
            continue;
        }
        if ($columns = $DB->get_columns($table)) {
            $DB->set_debug(true);
            foreach ($columns as $column) {
                $DB->replace_all_text($table, $column, $search, $replace);
            }
            $DB->set_debug(false);
        }
    }
    // delete modinfo caches
    rebuild_course_cache(0, true);
    // TODO: we should ask all plugins to do the search&replace, for now let's do only blocks...
    $blocks = core_component::get_plugin_list('block');
    foreach ($blocks as $blockname => $fullblock) {
        if ($blockname === 'NEWBLOCK') {
            // Someone has unzipped the template, ignore it
            continue;
        }
        if (!is_readable($fullblock . '/lib.php')) {
            continue;
        }
        $function = 'block_' . $blockname . '_global_db_replace';
        include_once $fullblock . '/lib.php';
        if (!function_exists($function)) {
            continue;
        }
        echo $OUTPUT->notification("Replacing in {$blockname} blocks...", 'notifysuccess');
        $function($search, $replace);
        echo $OUTPUT->notification("...finished", 'notifysuccess');
    }
    purge_all_caches();
    return true;
}
开发者ID:Alexbado,项目名称:moodle2,代码行数:55,代码来源:adminlib.php


示例8: test_matching_cacherev

 public function test_matching_cacherev()
 {
     global $DB, $CFG;
     $this->resetAfterTest();
     $this->setAdminUser();
     $cache = cache::make('core', 'coursemodinfo');
     // Generate the course and pre-requisite module.
     $course = $this->getDataGenerator()->create_course(array('format' => 'topics', 'numsections' => 3), array('createsections' => true));
     // Make sure the cacherev is set.
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertGreaterThan(0, $cacherev);
     $prevcacherev = $cacherev;
     // Reset course cache and make sure cacherev is bumped up but cache is empty.
     rebuild_course_cache($course->id, true);
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertGreaterThan($prevcacherev, $cacherev);
     $this->assertEmpty($cache->get($course->id));
     $prevcacherev = $cacherev;
     // Build course cache. Cacherev should not change but cache is now not empty. Make sure cacherev is the same everywhere.
     $modinfo = get_fast_modinfo($course->id);
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertEquals($prevcacherev, $cacherev);
     $cachedvalue = $cache->get($course->id);
     $this->assertNotEmpty($cachedvalue);
     $this->assertEquals($cacherev, $cachedvalue->cacherev);
     $this->assertEquals($cacherev, $modinfo->get_course()->cacherev);
     $prevcacherev = $cacherev;
     // Little trick to check that cache is not rebuilt druing the next step - substitute the value in MUC and later check that it is still there.
     $cache->set($course->id, (object) array_merge((array) $cachedvalue, array('secretfield' => 1)));
     // Clear static cache and call get_fast_modinfo() again (pretend we are in another request). Cache should not be rebuilt.
     course_modinfo::clear_instance_cache();
     $modinfo = get_fast_modinfo($course->id);
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertEquals($prevcacherev, $cacherev);
     $cachedvalue = $cache->get($course->id);
     $this->assertNotEmpty($cachedvalue);
     $this->assertEquals($cacherev, $cachedvalue->cacherev);
     $this->assertNotEmpty($cachedvalue->secretfield);
     $this->assertEquals($cacherev, $modinfo->get_course()->cacherev);
     $prevcacherev = $cacherev;
     // Rebuild course cache. Cacherev must be incremented everywhere.
     rebuild_course_cache($course->id);
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertGreaterThan($prevcacherev, $cacherev);
     $cachedvalue = $cache->get($course->id);
     $this->assertNotEmpty($cachedvalue);
     $this->assertEquals($cacherev, $cachedvalue->cacherev);
     $modinfo = get_fast_modinfo($course->id);
     $this->assertEquals($cacherev, $modinfo->get_course()->cacherev);
     $prevcacherev = $cacherev;
     // Update cacherev in DB and make sure the cache will be rebuilt on the next call to get_fast_modinfo().
     increment_revision_number('course', 'cacherev', 'id = ?', array($course->id));
     // We need to clear static cache for course_modinfo instances too.
     course_modinfo::clear_instance_cache();
     $modinfo = get_fast_modinfo($course->id);
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertGreaterThan($prevcacherev, $cacherev);
     $cachedvalue = $cache->get($course->id);
     $this->assertNotEmpty($cachedvalue);
     $this->assertEquals($cacherev, $cachedvalue->cacherev);
     $this->assertEquals($cacherev, $modinfo->get_course()->cacherev);
     $prevcacherev = $cacherev;
     // Reset cache for all courses and make sure this course cache is reset.
     rebuild_course_cache(0, true);
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertGreaterThan($prevcacherev, $cacherev);
     $this->assertEmpty($cache->get($course->id));
     // Rebuild again.
     $modinfo = get_fast_modinfo($course->id);
     $cachedvalue = $cache->get($course->id);
     $this->assertNotEmpty($cachedvalue);
     $this->assertEquals($cacherev, $cachedvalue->cacherev);
     $this->assertEquals($cacherev, $modinfo->get_course()->cacherev);
     $prevcacherev = $cacherev;
     // Purge all caches and make sure cacherev is increased and data from MUC erased.
     purge_all_caches();
     $cacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
     $this->assertGreaterThan($prevcacherev, $cacherev);
     $this->assertEmpty($cache->get($course->id));
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:80,代码来源:modinfolib_test.php


示例9: test_update_reference_internal

 /**
  * Make sure that when internal file is updated all references to it are
  * updated immediately. When it is deleted, the references are converted
  * to true copies.
  */
 public function test_update_reference_internal()
 {
     purge_all_caches();
     $this->resetAfterTest(true);
     $user = $this->setup_three_private_files();
     $fs = get_file_storage();
     $repos = repository::get_instances(array('type' => 'user'));
     $repo = reset($repos);
     // Create two aliases linking the same original.
     $areafiles = array_values($fs->get_area_files($user->ctxid, 'user', 'private', false, 'filename', false));
     $originalfile = $areafiles[0];
     $this->assertInstanceOf('stored_file', $originalfile);
     $contenthash = $originalfile->get_contenthash();
     $filesize = $originalfile->get_filesize();
     $substitutefile = $areafiles[1];
     $this->assertInstanceOf('stored_file', $substitutefile);
     $newcontenthash = $substitutefile->get_contenthash();
     $newfilesize = $substitutefile->get_filesize();
     $originalrecord = array('contextid' => $originalfile->get_contextid(), 'component' => $originalfile->get_component(), 'filearea' => $originalfile->get_filearea(), 'itemid' => $originalfile->get_itemid(), 'filepath' => $originalfile->get_filepath(), 'filename' => $originalfile->get_filename());
     $aliasrecord = $this->generate_file_record();
     $aliasrecord->filepath = '/A/';
     $aliasrecord->filename = 'symlink.txt';
     $ref = $fs->pack_reference($originalrecord);
     $symlink1 = $fs->create_file_from_reference($aliasrecord, $repo->id, $ref);
     // Make sure created alias is a reference and has the same size and contenthash as source.
     $this->assertEquals($contenthash, $symlink1->get_contenthash());
     $this->assertEquals($filesize, $symlink1->get_filesize());
     $this->assertEquals($repo->id, $symlink1->get_repository_id());
     $this->assertNotEmpty($symlink1->get_referencefileid());
     $referenceid = $symlink1->get_referencefileid();
     $aliasrecord->filepath = '/B/';
     $aliasrecord->filename = 'symlink.txt';
     $ref = $fs->pack_reference($originalrecord);
     $symlink2 = $fs->create_file_from_reference($aliasrecord, $repo->id, $ref);
     // Make sure created alias is a reference and has the same size and contenthash as source.
     $this->assertEquals($contenthash, $symlink2->get_contenthash());
     $this->assertEquals($filesize, $symlink2->get_filesize());
     $this->assertEquals($repo->id, $symlink2->get_repository_id());
     // Make sure both aliases have the same reference id.
     $this->assertEquals($referenceid, $symlink2->get_referencefileid());
     // Overwrite ofiginal file.
     $originalfile->replace_file_with($substitutefile);
     $this->assertEquals($newcontenthash, $originalfile->get_contenthash());
     $this->assertEquals($newfilesize, $originalfile->get_filesize());
     // References to the internal files must be synchronised immediately.
     // Refetch A/symlink.txt file.
     $symlink1 = $fs->get_file($aliasrecord->contextid, $aliasrecord->component, $aliasrecord->filearea, $aliasrecord->itemid, '/A/', 'symlink.txt');
     $this->assertTrue($symlink1->is_external_file());
     $this->assertEquals($newcontenthash, $symlink1->get_contenthash());
     $this->assertEquals($newfilesize, $symlink1->get_filesize());
     $this->assertEquals($repo->id, $symlink1->get_repository_id());
     $this->assertEquals($referenceid, $symlink1->get_referencefileid());
     // Refetch B/symlink.txt file.
     $symlink2 = $fs->get_file($aliasrecord->contextid, $aliasrecord->component, $aliasrecord->filearea, $aliasrecord->itemid, '/B/', 'symlink.txt');
     $this->assertTrue($symlink2->is_external_file());
     $this->assertEquals($newcontenthash, $symlink2->get_contenthash());
     $this->assertEquals($newfilesize, $symlink2->get_filesize());
     $this->assertEquals($repo->id, $symlink2->get_repository_id());
     $this->assertEquals($referenceid, $symlink2->get_referencefileid());
     // Remove original file.
     $originalfile->delete();
     // References must be converted to independend files.
     // Refetch A/symlink.txt file.
     $symlink1 = $fs->get_file($aliasrecord->contextid, $aliasrecord->component, $aliasrecord->filearea, $aliasrecord->itemid, '/A/', 'symlink.txt');
     $this->assertFalse($symlink1->is_external_file());
     $this->assertEquals($newcontenthash, $symlink1->get_contenthash());
     $this->assertEquals($newfilesize, $symlink1->get_filesize());
     $this->assertNull($symlink1->get_repository_id());
     $this->assertNull($symlink1->get_referencefileid());
     // Refetch B/symlink.txt file.
     $symlink2 = $fs->get_file($aliasrecord->contextid, $aliasrecord->component, $aliasrecord->filearea, $aliasrecord->itemid, '/B/', 'symlink.txt');
     $this->assertFalse($symlink2->is_external_file());
     $this->assertEquals($newcontenthash, $symlink2->get_contenthash());
     $this->assertEquals($newfilesize, $symlink2->get_filesize());
     $this->assertNull($symlink2->get_repository_id());
     $this->assertNull($symlink2->get_referencefileid());
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:82,代码来源:file_storage_test.php


示例10: upgrade_core

/**
 * Upgrade moodle core
 * @param float $version target version
 * @param bool $verbose
 * @return void, may throw exception
 */
function upgrade_core($version, $verbose) {
    global $CFG;

    raise_memory_limit(MEMORY_EXTRA);

    require_once($CFG->libdir.'/db/upgrade.php');    // Defines upgrades

    try {
        // Reset caches before any output
        purge_all_caches();

        // Upgrade current language pack if we can
        upgrade_language_pack();

        print_upgrade_part_start('moodle', false, $verbose);

        // one time special local migration pre 2.0 upgrade script
        if ($CFG->version < 2007101600) {
            $pre20upgradefile = "$CFG->dirroot/local/upgrade_pre20.php";
            if (file_exists($pre20upgradefile)) {
                set_time_limit(0);
                require($pre20upgradefile);
                // reset upgrade timeout to default
                upgrade_set_timeout();
            }
        }

        $result = xmldb_main_upgrade($CFG->version);
        if ($version > $CFG->version) {
            // store version if not already there
            upgrade_main_savepoint($result, $version, false);
        }

        // perform all other component upgrade routines
        update_capabilities('moodle');
        log_update_descriptions('moodle');
        external_update_descriptions('moodle');
        events_update_definition('moodle');
        message_update_providers('moodle');

        // Reset caches again, just to be sure
        purge_all_caches();

        // Clean up contexts - more and more stuff depends on existence of paths and contexts
        context_helper::cleanup_instances();
        context_helper::create_instances(null, false);
        context_helper::build_all_paths(false);
        $syscontext = context_system::instance();
        $syscontext->mark_dirty();

        print_upgrade_part_end('moodle', false, $verbose);
    } catch (Exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:nicusX,项目名称:moodle,代码行数:61,代码来源:upgradelib.php


示例11: execute

 public function execute()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/lib.php';
     unset($CFG->passwordpolicy);
     $options = $this->expandedOptions;
     if ($options['all']) {
         //run on the whole mdl_user table
         $sql = "UPDATE {user} SET ";
         $sqlFragment = array();
         $parameters = array();
         //we want to use the options that were actually provided on the commandline
         if ($this->parsedOptions->has('password')) {
             $sqlFragment[] = 'password = ?';
             $parameters['password'] = md5($this->parsedOptions['password']->value);
         }
         if ($this->parsedOptions->has('email')) {
             $sqlFragment[] = 'email = ?';
             $parameters['email'] = $this->parsedOptions['email']->value;
         }
         if ($this->parsedOptions->has('auth')) {
             $sqlFragment[] = 'auth = ?';
             $parameters['auth'] = $this->parsedOptions['auth']->value;
         }
         if (count($sqlFragment) == 0) {
             cli_error('You need to provide at least one option for updating a profile field (password or email)');
         }
         $sql .= implode(' , ', $sqlFragment);
         $DB->execute($sql, $parameters);
         exit(0);
     }
     foreach ($this->arguments as $argument) {
         if ($options['id']) {
             $user = $DB->get_record('user', array('id' => $argument));
         } else {
             $user = $DB->get_record('user', array('username' => $argument));
         }
         if (!$user) {
             cli_problem("User '{$argument}' not found'");
             continue;
         }
         if ($this->parsedOptions->has('password')) {
             $user->password = md5($this->parsedOptions['password']->value);
         }
         if ($this->parsedOptions->has('email')) {
             $user->email = $this->parsedOptions['email']->value;
         }
         if ($this->parsedOptions->has('auth')) {
             $user->auth = $this->parsedOptions['auth']->value;
         }
         if ($this->parsedOptions->has('global')) {
             foreach (explode(',', $CFG->siteadmins) as $admin) {
                 $admin = (int) $admin;
                 if ($admin) {
                     $admins[$admin] = $admin;
                 }
             }
             if (!isset($admins[$user->id])) {
                 $admins[$user->id] = $user->id;
             }
             set_config('siteadmins', implode(',', $admins));
             purge_all_caches();
         }
         echo $DB->update_record('user', $user) . "\n";
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:66,代码来源:UserMod.php


示例12: upgrade_core

/**
 * Upgrade moodle core
 * @param float $version target version
 * @param bool $verbose
 * @return void, may throw exception
 */
function upgrade_core($version, $verbose)
{
    global $CFG, $SITE, $DB, $COURSE;
    raise_memory_limit(MEMORY_EXTRA);
    require_once $CFG->libdir . '/db/upgrade.php';
    // Defines upgrades
    try {
        // Reset caches before any output
        purge_all_caches();
        cache_helper::purge_all(true);
        // Upgrade current language pack if we can
        upgrade_language_pack();
        print_upgrade_part_start('moodle', false, $verbose);
        // Pre-upgrade scripts for local hack workarounds.
        $preupgradefile = "{$CFG->dirroot}/local/preupgrade.php";
        if (file_exists($preupgradefile)) {
            set_time_limit(0);
            require $preupgradefile;
            // Reset upgrade timeout to default.
            upgrade_set_timeout();
        }
        $result = xmldb_main_upgrade($CFG->version);
        if ($version > $CFG->version) {
            // store version if not already there
            upgrade_main_savepoint($result, $version, false);
        }
        // In case structure of 'course' table has been changed and we forgot to update $SITE, re-read it from db.
        $SITE = $DB->get_record('course', array('id' => $SITE->id));
        $COURSE = clone $SITE;
        // perform all other component upgrade routines
        update_capabilities('moodle');
        log_update_descriptions('moodle');
        external_update_descriptions('moodle');
        events_update_definition('moodle');
        message_update_providers('moodle');
        // Update core definitions.
        cache_helper::update_definitions(true);
        // Purge caches again, just to be sure we arn't holding onto old stuff now.
        purge_all_caches();
        cache_helper::purge_all(true);
        // Clean up contexts - more and more stuff depends on existence of paths and contexts
        context_helper::cleanup_instances();
        context_helper::create_instances(null, false);
        context_helper::build_all_paths(false);
        $syscontext = context_system::instance();
        $syscontext->mark_dirty();
        print_upgrade_part_end('moodle', false, $verbose);
    } catch (Exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:57,代码来源:upgradelib.php


示例13: upgrade_core

/**
 * Upgrade moodle core
 * @param float $version target version
 * @param bool $verbose
 * @return void, may throw exception
 */
function upgrade_core($version, $verbose)
{
    global $CFG;
    raise_memory_limit(MEMORY_EXTRA);
    require_once $CFG->libdir . '/db/upgrade.php';
    // Defines upgrades
    try {
        // Reset caches before any output
        purge_all_caches();
        // Disable the use of cache stores here. We will reset the factory after we've performed the installation.
        // This ensures that we don't permanently cache anything during installation.
        cache_factory::disable_stores();
        // Upgrade current language pack if we can
        upgrade_language_pack();
        print_upgrade_part_start('moodle', false, $verbose);
        // one time special local migration pre 2.0 upgrade script
        if ($CFG->version < 2007101600) {
            $pre20upgradefile = "{$CFG->dirroot}/local/upgrade_pre20.php";
            if (file_exists($pre20upgradefile)) {
                set_time_limit(0);
                require $pre20upgradefile;
                // reset upgrade timeout to default
                upgrade_set_timeout();
            }
        }
        $result = xmldb_main_upgrade($CFG->version);
        if ($version > $CFG->version) {
            // store version if not already there
            upgrade_main_savepoint($result, $version, false);
        }
        // perform all other component upgrade routines
        update_capabilities('moodle');
        log_update_descriptions('moodle');
        external_update_descriptions('moodle');
        events_update_definition('moodle');
        message_update_providers('moodle');
        // Update core definitions.
        cache_helper::update_definitions(true);
        // Reset the cache, this returns it to a normal operation state.
        cache_factory::reset();
        // Purge caches again, just to be sure we arn't holding onto old stuff now.
        purge_all_caches();
        // Clean up contexts - more and more stuff depends on existence of paths and contexts
        context_helper::cleanup_instances();
        context_helper::create_instances(null, false);
        context_helper::build_all_paths(false);
        $syscontext = context_system::instance();
        $syscontext->mark_dirty();
        print_upgrade_part_end('moodle', false, $verbose);
    } catch (Exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:59,代码来源:upgradelib.php


示例14: xmldb_format_grid_upgrade

function xmldb_format_grid_upgrade($oldversion = 0)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011041802) {
        // Define table course_grid_summary to be created.
        $table = new xmldb_table('course_grid_summary');
        // Adding fields to table course_grid_summary.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
        $table->add_field('show_summary', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0', null);
        $table->add_field('course_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
        // Adding keys to table course_grid_summary.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Launch create table for course_grid_summary.
        $dbman->create_table($table);
        upgrade_plugin_savepoint(true, '2011041802', 'format', 'grid');
    }
    if ($oldversion < 2012011701) {
        // Rename the tables.
        if ($dbman->table_exists('course_grid_icon')) {
            $table = new xmldb_table('course_grid_icon');
            if (!$dbman->table_exists('format_grid_icon')) {
                $dbman->rename_table($table, 'format_grid_icon');
            } else {
                // May as well tidy up the db.
                $dbman->drop_table($table);
            }
        }
        if ($dbman->table_exists('course_grid_summary')) {
            $table = new xmldb_table('course_grid_summary');
            if (!$dbman->table_exists('format_grid_summary')) {
                $dbman->rename_table($table, 'format_grid_summary');
            } else {
                // May as well tidy up the db.
                $dbman->drop_table($table);
            }
        }
        upgrade_plugin_savepoint(true, '2012011701', 'format', 'grid');
    }
    if ($oldversion < 2012071500) {
        $table = new xmldb_table('format_grid_summary');
        $field = new xmldb_field('course_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        // Rename course_id.
        $dbman->rename_field($table, $field, 'courseid');
        $field = new xmldb_field('show_summary', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
        // Rename show_summary.
        $dbman->rename_field($table, $field, 'showsummary');
        // Add fields and change to unsigned.
        $table = new xmldb_table('format_grid_icon');
        $field = new xmldb_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '1', 'sectionid');
        // Conditionally launch add field courseid.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_plugin_savepoint(true, '2012071500', 'format', 'grid');
    }
    if ($oldversion < 2013110400) {
        $table = new xmldb_table('format_grid_icon');
        $field = new xmldb_field('imagepath', XMLDB_TYPE_TEXT, null, null, null, null, null);
        // Rename imagepath.
        $dbman->rename_field($table, $field, 'image');
        $field = new xmldb_field('displayedimageindex', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        // Conditionally launch add field displayediconpath.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_plugin_savepoint(true, '2013110400', 'format', 'grid');
    }
    // Automatic 'Purge all caches'....
    if ($oldversion < 2114052000) {
        purge_all_caches();
    }
    return true;
}
开发者ID:Keneth1212,项目名称:moodle,代码行数:74,代码来源:upgrade.php


示例15: deployment_execute

 /**
  * Flavours deployment
  *
  * Executes the deployment delegating to the specific ingredient types managers, it
  * opens the flavour compressed file to extract the data and cleans the flavour temp
  * directory when finishes
  */
 public function deployment_execute()
 {
     global $CFG;
     $outputs = array();
     // Deployment results
     $errorredirect = $this->url . '?action=deployment_upload&sesskey=' . sesskey();
     $form = new flavours_deployment_form($this->url);
     if (!($formdata = $form->get_data())) {
         $this->unlink($flavourpath);
         redirect($errorredirect, get_string('reselect', 'local_flavours'), 2);
     }
     // Flavour contents
     $flavourpath = $CFG->dataroot . '/temp/' . $formdata->flavourhash;
     $flavourfilename = $flavourpath . '/flavour.zip';
     // Getting the ingredients to deploy
     if (!($flavouringredients = $this->get_ingredients_from_form())) {
         $this->unlink($flavourpath);
         redirect($errorredirect, get_string('reselect', 'local_flavours'), 2);
     }
     // Getting zip contents
     if (!unzip_file($flavourfilename, $flavourpath, false)) {
         print_error('errorcantunzip', 'local_flavours');
     }
     $flavourzip = new ZipArchive();
     if (!$flavourzip->open($flavourfilename, 0)) {
         $this->unlink($flavourpath);
         redirect($errorredirect, get_string('errordeployflavour', 'local_flavours'), 4);
     }
     // Getting the flavour xml which describes the flavour contents
     $xml = $this->get_flavour_xml($flavourzip);
     // Deploying ingredients when possible
     foreach ($flavouringredients as $type => $ingredientstodeploy) {
         $this->ingredients[$type] = $this->instance_ingredient_type($type);
         // Ingredient type filesystem
         $ingredienttypepath = $flavourpath . '/flavour/' . $type;
         if (!file_exists($ingredienttypepath)) {
             $ingredienttypepath = false;
         }
         // Deploying ingredients and storing the problems encountered to give feedback
         $xmldata = $xml->ingredient[0]->{$type};
         $outputs[$type] = $this->ingredients[$type]->deploy_ingredients($ingredientstodeploy, $ingredienttypepath, $xmldata);
         // Prepare to display deployment results
         foreach ($ingredientstodeploy as $ingredientname => $ingredientdata) {
             // Then success
             if (empty($outputs[$type][$ingredientname])) {
                 $outputs[$type][$ingredientname] = true;
             }
         }
     }
     // Output results
     $table = new html_table();
     $table->attributes['class'] = 'generaltable boxaligncenter';
     $table->align = array('left', 'left', 'center');
     $table->head = array(get_string('ingredienttype', 'local_flavours'), get_string('ingredient', 'local_flavours'), get_string('deploymentresult', 'local_flavours'));
     // Fill the table
     foreach ($outputs as $type => $ingredients) {
         foreach ($ingredients as $ingredientname => $outputs) {
             // Success
             if (is_bool($outputs)) {
                 $feedback = get_string('success');
                 $classname = 'notifysuccess';
             } else {
                 $feedback = $this->get_restrictions_string($outputs);
                 $classname = 'notifyproblem';
             }
             $feedback = '<span class="' . $classname . '">' . $feedback . '</span>';
             $table->data[] = array($this->ingredients[$type]->name, $ingredientname, $feedback);
         }
     }
     // Will be printed on the renderer
     $this->renderable = new flavours_renderable_deployment_execute($table);
     // Finishing
     $this->unlink($flavourpath);
     purge_all_caches();
 }
开发者ID:forloops,项目名称:moodle-local_flavours,代码行数:82,代码来源:flavours_deployment.class.php


示例16: mnetadmin_rpc_purge_caches

/**
 * Purge internally all caches.
 * @param object $user The calling user, containing mnethostroot reference and hostroot reference.
 */
function mnetadmin_rpc_purge_caches($user, $json_ 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP purify函数代码示例发布时间:2022-05-15
下一篇:
PHP purge函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap