From 5b8b59008ab41c2eb22face8a2fd5ab97727e24c Mon Sep 17 00:00:00 2001 From: Xu Date: Sun, 18 Feb 2024 11:59:50 +0100 Subject: [PATCH] number of mails send when news saved --- resources/lang/de_DE/default.po | 2 +- resources/lang/en_US/default.po | 2 +- resources/views/pages/news/edit.twig | 2 +- src/Controllers/Admin/NewsController.php | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 513c437b..19401336 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -90,7 +90,7 @@ msgid "form.submit" msgstr "Absenden" msgid "form.send_notification" -msgstr "Benachrichtigungen versenden" +msgstr "%d Benachrichtigungen versenden" msgid "credits.source" msgstr "Quellcode" diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index e45e758a..124bddb6 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -23,7 +23,7 @@ msgid "form.submit" msgstr "Submit" msgid "form.send_notification" -msgstr "Send notifications" +msgstr "Send %d notifications" msgid "general.login" msgstr "Login" diff --git a/resources/views/pages/news/edit.twig b/resources/views/pages/news/edit.twig index 639dd9d7..b57bb490 100644 --- a/resources/views/pages/news/edit.twig +++ b/resources/views/pages/news/edit.twig @@ -78,7 +78,7 @@ {{ f.delete(__('form.delete'), {'confirm_title': __('news.delete.title', [news.title[:40]|e])}) }} {% endif %} - {{ f.checkbox('send_notification', __('form.send_notification'), {'checked': send_notification, 'class': 'ms-2 form-check-inline'}) }} + {{ f.checkbox('send_notification', __('form.send_notification', [notifications_count]), {'checked': send_notification, 'class': 'ms-2 form-check-inline'}) }} diff --git a/src/Controllers/Admin/NewsController.php b/src/Controllers/Admin/NewsController.php index a94263da..dc5fe766 100644 --- a/src/Controllers/Admin/NewsController.php +++ b/src/Controllers/Admin/NewsController.php @@ -12,6 +12,7 @@ use Engelsystem\Http\Redirector; use Engelsystem\Http\Request; use Engelsystem\Http\Response; use Engelsystem\Models\News; +use Engelsystem\Models\User\Settings; use Psr\Log\LoggerInterface; class NewsController extends BaseController @@ -44,6 +45,7 @@ class NewsController extends BaseController protected function showEdit(?News $news, bool $sendNotification = true, bool $isMeetingDefault = false): Response { + $notificationsCount = Settings::whereEmailNews(true)->count(); return $this->response->withView( 'pages/news/edit.twig', [ @@ -52,6 +54,7 @@ class NewsController extends BaseController 'is_pinned' => $news ? $news->is_pinned : false, 'is_highlighted' => $news ? $news->is_highlighted : false, 'send_notification' => $sendNotification, + 'notifications_count' => $notificationsCount, ], ); }