diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-04-11 16:18:31 -0500 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-04-12 17:16:26 +0200 |
commit | d0bae447fb4a8ad6e7b3d51390cb9a2bdbf24591 (patch) | |
tree | ba576851b63474bdeaf849e890fa4454d524dced /apps/sharebymail/lib | |
parent | 33e077c1c1243884342d51ddc57a1aca4f33049d (diff) | |
download | nextcloud-server-d0bae447fb4a8ad6e7b3d51390cb9a2bdbf24591.tar.gz nextcloud-server-d0bae447fb4a8ad6e7b3d51390cb9a2bdbf24591.zip |
Use new email design for sharebymail emails
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/sharebymail/lib')
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 99 |
1 files changed, 39 insertions, 60 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index ec9568b734e..8f63ef028d9 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -260,42 +260,34 @@ class ShareByMailProvider implements IShareProvider { } $message = $this->mailer->createMessage(); - $htmlBody = $this->createMailBody('mail', $filename, $link, $ownerDisplayName, $initiatorDisplayName); - $textBody = $this->createMailBody('altmail', $filename, $link, $ownerDisplayName, $initiatorDisplayName); - $message->setTo([$shareWith]); - $message->setSubject($subject); - $message->setBody($textBody, 'text/plain'); - $message->setHtmlBody($htmlBody); - $this->mailer->send($message); - } + $emailTemplate = $this->mailer->createEMailTemplate(); - /** - * create mail body - * - * @param $filename - * @param $link - * @param $owner - * @param $initiator - * @return string plain text mail - * @throws HintException - */ - protected function createMailBody($template, $filename, $link, $owner, $initiator) { - - $mailBodyTemplate = new Template('sharebymail', $template, ''); - $mailBodyTemplate->assign ('filename', \OCP\Util::sanitizeHTML($filename)); - $mailBodyTemplate->assign ('link', $link); - $mailBodyTemplate->assign ('owner', \OCP\Util::sanitizeHTML($owner)); - $mailBodyTemplate->assign ('initiator', \OCP\Util::sanitizeHTML($initiator)); - $mailBodyTemplate->assign ('onBehalfOf', $initiator !== $owner); - $mailBody = $mailBodyTemplate->fetchPage(); - - if (is_string($mailBody)) { - return $mailBody; + $emailTemplate->addHeader(); + $emailTemplate->addHeading($this->l->t('%s shared »%s« with you', [$ownerDisplayName, $filename])); + + if ($owner === $initiator) { + $text = $this->l->t('%s shared »%s« with you.', [$ownerDisplayName, $filename]); + } else { + $text= $this->l->t('%s shared »%s« with you on behalf of %s.', [$ownerDisplayName, $filename, $initiator]); } - throw new HintException('Failed to create the E-mail', - $this->l->t('Failed to create the E-mail')); + $text .= ' ' . $this->l->t('Click the button below to open it.'); + + $emailTemplate->addBodyText($text); + + $emailTemplate->addBodyButton( + $this->l->t('Open »%s«', [$filename]), + $link + ); + $emailTemplate->addFooter(); + + $message->setTo([$shareWith]); + $message->setSubject($subject); + $message->setBody($emailTemplate->renderText(), 'text/plain'); + $message->setHtmlBody($emailTemplate->renderHTML()); + $this->mailer->send($message); + } /** @@ -316,39 +308,26 @@ class ShareByMailProvider implements IShareProvider { $subject = (string)$this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]); $message = $this->mailer->createMessage(); - $htmlBody = $this->createMailBodyToSendPassword('mailpassword', $filename, $initiatorDisplayName, $password); - $textBody = $this->createMailBodyToSendPassword('altmailpassword', $filename,$initiatorDisplayName, $password); - $message->setTo([$shareWith]); - $message->setSubject($subject); - $message->setBody($textBody, 'text/plain'); - $message->setHtmlBody($htmlBody); - $this->mailer->send($message); - } + $emailTemplate = $this->mailer->createEMailTemplate(); - /** - * create mail body to send password to recipient - * - * @param string $filename - * @param string $initiator - * @param string $password - * @return string plain text mail - * @throws HintException - */ - protected function createMailBodyToSendPassword($template, $filename, $initiator, $password) { + $emailTemplate->addHeader(); + $emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename])); - $mailBodyTemplate = new Template('sharebymail', $template, ''); - $mailBodyTemplate->assign ('filename', \OCP\Util::sanitizeHTML($filename)); - $mailBodyTemplate->assign ('password', \OCP\Util::sanitizeHTML($password)); - $mailBodyTemplate->assign ('initiator', \OCP\Util::sanitizeHTML($initiator)); - $mailBody = $mailBodyTemplate->fetchPage(); + $emailTemplate->addBodyText($this->l->t( + '%s shared »%s« with you. You should have already received a separate mail with a link to access it.', + [$initiatorDisplayName, $filename] + )); + $emailTemplate->addBodyText($this->l->t('It is protected with the following password: %s', [$password])); - if (is_string($mailBody)) { - return $mailBody; - } + $emailTemplate->addFooter(); + + $message->setTo([$shareWith]); + $message->setSubject($subject); + $message->setBody($emailTemplate->renderText(), 'text/plain'); + $message->setHtmlBody($emailTemplate->renderHTML()); + $this->mailer->send($message); - throw new HintException('Failed to create the E-mail', - $this->l->t('Failed to create the E-mail')); } |