Skip to content

Commit 5375626

Browse files
authored
feat: Added panic switch (#101)
1 parent 42c07d2 commit 5375626

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

lbplanner/classes/enums/SETTINGS.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class SETTINGS extends Enum {
4343
* NOTE: This is a constant! Do not set outside version.php under ANY circumstances!
4444
*/
4545
const V_FULLNUM = 'release_fullnum';
46+
/**
47+
* Key for the panic / fulloff button.
48+
*/
49+
const PANIC = 'panic';
4650
/**
4751
* Key for the setting for how many days into the future a student should be able to reserve a slot.
4852
*/

lbplanner/lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
use local_lbplanner\helpers\sentry_helper;
26+
use local_lbplanner\enums\SETTINGS;
2627

2728
/**
2829
* Callback for any webservices that get called by external actors.
@@ -34,6 +35,9 @@
3435
function local_lbplanner_override_webservice_execution(stdClass $externalfunctioninfo, array $params): mixed {
3536
// Only override calling our own functions.
3637
if ($externalfunctioninfo->component === 'local_lbplanner') {
38+
if (get_config('local_lbplanner', SETTINGS::PANIC) === '1') {
39+
throw new \moodle_exception('PANIC'); // TODO: add to translations.
40+
}
3741
sentry_helper::init();
3842
// Actually calling the function (since we're overriding this part, duh).
3943
try {

lbplanner/settings.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@
6666
PARAM_TEXT
6767
);
6868
$settings->add($sentrydsnsett);
69+
70+
$panicsett = new admin_setting_configcheckbox(
71+
'local_lbplanner/' . SETTINGS::PANIC,
72+
'PANIC SWITCH',
73+
'Turns API off - only use in emergencies. No data loss, but total loss of EduPlanner services until box is unchecked.',
74+
'0',
75+
);
76+
$settings->add($panicsett);
6977
}

0 commit comments

Comments
 (0)