aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Mail
diff options
context:
space:
mode:
authorbrad2014 <brad2014@users.noreply.github.com>2019-10-08 00:23:26 -0700
committerbrad2014 <brad2014@users.noreply.github.com>2020-08-20 22:16:47 +0200
commit781359a5827f8a6fa477cbc23b0c8ef5e94bac23 (patch)
treea259baeb6ac818956896e3fac443a0dba908f5d5 /lib/private/Mail
parentf9d16edd949605d1cfc49fab040c9ac2ecd63edd (diff)
downloadnextcloud-server-781359a5827f8a6fa477cbc23b0c8ef5e94bac23.tar.gz
nextcloud-server-781359a5827f8a6fa477cbc23b0c8ef5e94bac23.zip
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler to review and approve, with fewer changes, some disabled by default. It addresses issues #12391 and #13555, with the following changes: - The plainText of iMIP emails has been upgraded as described in issue #12391. The HTML design style has not been changed. - Some of the HTML and plainText content has been rearranged (simplified header language, moving the event title to from text body to the first item in the bullet list, spelling corrections, moving the description to the end of the list), per issue #12391. - The interface for EMailTemplate has been extended: addBodyListItem now takes an optional `plainIndent` parameter. Existing callers see no change. Where new calls set the new parameter >0, the list item label (metaInfo) is put in column 1, and the value is indented into column 2 (properly accounting for multiple lines, if any). - An optional dav config setting has been added, `invitation_list_attendees`. It defaults to 'no', leaving emails unchanged. If set by the site admin to 'yes', then iMIP emails include, for the organizer and each attendee, their name, email, and a ✔︎ if they have accepted the invitation. - Minor refactoring. Notes: - The labels for organizers and attendees list items are new, and require translation/localization. - Dav config settings are documented in the code, but not in the Administrator's Guide. Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
Diffstat (limited to 'lib/private/Mail')
-rw-r--r--lib/private/Mail/EMailTemplate.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php
index 2c8efa7e010..054378c2afa 100644
--- a/lib/private/Mail/EMailTemplate.php
+++ b/lib/private/Mail/EMailTemplate.php
@@ -450,14 +450,16 @@ EOF;
* if empty the $text is used, if false none will be used
* @param string|bool $plainMetaInfo Meta info that is used in the plain text email
* if empty the $metaInfo is used, if false none will be used
+ * @param integer plainIndent If > 0, Indent plainText by this amount.
* @since 12.0.0
*/
- public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '') {
+ public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0) {
$this->ensureBodyListOpened();
if ($plainText === '') {
$plainText = $text;
$text = htmlspecialchars($text);
+ $text = str_replace("\n", "<br/>", $text); // convert newlines to HTML breaks
}
if ($plainMetaInfo === '') {
$plainMetaInfo = $metaInfo;
@@ -475,11 +477,27 @@ EOF;
}
$this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
if ($plainText !== false) {
- $this->plainBody .= ' * ' . $plainText;
- if ($plainMetaInfo !== false) {
- $this->plainBody .= ' (' . $plainMetaInfo . ')';
+ if ($plainIndent === 0) {
+ /*
+ * If plainIndent is not set by caller, this is the old NC17 layout code.
+ */
+ $this->plainBody .= ' * ' . $plainText;
+ if ($plainMetaInfo !== false) {
+ $this->plainBody .= ' (' . $plainMetaInfo . ')';
+ }
+ $this->plainBody .= PHP_EOL;
+ } else {
+ /*
+ * Caller can set plainIndent > 0 to format plainText in tabular fashion.
+ * with plainMetaInfo in column 1, and plainText in column 2.
+ * The plainMetaInfo label is right justified in a field of width
+ * "plainIndent". Multilines after the first are indented plainIndent+1
+ * (to account for space after label). Fixes: #12391
+ */
+ $this->plainBody .= sprintf("%${plainIndent}s %s\n",
+ $plainMetaInfo,
+ str_replace("\n", "\n" . str_repeat(' ', $plainIndent+1), $plainText));
}
- $this->plainBody .= PHP_EOL;
}
}
@@ -538,7 +556,7 @@ EOF;
$textColor = $this->themingDefaults->getTextColorPrimary();
$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);
- $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
+ $this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
}