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

PHP events_update_definition函数代码示例

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

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



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

示例1: test_events_update_definition__update

 /**
  * Tests the update of event handlers from file.
  */
 public function test_events_update_definition__update()
 {
     global $DB;
     // First modify directly existing handler.
     $handler = $DB->get_record('events_handlers', array('component' => 'unittest', 'eventname' => 'test_instant'));
     $original = $handler->handlerfunction;
     // Change handler in db.
     $DB->set_field('events_handlers', 'handlerfunction', serialize('some_other_function_handler'), array('id' => $handler->id));
     // Update the definition, it should revert the handler back.
     events_update_definition('unittest');
     $handler = $DB->get_record('events_handlers', array('component' => 'unittest', 'eventname' => 'test_instant'));
     $this->assertSame($handler->handlerfunction, $original, 'update should sync db with file definition: %s');
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:16,代码来源:eventslib_test.php


示例2: upgrade_blocks_plugins


//.........这里部分代码省略.........
                    if ($oldupgrade && function_exists($oldupgrade_function)) {
                        $db->debug = true;
                        $oldupgrade_status = $oldupgrade_function($currblock->version, $block);
                    } else {
                        if ($oldupgrade) {
                            notify('Upgrade function ' . $oldupgrade_function . ' was not available in ' . $fullblock . '/db/' . $CFG->dbtype . '.php');
                        }
                    }
                    /// Then, the new function if exists and the old one was ok
                    $newupgrade_status = true;
                    if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) {
                        $db->debug = true;
                        $newupgrade_status = $newupgrade_function($currblock->version, $block);
                    } else {
                        if ($newupgrade) {
                            notify('Upgrade function ' . $newupgrade_function . ' was not available in ' . $fullblock . '/db/upgrade.php');
                        }
                    }
                    $db->debug = false;
                    /// Now analyze upgrade results
                    if ($oldupgrade_status && $newupgrade_status) {
                        // No upgrading failed
                        // Set the block cron on upgrade
                        $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
                        // OK so far, now update the block record
                        $block->id = $currblock->id;
                        if (!update_record('block', $block)) {
                            error('Could not update block ' . $block->name . ' record in block table!');
                        }
                        $component = 'block/' . $block->name;
                        if (!update_capabilities($component)) {
                            error('Could not update ' . $block->name . ' capabilities!');
                        }
                        events_update_definition($component);
                        notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
                    } else {
                        notify('Upgrading block ' . $block->name . ' from ' . $currblock->version . ' to ' . $block->version . ' FAILED!');
                    }
                    echo '<hr />';
                } else {
                    upgrade_log_start();
                    error('Version mismatch: block ' . $block->name . ' can\'t downgrade ' . $currblock->version . ' -> ' . $block->version . '!');
                }
            }
        } else {
            // block not installed yet, so install it
            // If it allows multiples, start with it enabled
            if ($blockobj->instance_allow_multiple()) {
                $block->multiple = 1;
            }
            // Set the block cron on install
            $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
            // [pj] Normally this would be inline in the if, but we need to
            //      check for NULL (necessary for 4.0.5 <= PHP < 4.2.0)
            $conflictblock = array_search($blocktitle, $blocktitles);
            if ($conflictblock !== false && $conflictblock !== NULL) {
                // Duplicate block titles are not allowed, they confuse people
                // AND PHP's associative arrays ;)
                error('<strong>Naming conflict</strong>: block <strong>' . $block->name . '</strong> has the same title with an existing block, <strong>' . $conflictblock . '</strong>!');
            }
            if (empty($updated_blocks)) {
                $strblocksetup = get_string('blocksetup');
                print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
            }
            $updated_blocks = true;
            upgrade_log_start();
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:67,代码来源:blocklib.php


示例3: 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.
        cache_helper::purge_all(true);
        purge_all_caches();

        // 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)) {
            core_php_time_limit::raise();
            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');
        \core\task\manager::reset_scheduled_tasks_for_component('moodle');
        message_update_providers('moodle');
        \core\message\inbound\manager::update_handlers_for_component('moodle');
        // Update core definitions.
        cache_helper::update_definitions(true);

        // Purge caches again, just to be sure we arn't holding onto old stuff now.
        cache_helper::purge_all(true);
        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:jtibbetts,项目名称:moodle,代码行数:69,代码来源:upgradelib.php


示例4: upgrade_local_db

/**
 * This function checks to see whether local database customisations are up-to-date
 * by comparing $CFG->local_version to the variable $local_version defined in
 * local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
 * in a file called 'local/db/upgrade.php', and if it's there calls it with the
 * appropiate $oldversion parameter. Then it updates $CFG->local_version.
 * On success it prints a continue link. On failure it prints an error.
 *
 * @uses $CFG
 * @uses $db to do something really evil with the debug setting that should probably be eliminated. TODO!
 * @param string $continueto a URL passed to print_continue() if the local upgrades succeed.
 */
function upgrade_local_db($continueto)
{
    global $CFG, $db;
    // if we don't have code version or a db upgrade file, just return true, we're unneeded
    if (!file_exists($CFG->dirroot . '/local/version.php') || !file_exists($CFG->dirroot . '/local/db/upgrade.php')) {
        return true;
    }
    require_once $CFG->dirroot . '/local/version.php';
    // Get code versions
    if (empty($CFG->local_version)) {
        // normally we'd install, but just replay all the upgrades.
        $CFG->local_version = 0;
    }
    if ($local_version > $CFG->local_version) {
        // upgrade!
        $strdatabaseupgrades = get_string('databaseupgrades');
        print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript());
        upgrade_log_start();
        require_once $CFG->dirroot . '/local/db/upgrade.php';
        $db->debug = true;
        if (xmldb_local_upgrade($CFG->local_version)) {
            $db->debug = false;
            if (set_config('local_version', $local_version)) {
                notify(get_string('databasesuccess'), 'notifysuccess');
                notify(get_string('databaseupgradelocal', '', $local_version), 'notifysuccess');
                print_continue($continueto);
                print_footer('none');
                exit;
            } else {
                error('Upgrade of local database customisations failed! (Could not update version in config table)');
            }
        } else {
            $db->debug = false;
            error('Upgrade failed!  See local/version.php');
        }
    } else {
        if ($local_version < $CFG->local_version) {
            upgrade_log_start();
            notify('WARNING!!!  The local version you are using is OLDER than the version that made these databases!');
        }
    }
    /// Capabilities
    if (!update_capabilities('local')) {
        error('Could not set up the capabilities for local!');
    }
    if (!events_update_definition('local')) {
        error('Could not set up the events definitions for local!');
    }
    upgrade_log_finish();
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:62,代码来源:locallib.php


示例5: test_legacy

 public function test_legacy()
 {
     global $DB;
     $this->resetAfterTest(true);
     $observers = array(array('eventname' => '\\core_tests\\event\\unittest_executed', 'callback' => '\\core_tests\\event\\unittest_observer::observe_one'), array('eventname' => '*', 'callback' => '\\core_tests\\event\\unittest_observer::observe_all', 'includefile' => null, 'internal' => 1, 'priority' => 9999));
     $DB->delete_records('log', array());
     events_update_definition('unittest');
     $DB->delete_records_select('events_handlers', "component <> 'unittest'");
     events_get_handlers('reset');
     $this->assertEquals(3, $DB->count_records('events_handlers'));
     set_config('loglifetime', 60 * 60 * 24 * 5);
     \core\event\manager::phpunit_replace_observers($observers);
     \core_tests\event\unittest_observer::reset();
     $event1 = \core_tests\event\unittest_executed::create(array('courseid' => 1, 'context' => \context_system::instance(), 'other' => array('sample' => 5, 'xx' => 10)));
     $event1->trigger();
     $event2 = \core_tests\event\unittest_executed::create(array('courseid' => 2, 'context' => \context_system::instance(), 'other' => array('sample' => 6, 'xx' => 11)));
     $event2->nest = true;
     $event2->trigger();
     $this->assertSame(array('observe_all-1', 'observe_one-1', 'legacy_handler-1', 'observe_all-nesting-2', 'legacy_handler-3', 'observe_one-2', 'observe_all-3', 'observe_one-3', 'legacy_handler-2'), \core_tests\event\unittest_observer::$info);
     $this->assertSame($event1, \core_tests\event\unittest_observer::$event[0]);
     $this->assertSame($event1, \core_tests\event\unittest_observer::$event[1]);
     $this->assertSame(array(1, 5), \core_tests\event\unittest_observer::$event[2]);
     $logs = $DB->get_records('log', array(), 'id ASC');
     $this->assertCount(3, $logs);
     $log = array_shift($logs);
     $this->assertEquals(1, $log->course);
     $this->assertSame('core_unittest', $log->module);
     $this->assertSame('view', $log->action);
     $log = array_shift($logs);
     $this->assertEquals(2, $log->course);
     $this->assertSame('core_unittest', $log->module);
     $this->assertSame('view', $log->action);
     $log = array_shift($logs);
     $this->assertEquals(3, $log->course);
     $this->assertSame('core_unittest', $log->module);
     $this->assertSame('view', $log->action);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:37,代码来源:event_test.php


示例6: moodle_install_roles

 }
 $db->debug = false;
 /// If successful, continue upgrading roles and setting everything properly
 if ($status) {
     if (empty($CFG->rolesactive)) {
         /// Groups upgrade is now in core above.
         // Upgrade to the roles system.
         moodle_install_roles();
         set_config('rolesactive', 1);
     } else {
         if (!update_capabilities()) {
             error('Had trouble upgrading the core capabilities for the Roles System');
         }
     }
     // update core events
     events_update_definition();
     require_once $CFG->libdir . '/statslib.php';
     if (!stats_upgrade_for_roles_wrapper()) {
         notify('Couldn\'t upgrade the stats tables to use the new roles system');
     }
     if (set_config("version", $version)) {
         remove_dir($CFG->dataroot . '/cache', true);
         // flush cache
         notify($strdatabasesuccess, "green");
         print_continue("upgradesettings.php");
         print_footer('none');
         exit;
     } else {
         error('Upgrade failed!  (Could not update version in config table)');
     }
     /// Main upgrade not success
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:index.php


示例7: 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.
        cache_helper::purge_all(true);
        purge_all_caches();
        // 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)) {
            core_php_time_limit::raise();
            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);
        }
        // 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.
        cache_helper::purge_all(true);
        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:covex-nn,项目名称:moodle,代码行数:54,代码来源:upgradelib.php


示例8: test_events_trigger_debugging

 /**
  * Tests events_trigger() function.
  */
 public function test_events_trigger_debugging()
 {
     events_update_definition('unittest');
     $this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER);
     $this->assertEquals(0, events_trigger('test_instant', 'ok'));
     $debugmessages = array('events_trigger() is deprecated, please use new events instead', self::DEBUGGING_MSG);
     $this->assertDebuggingCalledCount(2, $debugmessages, array(DEBUG_DEVELOPER, DEBUG_DEVELOPER));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:eventslib_test.php


示例9: 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;
    require_once $CFG->libdir . '/db/upgrade.php';
    // Defines upgrades
    try {
        // Upgrade current language pack if we can
        if (empty($CFG->skiplangupgrade)) {
            upgrade_language_pack(false);
        }
        print_upgrade_part_start('moodle', false, $verbose);
        // one time special local migration pre 2.0 upgrade script
        if ($version < 2007101600) {
            $pre20upgradefile = "{$CFG->dirrot}/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');
        events_update_definition('moodle');
        message_update_providers('moodle');
        remove_dir($CFG->dataroot . '/cache', true);
        // flush cache
        print_upgrade_part_end('moodle', false, $verbose);
    } catch (Exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:43,代码来源:upgradelib.php


示例10: test_legacy

 public function test_legacy()
 {
     global $DB, $CFG;
     $this->resetAfterTest(true);
     $observers = array(array('eventname' => '\\core_tests\\event\\unittest_executed', 'callback' => '\\core_tests\\event\\unittest_observer::observe_one'), array('eventname' => '*', 'callback' => '\\core_tests\\event\\unittest_observer::observe_all', 'includefile' => null, 'internal' => 1, 'priority' => 9999));
     $DB->delete_records('log', array());
     events_update_definition('unittest');
     $this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER);
     $DB->delete_records_select('events_handlers', "component <> 'unittest'");
     events_get_handlers('reset');
     $this->assertEquals(3, $DB->count_records('events_handlers'));
     set_config('loglifetime', 60 * 60 * 24 * 5);
     \core\event\manager::phpunit_replace_observers($observers);
     \core_tests\event\unittest_observer::reset();
     $event1 = \core_tests\event\unittest_executed::create(array('context' => \context_system::instance(), 'other' => array('sample' => 5, 'xx' => 10)));
     $event1->trigger();
     $this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER);
     $event2 = \core_tests\event\unittest_executed::create(array('context' => \context_system::instance(), 'other' => array('sample' => 6, 'xx' => 11)));
     $event2->nest = true;
     $event2->trigger();
     $this->assertDebuggingCalledCount(2, array(self::DEBUGGING_MSG, self::DEBUGGING_MSG), array(DEBUG_DEVELOPER, DEBUG_DEVELOPER));
     $this->assertSame(array('observe_all-5', 'observe_one-5', 'legacy_handler-0', 'observe_all-nesting-6', 'legacy_handler-0', 'observe_one-6', 'observe_all-666', 'observe_one-666', 'legacy_handler-0'), \core_tests\event\unittest_observer::$info);
     $this->assertSame($event1, \core_tests\event\unittest_observer::$event[0]);
     $this->assertSame($event1, \core_tests\event\unittest_observer::$event[1]);
     $this->assertSame(array(0, 5), \core_tests\event\unittest_observer::$event[2]);
     $logs = $DB->get_records('log', array(), 'id ASC');
     $this->assertCount(0, $logs);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:28,代码来源:event_test.php


示例11: upgrade_language_pack

        } else {
            /// Launch main upgrade
            try {
                // Upgrade current language pack if we can
                if (empty($CFG->skiplangupgrade)) {
                    upgrade_language_pack(false);
                }
                print_upgrade_part_start('moodle', false);
                $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');
                events_update_definition('moodle');
                message_update_providers('moodle');
                message_update_providers('message');
                remove_dir($CFG->dataroot . '/cache', true);
                // flush cache
                print_upgrade_part_end('moodle', false);
            } catch (Exception $ex) {
                upgrade_handle_exception($ex);
            }
        }
    }
} else {
    if ($version < $CFG->version) {
        notify("WARNING!!!  The code you are using is OLDER than the version that made these databases!");
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:index.php


示例12: vmoodle_upgrade_subplugins_modules

/**
 * Find and check all submodules and load them up or upgrade them if necessary
 *
 * @global object
 * @global object
 */
function vmoodle_upgrade_subplugins_modules($startcallback, $endcallback, $verbose = true)
{
    global $CFG, $DB;
    include $CFG->dirroot . '/local/vmoodle/db/subplugins.php';
    foreach ($subplugins as $type => $subpluginpath) {
        $plugindirs = glob($CFG->dirroot . '/' . $subpluginpath . '/*');
        foreach ($plugindirs as $dir) {
            $plug = basename($dir);
            $fullplug = $dir;
            if ($plug === 'CVS') {
                // Someone has unzipped the template, ignore it.
                continue;
            }
            if ($plug === 'NEWMODULE') {
                // Someone has unzipped the template, ignore it.
                continue;
            }
            // Reset time so that it works when installing a large number of plugins.
            set_time_limit(600);
            $component = clean_param($type . '_' . $plug, PARAM_COMPONENT);
            // standardised plugin name
            // Check plugin dir is valid name.
            if (empty($component)) {
                throw new plugin_defective_exception($type . '_' . $plug, 'Invalid plugin directory name.');
            }
            if (!is_readable($fullplug . '/version.php')) {
                continue;
            }
            $plugin = new stdClass();
            require $fullplug . '/version.php';
            // Defines $plugin with version etc.
            // If plugin tells us it's full name we may check the location.
            if (isset($plugin->component)) {
                if ($plugin->component !== $component) {
                    throw new plugin_defective_exception($component, 'Plugin installed in wrong folder.');
                }
            }
            if (empty($plugin->version)) {
                throw new plugin_defective_exception($component, 'Missing version value in version.php');
            }
            $plugin->name = $plug;
            $plugin->fullname = $component;
            if (!empty($plugin->requires)) {
                if ($plugin->requires > $CFG->version) {
                    throw new upgrade_requires_exception($component, $plugin->version, $CFG->version, $plugin->requires);
                } else {
                    if ($plugin->requires < 2010000000) {
                        throw new plugin_defective_exception($component, 'Plugin is not compatible with Moodle 2.x or later.');
                    }
                }
            }
            // Try to recover from interrupted install.php if needed.
            if (file_exists($fullplug . '/db/install.php')) {
                if (get_config($plugin->fullname, 'installrunning')) {
                    require_once $fullplug . '/db/install.php';
                    $recover_install_function = 'xmldb_' . $plugin->fullname . '_install_recovery';
                    if (function_exists($recover_install_function)) {
                        $startcallback($component, true, $verbose);
                        $recover_install_function();
                        unset_config('installrunning', $plugin->fullname);
                        update_capabilities($component);
                        log_update_descriptions($component);
                        external_update_descriptions($component);
                        events_update_definition($component);
                        message_update_providers($component);
                        if ($type === 'message') {
                            message_update_processors($plug);
                        }
                        vmoodle_upgrade_plugin_mnet_functions($component, $fullplug);
                        // Fix wrongly twicked paths.
                        if ($rpc_shifted_defines = $DB->get_records_select('mnet_rpc', " xmlrpcpath LIKE 'vmoodleadminset' ", array())) {
                            foreach ($rpc_shifted_defines as $rpc) {
                                $rpc->xmlrpcpath = str_replace('vmoocleadminset', 'local/vmoodle/plugins');
                                $DB->update_record('mnet_rpc', $rpc);
                            }
                        }
                        $endcallback($component, true, $verbose);
                    }
                }
            }
            $installedversion = get_config($plugin->fullname, 'version');
            if (empty($installedversion)) {
                // New installation.
                $startcallback($component, true, $verbose);
                // Install tables if defined.
                if (file_exists($fullplug . '/db/install.xml')) {
                    $DB->get_manager()->install_from_xmldb_file($fullplug . '/db/install.xml');
                }
                // Store version.
                upgrade_plugin_savepoint(true, $plugin->version, $type, $plug, false);
                // Execute post install file.
                if (file_exists($fullplug . '/db/install.php')) {
                    require_once $fullplug . '/db/install.php';
                    set_config('installrunning', 1, $plugin->fullname);
//.........这里部分代码省略.........
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:101,代码来源:upgradelib.php


示例13: upgrade_local_db

/**
 * This function checks to see whether local database customisations are up-to-date
 * by comparing $CFG->local_version to the variable $local_version defined in
 * local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
 * in a file called 'local/db/upgrade.php', and if it's there calls it with the
 * appropiate $oldversion parameter. Then it updates $CFG->local_version.
 *
 * @uses $CFG
 */
function upgrade_local_db($startcallback, $endcallback)
{
    global $CFG, $DB;
    // if we don't have code version, just return false
    if (!file_exists($CFG->dirroot . '/local/version.php')) {
        return;
    }
    $local_version = null;
    require $CFG->dirroot . '/local/version.php';
    // Get code versions
    if (empty($CFG->local_version)) {
        // install
        $startcallback('local', true);
        if (file_exists($CFG->dirroot . '/local/db/install.php')) {
            require_once $CFG->dirroot . '/local/db/install.php';
            xmldb_local_install();
        }
        set_config('local_version', $local_version);
        /// Install various components
        events_update_definition('local');
        update_capabilities('local');
        message_update_providers('local');
        $endcallback('local', true);
    } else {
        if ($local_version > $CFG->local_version) {
            // upgrade!
            $startcallback('local', false);
            if (file_exists($CFG->dirroot . '/local/db/upgrade.php')) {
                require_once $CFG->dirroot . '/local/db/upgrade.php';
                xmldb_local_upgrade($CFG->local_version);
            }
            set_config('local_version', $local_version);
            /// Upgrade various components
            events_update_definition('local');
            update_capabilities('local');
            message_update_providers('local');
            $endcallback('local', false);
        } else {
            if ($local_version < $CFG->local_version) {
                throw new downgrade_exception('local', $CFG->local_version, $local_version);
            }
        }
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:53,代码来源:upgradelib.php


示例14: upgrade_local_dbs

/**
 * This function checks to see whether local database customisations are up-to-date
 * by comparing $CFG->local_version to the variable $local_version defined in
 * local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
 * in a file called 'local/db/upgrade.php', and if it's there calls it with the
 * appropiate $oldversion parameter. Then it updates $CFG->local_version.
 * On success it prints a continue link. On failure it prints an error.
 *
 * @uses $CFG
 * @uses $db to do something really evil with the debug setting that should probably be eliminated. TODO!
 * @param string $continueto a URL passed to print_continue() if the local upgrades succeed.
 */
function upgrade_local_dbs($continueto)
{
    global $CFG, $db;
    $path = '/local';
    $pat = 'local';
    $status = true;
    $changed = false;
    $firstloop = true;
    while (is_dir($CFG->dirroot . $path)) {
        // if we don't have code version or a db upgrade file, check lower
        if (!file_exists($CFG->dirroot . "{$path}/version.php") || !file_exists($CFG->dirroot . "{$path}/db/upgrade.php")) {
            $path .= '/local';
            $pat .= 'local';
            continue;
        }
        require_once $CFG->dirroot . "{$path}/version.php";
        // Get code versions
        $cfgvarname = "{$pat}_version";
        if (empty($CFG->{$cfgvarname})) {
            // normally we'd install, but just replay all the upgrades.
            $CFG->{$cfgvarname} = 0;
        }
        $localversionvar = "{$pat}_version";
        // echo "($localversionvar) ".$$localversionvar." > ($cfgvarname) ".$CFG->{$cfgvarname}."<br/>";
        if (${$localversionvar} > $CFG->{$cfgvarname}) {
            // something upgrades!
            upgrade_log_start();
            /// Capabilities
            /// do this first *instead of* last , so that the installer has the chance to locally assign caps
            if (!update_capabilities($pat)) {
                error('Could not set up the capabilities for ' . $pat . '!');
            }
            if ($firstloop) {
                $strdatabaseupgrades = get_string('databaseupgrades');
                print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript());
                $firstloop = false;
            }
            $changed = true;
            require_once $CFG->dirroot . "{$path}/db/upgrade.php";
            $db->debug = true;
            $upgradefunc = "xmldb_{$pat}_upgrade";
            if ($upgradefunc($CFG->{$cfgvarname})) {
                $db->debug = false;
                if (set_config($localversionvar, ${$localversionvar})) {
                    notify(get_string('databasesuccess'), 'notifysuccess');
                    notify(get_string('databaseupgradelocal', '', $path . ' >> ' . ${$localversionvar}), 'notifysuccess');
                } else {
                    $status = false;
                    error('Upgrade of local database customisations failed in $path! (Could not update version in config table)');
                }
            } else {
                $db->debug = false;
                error("Upgrade failed!  See {$path}/version.php");
            }
            if (!events_update_definition($pat)) {
                error('Could not set up the events definitions for ' . $pat . '!');
            }
            upgrade_log_finish();
        } else {
            if (${$localversionvar} < $CFG->{$cfgvarname}) {
                notify("WARNING!!!  The local version you are using in {$path} is OLDER than the version that made these databases!");
            }
        }
        $path .= '/local';
        $pat .= 'local';
    }
    if ($changed) {
        print_continue($continueto);
        print_footer('none');
        exit;
    }
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:84,代码来源:locallib.php


示例15: 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


示例16: test__events_update_definition__update

 /**
  * Tests the update of event handlers from file
  */
 function test__events_update_definition__update()
 {
     // first modify directly existing handler
     $handler = get_record('events_handlers', 'handlermodule', 'unittest', 'eventname', 'test_instant');
     $original = $handler->handlerfunction;
     // change handler in db
     set_field('events_handlers', 'handlerfunction', serialize('some_other_function_handler'), 'id', $handler->id);
     // update the definition, it should revert the handler back
     events_update_definition('unittest');
     $handler = get_record('events_handlers', 'handlermodule', 'unittest', 'eventname', 'test_instant');
     $this->assertEqual($handler->handlerfunction, $original, 'update should sync db with file definition: %s');
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:15,代码来源:testeventslib.php


示例17: 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



注:本文中的events_update_definition函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP evo_flush函数代码示例发布时间:2022-05-15
下一篇:
PHP events_uninstall函数代码示例发布时间: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