From: Tim Düsterhus Date: Thu, 16 Jun 2016 15:23:55 +0000 (+0200) Subject: Partially convert new follower notification to new email API X-Git-Tag: 3.0.0_Beta_1~916^2~1^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3c5d2b85f4a5623dde4cbd7b1872ea46ebe8523d;p=GitHub%2FWoltLab%2FWCF.git Partially convert new follower notification to new email API --- diff --git a/com.woltlab.wcf/templates/email_html.tpl b/com.woltlab.wcf/templates/email_html.tpl index bcfdf3da55..030e52da6a 100644 --- a/com.woltlab.wcf/templates/email_html.tpl +++ b/com.woltlab.wcf/templates/email_html.tpl @@ -19,6 +19,10 @@ text-decoration: none; } + td { + vertical-align: top; + } + {* see email_paddingHelper.tpl *} table.paddingHelper.block { width: 100%; @@ -48,6 +52,17 @@ td.button a { color: {$style->getVariable('wcfButtonPrimaryText', true)}; } + + .box128 { + border-top: 1px solid {$style->getVariable('wcfContentBorder', true)}; + border-bottom: 1px solid {$style->getVariable('wcfContentBorder', true)}; + padding: 20px; + } + + .containerHeadline h3 { + margin: 0; + padding: 0; + } diff --git a/com.woltlab.wcf/templates/email_notification.tpl b/com.woltlab.wcf/templates/email_notification.tpl index 0595d9ab17..5fb06f5b02 100644 --- a/com.woltlab.wcf/templates/email_notification.tpl +++ b/com.woltlab.wcf/templates/email_notification.tpl @@ -2,17 +2,21 @@ {capture assign='content'} {lang}wcf.user.notification.mail.plaintext.intro{/lang} -{@$notificationContent} +{if $notificationContent|is_array}{include file=$notificationContent[template] application=$notificationContent[application]}{* +*}{else}{@$notificationContent}{/if} {lang}wcf.user.notification.mail.plaintext.outro{/lang} {/capture} {include file='email_plaintext'} {else} {capture assign='content'} -

{lang}wcf.user.notification.mail.html.headline{/lang}

{lang}wcf.user.notification.mail.html.intro{/lang} - {@$notificationContent} + {if $notificationContent|is_array} + {include file=$notificationContent[template] application=$notificationContent[application]} + {else} + {@$notificationContent} + {/if} {lang}wcf.user.notification.mail.html.outro{/lang} {/capture} diff --git a/com.woltlab.wcf/templates/email_notification_userFollowFollowing.tpl b/com.woltlab.wcf/templates/email_notification_userFollowFollowing.tpl new file mode 100644 index 0000000000..7618d204bc --- /dev/null +++ b/com.woltlab.wcf/templates/email_notification_userFollowFollowing.tpl @@ -0,0 +1,18 @@ +{if $mimeType === 'text/plain'} +{lang}wcf.user.notification.follow.mail.plaintext{/lang} +{else} + {assign var='user' value=$event->getAuthor()} + {capture assign='userContent'} + + + + + +
{@$user->getAvatar()->getImageTag(128)} + {include file='email_userInformationHeadline'} +
+ {/capture} + {include file='email_paddingHelper' block=true class='box128' content=$userContent sandbox=true} +
+ {lang}wcf.user.notification.follow.mail.html{/lang} +{/if} diff --git a/com.woltlab.wcf/templates/email_plaintext.tpl b/com.woltlab.wcf/templates/email_plaintext.tpl index 50bdae538a..f3ce6aa970 100644 --- a/com.woltlab.wcf/templates/email_plaintext.tpl +++ b/com.woltlab.wcf/templates/email_plaintext.tpl @@ -1,8 +1,8 @@ -{if $beforeContent|isset}{@$beforeContent}{/if} +{if $beforeContent|isset}{@$beforeContent} -{@$content} +{/if}{@$content}{if $afterContent|isset} -{if $afterContent|isset}{@$afterContent}{/if} +{@$afterContent}{/if} {hascontent} {* this line ends with a space *} -- {* this line ends with a space *} diff --git a/com.woltlab.wcf/templates/email_userInformationHeadline.tpl b/com.woltlab.wcf/templates/email_userInformationHeadline.tpl new file mode 100644 index 0000000000..1296ecfd82 --- /dev/null +++ b/com.woltlab.wcf/templates/email_userInformationHeadline.tpl @@ -0,0 +1,11 @@ +
+

{$user->username}

+
+
+ {if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && $user->isAccessible('canViewProfile')} + {if $user->isVisibleOption('gender') && $user->gender}{lang}wcf.user.gender.{if $user->gender == 1}male{else}female{/if}{/lang}, {/if} + {if $user->isVisibleOption('birthday') && $user->getAge()}{@$user->getAge()}, {/if} + {if $user->isVisibleOption('location') && $user->location}{lang}wcf.user.membersList.location{/lang}, {/if} + {/if} + {lang}wcf.user.membersList.registrationDate{/lang} +
diff --git a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php index cc8e876d3b..4682001aaa 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -14,7 +14,7 @@ use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\event\EventHandler; use wcf\system\exception\SystemException; -use wcf\system\email\mime\AbstractMimePart; +use wcf\system\email\mime\MimePartFacade; use wcf\system\email\mime\RecipientAwareTextMimePart; use wcf\system\email\Email; use wcf\system\email\UserMailbox; @@ -664,15 +664,28 @@ class UserNotificationHandler extends SingletonFactory { 'title' => $event->getEmailTitle() ])); $email->addRecipient(new UserMailbox($user)); + // TODO: MessageID, References, In-Reply-To $message = $event->getEmailMessage('instant'); - if ($message instanceof AbstractMimePart) { - $email->setBody($message); + if (is_array($message)) { + $variables = [ + 'notificationContent' => $message, + 'event' => $event, + 'notificationType' => 'instant' + ]; + if (isset($message['variables'])) { + $variables['variables'] = $message['variables']; + } + + $html = new RecipientAwareTextMimePart('text/html', 'email_notification', 'wcf', $variables); + $plainText = new RecipientAwareTextMimePart('text/plain', 'email_notification', 'wcf', $variables); + $email->setBody(new MimePartFacade([$html, $plainText])); } else { $email->setBody(new RecipientAwareTextMimePart('text/plain', 'email_notification', 'wcf', [ 'notificationContent' => $message, - 'event' => $event + 'event' => $event, + 'notificationType' => 'instant' ])); } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php index 821f53988a..3b7c975c09 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php @@ -49,8 +49,18 @@ interface IUserNotificationEvent extends IDatabaseObjectProcessor { /** * Returns the message for this notification event. * + * If $notificationType is 'instant' this method should either: + * - Return a string to be inserted into a text/plain email (deprecated) + * - Return a ['template' => ..., 'application' => ..., 'variables' => ...] array + * to be included into the summary email. + * + * If $notificationType is 'daily' this method should either: + * - Return a string to be inserted into the summary email (deprecated) + * - Return a ['template' => ..., 'application' => ..., 'variables' => ...] array + * to be included into the summary email. + * * @param string $notificationType - * @return string + * @return mixed */ public function getEmailMessage($notificationType = 'instant'); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserFollowFollowingUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserFollowFollowingUserNotificationEvent.class.php index b04f468fce..afd6ccd642 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserFollowFollowingUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserFollowFollowingUserNotificationEvent.class.php @@ -1,5 +1,7 @@ getAuthors()); - $count = count($authors); - - if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.mail.stacked', [ - 'author' => $this->author, - 'authors' => $authors, - 'count' => $count, - 'others' => $count - 1, - 'notificationType' => $notificationType - ]); - } - - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.mail', ['author' => $this->author]); + return [ + 'template' => 'email_notification_userFollowFollowing', + 'application' => 'wcf' + ]; } /** diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 2d10d43571..d4a3c2f68c 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3234,24 +3234,38 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email} - getAnchorTag()} folgt {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> - getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weiteren{/if} folgen {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> - - - username} folgt {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> - username}{if $count == 2} und {else}, {/if}{@$authors[1]->username}{if $count == 3} und {@$authors[2]->username}{/if}{else}{@$authors[0]->username} und {#$others} weiteren{/if} folgen {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> + + + + + + + + + + + + + + - + getUser()->username},]]> eventID}&userID={@$mailbox->getUser()->userID}&token={@$mailbox->getUser()->notificationMailToken}{/link}]]> +Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} nur diese E-Mail-Benachrichtigung nicht mehr erhalten {if LANGUAGE_USE_INFORMAL_VARIANT}möchtest{else}möchten{/if}, dann {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} diese direkt abbestellen: {link controller='NotificationDisable' isEmail=true}eventID={@$event->eventID}&userID={@$mailbox->getUser()->userID}&token={@$mailbox->getUser()->notificationMailToken}{/link}.]]> + Hallo {$mailbox->getUser()->username},]]> + Diese E-Mail ist eine automatische Benachrichtigung. Bitte antworten Sie nicht auf diese E-Mail.

+ +

{if LANGUAGE_USE_INFORMAL_VARIANT}Besuche deine{else}Besuchen Sie Ihre{/if} Benachrichtigungseinstellungen, um die +Benachrichtigungen auf {PAGE_TITLE|language} nach {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Wünschen zu konfigurieren.

+ +

Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} nur diese E-Mail-Benachrichtigung nicht mehr erhalten {if LANGUAGE_USE_INFORMAL_VARIANT}möchtest{else}möchten{/if}, dann {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} diese direkt abbestellen.

]]>
email} {if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} folgenden Link aufrufen, um die Benachrichtigung abzuschalten: {link controller='NotificationDisable' isEmail=true}userID={@$user->userID}&token={@$token}{/link}]]> - - - - - - - - - - - - - - - + + + + + getAnchorTag()} folgt {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> + getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weiteren{/if} folgen {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> + getAuthor()->username} [URL:{link controller='User' object=$event->getAuthor() isEmail=true}{/link}] folgt {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.]]> + {$event->getAuthor()->username} folgt {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}.

]]>
userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar an {if LANGUAGE_USE_INFORMAL_VARIANT}deiner{else}Ihrer{/if} Pinnwand verfasst.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 1878d3f763..4d24c40811 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3270,22 +3270,39 @@ Open the link below to access the user profile: - getAnchorTag()} follows you.]]> - getAnchorTag()}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} others{/if} follow you.]]> - username} follows you.]]> - username}{if $count == 2} and {else}, {/if}{@$authors[1]->username}{if $count == 3} and {@$authors[2]->username}{/if}{else}{@$authors[0]->username} and {#$others} others{/if} follow you.]]> - - + + + + + + + + + + - + + + -You can manage your notification settings for {@PAGE_TITLE|language} on the page below: -{link controller='NotificationSettings' isEmail=true}{/link} - -If you do not want to receive further email notifications for this event, you can quickly disable it by opening the link below: -{link controller='NotificationDisable' isEmail=true}eventID={@$notification->eventID}&userID={@$user->userID}&token={@$token}{/link}]]> - username},]]> + + getUser()->username},]]> + eventID}&userID={@$mailbox->getUser()->userID}&token={@$mailbox->getUser()->notificationMailToken}{/link}]]> + Dear {$mailbox->getUser()->username},]]> + This is an automatic notification, please do not reply to this email!

+ +

Visit your notification settings to configure +your notifications on {PAGE_TITLE|language} as you wish.

+ +

You can disable only this type of notification as well.

]]>
userID}&token={@$token}{/link}]]> - - - - - - - - - - - - - - + + + + + getAnchorTag()} follows you.]]> + getAnchorTag()}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} others{/if} follow you.]]> + getAuthor()->username} [URL:{link controller='User' object=$event->getAuthor() isEmail=true}{/link}] is following you.]]> + getAuthor() isEmail=true}{/link}">{$event->getAuthor()->username} is following you.]]> userID}A guest{else}{@$author->getAnchorTag()}{/if} wrote a comment on your wall.]]>