mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-27171 messages: populate messaging defaults after the installation
This makes the order of plugins returned by get_plugin_types not important as all messaging defaults population is done at the end. Signed-off-by: Ruslan Kabalin <ruslan.kabalin@luns.net.uk>
This commit is contained in:
parent
60bbe7684a
commit
67147c2550
@ -43,6 +43,7 @@ define('NO_OUTPUT_BUFFERING', true);
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/installlib.php'); // general upgrade/install related functions
|
||||
|
||||
$id = optional_param('id', '', PARAM_TEXT);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
@ -320,11 +321,8 @@ if (moodle_needs_upgrading()) {
|
||||
// If this is the first install, indicate that this site is fully configured
|
||||
// except the admin password
|
||||
if (during_initial_install()) {
|
||||
// ensure message preferences for the core message providers are set
|
||||
$fileproviders = message_get_providers_from_file('moodle');
|
||||
foreach ($fileproviders as $messagename => $fileprovider) {
|
||||
message_set_default_message_preference('moodle', $messagename, $fileprovider);
|
||||
}
|
||||
// ensure default message preferences for message providers are set
|
||||
install_populate_default_messaging_prefs();
|
||||
|
||||
set_config('rolesactive', 1); // after this, during_initial_install will return false.
|
||||
set_config('adminsetuppending', 1);
|
||||
|
@ -558,11 +558,8 @@ function install_cli_database(array $options, $interactive) {
|
||||
// install all plugins types, local, etc.
|
||||
upgrade_noncore(true);
|
||||
|
||||
// ensure message preferences for the core message providers are set
|
||||
$fileproviders = message_get_providers_from_file('moodle');
|
||||
foreach ($fileproviders as $messagename => $fileprovider) {
|
||||
message_set_default_message_preference('moodle', $messagename, $fileprovider);
|
||||
}
|
||||
// ensure default message preferences for message providers are set
|
||||
install_populate_default_messaging_prefs();
|
||||
|
||||
// set up admin user password
|
||||
$DB->set_field('user', 'password', hash_internal_user_password($options['adminpass']), array('username' => 'admin'));
|
||||
@ -594,3 +591,24 @@ function install_cli_database(array $options, $interactive) {
|
||||
$DB->set_field('course', 'fullname', $options['fullname'], array('format' => 'site'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate default messaging preferences after installation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_populate_default_messaging_prefs() {
|
||||
global $DB;
|
||||
|
||||
$providers = $DB->get_records_sql('SELECT DISTINCT component FROM {message_providers}');
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
foreach ($providers as $provider) {
|
||||
// load message providers from files
|
||||
$fileproviders = message_get_providers_from_file($provider->component);
|
||||
foreach ($fileproviders as $messagename => $fileprovider) {
|
||||
message_set_default_message_preference($provider->component, $messagename, $fileprovider);
|
||||
}
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
}
|
@ -7067,12 +7067,10 @@ function get_plugin_types($fullpaths=true) {
|
||||
static $fullinfo = null;
|
||||
|
||||
if (!$info) {
|
||||
// BEWARE: message/output should always be the first as we need to have
|
||||
// message outputs installed before installing every other plugin.
|
||||
$info = array('message' => 'message/output',
|
||||
'mod' => 'mod',
|
||||
$info = array('mod' => 'mod',
|
||||
'auth' => 'auth',
|
||||
'enrol' => 'enrol',
|
||||
'message' => 'message/output',
|
||||
'block' => 'blocks',
|
||||
'filter' => 'filter',
|
||||
'editor' => 'lib/editor',
|
||||
|
Loading…
x
Reference in New Issue
Block a user