From 6b273288bd47141c77634cbf36988abad0961df3 Mon Sep 17 00:00:00 2001 From: Xu Date: Fri, 25 Aug 2023 20:33:14 +0200 Subject: [PATCH] add config option for ifsg_light --- config/config.default.php | 4 ++++ resources/views/pages/settings/certificates.twig | 8 +++++--- src/Controllers/SettingsController.php | 8 +++++--- tests/Unit/Controllers/SettingsControllerTest.php | 2 ++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 1896fbb0..97da2129 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -326,6 +326,10 @@ return [ # Instruction in accordance with § 43 Para. 1 of the German Infection Protection Act (IfSG) 'ifsg_enabled' => (bool) env('IFSG_ENABLED', false), + # Instruction only onsite in accordance with § 43 Para. 1 of the German Infection Protection Act (IfSG) + 'ifsg_light_enabled' => (bool) env('IFSG_LIGHT_ENABLED', false) + && env('IFSG_ENABLED', false), + // Available locales in /resources/lang/ 'locales' => [ 'de_DE' => 'Deutsch', diff --git a/resources/views/pages/settings/certificates.twig b/resources/views/pages/settings/certificates.twig index cc126b96..81d05107 100644 --- a/resources/views/pages/settings/certificates.twig +++ b/resources/views/pages/settings/certificates.twig @@ -11,9 +11,11 @@
{{ m.info(__('settings.certificates.info')) }} - {{ f.checkbox('ifsg_certificate_light', __('settings.ifsg_light'), { - 'checked': ifsg_certificate_light, - }) }} + {% if config('ifsg_light_enabled') %} + {{ f.checkbox('ifsg_certificate_light', __('settings.ifsg_light'), { + 'checked': ifsg_certificate_light, + }) }} + {% endif %} {{ f.checkbox('ifsg_certificate', __('settings.ifsg'), { 'checked': ifsg_certificate, }) }} diff --git a/src/Controllers/SettingsController.php b/src/Controllers/SettingsController.php index b84b0891..fc0e0846 100644 --- a/src/Controllers/SettingsController.php +++ b/src/Controllers/SettingsController.php @@ -233,9 +233,9 @@ class SettingsController extends BaseController return $this->response->withView( 'pages/settings/certificates', [ - 'settings_menu' => $this->settingsMenu(), + 'settings_menu' => $this->settingsMenu(), 'ifsg_certificate_light' => $user->license->ifsg_certificate_light, - 'ifsg_certificate' => $user->license->ifsg_certificate, + 'ifsg_certificate' => $user->license->ifsg_certificate, ] ); } @@ -252,7 +252,9 @@ class SettingsController extends BaseController throw new HttpNotFound('ifsg.disabled'); } - $user->license->ifsg_certificate_light = !$data['ifsg_certificate'] && $data['ifsg_certificate_light']; + if (config('ifsg_light_enabled')) { + $user->license->ifsg_certificate_light = !$data['ifsg_certificate'] && $data['ifsg_certificate_light']; + } $user->license->ifsg_certificate = (bool) $data['ifsg_certificate']; $user->license->save(); diff --git a/tests/Unit/Controllers/SettingsControllerTest.php b/tests/Unit/Controllers/SettingsControllerTest.php index 67abe2a8..0b37cf5e 100644 --- a/tests/Unit/Controllers/SettingsControllerTest.php +++ b/tests/Unit/Controllers/SettingsControllerTest.php @@ -583,6 +583,7 @@ class SettingsControllerTest extends ControllerTest public function testIfsgCertificate(): void { config(['ifsg_enabled' => true]); + config(['ifsg_light_enabled' => true]); $this->setExpects($this->auth, 'user', null, $this->user, $this->once()); $this->response->expects($this->once()) @@ -629,6 +630,7 @@ class SettingsControllerTest extends ControllerTest public function testSaveIfsgCertificateLight(): void { config(['ifsg_enabled' => true]); + config(['ifsg_light_enabled' => true]); $this->setExpects($this->auth, 'user', null, $this->user, $this->once()); $body = [