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

PHP upgrade_log_finish函数代码示例

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

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



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

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


示例2: print_error

/**
 * Print an error page displaying an error message.  New method - use this for new code.
 *
 * @uses $SESSION
 * @uses $CFG
 * @param string $errorcode The name of the string from error.php (or other specified file) to print
 * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
 * @param object $a Extra words and phrases that might be required in the error string
 * @param array $extralocations An array of strings with other locations to look for string files
 * @return does not return, terminates script
 */
function print_error($errorcode, $module = 'error', $link = '', $a = NULL, $extralocations = NULL)
{
    global $CFG, $SESSION, $THEME;
    if (empty($module) || $module === 'moodle' || $module === 'core') {
        $module = 'error';
    }
    $message = get_string($errorcode, $module, $a, $extralocations);
    if ($module === 'error' and strpos($message, '[[') === 0) {
        //search in moodle file if error specified - needed for backwards compatibility
        $message = get_string($errorcode, 'moodle', $a, $extralocations);
    }
    if (empty($link) and !defined('ADMIN_EXT_HEADER_PRINTED')) {
        if (!empty($SESSION->fromurl)) {
            $link = $SESSION->fromurl;
            unset($SESSION->fromurl);
        } else {
            $link = $CFG->wwwroot . '/';
        }
    }
    if (!empty($CFG->errordocroot)) {
        $errordocroot = $CFG->errordocroot;
    } else {
        if (!empty($CFG->docroot)) {
            $errordocroot = $CFG->docroot;
        } else {
            $errordocroot = 'http://docs.moodle.org';
        }
    }
    if (defined('FULLME') && FULLME == 'cron') {
        // Errors in cron should be mtrace'd.
        mtrace($message);
        die;
    }
    if ($module === 'error') {
        $modulelink = 'moodle';
    } else {
        $modulelink = $module;
    }
    $message = clean_text('<p class="errormessage">' . $message . '</p>' . '<p class="errorcode">' . '<a href="' . $errordocroot . '/en/error/' . $modulelink . '/' . $errorcode . '">' . get_string('moreinformation') . '</a></p>');
    if (!defined('HEADER_PRINTED')) {
        //header not yet printed
        @header('HTTP/1.0 404 Not Found');
        print_header(get_string('error'));
    } else {
        print_container_end_all(false, $THEME->open_header_containers);
    }
    echo '<br />';
    print_simple_box($message, '', '', '', '', 'errorbox');
    debugging('Stack trace:', DEBUG_DEVELOPER);
    // in case we are logging upgrade in admin/index.php stop it
    if (function_exists('upgrade_log_finish')) {
        upgrade_log_finish();
    }
    if (!empty($link)) {
        print_continue($link);
    }
    print_footer();
    for ($i = 0; $i < 512; $i++) {
        // Padding to help IE work with 404
        echo ' ';
    }
    die;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:74,代码来源:weblib.php


示例3: upgrade_blocks_plugins


//.........这里部分代码省略.........
                        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();
            print_heading($block->name);
            $db->debug = true;
            @set_time_limit(0);
            // To allow slow databases to complete the long SQL
            /// Both old .sql files and new install.xml are supported
            /// but we priorize install.xml (XMLDB) if present
            $status = false;
            if (file_exists($fullblock . '/db/install.xml')) {
                $status = install_from_xmldb_file($fullblock . '/db/install.xml');
                //New method
            } else {
                if (file_exists($fullblock . '/db/' . $CFG->dbtype . '.sql')) {
                    $status = modify_database($fullblock . '/db/' . $CFG->dbtype . '.sql');
                    //Old method
                } else {
                    $status = true;
                }
            }
            $db->debug = false;
            if ($status) {
                if ($block->id = insert_record('block', $block)) {
                    $blockobj->after_install();
                    $component = 'block/' . $block->name;
                    if (!update_capabilities($component)) {
                        notify('Could not set up ' . $block->name . ' capabilities!');
                    }
                    events_update_definition($component);
                    notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
                    echo '<hr />';
                } else {
                    error($block->name . ' block could not be added to the block list!');
                }
            } else {
                error('Block ' . $block->name . ' tables could NOT be set up successfully!');
            }
        }
        $blocktitles[$block->name] = $blocktitle;
    }
    if (!empty($notices)) {
        upgrade_log_start();
        foreach ($notices as $notice) {
            notify($notice);
        }
    }
    // Finally, if we are in the first_install of BLOCKS (this means that we are
    // upgrading from Moodle < 1.3), put blocks in all existing courses.
    if ($first_install) {
        upgrade_log_start();
        //Iterate over each course
        if ($courses = get_records('course')) {
            foreach ($courses as $course) {
                $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                blocks_repopulate_page($page);
            }
        }
    }
    if (!empty($CFG->siteblocksadded)) {
        /// This is a once-off hack to make a proper upgrade
        upgrade_log_start();
        $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
        blocks_repopulate_page($page);
        delete_records('config', 'name', 'siteblocksadded');
    }
    upgrade_log_finish();
    if (!empty($updated_blocks)) {
        print_continue($continueto);
        print_footer('none');
        die;
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:blocklib.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: upgrade_RPC_functions

/// Check for changes to RPC functions
require_once "{$CFG->dirroot}/{$CFG->admin}/mnet/adminlib.php";
upgrade_RPC_functions("{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Upgrade all plugins for gradebook
upgrade_plugins('gradeexport', 'grade/export', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
upgrade_plugins('gradeimport', 'grade/import', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
upgrade_plugins('gradereport', 'grade/report', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
/// Check all message output plugins and upgrade if necessary
upgrade_plugins('message', 'message/output', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
/// Check all course report plugins and upgrade if necessary
upgrade_plugins('coursereport', 'course/report', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
/// Check all admin report plugins and upgrade if necessary
upgrade_plugins('report', $CFG->admin . '/report', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
/// just make sure upgrade logging is properly terminated
upgrade_log_finish();
unset($_SESSION['installautopilot']);
/// Set up the blank site - to be customized later at the end of install.
if (!($site = get_site())) {
    // We are about to create the site "course"
    require_once $CFG->libdir . '/blocklib.php';
    $newsite = new object();
    $newsite->fullname = "";
    $newsite->shortname = "";
    $newsite->summary = NULL;
    $newsite->newsitems = 3;
    $newsite->numsections = 0;
    $newsite->category = 0;
    $newsite->format = 'site';
    // Only for this course
    $newsite->teacher = get_string("defaultcourseteacher");
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:index.php


示例6: error

/**
 * Print an error page displaying an error message.
 * Old method, don't call directly in new code - use print_error instead.
 *
 *
 * @uses $SESSION
 * @uses $CFG
 * @param string $message The message to display to the user about the error.
 * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
 */
function error($message, $link = '')
{
    global $CFG, $SESSION, $THEME;
    $message = clean_text($message);
    // In case nasties are in here
    if (defined('FULLME') && FULLME == 'cron') {
        // Errors in cron should be mtrace'd.
        mtrace($message);
        die;
    }
    if (!defined('HEADER_PRINTED')) {
        //header not yet printed
        @header('HTTP/1.0 404 Not Found');
        print_header(get_string('error'));
    } else {
        print_container_end_all(false, $THEME->open_header_containers);
    }
    echo '<br />';
    print_simple_box($message, '', '', '', '', 'errorbox');
    debugging('Stack trace:', DEBUG_DEVELOPER);
    // in case we are logging upgrade in admin/index.php stop it
    if (function_exists('upgrade_log_finish')) {
        upgrade_log_finish();
    }
    if (empty($link) and !defined('ADMIN_EXT_HEADER_PRINTED')) {
        if (!empty($SESSION->fromurl)) {
            $link = $SESSION->fromurl;
            unset($SESSION->fromurl);
        } else {
            $link = $CFG->wwwroot . '/';
        }
    }
    if (!empty($link)) {
        print_continue($link);
    }
    print_footer();
    for ($i = 0; $i < 512; $i++) {
        // Padding to help IE work with 404
        echo ' ';
    }
    die;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:52,代码来源:deprecatedlib.php


示例7: upgrade_backup_db


//.........这里部分代码省略.........
        upgrade_log_start();
        print_heading('backup');
        $db->debug = true;
        /// Both old .sql files and new install.xml are supported
        /// but we priorize install.xml (XMLDB) if present
        $status = false;
        if (file_exists($CFG->dirroot . '/backup/db/install.xml')) {
            $status = install_from_xmldb_file($CFG->dirroot . '/backup/db/install.xml');
            //New method
        } else {
            if (file_exists($CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.sql')) {
                $status = modify_database($CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.sql');
                //Old method
            }
        }
        $db->debug = false;
        if ($status) {
            if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
                //initialize default backup settings now
                $adminroot = admin_get_root();
                apply_default_settings($adminroot->locate('backups'));
                notify(get_string("databasesuccess"), "green");
                notify(get_string("databaseupgradebackups", "", $backup_version), "green");
                print_continue($continueto);
                print_footer('none');
                exit;
            } else {
                error("Upgrade of backup system failed! (Could not update version in config table)");
            }
        } else {
            error("Backup tables could NOT be set up successfully!");
        }
    }
    /// Upgrading code starts here
    $oldupgrade = false;
    $newupgrade = false;
    if (is_readable($CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.php')) {
        include_once $CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.php';
        // defines old upgrading function
        $oldupgrade = true;
    }
    if (is_readable($CFG->dirroot . '/backup/db/upgrade.php')) {
        include_once $CFG->dirroot . '/backup/db/upgrade.php';
        // defines new upgrading function
        $newupgrade = true;
    }
    if ($backup_version > $CFG->backup_version) {
        // Upgrade tables
        $strdatabaseupgrades = get_string("databaseupgrades");
        $navigation = array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'));
        print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation($navigation), '', upgrade_get_javascript());
        upgrade_log_start();
        print_heading('backup');
        /// Run de old and new upgrade functions for the module
        $oldupgrade_function = 'backup_upgrade';
        $newupgrade_function = 'xmldb_backup_upgrade';
        /// First, the old function if exists
        $oldupgrade_status = true;
        if ($oldupgrade && function_exists($oldupgrade_function)) {
            $db->debug = true;
            $oldupgrade_status = $oldupgrade_function($CFG->backup_version);
        } else {
            if ($oldupgrade) {
                notify('Upgrade function ' . $oldupgrade_function . ' was not available in ' . '/backup/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($CFG->backup_version);
        } else {
            if ($newupgrade) {
                notify('Upgrade function ' . $newupgrade_function . ' was not available in ' . '/backup/db/upgrade.php');
            }
        }
        $db->debug = false;
        /// Now analyze upgrade results
        if ($oldupgrade_status && $newupgrade_status) {
            // No upgrading failed
            if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
                notify(get_string("databasesuccess"), "green");
                notify(get_string("databaseupgradebackups", "", $backup_version), "green");
                print_continue($continueto);
                print_footer('none');
                exit;
            } else {
                error("Upgrade of backup system failed! (Could not update version in config table)");
            }
        } else {
            error("Upgrade failed!  See backup/version.php");
        }
    } else {
        if ($backup_version < $CFG->backup_version) {
            upgrade_log_start();
            notify("WARNING!!!  The code you are using is OLDER than the version that made these databases!");
        }
    }
    upgrade_log_finish();
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:lib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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