From: Tim Düsterhus
Date: Fri, 29 Jul 2016 13:49:44 +0000 (+0200)
Subject: Convert email notifications for new moderation comments to new API
X-Git-Tag: 3.0.0_Beta_1~916^2~1^2~1
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7c12ba94b147ad33fa45a7d6fa74fe710c9b6199;p=GitHub%2FWoltLab%2FWCF.git
Convert email notifications for new moderation comments to new API
---
diff --git a/com.woltlab.wcf/templates/email_notification_moderationQueueComment.tpl b/com.woltlab.wcf/templates/email_notification_moderationQueueComment.tpl
new file mode 100644
index 0000000000..2e5a8f1394
--- /dev/null
+++ b/com.woltlab.wcf/templates/email_notification_moderationQueueComment.tpl
@@ -0,0 +1,39 @@
+{assign var='count' value=$event->getAuthors()|count}{assign var='guestTimesTriggered' value=$event->getNotification()->guestTimesTriggered}{assign var='authors' value=$event->getAuthors()|array_values}
+{if $mimeType === 'text/plain'}
+{capture assign='authorList'}{lang}wcf.user.notification.mail.authorList.plaintext{/lang}{/capture}
+{lang}{$notificationContent[variables][languageItemPrefix]}.comment.mail.plaintext{/lang}{if $count == 1 && !$guestTimesTriggered}
+
+{$event->getUserNotificationObject()->message}{/if} {* this line ends with a space *}
+{else}
+ {capture assign='authorList'}{lang}wcf.user.notification.mail.authorList.html{/lang}{/capture}
+ {lang}{$notificationContent[variables][languageItemPrefix]}.comment.mail.html{/lang}
+ {assign var='user' value=$event->getAuthor()}
+ {assign var='comment' value=$event->getUserNotificationObject()}
+
+ {if $notificationType == 'instant'}{assign var='avatarSize' value=128}
+ {else}{assign var='avatarSize' value=64}{/if}
+ {capture assign='commentContent'}
+
+ {/capture}
+ {include file='email_paddingHelper' block=true class='box'|concat:$avatarSize content=$commentContent sandbox=true}
+{/if}
diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php
index 8381ec3423..cb073d2463 100644
--- a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php
+++ b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php
@@ -4,6 +4,7 @@ use wcf\data\moderation\queue\ViewableModerationQueue;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\notification\UserNotification;
use wcf\data\user\UserProfile;
+use wcf\system\email\Email;
use wcf\system\moderation\queue\IModerationQueueHandler;
use wcf\system\user\notification\object\IUserNotificationObject;
use wcf\system\WCF;
@@ -50,29 +51,19 @@ class ModerationQueueCommentUserNotificationEvent extends AbstractUserNotificati
* @inheritDoc
*/
public function getEmailMessage($notificationType = 'instant') {
- $authors = $this->getAuthors();
- if (count($authors) > 1) {
- if (isset($authors[0])) {
- unset($authors[0]);
- }
- $count = count($authors);
-
- return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.mail.stacked', [
- 'author' => $this->author,
- 'authors' => array_values($authors),
- 'count' => $count,
- 'others' => $count - 1,
+ return [
+ 'message-id' => 'com.woltlab.wcf.moderation.queue.notification/'.$this->getUserNotificationObject()->commentID,
+ 'template' => 'email_notification_moderationQueueComment',
+ 'application' => 'wcf',
+ 'references' => [
+ 'moderationQueue->queueID.'@'.Email::getHost().'>'
+ ],
+ 'variables' => [
'moderationQueue' => $this->moderationQueue,
- 'notificationType' => $notificationType
- ]);
- }
-
- return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.mail', [
- 'comment' => $this->userNotificationObject,
- 'author' => $this->author,
- 'moderationQueue' => $this->moderationQueue,
- 'notificationType' => $notificationType
- ]);
+ 'notificationType' => $notificationType,
+ 'languageItemPrefix' => $this->languageItemPrefix
+ ]
+ ];
}
/**
diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml
index 6a4a4e5de4..0c357536bf 100644
--- a/wcfsetup/install/lang/de.xml
+++ b/wcfsetup/install/lang/de.xml
@@ -2538,18 +2538,12 @@ Fehler sind beispielsweise:
- - userID}ein Gast{else}{@$author->username}{/if} hat einen Kommentar zum Moderationseintrag "{$moderationQueue->getTitle()}" verfasst:
-{if $notificationType == 'instant'}
----------------------------------
-{@$comment->message}
----------------------------------
-{/if}{$moderationQueue->getLink()}#comments]]>
- - username}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->username}{if $count == 3} und {@$authors[2]->username}{/if}{/if}{else}{@$authors[0]->username} und {#$others} weitere Benutzer{/if} haben Kommentare zum Moderationseintrag "{$moderationQueue->getTitle()}" verfasst:
-{$moderationQueue->getLink()}#comments]]>
- - userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar zum Moderationseintrag {$moderationQueue->getTitle()} verfasst.]]>
- - getAnchorTag()}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere Benutzer{/if} haben Kommentare zum Moderationseintrag {$moderationQueue->getTitle()} verfasst.]]>
+ - userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar zum Moderationseintrag {$moderationQueue->getTitle()} verfasst.]]>
+ - getAnchorTag()}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere Benutzer{/if} haben Kommentare zum Moderationseintrag {$moderationQueue->getTitle()} verfasst.]]>
+ - getTitle()} [URL:{$notificationContent[variables][moderationQueue]->getLink()}] verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} {if $count == 1 && !$guestTimesTriggered}hat einen Kommentar{else}haben Kommentare{/if} zum Moderationseintrag {$notificationContent[variables][moderationQueue]->getTitle()} verfasst:
]]>
- userID}ein Gast{else}{@$author->username}{/if} hat eine Antwort zum Kommentar von "{@$commentAuthor->username}" zum Moderationseintrag "{$moderationQueue->getTitle()}" verfasst:
{if $notificationType == 'instant'}
---------------------------------
@@ -2595,18 +2589,12 @@ Fehler sind beispielsweise:
- - userID}ein Gast{else}{@$author->username}{/if} hat einen Kommentar zum freizuschaltenden Inhalt "{$moderationQueue->getTitle()}" verfasst:
-{if $notificationType == 'instant'}
----------------------------------
-{@$comment->message}
----------------------------------
-{/if}{$moderationQueue->getLink()}#comments]]>
- - username}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->username}{if $count == 3}und {@$authors[2]->username}{/if}{/if}{else}{@$authors[0]->username} {#$others} weitere Benutzer {/if} haben Kommentare zum freizuschaltenden Inhalt "{$moderationQueue->getTitle()}" verfasst:
-{$moderationQueue->getLink()}#comments]]>
- - userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar zum freizuschaltenden Inhalt {$moderationQueue->getTitle()} verfasst.]]>
- - getAnchorTag()}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3}und {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere Benutzer{/if} haben Kommentare zum freizuschaltenden Inhalt {$moderationQueue->getTitle()} verfasst.]]>
+ - userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar zum freizuschaltenden Inhalt {$moderationQueue->getTitle()} verfasst.]]>
+ - getAnchorTag()}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3}und {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere Benutzer{/if} haben Kommentare zum freizuschaltenden Inhalt {$moderationQueue->getTitle()} verfasst.]]>
+ - getTitle()} [URL:{$notificationContent[variables][moderationQueue]->getLink()}] verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} {if $count == 1 && !$guestTimesTriggered}hat einen Kommentar{else}haben Kommentare{/if} zum freizuschaltenden Inhalt {$notificationContent[variables][moderationQueue]->getTitle()} verfasst:]]>
- userID}ein Gast{else}{@$author->username}{/if} hat eine Antwort zum Kommentar von "{@$commentAuthor->username}" zum freizuschaltenden Inhalt "{$moderationQueue->getTitle()}" verfasst:
{if $notificationType == 'instant'}
---------------------------------
@@ -2627,18 +2615,12 @@ Fehler sind beispielsweise:
- - userID}ein Gast{else}{@$author->username}{/if} hat einen Kommentar zur Meldung "{$moderationQueue->getTitle()}" verfasst:
-{if $notificationType == 'instant'}
----------------------------------
-{@$comment->message}
----------------------------------
-{/if}{$moderationQueue->getLink()}#comments]]>
- - username}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->username}{if $count == 3} und {@$authors[2]->username}{/if}{/if}{else}{@$authors[0]->username} und {#$others} weitere Benutzer{/if} haben Kommentare zur Meldung "{$moderationQueue->getTitle()}" verfasst:
-{$moderationQueue->getLink()}#comments]]>
- - userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar zur Meldung {$moderationQueue->getTitle()} verfasst.]]>
- - getAnchorTag()}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere Benutzer{/if} haben Kommentare zur Meldung {$moderationQueue->getTitle()} verfasst.]]>
+ - userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar zur Meldung {$moderationQueue->getTitle()} verfasst.]]>
+ - getAnchorTag()}{if $count != 1}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere Benutzer{/if} haben Kommentare zur Meldung {$moderationQueue->getTitle()} verfasst.]]>
+ - getTitle()} [URL:{$notificationContent[variables][moderationQueue]->getLink()}] verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} {if $count == 1 && !$guestTimesTriggered}hat einen Kommentar{else}haben Kommentare{/if} zu der Meldung {$notificationContent[variables][moderationQueue]->getTitle()} verfasst:]]>
- userID}ein Gast{else}{@$author->username}{/if} hat eine Antwort zum Kommentar von "{@$commentAuthor->username}" zur Meldung "{$moderationQueue->getTitle()}" verfasst:
{if $notificationType == 'instant'}
---------------------------------
diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml
index 8900fc0652..fea213d2a7 100644
--- a/wcfsetup/install/lang/en.xml
+++ b/wcfsetup/install/lang/en.xml
@@ -2542,18 +2542,12 @@ Errors are:
- - userID}a guest{else}{@$author->username}{/if} wrote a comment on the moderation entry "{$moderationQueue->getTitle()}":
-{if $notificationType == 'instant'}
----------------------------------
-{@$comment->message}
----------------------------------
-{/if}{$moderationQueue->getLink()}#comments]]>
- - username}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->username}{if $count == 3} and {@$authors[2]->username}{/if}{/if}{else}{@$authors[0]->username} and {#$others} other users{/if} wrote comments on the moderation entry "{$moderationQueue->getTitle()}":
-{$moderationQueue->getLink()}#comments]]>
- - userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on the moderation entry {$moderationQueue->getTitle()}.]]>
- - getAnchorTag()}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} wrote comments on the moderation entry {$moderationQueue->getTitle()}.]]>
+ - userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on the moderation entry {$moderationQueue->getTitle()}.]]>
+ - getAnchorTag()}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} wrote comments on the moderation entry {$moderationQueue->getTitle()}.]]>
+ - getTitle()} [URL:{$notificationContent[variables][moderationQueue]->getLink()}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} wrote {if $count == 1 && !$guestTimesTriggered}a comment{else}comments{/if} on the moderation entry {$notificationContent[variables][moderationQueue]->getTitle()}:]]>
- userID}a guest{else}{@$author->username}{/if} wrote a reply to {@$commentAuthor->username}âs comment on the moderation entry "{$moderationQueue->getTitle()}":
{if $notificationType == 'instant'}
---------------------------------
@@ -2599,18 +2593,12 @@ Errors are:
- - userID}a guest{else}{@$author->username}{/if} wrote a comment on "{$moderationQueue->getTitle()}" waiting for approval:
-{if $notificationType == 'instant'}
----------------------------------
-{@$comment->message}
----------------------------------
-{/if}{$moderationQueue->getLink()}#comments]]>
- - username}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->username}{if $count == 3} and {@$authors[2]->username}{/if}{/if}{else}{@$authors[0]->username} and {#$others} other users{/if} wrote comments on "{$moderationQueue->getTitle()}" waiting for approval:
-{$moderationQueue->getLink()}#comments]]>
- - userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on {$moderationQueue->getTitle()} waiting for approval.]]>
- - getAnchorTag()}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} wrote comments on {$moderationQueue->getTitle()} waiting for approval.]]>
+ - userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on {$moderationQueue->getTitle()} waiting for approval.]]>
+ - getAnchorTag()}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} wrote comments on {$moderationQueue->getTitle()} waiting for approval.]]>
+ - getTitle()} [URL:{$notificationContent[variables][moderationQueue]->getLink()}] waiting for approval{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} wrote {if $count == 1 && !$guestTimesTriggered}a comment{else}comments{/if} on the moderation entry {$notificationContent[variables][moderationQueue]->getTitle()} waiting for approval:]]>
- userID}a guest{else}{@$author->username}{/if} wrote a reply to {@$commentAuthor->username}âs comment on "{$moderationQueue->getTitle()}" waiting for approval:
{if $notificationType == 'instant'}
---------------------------------
@@ -2631,18 +2619,12 @@ Errors are:
- - userID}a guest{else}{@$author->username}{/if} wrote a comment on the report "{$moderationQueue->getTitle()}":
-{if $notificationType == 'instant'}
----------------------------------
-{@$comment->message}
----------------------------------
-{/if}{$moderationQueue->getLink()}#comments]]>
- - username}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->username}{if $count == 3} and {@$authors[2]->username}{/if}{/if}{else}{@$authors[0]->username} and {#$others} other users{/if} wrote comments on the report "{$moderationQueue->getTitle()}":
-{$moderationQueue->getLink()}#comments]]>
- - userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on {$moderationQueue->getTitle()} waiting for approval.]]>
- - getAnchorTag()}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} wrote comments on the report {$moderationQueue->getTitle()}.]]>
+ - userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on the report {$moderationQueue->getTitle()}.]]>
+ - getAnchorTag()}{if $count != 1}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} wrote comments on the report {$moderationQueue->getTitle()}.]]>
+ - getTitle()} [URL:{$notificationContent[variables][moderationQueue]->getLink()}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} wrote {if $count == 1 && !$guestTimesTriggered}a comment{else}comments{/if} on the report {$notificationContent[variables][moderationQueue]->getTitle()}:]]>
- userID}a guest{else}{@$author->username}{/if} wrote a reply to {@$commentAuthor->username}âs comment on the report "{$moderationQueue->getTitle()}":
{if $notificationType == 'instant'}
---------------------------------