Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (3 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/admin/cli/install.php

    r136 r1331  
    7070--fullname=STRING     The fullname of the site
    7171--shortname=STRING    The shortname of the site
     72--summary=STRING      The summary to be displayed on the front page
    7273--adminuser=USERNAME  Username for the moodle admin account. Default is admin
    7374--adminpass=PASSWORD  Password for the moodle admin account,
    7475                      required in non-interactive mode.
     76--adminemail=STRING   Email address for the moodle admin account.
     77--upgradekey=STRING   The upgrade key to be set in the config.php, leave empty to not set it.
    7578--non-interactive     No interactive questions, installation fails if any
    7679                      problem encountered.
     
    7982--allow-unstable      Install even if the version is not marked as stable yet,
    8083                      required in non-interactive mode.
     84--skip-database       Stop the installation before installing the database.
    8185-h, --help            Print out this help
    8286
     
    121125
    122126// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
    123 // This is a quick hack.  Ideally we should ask the admin for a value.  See MDL-22625 for more on this.
    124 if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
    125     @date_default_timezone_set(@date_default_timezone_get());
    126 }
     127if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
     128    fwrite(STDERR, "Timezone functions are not available.\n");
     129    exit(1);
     130}
     131date_default_timezone_set(@date_default_timezone_get());
    127132
    128133// make sure PHP errors are displayed - helps with diagnosing of problems
     
    251256        'fullname'          => '',
    252257        'shortname'         => '',
     258        'summary'           => '',
    253259        'adminuser'         => 'admin',
    254260        'adminpass'         => '',
     261        'adminemail'        => '',
     262        'upgradekey'        => '',
    255263        'non-interactive'   => false,
    256264        'agree-license'     => false,
    257265        'allow-unstable'    => false,
     266        'skip-database'     => false,
    258267        'help'              => false
    259268    ),
     
    267276// set up language
    268277$lang = clean_param($options['lang'], PARAM_SAFEDIR);
    269 if (file_exists($CFG->dirroot.'/install/lang/'.$lang)) {
     278$languages = get_string_manager()->get_list_of_translations();
     279if (array_key_exists($lang, $languages)) {
    270280    $CFG->lang = $lang;
    271281}
     
    282292
    283293//Print header
     294cli_logo();
     295echo PHP_EOL;
    284296echo get_string('cliinstallheader', 'install', $CFG->target_release)."\n";
    285297
     
    287299if ($interactive) {
    288300    cli_separator();
    289     $languages = get_string_manager()->get_list_of_translations();
    290301    // Do not put the langs into columns because it is not compatible with RTL.
    291     $langlist = implode("\n", $languages);
    292302    $default = $CFG->lang;
    293     cli_heading(get_string('availablelangs', 'install'));
    294     echo $langlist."\n";
     303    cli_heading(get_string('chooselanguagehead', 'install'));
     304    if (array_key_exists($default, $languages)) {
     305        echo $default.' - '.$languages[$default]."\n";
     306    }
     307    if ($default !== 'en') {
     308        echo 'en - English (en)'."\n";
     309    }
     310    echo '? - '.get_string('availablelangs', 'install')."\n";
    295311    $prompt = get_string('clitypevaluedefault', 'admin', $CFG->lang);
    296312    $error = '';
     
    298314        echo $error;
    299315        $input = cli_input($prompt, $default);
    300         $input = clean_param($input, PARAM_SAFEDIR);
    301 
    302         if (!file_exists($CFG->dirroot.'/install/lang/'.$input)) {
    303             $error = get_string('cliincorrectvalueretry', 'admin')."\n";
     316
     317        if ($input === '?') {
     318            echo implode("\n", $languages)."\n";
     319            $error = "\n";
     320
    304321        } else {
    305             $error = '';
     322            $input = clean_param($input, PARAM_SAFEDIR);
     323
     324            if (!array_key_exists($input, $languages)) {
     325                $error = get_string('cliincorrectvalueretry', 'admin')."\n";
     326            } else {
     327                $error = '';
     328            }
    306329        }
    307330    } while ($error !== '');
     
    688711}
    689712
     713// Ask for the admin email address.
     714if ($interactive) {
     715    cli_separator();
     716    cli_heading(get_string('cliadminemail', 'install'));
     717    $prompt = get_string('clitypevaluedefault', 'admin', $options['adminemail']);
     718    $options['adminemail'] = cli_input($prompt);
     719}
     720
     721// Validate that the address provided was an e-mail address.
     722if (!empty($options['adminemail']) && !validate_email($options['adminemail'])) {
     723    $a = (object) array('option' => 'adminemail', 'value' => $options['adminemail']);
     724    cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
     725}
     726
     727// Ask for the upgrade key.
     728if ($interactive) {
     729    cli_separator();
     730    cli_heading(get_string('upgradekeyset', 'admin'));
     731    if ($options['upgradekey'] !== '') {
     732        $prompt = get_string('clitypevaluedefault', 'admin', $options['upgradekey']);
     733        $options['upgradekey'] = cli_input($prompt, $options['upgradekey']);
     734    } else {
     735        $prompt = get_string('clitypevalue', 'admin');
     736        $options['upgradekey'] = cli_input($prompt);
     737    }
     738}
     739
     740// Set the upgrade key if it was provided.
     741if ($options['upgradekey'] !== '') {
     742    $CFG->upgradekey = $options['upgradekey'];
     743}
     744
    690745if ($interactive) {
    691746    if (!$options['agree-license']) {
     
    752807}
    753808
    754 install_cli_database($options, $interactive);
     809if (!$options['skip-database']) {
     810    install_cli_database($options, $interactive);
     811} else {
     812    echo get_string('cliskipdatabase', 'install')."\n";
     813}
    755814
    756815echo get_string('cliinstallfinished', 'install')."\n";
Note: See TracChangeset for help on using the changeset viewer.