From 2f2ce6a001092cde8adc9fdac694fd719f0fa69d Mon Sep 17 00:00:00 2001 From: Gwildor Sok Date: Tue, 21 May 2024 21:44:23 +0200 Subject: [PATCH] [SCOUT] Hide approve member applications behind flag for contacts --- .env | 1 + config/services.yaml | 1 + src/Controller/Admin/DashboardController.php | 16 +++++++++++++--- .../Admin/MembershipApplicationCrud.php | 10 +++++++++- .../email/html/contact_new_member.html.twig | 2 +- templates/email/text/contact_new_member.txt.twig | 4 ++-- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 067e284..5f8b4b4 100644 --- a/.env +++ b/.env @@ -60,6 +60,7 @@ USE_MIDDLE_NAME=true CONTRIBUTION_ENABLED=true SEND_FRESH_MEMBER_EMAIL_TO_BOARD=true SEND_FRESH_MEMBER_EMAIL_TO_DIVISION_EMAIL=false +ENABLE_DIVISION_CONTACTS_CAN_APPROVE_NEW_MEMBERS=false # Set to https in production environment SECURE_SCHEME='http' diff --git a/config/services.yaml b/config/services.yaml index 2f830aa..1a2321f 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -17,6 +17,7 @@ parameters: app.sendFreshMemberEmailToBoard: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_BOARD)%' app.sendFreshMemberEmailToDivisionEmail: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_DIVISION_EMAIL)%' app.contributionEnabled: '%env(bool:CONTRIBUTION_ENABLED)%' + app.enableDivisionContactsCanApproveNewMembers: '%env(bool:ENABLE_DIVISION_CONTACTS_CAN_APPROVE_NEW_MEMBERS)%' router.request_context.scheme: '%env(SECURE_SCHEME)%' asset.request_context.secure: true diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index d1469c8..e1fecbd 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -49,7 +49,7 @@ public function configureCrud(): Crud { public function configureMenuItems(): iterable { - return [ + $items = [ MenuItem::linkToDashboard('Dashboard', 'fa fa-home'), MenuItem::section('Website')->setPermission('ROLE_ADMIN'), @@ -58,7 +58,15 @@ public function configureMenuItems(): iterable MenuItem::section('Administratie'), MenuItem::linkToCrud('Leden', 'fa fa-users', Member::class), MenuItem::linkToCrud('Steunleden', 'fa fa-users', SupportMember::class)->setPermission('ROLE_ADMIN'), - MenuItem::linkToCrud('Aanmeldingen', 'fa fa-user-plus', MembershipApplication::class), + ]; + + $membership_applications = MenuItem::linkToCrud('Aanmeldingen', 'fa fa-user-plus', MembershipApplication::class); + if (!$this->getParameter('app.enableDivisionContactsCanApproveNewMembers')) { + $membership_applications->setPermission('ROLE_ADMIN'); + } + + array_push($items, + $membership_applications, MenuItem::linkToCrud('Groepen', 'fa fa-building', Division::class)->setPermission('ROLE_ADMIN'), MenuItem::linkToCrud('Lidmaatschapstypes', 'fa fa-building', MembershipStatus::class)->setPermission('ROLE_ADMIN'), @@ -69,6 +77,8 @@ public function configureMenuItems(): iterable MenuItem::linkToRoute('Home', 'fa fa-arrow-left', 'member_home'), MenuItem::linkToRoute('Statistieken', 'fa fa-bar-chart', 'admin_statistics')->setPermission('ROLE_ADMIN'), MenuItem::linkToLogout('Uitloggen', 'fa fa-lock') - ]; + ); + + return $items; } } diff --git a/src/Controller/Admin/MembershipApplicationCrud.php b/src/Controller/Admin/MembershipApplicationCrud.php index 90e8f9a..b589f96 100644 --- a/src/Controller/Admin/MembershipApplicationCrud.php +++ b/src/Controller/Admin/MembershipApplicationCrud.php @@ -56,11 +56,19 @@ public static function getEntityFqcn(): string public function configureCrud(Crud $crud): Crud { - return $crud + $crud ->setEntityLabelInSingular('aanmelding') ->setEntityLabelInPlural('Lidmaatschapsaanmeldingen') ->setSearchFields(['id', 'firstName', 'lastName', 'email', 'phone', 'city', 'postCode']) ; + + if ($this->getParameter('app.enableDivisionContactsCanApproveNewMembers')) { + $crud->setEntityPermission('ROLE_DIVISION_CONTACT'); + } else { + $crud->setEntityPermission('ROLE_ADMIN'); + } + + return $crud; } public function configureActions(Actions $actions): Actions diff --git a/templates/email/html/contact_new_member.html.twig b/templates/email/html/contact_new_member.html.twig index 36d5b85..e7f4ee9 100644 --- a/templates/email/html/contact_new_member.html.twig +++ b/templates/email/html/contact_new_member.html.twig @@ -1,7 +1,7 @@ {% extends 'email/html/layout.html.twig' %} {% block content %}

- Beste {{ contact.getFullName }}, + Beste {{ contact.getFirstName }},

Onlangs heeft een nieuw lid zich aangemeld bij {{ organisatienaam }}: {{ member.getFullName }}. diff --git a/templates/email/text/contact_new_member.txt.twig b/templates/email/text/contact_new_member.txt.twig index ed653d2..342525e 100644 --- a/templates/email/text/contact_new_member.txt.twig +++ b/templates/email/text/contact_new_member.txt.twig @@ -1,6 +1,6 @@ -r% extends 'email/text/layout.txt.twig' %} +{% extends 'email/text/layout.txt.twig' %} {% block content %} -Beste {{ contact.getFullName }}, +Beste {{ contact.getFirstName }}, Onlangs heeft een nieuw lid zich aangemeld bij {{ organisatienaam }}: {{ member.getFullName }}. Hun lidmaatschap is zojuist goedgekeurd door het bestuur van {{ organisatienaam }}. Bij het aanmelden heeft dit lid aangegeven zich graag aan te sluiten bij de groep {{ member.division.name }}.