diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-04-11 17:45:05 -0500 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-04-11 17:50:06 -0500 |
commit | be9a514dffa281af00bbfa54028cd84283f76ef5 (patch) | |
tree | 97fac561e5fa9db984762103fde49c244d9c8897 /lib | |
parent | 6bd1c50dc32ccc208723ef08af72b8bfe99b58bb (diff) | |
download | nextcloud-server-be9a514dffa281af00bbfa54028cd84283f76ef5.tar.gz nextcloud-server-be9a514dffa281af00bbfa54028cd84283f76ef5.zip |
Allow to set text versions for the plain text email
* allows different texts for HTML and text version of the email
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
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 |