public function test_environment()
 {
     global $CFG;
     require_once $CFG->libdir . '/environmentlib.php';
     list($envstatus, $environment_results) = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
     $this->assertNotEmpty($envstatus);
     foreach ($environment_results as $environment_result) {
         $this->assertTrue($environment_result->getStatus(), "Problem detected in environment ({$environment_result->part}:{$environment_result->info}), fix all warnings and errors!");
     }
 }
 /**
  * Test the environment.
  */
 public function test_environment()
 {
     global $CFG;
     require_once $CFG->libdir . '/environmentlib.php';
     list($envstatus, $environment_results) = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
     $this->assertNotEmpty($envstatus);
     foreach ($environment_results as $environment_result) {
         if ($environment_result->part === 'php_setting' and $environment_result->info === 'opcache.enable' and $environment_result->getLevel() === 'optional' and $environment_result->getStatus() === false) {
             $this->markTestSkipped('OPCache extension is not necessary for unit testing.');
             continue;
         }
         $this->assertTrue($environment_result->getStatus(), "Problem detected in environment ({$environment_result->part}:{$environment_result->info}), fix all warnings and errors!");
     }
 }
示例#3
0
 /**
  * Test the environment.
  */
 public function test_environment()
 {
     global $CFG;
     require_once $CFG->libdir . '/environmentlib.php';
     list($envstatus, $environment_results) = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
     $sslmessages = ['ssl/tls configuration not supported', 'invalid ssl/tls configuration'];
     $this->assertNotEmpty($envstatus);
     foreach ($environment_results as $environment_result) {
         if ($environment_result->part === 'php_setting' and $environment_result->info === 'opcache.enable' and $environment_result->getLevel() === 'optional' and $environment_result->getStatus() === false) {
             $this->markTestSkipped('OPCache extension is not necessary for unit testing.');
             continue;
         }
         if ($environment_result->part === 'custom_check' and in_array($environment_result->info, $sslmessages) and $environment_result->getLevel() === 'optional' and $environment_result->getStatus() === false) {
             $this->markTestSkipped('Up-to-date TLS libraries are not necessary for unit testing.');
             continue;
         }
         $this->assertTrue($environment_result->getStatus(), "Problem detected in environment ({$environment_result->part}:{$environment_result->info}), fix all warnings and errors!");
     }
 }
示例#4
0
文件: index.php 项目: numbas/moodle
 }
 if (empty($confirmupgrade)) {
     $a = new stdClass();
     $a->oldversion = "{$CFG->release} ({$CFG->version})";
     $a->newversion = "{$release} ({$version})";
     $strdatabasechecking = get_string('databasechecking', '', $a);
     $PAGE->set_title($stradministration);
     $PAGE->set_heading($strdatabasechecking);
     $PAGE->set_cacheable(false);
     $output = $PAGE->get_renderer('core', 'admin');
     echo $output->upgrade_confirm_page($a->newversion, $maturity);
     die;
 } else {
     if (empty($confirmrelease)) {
         require_once $CFG->libdir . '/environmentlib.php';
         list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
         $strcurrentrelease = get_string('currentrelease');
         $PAGE->navbar->add($strcurrentrelease);
         $PAGE->set_title($strcurrentrelease);
         $PAGE->set_heading($strcurrentrelease);
         $PAGE->set_cacheable(false);
         $output = $PAGE->get_renderer('core', 'admin');
         echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
         die;
     } else {
         if (empty($confirmplugins)) {
             $strplugincheck = get_string('plugincheck');
             $PAGE->navbar->add($strplugincheck);
             $PAGE->set_title($strplugincheck);
             $PAGE->set_heading($strplugincheck);
             $PAGE->set_cacheable(false);
示例#5
0
/**
 * Install Moodle DB,
 * config.php must exist, there must not be any tables in db yet.
 *
 * @param array $options adminpass is mandatory
 * @param bool $interactive
 * @return void
 */
function install_cli_database(array $options, $interactive)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/environmentlib.php';
    require_once $CFG->libdir . '/upgradelib.php';
    // show as much debug as possible
    @error_reporting(E_ALL | E_STRICT);
    @ini_set('display_errors', '1');
    $CFG->debug = E_ALL | E_STRICT;
    $CFG->debugdisplay = true;
    $CFG->version = '';
    $CFG->release = '';
    $CFG->branch = '';
    $version = null;
    $release = null;
    $branch = null;
    // read $version and $release
    require $CFG->dirroot . '/version.php';
    if ($DB->get_tables()) {
        cli_error(get_string('clitablesexist', 'install'));
    }
    if (empty($options['adminpass'])) {
        cli_error('Missing required admin password');
    }
    // test environment first
    list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
    if (!$envstatus) {
        $errors = environment_get_errors($environment_results);
        cli_heading(get_string('environment', 'admin'));
        foreach ($errors as $error) {
            list($info, $report) = $error;
            echo "!! {$info} !!\n{$report}\n\n";
        }
        exit(1);
    }
    if (!$DB->setup_is_unicodedb()) {
        if (!$DB->change_db_encoding()) {
            // If could not convert successfully, throw error, and prevent installation
            cli_error(get_string('unicoderequired', 'admin'));
        }
    }
    if ($interactive) {
        cli_separator();
        cli_heading(get_string('databasesetup'));
    }
    // install core
    install_core($version, true);
    set_config('release', $release);
    set_config('branch', $branch);
    if (PHPUNIT_TEST) {
        // mark as test database as soon as possible
        set_config('phpunittest', 'na');
    }
    // install all plugins types, local, etc.
    upgrade_noncore(true);
    // set up admin user password
    $DB->set_field('user', 'password', hash_internal_user_password($options['adminpass']), array('username' => 'admin'));
    // rename admin username if needed
    if (isset($options['adminuser']) and $options['adminuser'] !== 'admin' and $options['adminuser'] !== 'guest') {
        $DB->set_field('user', 'username', $options['adminuser'], array('username' => 'admin'));
    }
    // indicate that this site is fully configured
    set_config('rolesactive', 1);
    upgrade_finished();
    // log in as admin - we need do anything when applying defaults
    $admins = get_admins();
    $admin = reset($admins);
    session_set_user($admin);
    // apply all default settings, do it twice to fill all defaults - some settings depend on other setting
    admin_apply_default_settings(NULL, true);
    admin_apply_default_settings(NULL, true);
    set_config('registerauth', '');
    // set the site name
    if (isset($options['shortname']) and $options['shortname'] !== '') {
        $DB->set_field('course', 'shortname', $options['shortname'], array('format' => 'site'));
    }
    if (isset($options['fullname']) and $options['fullname'] !== '') {
        $DB->set_field('course', 'fullname', $options['fullname'], array('format' => 'site'));
    }
}
示例#6
0
     $continueform->url = new moodle_url('index.php', array('confirmupgrade' => 1));
     echo $OUTPUT->confirm(get_string('upgradesure', 'admin', $a->newversion), $continueform, 'index.php');
     echo $OUTPUT->footer();
     exit;
 } else {
     if (empty($confirmrelease)) {
         $strcurrentrelease = get_string('currentrelease');
         $navigation = build_navigation(array(array('name' => $strcurrentrelease, 'link' => null, 'type' => 'misc')));
         print_header($strcurrentrelease, $strcurrentrelease, $navigation, '', '', false, ' ', ' ');
         echo $OUTPUT->heading("Moodle {$release}");
         $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
         $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink);
         // extremely ugly validation hack
         echo $OUTPUT->box($releasenoteslink);
         require_once $CFG->libdir . '/environmentlib.php';
         if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) {
             print_upgrade_reload('index.php?confirmupgrade=1');
         } else {
             echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
             if (empty($CFG->skiplangupgrade)) {
                 echo $OUTPUT->box_start('generalbox', 'notice');
                 print_string('langpackwillbeupdated', 'admin');
                 echo $OUTPUT->box_end();
             }
             echo $OUTPUT->continue_button('index.php?confirmupgrade=1&confirmrelease=1');
         }
         echo $OUTPUT->footer();
         die;
     } elseif (empty($confirmplugins)) {
         $strplugincheck = get_string('plugincheck');
         $navigation = build_navigation(array(array('name' => $strplugincheck, 'link' => null, 'type' => 'misc')));
示例#7
0
if (!file_exists($configfile)) {
    cli_error('Can not create config file.');
}
// remember selected language
$installlang = $CFG->lang;
// return back to original dir before executing setup.php which changes the dir again
chdir($olddir);
// We have config.php, it is a real php script from now on :-)
require $configfile;
// use selected language
$CFG->lang = $installlang;
$SESSION->lang = $CFG->lang;
require "{$CFG->dirroot}/version.php";
// Test environment first.
require_once $CFG->libdir . '/environmentlib.php';
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
    $errors = environment_get_errors($environment_results);
    cli_heading(get_string('environment', 'admin'));
    foreach ($errors as $error) {
        list($info, $report) = $error;
        echo "!! {$info} !!\n{$report}\n\n";
    }
    exit(1);
}
// Test plugin dependencies.
$failed = array();
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
    cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
    cli_error(get_string('pluginschecktodo', 'admin'));
}
示例#8
0
    echo $help;
    die;
}
if (empty($CFG->version)) {
    cli_error(get_string('missingconfigversion', 'debug'));
}
require "{$CFG->dirroot}/version.php";
// defines $version and $release
$CFG->target_release = $release;
// used during installation and upgrades
if ($version < $CFG->version) {
    cli_error(get_string('downgradedcore', 'error'));
}
$newversion = "{$release} ({$version})";
// test environment first
if (!check_moodle_environment($version, $environment_results, false, ENV_SELECT_RELEASE)) {
    $errors = environment_get_errors($environment_results);
    cli_heading(get_string('environment', 'admin'));
    foreach ($errors as $error) {
        list($info, $report) = $error;
        echo "!! {$info} !!\n{$report}\n\n";
    }
    exit(1);
}
if ($interactive) {
    echo html_to_text(get_string('upgradesure', 'admin', $newversion)) . "\n";
    $prompt = get_string('cliyesnoprompt', 'admin');
    $input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
    if ($input == get_string('clianswerno', 'admin')) {
        exit(1);
    }
    if ($env_versions = get_list_of_environment_versions($contents)) {
        /// Set the current version at the beginning
        $env_version = normalize_version($current_version);
        //We need this later (for the upwards)
        $versions[$env_version] = $current_version;
        /// If no version has been previously selected, default to $current_version
        if (empty($version)) {
            $version = $env_version;
        }
        ///Iterate over each version, adding bigged than current
        foreach ($env_versions as $env_version) {
            if (version_compare(normalize_version($current_version), $env_version, '<')) {
                $versions[$env_version] = $env_version;
            }
        }
        /// Add 'upwards' to the last element
        $versions[$env_version] = $env_version . ' ' . $strupwards;
    } else {
        $versions = array('error' => $strerror);
    }
}
/// Print form and popup menu
echo '<div style="text-align:center">' . $strmoodleversion . ' ';
popup_form("{$CFG->wwwroot}/{$CFG->admin}/environment.php?version=", $versions, 'selectversion', $version, '');
echo '</div>';
/// End of main box
print_simple_box_end();
/// Gather and show results
$status = check_moodle_environment($version, $environment_results);
/// Print footer
admin_externalpage_print_footer();
示例#10
0
     print_header($strdatabasechecking, $stradministration, $navigation, "", "", false, "&nbsp;", "&nbsp;");
     notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
     print_footer('none');
     exit;
 } else {
     if (empty($confirmrelease)) {
         $strcurrentrelease = get_string("currentrelease");
         $navigation = build_navigation(array(array('name' => $strcurrentrelease, 'link' => null, 'type' => 'misc')));
         print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, "&nbsp;", "&nbsp;");
         print_heading("Moodle {$release}");
         print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
         require_once $CFG->libdir . '/environmentlib.php';
         print_heading(get_string('environment', 'admin'));
         remove_dir($CFG->dataroot . '/environment');
         /// Always delete downloaded env. info to force use of the released one. MDL-9796
         if (!check_moodle_environment($release, $environment_results, true)) {
             if (empty($CFG->skiplangupgrade)) {
                 print_box_start('generalbox', 'notice');
                 // MDL-8330
                 print_string('langpackwillbeupdated', 'admin');
                 print_box_end();
             }
             notice_yesno(get_string('environmenterrorupgrade', 'admin'), 'index.php?confirmupgrade=1&amp;confirmrelease=1', 'index.php');
         } else {
             notify(get_string('environmentok', 'admin'), 'notifysuccess');
             if (empty($CFG->skiplangupgrade)) {
                 print_box_start('generalbox', 'notice');
                 // MDL-8330
                 print_string('langpackwillbeupdated', 'admin');
                 print_box_end();
             }
示例#11
0
// Get current Moodle version
$current_version = $CFG->release;
// Calculate list of versions
$versions = array();
if ($contents = load_environment_xml()) {
    if ($env_versions = get_list_of_environment_versions($contents)) {
        // Set the current version at the beginning
        $env_version = normalize_version($current_version);
        //We need this later (for the upwards)
        $versions[$env_version] = $current_version;
        // If no version has been previously selected, default to $current_version
        if (empty($version)) {
            $version = $env_version;
        }
        //Iterate over each version, adding bigger than current
        foreach ($env_versions as $env_version) {
            if (version_compare(normalize_version($current_version), $env_version, '<')) {
                $versions[$env_version] = $env_version;
            }
        }
        // Add 'upwards' to the last element
        $versions[$env_version] = $env_version . ' ' . get_string('upwards', 'admin');
    } else {
        $versions = array('error' => get_string('error'));
    }
}
// Get the results of the environment check.
list($envstatus, $environment_results) = check_moodle_environment($version, ENV_SELECT_NEWER);
// Display the page.
$output = $PAGE->get_renderer('core', 'admin');
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
示例#12
0
function form_table($nextstage = WELCOME, $formaction = "install.php")
{
    global $INSTALL, $db;
    $enablenext = true;
    /// Print the standard form if we aren't in the DOWNLOADLANG page
    /// because it has its own form.
    if ($nextstage != DOWNLOADLANG) {
        $needtoopenform = false;
        ?>
        <form id="installform" method="post" action="<?php 
        echo $formaction;
        ?>
">
        <div><input type="hidden" name="stage" value="<?php 
        echo $nextstage;
        ?>
" /></div>

<?php 
    } else {
        $needtoopenform = true;
    }
    ?>
    <table class="install_table" cellspacing="3" cellpadding="3">

<?php 
    /// what we do depends on the stage we're at
    switch ($nextstage) {
        case WELCOME:
            /// Welcome and language settings
            ?>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('language');
            ?>
</p></td>
                <td class="td_right">
                <?php 
            choose_from_menu(get_installer_list_of_languages(), 'language', $INSTALL['language'], '');
            ?>
                </td>
            </tr>

<?php 
            break;
        case COMPATIBILITY:
            /// Compatibilty check
            $compatsuccess = true;
            /// Check that PHP is of a sufficient version
            print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
            $enablenext = $enablenext && inst_check_php_version();
            /// Check session auto start
            print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
            $enablenext = $enablenext && !ini_get_bool('session.auto_start');
            /// Check magic quotes
            print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
            $enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
            /// Check unsupported PHP configuration
            print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
            $enablenext = $enablenext && !ini_get_bool('register_globals');
            /// Check safe mode
            print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
            /// Check file uploads
            print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
            /// Check GD version
            print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
            /// Check memory limit
            print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
            break;
        case DIRECTORY:
            /// Directory settings
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('wwwroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40"name="wwwrootform" value="<?php 
            p($INSTALL['wwwrootform'], true);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dirroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php 
            p($INSTALL['dirrootform'], true);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dataroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="dataroot" value="<?php 
            p($INSTALL['dataroot'], true);
            ?>
" />
                </td>
            </tr>

<?php 
            break;
        case DATABASE:
            /// Database settings
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbtype', 'install');
            ?>
</p></td>
                <td class="td_right">
                <?php 
            choose_from_menu(array('mysql' => get_string('mysql', 'install'), 'mysqli' => get_string('mysqli', 'install'), 'oci8po' => get_string('oci8po', 'install'), 'postgres7' => get_string('postgres7', 'install'), 'mssql' => get_string('mssql', 'install'), 'mssql_n' => get_string('mssql_n', 'install'), 'odbc_mssql' => get_string('odbc_mssql', 'install')), 'dbtype', $INSTALL['dbtype'], '', 'toggledbinfo();');
            ?>
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbhost', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbhost" value="<?php 
            p($INSTALL['dbhost']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('database', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbname" value="<?php 
            p($INSTALL['dbname']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('user');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbuser" value="<?php 
            p($INSTALL['dbuser']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('password');
            ?>
</p></td>
                <td class="td_right">
                    <input type="password" class="input_database" name="dbpass" value="<?php 
            p($INSTALL['dbpass']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbprefix', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="prefix" value="<?php 
            p($INSTALL['prefix']);
            ?>
" />
                </td>
            </tr>

<?php 
            break;
        case ADMIN:
            /// Administration directory setting
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('admindirname', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="admindirname" value="<?php 
            p($INSTALL['admindirname']);
            ?>
" />
                </td>
            </tr>


<?php 
            break;
        case ENVIRONMENT:
            /// Environment checks
            ?>

            <tr>
                <td colspan="2">
                <?php 
            error_reporting(0);
            // Hide errors
            $dbconnected = $db->Connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname']);
            error_reporting(7);
            // Show errors
            if ($dbconnected) {
                /// Execute environment check, printing results
                @remove_dir($INSTALL['dataroot'] . '/environment');
                /// Always delete downloaded env. info to force use of the released one. MDL-9796
                check_moodle_environment($INSTALL['release'], $environment_results, true);
            } else {
                /// We never should reach this because DB has been tested before arriving here
                $errormsg = get_string('dbconnectionerror', 'install');
                $nextstage = DATABASE;
                echo '<p class="errormsg" style="text-align:center">' . get_string('dbconnectionerror', 'install') . '</p>';
            }
            ?>
                </td>
            </tr>

<?php 
            break;
        case DOWNLOADLANG:
            /// Download language from download.moodle.org
            ?>

            <tr>
                <td colspan="2">
                <?php 
            /// Get array of languages, we are going to use it
            $languages = get_installer_list_of_languages();
            /// Print the download form (button) if necessary
            if ($INSTALL['showdownloadlangpack'] == true && substr($INSTALL['language'], 0, 2) != 'en') {
                $options = array();
                $options['downloadlangpack'] = true;
                $options['stage'] = DOWNLOADLANG;
                $options['same'] = true;
                print_simple_box_start('center');
                print_single_button('install.php', $options, get_string('downloadlanguagebutton', 'install', $languages[$INSTALL['language']]), 'post');
                print_simple_box_end();
            } else {
                /// Show result info
                /// English lang packs aren't downloaded
                if (substr($INSTALL['language'], 0, 2) == 'en') {
                    print_simple_box(get_string('downloadlanguagenotneeded', 'install', $languages[$INSTALL['language']]), 'center', '80%');
                } else {
                    if ($INSTALL['downloadlangpackerror']) {
                        echo "<p class=\"errormsg\" align=\"center\">" . $INSTALL['downloadlangpackerror'] . "</p>\n";
                        print_simple_box(get_string('langdownloaderror', 'install', $languages[$INSTALL['language']]), 'center', '80%');
                    } else {
                        print_simple_box(get_string('langdownloadok', 'install', $languages[$INSTALL['language']]), 'center', '80%');
                    }
                }
            }
            ?>
                </td>
            </tr>

<?php 
            break;
        default:
    }
    ?>

    <tr>
        <td colspan="<?php 
    echo $nextstage == COMPATIBILITY ? 3 : 2;
    ?>
">

<?php 
    if ($needtoopenform) {
        ?>
            <form id="installform" method="post" action="<?php 
        echo $formaction;
        ?>
">
            <div><input type="hidden" name="stage" value="<?php 
        echo $nextstage;
        ?>
" /></div>
<?php 
    }
    $disabled = $enablenext ? '' : 'disabled="disabled"';
    ?>

            <?php 
    echo $nextstage < SAVE ? "<div><input {$disabled} type=\"submit\" name=\"next\" value=\"" . get_string('next') . "  &raquo;\" style=\"float: " . fix_align_rtl("right") . "\"/></div>\n" : "&nbsp;\n";
    ?>
            <?php 
    echo $nextstage > WELCOME ? "<div><input type=\"submit\" name=\"prev\" value=\"&laquo;  " . get_string('previous') . "\" style=\"float: " . fix_align_rtl("left") . "\"/></div>\n" : "&nbsp;\n";
    ?>

<?php 
    if ($needtoopenform) {
        ?>
            </form>
<?php 
    }
    ?>


        </td>

    </tr>

    </table>
<?php 
    if (!$needtoopenform) {
        ?>
    </form>
<?php 
    }
    ?>

<?php 
}
function mnetadmin_rpc_upgrade($user, $json_response = true)
{
    global $CFG, $USER;
    // Invoke local user and check his rights
    if ($auth_response = invoke_local_user((array) $user)) {
        if ($json_response) {
            return $auth_response;
        } else {
            return json_decode($auth_response);
        }
    }
    // Creating response
    $response = new stdclass();
    $response->status = RPC_SUCCESS;
    require "{$CFG->dirroot}/version.php";
    // defines $version, $release, $branch and $maturity
    $CFG->target_release = $release;
    // used during installation and upgrades
    if ($version < $CFG->version) {
        $response->status = RPC_FAILURE_RUN;
        $response->error = get_string('downgradedcore', 'error');
        $response->errors[] = get_string('downgradedcore', 'error');
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    $oldversion = "{$CFG->release} ({$CFG->version})";
    $newversion = "{$release} ({$version})";
    if (!moodle_needs_upgrading()) {
        $response->message = get_string('cliupgradenoneed', 'core_admin', $newversion);
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    // debug_trace('Remote Upgrade : Environment check');
    list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_NEWER);
    if (!$envstatus) {
        $response->status = RPC_FAILURE_RUN;
        $response->error = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade');
        $response->errors[] = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade');
        $response->detail = $environment_results;
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    // Test plugin dependencies.
    // debug_trace('Remote Upgrade : Plugins check');
    $failed = array();
    if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
        $response->status = RPC_FAILURE_RUN;
        $response->error = get_string('pluginschecktodo', 'admin');
        $response->errors[] = get_string('pluginschecktodo', 'admin');
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    ob_start();
    // debug_trace('Remote Upgrade : Upgrade core');
    if ($version > $CFG->version) {
        upgrade_core($version, false);
    }
    set_config('release', $release);
    set_config('branch', $branch);
    // unconditionally upgrade
    // debug_trace('Remote Upgrade : Upgrade other');
    upgrade_noncore(false);
    // log in as admin - we need doanything permission when applying defaults
    // debug_trace('Remote Upgrade : Turning ADMIN ');
    session_set_user(get_admin());
    // apply all default settings, just in case do it twice to fill all defaults
    // debug_trace('Remote Upgrade : Applying settings ');
    admin_apply_default_settings(NULL, false);
    admin_apply_default_settings(NULL, false);
    ob_end_clean();
    $response->message = vmoodle_get_string('upgradecomplete', 'vmoodleadminset_upgrade', $newversion);
    if ($json_response) {
        return json_encode($response);
    } else {
        return $response;
    }
}
示例#14
0
// Get current Moodle version
$current_version = $CFG->release;
// Calculate list of versions
$versions = array();
if ($contents = load_environment_xml()) {
    if ($env_versions = get_list_of_environment_versions($contents)) {
        // Set the current version at the beginning
        $env_version = normalize_version($current_version);
        //We need this later (for the upwards)
        $versions[$env_version] = $current_version;
        // If no version has been previously selected, default to $current_version
        if (empty($version)) {
            $version = $env_version;
        }
        //Iterate over each version, adding bigger than current
        foreach ($env_versions as $env_version) {
            if (version_compare(normalize_version($current_version), $env_version, '<')) {
                $versions[$env_version] = $env_version;
            }
        }
        // Add 'upwards' to the last element
        $versions[$env_version] = $env_version . ' ' . get_string('upwards', 'admin');
    } else {
        $versions = array('error' => get_string('error'));
    }
}
// Get the results of the environment check.
list($envstatus, $environment_results) = check_moodle_environment($version);
// Display the page.
$output = $PAGE->get_renderer('core', 'admin');
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
    die;
}
if (empty($CFG->version)) {
    cli_error(get_string('missingconfigversion', 'debug'));
}
require "{$CFG->dirroot}/version.php";
// defines $version, $release and $maturity
$CFG->target_release = $release;
// used during installation and upgrades
if ($version < $CFG->version) {
    cli_error(get_string('downgradedcore', 'error'));
}
$oldversion = "{$CFG->release} ({$CFG->version})";
$newversion = "{$release} ({$version})";
// test environment first
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
    $errors = environment_get_errors($environment_results);
    cli_heading(get_string('environment', 'admin'));
    foreach ($errors as $error) {
        list($info, $report) = $error;
        echo "!! {$info} !!\n{$report}\n\n";
    }
    exit(1);
}
if ($interactive) {
    $a = new stdClass();
    $a->oldversion = $oldversion;
    $a->newversion = $newversion;
    echo cli_heading(get_string('databasechecking', '', $a)) . PHP_EOL;
}
// make sure we are upgrading to a stable release or display a warning