From b860b37ba9d6256dda12d4455fbe3ec3b9a0c85c Mon Sep 17 00:00:00 2001 From: Xu Date: Fri, 21 Oct 2022 22:20:06 +0200 Subject: [PATCH] add option to hide angeltype at registration --- ...000000_add_hide_register_to_angeltypes.php | 43 +++++++++++++++++++ includes/controller/angeltypes_controller.php | 1 + includes/model/AngelType_model.php | 21 ++++++--- includes/pages/guest_login.php | 5 ++- includes/view/AngelTypes_view.php | 3 ++ resources/lang/de_DE/default.po | 3 ++ tests/Unit/HasDatabase.php | 1 + 7 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 db/migrations/2022_10_21_000000_add_hide_register_to_angeltypes.php diff --git a/db/migrations/2022_10_21_000000_add_hide_register_to_angeltypes.php b/db/migrations/2022_10_21_000000_add_hide_register_to_angeltypes.php new file mode 100644 index 00000000..acc706f1 --- /dev/null +++ b/db/migrations/2022_10_21_000000_add_hide_register_to_angeltypes.php @@ -0,0 +1,43 @@ +schema->hasTable('AngelTypes')) { + return; + } + + $this->schema->table( + 'AngelTypes', + function (Blueprint $table) { + $table->boolean('hide_register')->default(false)->after('show_on_dashboard'); + } + ); + } + + /** + * Reverse the migration + */ + public function down() + { + if (!$this->schema->hasTable('AngelTypes')) { + return; + } + + $this->schema->table( + 'AngelTypes', + function (Blueprint $table) { + $table->dropColumn('hide_register'); + } + ); + } +} diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index 17631412..dd4a993c 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -139,6 +139,7 @@ function angeltype_edit_controller() $angeltype['restricted'] = $request->has('restricted'); $angeltype['no_self_signup'] = $request->has('no_self_signup'); $angeltype['show_on_dashboard'] = $request->has('show_on_dashboard'); + $angeltype['hide_register'] = $request->has('hide_register'); $angeltype['requires_driver_license'] = $request->has('requires_driver_license'); } diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index 898d9f1d..937afecf 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -19,7 +19,8 @@ function AngelType_new() 'contact_name' => null, 'contact_dect' => null, 'contact_email' => null, - 'show_on_dashboard' => true + 'show_on_dashboard' => true, + 'hide_register' => false ]; } @@ -69,7 +70,8 @@ function AngelType_update($angeltype) `contact_name` = ?, `contact_dect` = ?, `contact_email` = ?, - `show_on_dashboard` = ? + `show_on_dashboard` = ?, + `hide_register` = ? WHERE `id` = ? ', [ @@ -82,6 +84,7 @@ function AngelType_update($angeltype) $angeltype['contact_dect'], $angeltype['contact_email'], (int)$angeltype['show_on_dashboard'], + (int)$angeltype['hide_register'], $angeltype['id'], ] ); @@ -93,7 +96,8 @@ function AngelType_update($angeltype) . $angeltype['contact_name'] . ', ' . $angeltype['contact_dect'] . ', ' . $angeltype['contact_email'] . ', ' - . $angeltype['show_on_dashboard'] + . $angeltype['show_on_dashboard'] . ', ' + . $angeltype['hide_register'] ); } @@ -116,9 +120,10 @@ function AngelType_create($angeltype) `contact_name`, `contact_dect`, `contact_email`, - `show_on_dashboard` + `show_on_dashboard`, + `hide_register` ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ', [ $angeltype['name'], @@ -129,7 +134,8 @@ function AngelType_create($angeltype) $angeltype['contact_name'], $angeltype['contact_dect'], $angeltype['contact_email'], - (int)$angeltype['show_on_dashboard'] + (int)$angeltype['show_on_dashboard'], + (int)$angeltype['hide_register'], ] ); @@ -141,7 +147,8 @@ function AngelType_create($angeltype) . $angeltype['contact_name'] . ', ' . $angeltype['contact_dect'] . ', ' . $angeltype['contact_email'] . ', ' - . $angeltype['show_on_dashboard'] + . $angeltype['show_on_dashboard'] . ', ' + . $angeltype['hide_register'] ); return $angeltype; diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index f03351f1..e0f7f474 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -75,8 +75,11 @@ function guest_register() } } foreach ($angel_types_source as $angel_type) { + if ($angel_type['hide_register']) { + continue; + } $angel_types[$angel_type['id']] = $angel_type['name'] - . ($angel_type['restricted'] ? ' (' . __('Requires introduction') . ')' : ''); + . ($angel_type['restricted'] ? ' (' . __('Requires introduction') . ')' : ''); if (!$angel_type['restricted']) { $selected_angel_types[] = $angel_type['id']; } diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index ef0cc43c..151417ee 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -111,6 +111,9 @@ function AngelType_edit_view($angeltype, $supporter_mode) $supporter_mode ? form_info(__('Show on dashboard'), $angeltype['show_on_dashboard'] ? __('Yes') : __('No')) : form_checkbox('show_on_dashboard', __('Show on dashboard'), $angeltype['show_on_dashboard']), + $supporter_mode + ? form_info(__('Hide at Registration'), $angeltype['hide_register'] ? __('Yes') : __('No')) + : form_checkbox('hide_register', __('Hide at Registration'), $angeltype['hide_register']), form_textarea('description', __('Description'), $angeltype['description']), form_info('', __('Please use markdown for the description.')), heading(__('Contact'), 3), diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 7647f8f1..d677d1e6 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2429,6 +2429,9 @@ msgstr "Möchtest Du wirklich %s zu %s hinzufügen?" msgid "Confirm user" msgstr "Benutzer bestätigen" +msgid "Hide at Registration" +msgstr "Ausblenden bei Registrierung" + #: includes/view/UserAngelTypes_view.php:176 msgid "save" msgstr "Speichern" diff --git a/tests/Unit/HasDatabase.php b/tests/Unit/HasDatabase.php index 359198a1..ea56f729 100644 --- a/tests/Unit/HasDatabase.php +++ b/tests/Unit/HasDatabase.php @@ -58,6 +58,7 @@ trait HasDatabase ['migration' => '2021_12_30_000000_remove_admin_news_html_privilege'], ['migration' => '2022_06_02_000000_create_voucher_edit_permission'], ['migration' => '2022_06_03_000000_shifts_add_transaction_id'], + ['migration' => '2022_10_21_000000_add_hide_register_to_angeltypes'], ] );