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:
Sara Arjona 2021-11-17 16:56:48 +01:00
parent 5ee0b620ae
commit 42895003e4
6 changed files with 198 additions and 0 deletions

View file

@ -719,6 +719,12 @@ if (during_initial_install()) {
set_config('rolesactive', 1); // after this, during_initial_install will return false.
set_config('adminsetuppending', 1);
set_config('registrationpending', 1); // Remind to register site after all other setup is finished.
// 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);
}
// we need this redirect to setup proper session
upgrade_finished("index.php?sessionstarted=1&lang=$CFG->lang");
}