This plugin allows the automated setup of various configurations that are usually hard to setup through config.php
.
It uses a special file config-seed.php
containing only the $CONFSEED
configuration variable, which is a stdClass
in which attributes can be set to be enforced at upgrade time:
version
This will be used as thelocal/confseed
plugin version. Only changes to that field will trigger new configuration enforcements.settings
is anarray
whose keys are the$CFG->
settings that need to be set to the provided valuesplugin_settings
is anarray
whose keys are the plugin sections; the sub arrays are key-value pairs written into the plugin tables. If the value is an existing file, it gets uploaded to said section.user_info_categories
is anarray
ofstdClass
$DB
descriptors for the{user_info_category}
database table, which keys are codename for the belowuser_info_fields
.- Mandatory fields:
id
name
user_info_fields
is anarray
ofstdClass
$DB
descriptors for the{user_info_field}
database table, which keys are the tableshortname
s. Please refer touser/profile/field/*/define.class.php
for the various attributes' usages.- Mandatory fields:
name
datatype
auth_enable
is anarray
of authentication plugins (withoutauth/
norauth_
prefixes) that need to be forcibly enabledauth_disable
is anarray
of authentication plugins (withoutauth/
norauth_
prefixes) that need to be forcibly disabledenrol_enable
is anarray
of enrolment plugins (withoutenrol/
norenrolq_
prefixes) that need to be forcibly enabledenrol_disable
is anarray
of enrolment plugins (withoutenrol/
norenrol_
prefixes) that need to be forcibly disableduninstall_plugins
is anarray
of full plugin names (such astheme_oldmamma
) to be uninstalled. If set, all pre-2.7 themes are also uninstalledfilter_activation
is anarray
of plugin names (such asgeshi
) to be activated/deactivated; the values must be -1 or 1 integers.languages
is anarray
of short language names (such as'de'
,'fr'
) that will be installed.
<?php
$CONFSEED = new stdClass();
$CONFSEED->version = 2020060800;
// Set some values.
$CONFSEED->languages = ['de', 'fr'];
$CONFSEED->settings = [
'theme' => 'boost',
'enablewebservices' => 1,
];
// Set some plugin values (like 'moodlecourse | format'), or upload certain files.
$CONFSEED->plugin_settings = [
'moodlecourse' => [
'format' => 'weeks',
],
'core_admin' => [
'logo' => 'local/logo.png'
]
];
// Uninstall certain plugins; all the pre-2.7 themes are uninstalled forcibly if the variable is set.
$CONFSEED->uninstall_plugins = [
'theme_oldmamma',
];
// Create user profile categories.
$CONFSEED->user_info_categories = [
'food' => (object) [
'id' => 1,
'name' => 'Alimentary restrictions',
'sortorder' => 1,
],
];
// Create user profile fields.
$CONFSEED->user_info_fields = [
'meat' => (object) [
'category' => 'food',
'name' => 'I eat meat',
'required' => false,
'signup' => true,
'datatype' => 'checkbox',
'defaultdata' => false
],
'freetext' => (object) [
'category' => 'food',
'name' => 'Comments …',
'signup' => true,
'datatype' => 'text',
'param1' => 60, // Display size.
'param2' => 512, // Maximum length.
],
];
// Enable or disable certain authentications.
$CONFSEED->auth_enable = ['cas', ];
$CONFSEED->auth_disable = ['email', ];
// Enable or disable certain enrolment methods.
$CONFSEED->enrol_enable = ['database', ];
$CONFSEED->enrol_disable = ['self', ];
// Show or hide certain activity modules.
$CONFSEED->mod_show = ['assignment', ];
$CONFSEED->mod_hide = ['book', ];
// Enable or disable certain webservices protocols.
$CONFSEED->wsprotocols_enable = ['rest', ];
$CONFSEED->wsprotocols_disable = ['soap', ];
// Activate/Deactivate a Filter plugin by default.
$CONFSEED->filter_activation = [
'geshi' => 1,
'algebra' => -1
];
Due to Moodle forcibly setting default settings for all plugins as well as some variables such as registerauth
during an initial installation; local_confseed
sets itself a lower version upon install, in order to trigger upon upgrade immediately after.
In other words: upon a Moodle initial installation, local_confseed
will not have run, so a Moodle upgrade is needed for local_confseed
to work.