Set the subject with the email template to allow theming

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/6515/head
Joas Schilling 7 years ago
parent f109c1a10c
commit 8b37fe7f65
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
  1. 14
      apps/sharebymail/lib/ShareByMailProvider.php
  2. 3
      core/Controller/LostController.php
  3. 4
      lib/private/Share20/Manager.php
  4. 3
      settings/Controller/MailSettingsController.php
  5. 8
      settings/Hooks.php
  6. 3
      settings/Mailer/NewUserMailHelper.php

@ -380,8 +380,6 @@ class ShareByMailProvider implements IShareProvider {
\DateTime $expiration = null) {
$initiatorUser = $this->userManager->get($initiator);
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$subject = (string)$this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
$message = $this->mailer->createMessage();
$emailTemplate = $this->mailer->createEMailTemplate('sharebymail.RecipientNotification', [
@ -392,6 +390,7 @@ class ShareByMailProvider implements IShareProvider {
'shareWith' => $shareWith,
]);
$emailTemplate->setSubject($this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename)));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('%s shared »%s« with you', [$initiatorDisplayName, $filename]), false);
$text = $this->l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
@ -428,7 +427,7 @@ class ShareByMailProvider implements IShareProvider {
$emailTemplate->addFooter();
}
$message->setSubject($subject);
$message->setSubject($emailTemplate->renderSubject());
$message->setPlainBody($emailTemplate->renderText());
$message->setHtmlBody($emailTemplate->renderHtml());
$this->mailer->send($message);
@ -455,7 +454,6 @@ class ShareByMailProvider implements IShareProvider {
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
$subject = (string)$this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]);
$plainBodyPart = $this->l->t("%s shared »%s« with you.\nYou should have already received a separate mail with a link to access it.\n", [$initiatorDisplayName, $filename]);
$htmlBodyPart = $this->l->t('%s shared »%s« with you. You should have already received a separate mail with a link to access it.', [$initiatorDisplayName, $filename]);
@ -468,6 +466,8 @@ class ShareByMailProvider implements IShareProvider {
'initiatorEmail' => $initiatorEmailAddress,
'shareWith' => $shareWith,
]);
$emailTemplate->setSubject($this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
$emailTemplate->addBodyText($htmlBodyPart, $plainBodyPart);
@ -491,7 +491,7 @@ class ShareByMailProvider implements IShareProvider {
}
$message->setTo([$shareWith]);
$message->setSubject($subject);
$message->setSubject($emailTemplate->renderSubject());
$message->setBody($emailTemplate->renderText(), 'text/plain');
$message->setHtmlBody($emailTemplate->renderHtml());
$this->mailer->send($message);
@ -524,7 +524,6 @@ class ShareByMailProvider implements IShareProvider {
);
}
$subject = (string)$this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]);
$bodyPart = $this->l->t("You just shared »%s« with %s. The share was already send to the recipient. Due to the security policies defined by the administrator of %s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.", [$filename, $shareWith, $this->defaults->getName()]);
$message = $this->mailer->createMessage();
@ -536,6 +535,7 @@ class ShareByMailProvider implements IShareProvider {
'shareWith' => $shareWith,
]);
$emailTemplate->setSubject($this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
$emailTemplate->addBodyText($bodyPart);
@ -547,7 +547,7 @@ class ShareByMailProvider implements IShareProvider {
$message->setFrom([$initiatorEMailAddress => $initiatorDisplayName]);
}
$message->setTo([$initiatorEMailAddress => $initiatorDisplayName]);
$message->setSubject($subject);
$message->setSubject($emailTemplate->renderSubject());
$message->setBody($emailTemplate->renderText(), 'text/plain');
$message->setHtmlBody($emailTemplate->renderHtml());
$this->mailer->send($message);

@ -309,6 +309,7 @@ class LostController extends Controller {
'link' => $link,
]);
$emailTemplate->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l10n->t('Password reset'));
@ -327,7 +328,7 @@ class LostController extends Controller {
try {
$message = $this->mailer->createMessage();
$message->setTo([$email => $user->getUID()]);
$message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
$message->setSubject($emailTemplate->renderSubject());
$message->setPlainBody($emailTemplate->renderText());
$message->setHtmlBody($emailTemplate->renderHtml());
$message->setFrom([$this->from => $this->defaults->getName()]);

@ -702,7 +702,6 @@ class Manager implements IManager {
\DateTime $expiration = null) {
$initiatorUser = $this->userManager->get($initiator);
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$subject = $l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
$message = $this->mailer->createMessage();
@ -714,6 +713,7 @@ class Manager implements IManager {
'shareWith' => $shareWith,
]);
$emailTemplate->setSubject($l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename)));
$emailTemplate->addHeader();
$emailTemplate->addHeading($l->t('%s shared »%s« with you', [$initiatorDisplayName, $filename]), false);
$text = $l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
@ -750,7 +750,7 @@ class Manager implements IManager {
$emailTemplate->addFooter();
}
$message->setSubject($subject);
$message->setSubject($emailTemplate->renderSubject());
$message->setPlainBody($emailTemplate->renderText());
$message->setHtmlBody($emailTemplate->renderHtml());
$this->mailer->send($message);

@ -151,6 +151,7 @@ class MailSettingsController extends Controller {
'displayname' => $displayName,
]);
$template->setSubject($this->l10n->t('Email setting test'));
$template->addHeader();
$template->addHeading($this->l10n->t('Well done, %s!', [$displayName]));
$template->addBodyText($this->l10n->t('If you received this email, the email configuration seems to be correct.'));
@ -158,7 +159,7 @@ class MailSettingsController extends Controller {
$message = $this->mailer->createMessage();
$message->setTo([$email => $displayName]);
$message->setSubject($this->l10n->t('Email setting test'));
$message->setSubject($template->renderSubject());
$message->setHtmlBody($template->renderHtml());
$message->setPlainBody($template->renderText());
$errors = $this->mailer->send($message);

@ -122,6 +122,8 @@ class Hooks {
'emailAddress' => $user->getEMailAddress(),
'instanceUrl' => $instanceUrl,
]);
$template->setSubject($this->l->t('Password for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
$template->addHeader();
$template->addHeading($this->l->t('Password changed for %s', [$user->getDisplayName()]), false);
$template->addBodyText($text . ' ' . $this->l->t('If you did not request this, please contact an administrator.'));
@ -130,7 +132,7 @@ class Hooks {
$message = $this->mailer->createMessage();
$message->setTo([$user->getEMailAddress() => $user->getDisplayName()]);
$message->setSubject($this->l->t('Password for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
$message->setSubject($template->renderSubject());
$message->setBody($template->renderText(), 'text/plain');
$message->setHtmlBody($template->renderHtml());
@ -193,6 +195,8 @@ class Hooks {
'oldEMailAddress' => $oldMailAddress,
'instanceUrl' => $instanceUrl,
]);
$template->setSubject($this->l->t('Email address for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
$template->addHeader();
$template->addHeading($this->l->t('Email address changed for %s', [$user->getDisplayName()]), false);
$template->addBodyText($text . ' ' . $this->l->t('If you did not request this, please contact an administrator.'));
@ -204,7 +208,7 @@ class Hooks {
$message = $this->mailer->createMessage();
$message->setTo([$oldMailAddress => $user->getDisplayName()]);
$message->setSubject($this->l->t('Email address for %1$s changed on %2$s', [$user->getDisplayName(), $instanceUrl]));
$message->setSubject($template->renderSubject());
$message->setBody($template->renderText(), 'text/plain');
$message->setHtmlBody($template->renderHtml());

@ -124,6 +124,7 @@ class NewUserMailHelper {
'resetTokenGenerated' => $generatePasswordResetToken,
]);
$emailTemplate->setSubject($this->l10n->t('Your %s account was created', [$this->themingDefaults->getName()]));
$emailTemplate->addHeader();
if ($displayName === $userId) {
$emailTemplate->addHeading($this->l10n->t('Welcome aboard'));
@ -159,7 +160,7 @@ class NewUserMailHelper {
IEMailTemplate $emailTemplate) {
$message = $this->mailer->createMessage();
$message->setTo([$user->getEMailAddress() => $user->getDisplayName()]);
$message->setSubject($this->l10n->t('Your %s account was created', [$this->themingDefaults->getName()]));
$message->setSubject($emailTemplate->renderSubject());
$message->setHtmlBody($emailTemplate->renderHtml());
$message->setPlainBody($emailTemplate->renderText());
$message->setFrom([$this->fromAddress => $this->themingDefaults->getName()]);

Loading…
Cancel
Save