From 050ce1d40bf344510338a401ce6b68f76ed3f5e5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 11 Apr 2017 16:13:34 -0500 Subject: Add addBodyButton to add a single button to email templates Signed-off-by: Morris Jobke --- lib/public/Mail/IEMailTemplate.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/public') diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index a1922e86151..7b85c154c36 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -92,6 +92,16 @@ interface IEMailTemplate { */ public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = ''); + /** + * Adds a button to the body of the email + * + * @param string $text Text of button + * @param string $url URL of button + * + * @since 12.0.0 + */ + public function addBodyButton($text, $url); + /** * Adds a logo and a text to the footer.
in the text will be replaced by new lines in the plain text email * -- cgit v1.2.3 From 33e077c1c1243884342d51ddc57a1aca4f33049d Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 11 Apr 2017 16:17:44 -0500 Subject: Properly escape heading, body and button text Signed-off-by: Morris Jobke --- lib/private/Mail/EMailTemplate.php | 16 +++++++++++----- lib/public/Mail/IEMailTemplate.php | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/public') diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index b47dcf09bfb..bfaee72bedd 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -345,7 +345,7 @@ EOF; $plainTitle = $title; } - $this->htmlBody .= vsprintf($this->heading, [$title]); + $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; } @@ -368,7 +368,7 @@ EOF; $this->bodyOpened = true; } - $this->htmlBody .= vsprintf($this->bodyText, [$text]); + $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; } @@ -382,7 +382,12 @@ EOF; * @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, $plainTextLeft = '', $plainTextRight = '') { + public function addBodyButtonGroup($textLeft, + $urlLeft, + $textRight, + $urlRight, + $plainTextLeft = '', + $plainTextRight = '') { if ($this->footerAdded) { return; } @@ -400,7 +405,8 @@ EOF; } $color = $this->themingDefaults->getColorPrimary(); - $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textLeft, $urlRight, $textRight]); + + $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]); $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; @@ -433,7 +439,7 @@ EOF; /** * Adds a logo and a text to the footer.
in the text will be replaced by new lines in the plain text email * - * @param string $text + * @param string $text If the text is empty the default "Name - Slogan
This is an automatically generated email" will be used */ public function addFooter($text = '') { if($text === '') { diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index 7b85c154c36..d0123f22739 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -105,7 +105,7 @@ interface IEMailTemplate { /** * Adds a logo and a text to the footer.
in the text will be replaced by new lines in the plain text email * - * @param string $text + * @param string $text If the text is empty the default "Name - Slogan
This is an automatically generated email" will be used * * @since 12.0.0 */ -- cgit v1.2.3 From 506c7731a6168e35bff28c32d9bea933aee907d4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 12 Apr 2017 11:52:33 +0200 Subject: Don't duplicate the sentence with the header Signed-off-by: Joas Schilling --- apps/sharebymail/lib/ShareByMailProvider.php | 2 +- lib/private/Mail/EMailTemplate.php | 7 +++++-- lib/public/Mail/IEMailTemplate.php | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/public') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 8f63ef028d9..f2c68f9376d 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -264,7 +264,7 @@ class ShareByMailProvider implements IShareProvider { $emailTemplate = $this->mailer->createEMailTemplate(); $emailTemplate->addHeader(); - $emailTemplate->addHeading($this->l->t('%s shared »%s« with you', [$ownerDisplayName, $filename])); + $emailTemplate->addHeading($this->l->t('%s shared »%s« with you', [$ownerDisplayName, $filename]), false); if ($owner === $initiator) { $text = $this->l->t('%s shared »%s« with you.', [$ownerDisplayName, $filename]); diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index bfaee72bedd..f82ddc689eb 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -353,7 +353,8 @@ EOF; * 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 + * @param string|bool $plainText Text that is used in the plain text email + * if empty the $text is used, if false none will be used */ public function addBodyText($text, $plainText = '') { if ($this->footerAdded) { @@ -369,7 +370,9 @@ EOF; } $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]); - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; + if ($plainText !== false) { + $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; + } } /** diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index d0123f22739..8e3233ee426 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -72,7 +72,8 @@ interface IEMailTemplate { * 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 + * @param string|bool $plainText Text that is used in the plain text email + * if empty the $text is used, if false none will be used * * @since 12.0.0 */ -- cgit v1.2.3 From 4b639e276322b6294b8ac62d88de0985c0ab637a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 12 Apr 2017 15:33:14 +0200 Subject: No newlines when heading is empty Signed-off-by: Joas Schilling --- lib/private/Mail/EMailTemplate.php | 7 +++++-- lib/public/Mail/IEMailTemplate.php | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/public') diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index b0378496d9e..805126d2ad8 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -335,7 +335,8 @@ 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 + * @param string $plainTitle|bool Title that is used in the plain text email + * if empty the $title is used, if false none will be used */ public function addHeading($title, $plainTitle = '') { if ($this->footerAdded) { @@ -346,7 +347,9 @@ EOF; } $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; + if ($plainTitle !== false) { + $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; + } } /** diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index 8e3233ee426..4e308509c42 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -62,7 +62,8 @@ 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 + * @param string $plainTitle|bool Title that is used in the plain text email + * if empty the $title is used, if false none will be used * * @since 12.0.0 */ -- cgit v1.2.3