mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Merge pull request #398 from catalyst/MOODLE_501_issue390
Issue #390: Changed outage auto-start default parameter from checkbox to dropdown with option to fully disable.
This commit is contained in:
@@ -100,6 +100,11 @@ class outagedb {
|
||||
$outage->modifiedby = $USER->id;
|
||||
$outage->lastmodified = time();
|
||||
|
||||
// Setting autostart to false if the default autostart is configured to "Force off".
|
||||
if (get_config('default_autostart', 'auth_outage') === '2') {
|
||||
$outage->autostart = 0;
|
||||
}
|
||||
|
||||
if ($outage->id === null) {
|
||||
// If new outage, set its creator.
|
||||
$outage->createdby = $USER->id;
|
||||
|
||||
@@ -48,8 +48,10 @@ class edit extends moodleform {
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'autostart', get_string('autostart', 'auth_outage'));
|
||||
$mform->addHelpButton('autostart', 'autostart', 'auth_outage');
|
||||
if (get_config('auth_outage', 'default_autostart') !== '2') {
|
||||
$mform->addElement('checkbox', 'autostart', get_string('autostart', 'auth_outage'));
|
||||
$mform->addHelpButton('autostart', 'autostart', 'auth_outage');
|
||||
}
|
||||
|
||||
$mform->addElement('duration', 'warningduration', get_string('warningduration', 'auth_outage'));
|
||||
$mform->addHelpButton('warningduration', 'warningduration', 'auth_outage');
|
||||
|
||||
@@ -223,7 +223,7 @@ class outagelib {
|
||||
* @param outage|null $outage Outage or null if no scheduled outage.
|
||||
*/
|
||||
private static function update_maintenance_later($outage) {
|
||||
if (is_null($outage) || !$outage->autostart) {
|
||||
if (is_null($outage) || !$outage->autostart || get_config('default_autostart', 'auth_outage') === '2') {
|
||||
unset_config('maintenance_later');
|
||||
} else {
|
||||
$message = get_config('moodle', 'maintenance_message');
|
||||
|
||||
@@ -32,6 +32,9 @@ $string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup t
|
||||
$string['auth_outagedescription'] = 'Auxiliary plugin that warns users about a future outage and prevents them from logging in once the outage starts.';
|
||||
$string['autostart'] = 'Auto start maintenance mode.';
|
||||
$string['autostart_help'] = 'If selected, when the outage starts it will automatically turn on Moodle maintenance mode.';
|
||||
$string['autostartoff'] = 'Default off';
|
||||
$string['autostarton'] = 'Default on';
|
||||
$string['autostartforcedoff'] = 'Force off';
|
||||
$string['builtinallowediplist'] = 'Builtin Allowed IP List';
|
||||
$string['builtinallowediplist_desc'] = 'A second allowed IP list which makes it easier to have some IPs forced in config.php and others editable in the UI';
|
||||
$string['clicreateexamples'] = "Create an outage starting in 10 seconds\n\n> php create.php -s=10";
|
||||
|
||||
@@ -43,11 +43,16 @@ if ($hassiteconfig) {
|
||||
get_string('settingssectiondefaultsdescription', 'auth_outage') . $description
|
||||
));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
$settings->add(new admin_setting_configselect(
|
||||
'auth_outage/default_autostart',
|
||||
get_string('defaultoutageautostart', 'auth_outage'),
|
||||
get_string('defaultoutageautostartdescription', 'auth_outage'),
|
||||
$defaults['default_autostart']
|
||||
'0',
|
||||
[
|
||||
'0' => get_string('autostartoff', 'auth_outage'),
|
||||
'1' => get_string('autostarton', 'auth_outage'),
|
||||
'2' => get_string('autostartforcedoff', 'auth_outage'),
|
||||
]
|
||||
));
|
||||
|
||||
$settings->add(new admin_setting_configduration(
|
||||
|
||||
Reference in New Issue
Block a user