Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text only email #902

Merged
merged 13 commits into from May 21, 2015
15 changes: 15 additions & 0 deletions Idno/Core/Email.php
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Idno/Entities/Invitation.php
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions Idno/Entities/User.php
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions Idno/Pages/Account/Password.php
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions Idno/Pages/Admin/EmailTest.php
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions Idno/Pages/Admin/Export/Generate.php
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Idno/Pages/Admin/Import.php
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions templates/email-text/account/invite.tpl.php
@@ -0,0 +1,12 @@
Join us!
=======

Hi there! Your friend *<?=$vars['inviter']?>* has invited you to join <?=\Idno\Core\site()->config()->title?>: <?=\Idno\Core\site()->config()->getDisplayURL()?>.

You can use this space to publish your stories, share things that interest you, and discuss things that matter.

Get started with *<?=\Idno\Core\site()->config()->title?>* by setting up your account.

Sign up now: <?=\Idno\Core\site()->config()->getDisplayURL()?>account/register/?email=<?=urlencode($vars['email'])?>&code=<?=urlencode($vars['code'])?>

If you have any questions at all, please don't hesitate to contact us by sending an email to <?=\Idno\Core\site()->config()->from_email?>
8 changes: 8 additions & 0 deletions 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).

<?= \Idno\Core\site()->config()->getDisplayURL() ?>account/password/reset/?email=<?= urlencode($vars['email']) ?>&code=<?= urlencode($vars['code']) ?>
6 changes: 6 additions & 0 deletions 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: <?=\Idno\Core\site()->config()->getDisplayURL()?>
6 changes: 6 additions & 0 deletions 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: <?=\Idno\Core\site()->config()->getDisplayURL()?>admin/export/
7 changes: 7 additions & 0 deletions 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: <?=\Idno\Core\site()->config()->getDisplayURL()?>
3 changes: 3 additions & 0 deletions templates/email-text/content/notification/like.tpl.php
@@ -0,0 +1,3 @@
Hi! We wanted to let you know that *<?=$vars['owner_name']?>* liked the post *<?=$vars['object']->getNotificationTitle()?>*<br>

View post: <?=$vars['object']->getDisplayURL()?>
18 changes: 18 additions & 0 deletions templates/email-text/content/notification/reply.tpl.php
@@ -0,0 +1,18 @@
Hi! We wanted to let you know that *<?=$vars['owner_name']?>* replied to the post *<?=$vars['object']->getNotificationTitle()?>*.

Here's what they said:

> <?= strip_tags(preg_replace('#<br\s*/?>#i', "\n> ", str_replace("\n", "\n> ", $vars['content']))); ?>

<?php

if (!empty($vars['object'])) {

?>

View post: <?=$vars['object']->getDisplayURL()?>
<?php

}

?>
17 changes: 17 additions & 0 deletions templates/email-text/content/notification/rsvp.tpl.php
@@ -0,0 +1,17 @@
Hi! We wanted to let you know that *<?=$vars['owner_name']?>* RSVPed to the event *<?=$vars['object']->getNotificationTitle()?>*.

Here's what they said:

> <?= strip_tags(preg_replace('#<br\s*/?>#i', "\n> ", str_replace("\n", "\n> ", $vars['content']))); ?>

<?php

if (!empty($vars['object'])) {

?>
View post: <?=$vars['object']->getDisplayURL()?>
<?php

}

?>
3 changes: 3 additions & 0 deletions templates/email-text/content/notification/share.tpl.php
@@ -0,0 +1,3 @@
Hi! We wanted to let you know that *<?=$vars['owner_name']?>* reshared the post *<?=$vars['object']->getNotificationTitle()?>*

View post: <?=$vars['object']->getDisplayURL()?>