From e32aa4ede6a2df20e04344d3224a6275e66bd276 Mon Sep 17 00:00:00 2001 From: NIELS ROELS Date: Wed, 30 Mar 2016 15:33:49 +0200 Subject: [PATCH 1/3] Poke mail added to notify buddy of empty wishlist --- .../Controller/EntryController.php | 20 ++++++ .../Mailer/MailerService.php | 31 +++++++++ .../Resources/translations/messages.en.yml | 18 ++++- .../views/Emails/pokebuddy.html.twig | 66 +++++++++++++++++++ .../Resources/views/Emails/pokebuddy.txt.twig | 6 ++ .../Resources/views/Entry/index.html.twig | 2 +- 6 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.html.twig create mode 100644 src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.txt.twig diff --git a/src/Intracto/SecretSantaBundle/Controller/EntryController.php b/src/Intracto/SecretSantaBundle/Controller/EntryController.php index cd217075..16e6b930 100644 --- a/src/Intracto/SecretSantaBundle/Controller/EntryController.php +++ b/src/Intracto/SecretSantaBundle/Controller/EntryController.php @@ -195,4 +195,24 @@ public function dumpEntriesAction() return ['entries' => $this->entryRepository->findAfter($startCrawling)]; } + + /** + * @Route("/poke/{url}/{entryId}", name="poke_buddy") + * @Template() + */ + public function pokeBuddyAction($url, $entryId) + { + $entry = $this->entryRepository->find($entryId); + + $entryService = $this->get('intracto_secret_santa.mail'); + $entryService->sendPokeMailToBuddy($entry); + + $translator = $this->get('translator'); + $this->get('session')->getFlashBag()->add( + 'success', + $translator->trans('flashes.entry.poke_buddy') + ); + + return $this->redirect($this->generateUrl('entry_view', ['url' => $url])); + } } diff --git a/src/Intracto/SecretSantaBundle/Mailer/MailerService.php b/src/Intracto/SecretSantaBundle/Mailer/MailerService.php index f5225dd1..9b513aef 100644 --- a/src/Intracto/SecretSantaBundle/Mailer/MailerService.php +++ b/src/Intracto/SecretSantaBundle/Mailer/MailerService.php @@ -190,4 +190,35 @@ public function sendForgotManageLinkMail($email) return true; } + + /** + * @param Entry $entry + */ + public function sendPokeMailToBuddy(Entry $entry) + { + $this->translator->setLocale($entry->getPool()->getLocale()); + $this->mailer->send(\Swift_Message::newInstance() + ->setSubject($this->translator->trans('emails.poke_buddy.subject')) + ->setFrom($this->adminEmail, $this->translator->trans('emails.sender')) + ->setTo($entry->getEmail(), $entry->getName()) + ->setBody( + $this->templating->render( + 'IntractoSecretSantaBundle:Emails:pokebuddy.html.twig', + [ + 'entry' => $entry, + ] + ), + 'text/html' + ) + ->addPart( + $this->templating->render( + 'IntractoSecretSantaBundle:Emails:pokebuddy.txt.twig', + [ + 'entry' => $entry, + ] + ), + 'text/plain' + ) + ); + } } \ No newline at end of file diff --git a/src/Intracto/SecretSantaBundle/Resources/translations/messages.en.yml b/src/Intracto/SecretSantaBundle/Resources/translations/messages.en.yml index 71a2a976..071128be 100644 --- a/src/Intracto/SecretSantaBundle/Resources/translations/messages.en.yml +++ b/src/Intracto/SecretSantaBundle/Resources/translations/messages.en.yml @@ -124,7 +124,9 @@ entry: title: Your wishlist description: To help your Secret Santa, you can leave a wishlist here. Our gnomes will take care of communicating this to your Secret Santa. You can re-order the list by dragging the items in place. wishlist_empty: Your wishlist is empty. Add something! - +poke: + poke: Poke + poke_sentence: your budy to let him/her know their wishlist is empty. static: privacy_policy: title: Privacy Policy @@ -350,6 +352,19 @@ emails: You have requested all matches in your mailing list. Please be aware that all the members will be able to see this on their wishlist page. Following is an overview of which members are supposed to get gifts for which users. + poke_buddy: + subject: Your buddy is waiting for your wishlist + message: + html: > + Dear %name%,
+
+ Your Secret Santa buddy is waiting for you to add some items to your wishlist.
+
+ Click the link below and add some stuff to your wishlist you'd like. + txt: > + Dear %name%, + Your Secret Santa buddy is waiting for you to add some items to your wishlist. + Click the link below and add some stuff to your wishlist you'd like. forgot_link: text: 'Hi there,

You have requested us to resend your activation mail with the event manage link(s)
' subject: 'Resend activation mail' @@ -369,6 +384,7 @@ flashes: resent: Resent!
The e-mail to %email% has been resent.
entry: wishlist_updated:

Wishlist updated

We've sent out our gnomes to notify your Secret Santa about your wishes! + poke_buddy:

Poked

We've sent out our gnomes to ask your Secret Santa to add items to the wishlist! edit_email:

Not saved

There is an error in the email address. saved_email:

Saved

The new email address was saved. We also resent the e-mail. analytics: diff --git a/src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.html.twig b/src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.html.twig new file mode 100644 index 00000000..0679d2be --- /dev/null +++ b/src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.html.twig @@ -0,0 +1,66 @@ +{% extends "IntractoSecretSantaBundle:Emails:basemail.html.twig" %} +{% block main %} + + + + + + + + + +
+ + +

{{ "emails.poke_buddy.message.html"|trans({"%name%": entry.name })|raw }}

+
+ +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + {{ "btn.update_wishlist"|trans }} + +
+ +
+ +
+
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.txt.twig b/src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.txt.twig new file mode 100644 index 00000000..ede02bbf --- /dev/null +++ b/src/Intracto/SecretSantaBundle/Resources/views/Emails/pokebuddy.txt.twig @@ -0,0 +1,6 @@ +{{ "emails.poke_buddy.message.txt"|trans({"%name%": entry.name})|raw }} + +{{ "btn.update_wishlist"|trans }}: +{{ url("entry_view", { "url": entry.url, "_locale": entry.pool.locale }) }} + +{{ "emails.base.created_by"|trans }} http://www.intracto.com \ No newline at end of file diff --git a/src/Intracto/SecretSantaBundle/Resources/views/Entry/index.html.twig b/src/Intracto/SecretSantaBundle/Resources/views/Entry/index.html.twig index 4038d5f2..407bec6c 100644 --- a/src/Intracto/SecretSantaBundle/Resources/views/Entry/index.html.twig +++ b/src/Intracto/SecretSantaBundle/Resources/views/Entry/index.html.twig @@ -39,7 +39,7 @@ {% if(secret_santa.getwishlist) %} {{ secret_santa.getwishlist|linkify|raw }} {% else %} - {{ 'entry.wishlist_not_provided'|trans({'%name%': entry.entry.name}) }}. + {{ 'entry.wishlist_not_provided'|trans({'%name%': entry.entry.name}) }}. {{ 'poke.poke'|trans }} {{ 'poke.poke_sentence'|trans }} {% endif %} {% else %}