diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php index 7672fadb..8d1f045d 100644 --- a/includes/controller/user_angeltypes_controller.php +++ b/includes/controller/user_angeltypes_controller.php @@ -216,6 +216,36 @@ function user_angeltype_confirm_email(User $user, array $angeltype): void } } +/** + * @param User $user + * @param array $angeltype + * @return void + */ +function user_angeltype_add_email(User $user, array $angeltype): void +{ + if (!$user->settings->email_shiftinfo || $user->id == auth()->user()->id) { + return; + } + + try { + /** @var EngelsystemMailer $mailer */ + $mailer = app(EngelsystemMailer::class); + $mailer->sendViewTranslated( + $user, + 'notification.angeltype.added', + 'emails/angeltype-added', + ['name' => $angeltype['name'], 'angeltype' => $angeltype, 'username' => $user->name] + ); + } catch (SwiftException $e) { + /** @var LoggerInterface $logger */ + $logger = app('logger'); + $logger->error( + 'Unable to send email "{title}" to user {user} with {exception}', + ['title' => __('notification.angeltype.added'), 'user' => $user->name, 'exception' => $e] + ); + } +} + /** * Remove a user from an Angeltype. * @@ -386,6 +416,8 @@ function user_angeltype_add_controller(): array AngelType_name_render($angeltype, true) )); + user_angeltype_add_email($user_source, $angeltype); + throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); } } diff --git a/resources/lang/de_DE/additional.po b/resources/lang/de_DE/additional.po index 53c9bf40..1ad2d450 100644 --- a/resources/lang/de_DE/additional.po +++ b/resources/lang/de_DE/additional.po @@ -148,5 +148,14 @@ msgstr "Du wurdest von einem Supporter als %1$s bestätigt." msgid "notification.angeltype.confirmed.text" msgstr "Eine Beschreibung findest du unter %2$s" +msgid "notification.angeltype.added" +msgstr "Du wurdest als %s hinzugefügt" + +msgid "notification.angeltype.added.introduction" +msgstr "Du wurdest von einem Supporter als %1$s hinzugefügt." + +msgid "notification.angeltype.added.text" +msgstr "Eine Beschreibung findest du unter %2$s" + msgid "user.edit.success" msgstr "Benutzer erfolgreich bearbeitet." diff --git a/resources/lang/en_US/additional.po b/resources/lang/en_US/additional.po index ce32fba5..b6a070a3 100644 --- a/resources/lang/en_US/additional.po +++ b/resources/lang/en_US/additional.po @@ -144,5 +144,14 @@ msgstr "You have been confirmed as an %1$s by a supporter." msgid "notification.angeltype.confirmed.text" msgstr "You can find a description at %2$s" +msgid "notification.angeltype.added" +msgstr "You have been added as an %s" + +msgid "notification.angeltype.added.introduction" +msgstr "You have been added as an %1$s by a supporter." + +msgid "notification.angeltype.added.text" +msgstr "You can find a description at %2$s" + msgid "user.edit.success" msgstr "User edited successfully." diff --git a/resources/views/emails/angeltype-added.twig b/resources/views/emails/angeltype-added.twig new file mode 100644 index 00000000..5ce3fc83 --- /dev/null +++ b/resources/views/emails/angeltype-added.twig @@ -0,0 +1,11 @@ +{% extends "emails/mail.twig" %} + +{% set url=url('/angeltypes', {'action': 'view', 'angeltype_id': angeltype.id}) %} + +{% block introduction %} +{{ __('notification.angeltype.added.introduction', [angeltype.name, url])|raw }} +{% endblock %} + +{% block message %} +{{ __('notification.angeltype.added.text', [angeltype.name, url])|raw }} +{% endblock %}