diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-04-12 10:15:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-12 10:15:06 +0200 |
commit | d127f47801188308f29842db08ca4f57a4d2a328 (patch) | |
tree | 3800db32c9f20ddc8a22ddadecd0f879db4c66d1 /lib | |
parent | feb594e212bc9f73ae5b2a9da5afff753003ae14 (diff) | |
parent | be9a514dffa281af00bbfa54028cd84283f76ef5 (diff) | |
download | nextcloud-server-d127f47801188308f29842db08ca4f57a4d2a328.tar.gz nextcloud-server-d127f47801188308f29842db08ca4f57a4d2a328.zip |
Merge pull request #4310 from nextcloud/allow-plain-text-email
Allow to set text versions for the plain text email
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Mail/EMailTemplate.php | 31 | ||||
-rw-r--r-- | lib/public/Mail/IEMailTemplate.php | 10 |
2 files changed, 31 insertions, 10 deletions
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index 402916cf74a..338f6594f5e 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -295,25 +295,33 @@ EOF; * Adds a heading to the email * * @param string $title + * @param string $plainTitle Title that is used in the plain text email - if empty the $title is used */ - public function addHeading($title) { + public function addHeading($title, $plainTitle = '') { if ($this->footerAdded) { return; } + if ($plainTitle === '') { + $plainTitle = $title; + } $this->htmlBody .= vsprintf($this->heading, [$title]); - $this->plainBody .= $title . PHP_EOL . PHP_EOL; + $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; } /** * Adds a paragraph to the body of the email * * @param string $text + * @param string $plainText Text that is used in the plain text email - if empty the $text is used */ - public function addBodyText($text) { + public function addBodyText($text, $plainText = '') { if ($this->footerAdded) { return; } + if ($plainText === '') { + $plainText = $text; + } if (!$this->bodyOpened) { $this->htmlBody .= $this->bodyBegin; @@ -321,7 +329,7 @@ EOF; } $this->htmlBody .= vsprintf($this->bodyText, [$text]); - $this->plainBody .= $text . PHP_EOL . PHP_EOL; + $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; } /** @@ -331,11 +339,20 @@ EOF; * @param string $urlLeft URL of left button * @param string $textRight Text of right button * @param string $urlRight URL of right button + * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used + * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used */ - public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight) { + public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = '') { if ($this->footerAdded) { return; } + if ($plainTextLeft === '') { + $plainTextLeft = $textLeft; + } + + if ($plainTextRight === '') { + $plainTextRight = $textRight; + } if (!$this->bodyOpened) { $this->htmlBody .= $this->bodyBegin; @@ -344,8 +361,8 @@ EOF; $color = $this->themingDefaults->getColorPrimary(); $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textLeft, $urlRight, $textRight]); - $this->plainBody .= $textLeft . ': ' . $urlLeft . PHP_EOL; - $this->plainBody .= $textRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; + $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; + $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; } diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index bcb53f610e4..a1922e86151 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -62,19 +62,21 @@ interface IEMailTemplate { * Adds a heading to the email * * @param string $title + * @param string $plainTitle Title that is used in the plain text email - if empty the $title is used * * @since 12.0.0 */ - public function addHeading($title); + public function addHeading($title, $plainTitle = ''); /** * Adds a paragraph to the body of the email * * @param string $text + * @param string $plainText Text that is used in the plain text email - if empty the $text is used * * @since 12.0.0 */ - public function addBodyText($text); + public function addBodyText($text, $plainText = ''); /** * Adds a button group of two buttons to the body of the email @@ -83,10 +85,12 @@ interface IEMailTemplate { * @param string $urlLeft URL of left button * @param string $textRight Text of right button * @param string $urlRight URL of right button + * @param string $plainTextLeft Text of left button that is used in the plain text version - if empty the $textLeft is used + * @param string $plainTextRight Text of right button that is used in the plain text version - if empty the $textRight is used * * @since 12.0.0 */ - public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight); + public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = ''); /** * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |