From 9bf9bd282379df1f19120a01cf32adce8ba3d6ad Mon Sep 17 00:00:00 2001 From: Xu Date: Wed, 27 Mar 2024 21:05:44 +0100 Subject: [PATCH] add 'enable_email_goody' config and fix wording --- config/config.default.php | 5 ++++- resources/lang/de_DE/default.po | 4 ++++ resources/lang/en_US/default.po | 4 ++++ resources/views/pages/registration.twig | 3 ++- resources/views/pages/settings/profile.twig | 3 ++- src/Controllers/RegistrationController.php | 2 +- src/Controllers/SettingsController.php | 5 +++-- tests/Unit/Controllers/SettingsControllerTest.php | 1 + 8 files changed, 21 insertions(+), 6 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index e9b413c6..0183731c 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -85,9 +85,12 @@ return [ 'sendmail' => env('MAIL_SENDMAIL', '/usr/sbin/sendmail -bs'), ], - # Your privacy@ contact address + // Your privacy@ contact address 'privacy_email' => env('PRIVACY_EMAIL', null), + // Show opt in to save some personal data after the event on user profile and registration pages + 'enable_email_goody' => (bool) env('ENABLE_EMAIL_GOODY', true), + // Initial admin password 'setup_admin_password' => env('SETUP_ADMIN_PASSWORD', null), diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 29907739..b93d307f 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1637,6 +1637,10 @@ msgstr "Erlaube Himmel-Engeln mich per E-Mail zu kontaktieren." msgid "settings.profile.email_goody" msgstr "Um gegebenenfalls Voucher für das nächste gleichartige Event zu erhalten stimme ich zu, " +"dass mein Nick, E-Mail-Adresse und geleistete Arbeit solange gespeichert werden." + +msgid "settings.profile.email_tshirt" +msgstr "Um gegebenenfalls Voucher für das nächste gleichartige Event zu erhalten stimme ich zu, " "dass mein Nick, E-Mail-Adresse, geleistete Arbeit und T-Shirt-Größe solange gespeichert werden." msgid "settings.profile.privacy" diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index d5ae8b74..70b7594c 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -339,6 +339,10 @@ msgstr "Allow heaven angels to contact me by e-mail." msgid "settings.profile.email_goody" msgstr "To possibly receive vouchers for the next similar event, I consent " +"that my nick, e-mail address and worked hours will be stored until then." + +msgid "settings.profile.email_tshirt" +msgstr "To possibly receive vouchers for the next similar event, I consent " "that my nick, e-mail address, worked hours and T-shirt size will be stored until then." msgid "settings.profile.privacy" diff --git a/resources/views/pages/registration.twig b/resources/views/pages/registration.twig index cedd70cf..15f27d66 100644 --- a/resources/views/pages/registration.twig +++ b/resources/views/pages/registration.twig @@ -196,7 +196,8 @@ {% if isGoodieEnabled %}
{% set privacy_email = config('privacy_email') %} - {% set email_goody_label = __('settings.profile.email_goody') ~ + {% set email_goody_label = + (isGoodieTShirt ? __('settings.profile.email_tshirt') : __('settings.profile.email_goody')) ~ (privacy_email ? ' ' ~ __('settings.profile.privacy', [privacy_email]) : '') %} {{ f.checkbox( diff --git a/resources/views/pages/settings/profile.twig b/resources/views/pages/settings/profile.twig index 09d95a13..a544618c 100644 --- a/resources/views/pages/settings/profile.twig +++ b/resources/views/pages/settings/profile.twig @@ -135,7 +135,8 @@ }) }} {% if goodie_enabled %} {% set privacy_email = config('privacy_email') %} - {% set email_goody_label = __('settings.profile.email_goody') ~ + {% set email_goody_label = + (goodie_tshirt ? __('settings.profile.email_tshirt') : __('settings.profile.email_goody')) ~ (privacy_email ? ' ' ~ __('settings.profile.privacy', [privacy_email]) : '') %} {{ f.checkbox('email_goody', email_goody_label, { diff --git a/src/Controllers/RegistrationController.php b/src/Controllers/RegistrationController.php index 26178d38..7757827a 100644 --- a/src/Controllers/RegistrationController.php +++ b/src/Controllers/RegistrationController.php @@ -99,7 +99,7 @@ class RegistrationController extends BaseController 'isPasswordEnabled' => $this->userFactory->determineIsPasswordEnabled(), 'isDECTEnabled' => $this->config->get('enable_dect'), 'isShowMobileEnabled' => $this->config->get('enable_mobile_show'), - 'isGoodieEnabled' => $goodieType !== GoodieType::None, + 'isGoodieEnabled' => $goodieType !== GoodieType::None && config('enable_email_goody'), 'isGoodieTShirt' => $goodieType === GoodieType::Tshirt, 'isPronounEnabled' => $this->config->get('enable_pronoun'), 'isFullNameEnabled' => $this->config->get('enable_user_name'), diff --git a/src/Controllers/SettingsController.php b/src/Controllers/SettingsController.php index ffa1399a..8a6d34e1 100644 --- a/src/Controllers/SettingsController.php +++ b/src/Controllers/SettingsController.php @@ -46,7 +46,8 @@ class SettingsController extends BaseController [ 'settings_menu' => $this->settingsMenu(), 'userdata' => $user, - 'goodie_enabled' => $this->config->get('goodie_type') !== GoodieType::None->value, + 'goodie_enabled' => $this->config->get('goodie_type') !== GoodieType::None->value + && config('enable_email_goody'), 'goodie_tshirt' => $this->config->get('goodie_type') === GoodieType::Tshirt->value, 'tShirtLink' => $this->config->get('tshirt_link'), 'isPronounRequired' => $requiredFields['pronoun'], @@ -105,7 +106,7 @@ class SettingsController extends BaseController $user->settings->email_human = $data['email_human'] ?: false; $user->settings->email_messages = $data['email_messages'] ?: false; - if ($goodie_enabled) { + if ($goodie_enabled && config('enable_email_goody')) { $user->settings->email_goody = $data['email_goody'] ?: false; } diff --git a/tests/Unit/Controllers/SettingsControllerTest.php b/tests/Unit/Controllers/SettingsControllerTest.php index 9d38d26c..9a3af7cb 100644 --- a/tests/Unit/Controllers/SettingsControllerTest.php +++ b/tests/Unit/Controllers/SettingsControllerTest.php @@ -74,6 +74,7 @@ class SettingsControllerTest extends ControllerTest 'enable_planned_arrival' => true, 'enable_dect' => true, 'enable_mobile_show' => true, + 'enable_email_goody' => true, 'goodie_type' => GoodieType::Tshirt->value, ]);