mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-73145 install: Apply site preset if defined in config
A new setting, $CFG->setsitepresetduringinstall, has been added to config file, to let admins define the site admin preset to be applied during the Moodle installation. Besides, a new parameter, "--sitepreset" has been also added to admin/cli/install.php, to let define it too when running the upgrade process using CLI.
This commit is contained in:
parent
5ee0b620ae
commit
42895003e4
6 changed files with 198 additions and 0 deletions
|
@ -263,6 +263,11 @@ function install_generate_configphp($database, $cfg) {
|
|||
$configphp .= '$CFG->upgradekey = ' . var_export($cfg->upgradekey, true) . ';' . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
if (isset($cfg->setsitepresetduringinstall) and $cfg->setsitepresetduringinstall !== '') {
|
||||
$configphp .= '$CFG->setsitepresetduringinstall = ' . var_export($cfg->setsitepresetduringinstall, true) .
|
||||
';' . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
$configphp .= 'require_once(__DIR__ . \'/lib/setup.php\');' . PHP_EOL . PHP_EOL;
|
||||
$configphp .= '// There is no php closing tag in this file,' . PHP_EOL;
|
||||
$configphp .= '// it is intentional because it prevents trailing whitespace problems!' . PHP_EOL;
|
||||
|
@ -525,4 +530,9 @@ function install_cli_database(array $options, $interactive) {
|
|||
|
||||
// Redirect to site registration on first login.
|
||||
set_config('registrationpending', 1);
|
||||
|
||||
// Apply default preset, if it is defined in $CFG and has a valid value.
|
||||
if (!empty($CFG->setsitepresetduringinstall)) {
|
||||
\tool_admin_presets\helper::change_default_preset($CFG->setsitepresetduringinstall);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue