MDL-75195 core: Added supportemail option to install_database.php

This commit is contained in:
raortegar 2023-07-05 20:11:37 +02:00
parent ef93325f27
commit b914f01316
2 changed files with 14 additions and 1 deletions

View File

@ -57,6 +57,7 @@ Options:
--fullname=STRING Name of the site
--shortname=STRING Name of the site
--summary=STRING The summary to be displayed on the front page
--supportemail=STRING Email address for support and help.
-h, --help Print out this help
Example:
@ -98,6 +99,7 @@ list($options, $unrecognized) = cli_get_params(
'fullname' => '',
'shortname' => '',
'summary' => '',
'supportemail' => '',
'agree-license' => false,
'help' => false
),
@ -136,6 +138,15 @@ if (!empty($options['adminemail']) && !validate_email($options['adminemail'])) {
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
// Validate that the supportemail provided was an e-mail address.
if (!empty($options['supportemail']) && !validate_email($options['supportemail'])) {
$a = (object) [
'option' => 'supportemail',
'value' => $options['supportemail']
];
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
$options['lang'] = clean_param($options['lang'], PARAM_SAFEDIR);
if (!file_exists($CFG->dirroot.'/install/lang/'.$options['lang'])) {
$options['lang'] = 'en';

View File

@ -507,8 +507,10 @@ function install_cli_database(array $options, $interactive) {
}
// Set the support email address if specified.
if (isset($options['supportemail'])) {
if (!empty($options['supportemail'])) {
set_config('supportemail', $options['supportemail']);
} else if (!empty($options['adminemail'])) {
set_config('supportemail', $options['adminemail']);
}
// indicate that this site is fully configured