diff --git a/admin/cli/install_database.php b/admin/cli/install_database.php index ac1245ae9ee..e4ed7ba124b 100644 --- a/admin/cli/install_database.php +++ b/admin/cli/install_database.php @@ -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'; diff --git a/lib/installlib.php b/lib/installlib.php index 13395b087a3..6847d9ba437 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -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