From f276324f1512f95400448b41cfb3ca17ff2c1750 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:28:06 +0100 Subject: [PATCH 01/13] Refs #832: Ability to set a text component from a template --- Idno/Core/Email.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Idno/Core/Email.php b/Idno/Core/Email.php index e77110797e..a286949826 100644 --- a/Idno/Core/Email.php +++ b/Idno/Core/Email.php @@ -115,6 +115,21 @@ function setHTMLBodyFromTemplate($template_name, $vars = array()) return $this->setHTMLBody($body); } + + /** + * Set the text only component of an email. + * @param type $template_name + * @param type $vars + * @return mixed + */ + function setTextBodyFromTemplate($template_name, $vars = array()) + { + $t = clone site()->template(); + $t->setTemplateType('email-text'); + $body = $t->__($vars)->draw($template_name); + + return $this->setTextBody($body); + } /** * Sets the plain text body of the message From 6457f5f35842e34ea5836c1ebaba556a416b5d0f Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:28:41 +0100 Subject: [PATCH 02/13] Text version of the invite email --- templates/email-text/account/invite.tpl.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 templates/email-text/account/invite.tpl.php diff --git a/templates/email-text/account/invite.tpl.php b/templates/email-text/account/invite.tpl.php new file mode 100644 index 0000000000..3203d17945 --- /dev/null +++ b/templates/email-text/account/invite.tpl.php @@ -0,0 +1,12 @@ +Join us! +======= + +Hi there! Your friend ** has invited you to join config()->title?>: config()->getDisplayURL()?>. + +You can use this space to publish your stories, share things that interest you, and discuss things that matter. + +Get started with *config()->title?>* by setting up your account. + +Sign up now: config()->getDisplayURL()?>account/register/?email=&code= + +If you have any questions at all, please don't hesitate to contact us by sending an email to config()->from_email?> From 7d5ae2d8de1d0d3b14c18894c07ebd6c5d7bf540 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:29:28 +0100 Subject: [PATCH 03/13] Adding text only component for email --- Idno/Entities/Invitation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Idno/Entities/Invitation.php b/Idno/Entities/Invitation.php index 9ddef0fddf..bcf4016bd5 100644 --- a/Idno/Entities/Invitation.php +++ b/Idno/Entities/Invitation.php @@ -63,6 +63,7 @@ function sendToEmail($email) $message->addTo($email); $message->setSubject(\Idno\Core\site()->session()->currentUser()->getTitle() . " has invited you to join " . \Idno\Core\site()->config()->title . '!'); $message->setHTMLBodyFromTemplate('account/invite', array('email' => $email, 'code' => $this->code, 'inviter' => \Idno\Core\site()->session()->currentUser()->getTitle())); + $message->setTextBodyFromTemplate('account/invite', array('email' => $email, 'code' => $this->code, 'inviter' => \Idno\Core\site()->session()->currentUser()->getTitle())); return $message->send(); } From 2c49ecb3b656c6a8a2032386d2e79f7abaf40b6c Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:30:53 +0100 Subject: [PATCH 04/13] Adding text only component for email --- templates/email-text/account/password.tpl.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 templates/email-text/account/password.tpl.php diff --git a/templates/email-text/account/password.tpl.php b/templates/email-text/account/password.tpl.php new file mode 100644 index 0000000000..8c2d39c26e --- /dev/null +++ b/templates/email-text/account/password.tpl.php @@ -0,0 +1,8 @@ +Forgot your password? +===================== + +We heard you forgot your password. Don't worry. It happens to the best of us. + +You can reset your password by clicking the link below (or copy and paste it into your browser). + +config()->getDisplayURL() ?>account/password/reset/?email=&code= \ No newline at end of file From 05f22126f1851a921ab5c386943a770874f6591a Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:34:13 +0100 Subject: [PATCH 05/13] Adding text only component for email --- Idno/Pages/Account/Password.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Idno/Pages/Account/Password.php b/Idno/Pages/Account/Password.php index 716ff754a4..3a3c98cd93 100644 --- a/Idno/Pages/Account/Password.php +++ b/Idno/Pages/Account/Password.php @@ -51,6 +51,7 @@ function postContent() $email->setSubject("Password reset"); $email->addTo($user->email); $email->setHTMLBody($t->__(array('email' => $email_address, 'code' => $auth_code))->draw('account/password')); + $email->setTextBodyFromTemplate('account/password', array('email' => $email_address, 'code' => $auth_code)); $email->send(); $this->forward(\Idno\Core\site()->config()->getURL() . 'account/password/?sent=true'); From 8691af9612b2a3af87e774068f7f51b4d92ef041 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:37:01 +0100 Subject: [PATCH 06/13] Adding text only component for email --- templates/email-text/admin/emailtest.tpl.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 templates/email-text/admin/emailtest.tpl.php diff --git a/templates/email-text/admin/emailtest.tpl.php b/templates/email-text/admin/emailtest.tpl.php new file mode 100644 index 0000000000..e8911fe01c --- /dev/null +++ b/templates/email-text/admin/emailtest.tpl.php @@ -0,0 +1,6 @@ +Test Email +========== + +If you can read this, it means that your email settings are configured correctly! + +Visit your site: config()->getDisplayURL()?> From 57e021cc76def6988f792cc77af0f4eb1de211ea Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:37:48 +0100 Subject: [PATCH 07/13] Adding text only component for email --- Idno/Pages/Admin/EmailTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Idno/Pages/Admin/EmailTest.php b/Idno/Pages/Admin/EmailTest.php index 571e54fdf5..f91d51f482 100644 --- a/Idno/Pages/Admin/EmailTest.php +++ b/Idno/Pages/Admin/EmailTest.php @@ -20,6 +20,7 @@ function postContent() $message->addTo($email); $message->setSubject("Test email from " . \Idno\Core\site()->config()->title . '!'); $message->setHTMLBodyFromTemplate('admin/emailtest'); + $message->setTextBodyFromTemplate('admin/emailtest'); if ($message->send()) { \Idno\Core\site()->session()->addMessage("Test email sent to $email"); From e5139d3a6883619a8297469f86d9ed2dbdd747cc Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:38:36 +0100 Subject: [PATCH 08/13] Adding text only component for email --- Idno/Pages/Admin/Export/Generate.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Idno/Pages/Admin/Export/Generate.php b/Idno/Pages/Admin/Export/Generate.php index 8eca43e6b2..58beec9b59 100644 --- a/Idno/Pages/Admin/Export/Generate.php +++ b/Idno/Pages/Admin/Export/Generate.php @@ -72,6 +72,7 @@ function postContent() $mail = new Email(); $mail->setHTMLBodyFromTemplate('admin/export'); + $mail->setTextBodyFromTemplate('admin/export'); $mail->addTo(\Idno\Core\site()->session()->currentUser()->email); $mail->setSubject("Your data export is ready"); $mail->send(); From fb067d1a039cc177524522053b4a50d350fb3b54 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:39:01 +0100 Subject: [PATCH 09/13] Adding text only component for email --- Idno/Pages/Admin/Import.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Idno/Pages/Admin/Import.php b/Idno/Pages/Admin/Import.php index 32b559987f..3c9b29ea04 100644 --- a/Idno/Pages/Admin/Import.php +++ b/Idno/Pages/Admin/Import.php @@ -66,6 +66,7 @@ function postContent() if ($imported) { $mail = new Email(); $mail->setHTMLBodyFromTemplate('admin/import'); + $mail->setTextBodyFromTemplate('admin/import'); $mail->addTo(\Idno\Core\site()->session()->currentUser()->email); $mail->setSubject("Your data import has completed"); $mail->send(); From 2990e533bab57ff6936b579ee034a403e2db6403 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:39:09 +0100 Subject: [PATCH 10/13] Adding text only component for email --- templates/email-text/admin/export.tpl.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 templates/email-text/admin/export.tpl.php diff --git a/templates/email-text/admin/export.tpl.php b/templates/email-text/admin/export.tpl.php new file mode 100644 index 0000000000..5ff4b6b013 --- /dev/null +++ b/templates/email-text/admin/export.tpl.php @@ -0,0 +1,6 @@ +Your data is ready! +=================== + +We've gathered all your site content and placed it in an archive for you. To go get it, click the following link: + +Get your data: config()->getDisplayURL()?>admin/export/ From 0b56a67eeb55250dfdbb27444c1614fd941cb2dc Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:39:16 +0100 Subject: [PATCH 11/13] Adding text only component for email --- templates/email-text/admin/import.tpl.php | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 templates/email-text/admin/import.tpl.php diff --git a/templates/email-text/admin/import.tpl.php b/templates/email-text/admin/import.tpl.php new file mode 100644 index 0000000000..68bdfd9477 --- /dev/null +++ b/templates/email-text/admin/import.tpl.php @@ -0,0 +1,7 @@ +Your data is ready! +=================== + +We've taken the data you supplied and turned it into Known posts! Photos that you had previously +uploaded to the service and embedded into your posts have also been imported. + +Visit your site: config()->getDisplayURL()?> From eb65661437fa93a76c0339ceb769c995b94cc0b3 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:57:26 +0100 Subject: [PATCH 12/13] Adding text only component for email --- .../content/notification/like.tpl.php | 3 +++ .../content/notification/reply.tpl.php | 18 ++++++++++++++++++ .../content/notification/rsvp.tpl.php | 17 +++++++++++++++++ .../content/notification/share.tpl.php | 3 +++ 4 files changed, 41 insertions(+) create mode 100644 templates/email-text/content/notification/like.tpl.php create mode 100644 templates/email-text/content/notification/reply.tpl.php create mode 100644 templates/email-text/content/notification/rsvp.tpl.php create mode 100644 templates/email-text/content/notification/share.tpl.php diff --git a/templates/email-text/content/notification/like.tpl.php b/templates/email-text/content/notification/like.tpl.php new file mode 100644 index 0000000000..80755a0c38 --- /dev/null +++ b/templates/email-text/content/notification/like.tpl.php @@ -0,0 +1,3 @@ +Hi! We wanted to let you know that ** liked the post *getNotificationTitle()?>*
+ +View post: getDisplayURL()?> diff --git a/templates/email-text/content/notification/reply.tpl.php b/templates/email-text/content/notification/reply.tpl.php new file mode 100644 index 0000000000..55ffceb7c7 --- /dev/null +++ b/templates/email-text/content/notification/reply.tpl.php @@ -0,0 +1,18 @@ +Hi! We wanted to let you know that ** replied to the post *getNotificationTitle()?>*. + +Here's what they said: + +> #i', "\n> ", str_replace("\n", "\n> ", $vars['content']))); ?> + + + + View post: getDisplayURL()?> + \ No newline at end of file diff --git a/templates/email-text/content/notification/rsvp.tpl.php b/templates/email-text/content/notification/rsvp.tpl.php new file mode 100644 index 0000000000..5555125a43 --- /dev/null +++ b/templates/email-text/content/notification/rsvp.tpl.php @@ -0,0 +1,17 @@ +Hi! We wanted to let you know that ** RSVPed to the event *getNotificationTitle()?>*. + +Here's what they said: + +> #i', "\n> ", str_replace("\n", "\n> ", $vars['content']))); ?> + + +View post: getDisplayURL()?> + \ No newline at end of file diff --git a/templates/email-text/content/notification/share.tpl.php b/templates/email-text/content/notification/share.tpl.php new file mode 100644 index 0000000000..96212bae8a --- /dev/null +++ b/templates/email-text/content/notification/share.tpl.php @@ -0,0 +1,3 @@ +Hi! We wanted to let you know that ** reshared the post *getNotificationTitle()?>* + +View post: getDisplayURL()?> From 835b6af515876da8f156f8e7961e2d89d408d922 Mon Sep 17 00:00:00 2001 From: Marcus Povey Date: Wed, 20 May 2015 14:58:03 +0100 Subject: [PATCH 13/13] Closes #832: Notification emails now sent with text component. --- Idno/Entities/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Idno/Entities/User.php b/Idno/Entities/User.php index 096ee86500..85788e74ee 100644 --- a/Idno/Entities/User.php +++ b/Idno/Entities/User.php @@ -102,6 +102,7 @@ static function registerEvents() $email = new Email(); $email->setSubject($eventdata['message']); $email->setHTMLBodyFromTemplate($eventdata['message_template'], $vars); + $email->setTextBodyFromTemplate($eventdata['message_template'], $vars); $email->addTo($user->email); $email->send(); }