diff --git a/lbplanner/classes/enums/SETTINGS.php b/lbplanner/classes/enums/SETTINGS.php index 26414a50..2c43a255 100644 --- a/lbplanner/classes/enums/SETTINGS.php +++ b/lbplanner/classes/enums/SETTINGS.php @@ -43,6 +43,10 @@ class SETTINGS extends Enum { * NOTE: This is a constant! Do not set outside version.php under ANY circumstances! */ const V_FULLNUM = 'release_fullnum'; + /** + * Key for the panic / fulloff button. + */ + const PANIC = 'panic'; /** * Key for the setting for how many days into the future a student should be able to reserve a slot. */ diff --git a/lbplanner/lib.php b/lbplanner/lib.php index 07eaea0e..59b097bd 100644 --- a/lbplanner/lib.php +++ b/lbplanner/lib.php @@ -23,6 +23,7 @@ */ use local_lbplanner\helpers\sentry_helper; +use local_lbplanner\enums\SETTINGS; /** * Callback for any webservices that get called by external actors. @@ -34,6 +35,9 @@ function local_lbplanner_override_webservice_execution(stdClass $externalfunctioninfo, array $params): mixed { // Only override calling our own functions. if ($externalfunctioninfo->component === 'local_lbplanner') { + if (get_config('local_lbplanner', SETTINGS::PANIC) === '1') { + throw new \moodle_exception('PANIC'); // TODO: add to translations. + } sentry_helper::init(); // Actually calling the function (since we're overriding this part, duh). try { diff --git a/lbplanner/settings.php b/lbplanner/settings.php index 827607f2..e36e054a 100644 --- a/lbplanner/settings.php +++ b/lbplanner/settings.php @@ -66,4 +66,12 @@ PARAM_TEXT ); $settings->add($sentrydsnsett); + + $panicsett = new admin_setting_configcheckbox( + 'local_lbplanner/' . SETTINGS::PANIC, + 'PANIC SWITCH', + 'Turns API off - only use in emergencies. No data loss, but total loss of EduPlanner services until box is unchecked.', + '0', + ); + $settings->add($panicsett); }