diff --git a/admin/cli/install.php b/admin/cli/install.php index bb9441ee0a2..80bcdd9d906 100644 --- a/admin/cli/install.php +++ b/admin/cli/install.php @@ -75,6 +75,7 @@ Options: required in non-interactive mode. --adminemail=STRING Email address for the moodle admin account. --sitepreset=STRING Admin site preset to be applied during the installation process. +--supportemail=STRING Email address for support and help. --upgradekey=STRING The upgrade key to be set in the config.php, leave empty to not set it. --non-interactive No interactive questions, installation fails if any problem encountered. @@ -256,6 +257,7 @@ list($options, $unrecognized) = cli_get_params( 'adminpass' => '', 'adminemail' => '', 'sitepreset' => '', + 'supportemail' => '', 'upgradekey' => '', 'non-interactive' => false, 'agree-license' => false, @@ -739,6 +741,20 @@ if (!$skipdatabase) { $a = (object)['option' => 'adminemail', 'value' => $options['adminemail']]; cli_error(get_string('cliincorrectvalueerror', 'admin', $a)); } + + // Ask for the support email address. + if ($interactive) { + cli_separator(); + cli_heading(get_string('clisupportemail', 'install')); + $prompt = get_string('clitypevaluedefault', 'admin', $options['supportemail']); + $options['supportemail'] = cli_input($prompt, $options['supportemail']); + } + + // Validate that the support email address provided is valid. + if (!empty($options['supportemail']) && !validate_email($options['supportemail'])) { + $a = (object)['option' => 'supportemail', 'value' => $options['supportemail']]; + cli_error(get_string('cliincorrectvalueerror', 'admin', $a)); + } } // Ask for the upgrade key. diff --git a/lang/en/install.php b/lang/en/install.php index 681807f7a02..a54a1aa8800 100644 --- a/lang/en/install.php +++ b/lang/en/install.php @@ -48,6 +48,7 @@ $string['cliinstallfinished'] = 'Installation completed successfully.'; $string['cliinstallheader'] = 'Moodle {$a} command line installation program'; $string['climustagreelicense'] = 'In non-interactive mode you must agree to the licence by specifying --agree-license option'; $string['cliskipdatabase'] = 'Skipping database installation.'; +$string['clisupportemail'] = 'Support email address'; $string['clitablesexist'] = 'Database tables already present; CLI installation cannot continue.'; $string['compatibilitysettings'] = 'Checking your PHP settings ...'; $string['compatibilitysettingshead'] = 'Checking your PHP settings ...'; diff --git a/lib/installlib.php b/lib/installlib.php index e54b6a06b9f..8a9ca0ed047 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -506,6 +506,11 @@ function install_cli_database(array $options, $interactive) { $DB->set_field('user', 'username', $options['adminuser'], array('username' => 'admin')); } + // Set the support email address if specified. + if (isset($options['supportemail'])) { + set_config('supportemail', $options['supportemail']); + } + // indicate that this site is fully configured set_config('rolesactive', 1); upgrade_finished();