Added stacking support for wall comments
authorAlexander Ebert <ebert@woltlab.com>
Fri, 20 Jun 2014 10:14:00 +0000 (12:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 20 Jun 2014 10:14:00 +0000 (12:14 +0200)
wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php
wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php
wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php
wcfsetup/install/lang/de.xml

index 363d9ae29da0c5ff26395723a088c708eef2a35c..b024727c1cb47dd882f649822983f4ebb817db2a 100644 (file)
@@ -17,10 +17,23 @@ use wcf\system\WCF;
  * @category   Community Framework
  */
 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractUserNotificationEvent {
+       /**
+        * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+        */
+       protected $stackable = true;
+       
        /**
         * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
         */
        public function getTitle() {
+               $count = count($this->getAuthors());
+               if ($count > 1) {
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array(
+                               'count' => $count,
+                               'timesTriggered' => $this->timesTriggered
+                       ));
+               }
+               
                return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
        }
        
@@ -39,6 +52,16 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractUserN
                        ));
                }
                
+               $authors = array_values($this->getAuthors());
+               $count = count($authors);
+               if ($count > 1) {
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array(
+                               'authors' => $authors,
+                               'count' => $count,
+                               'others' => max($count - 1, 0)
+                       ));
+               }
+               
                return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
                        'author' => $this->author,
                        'commentAuthor' => $commentAuthor
@@ -75,4 +98,11 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractUserN
        public function getLink() {
                return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
        }
+       
+       /**
+        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+        */
+       public function getEventHash() {
+               return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
+       }
 }
index 335d6461b3c8956ce48c02cc6005a6fbb399f45e..b5e54101b2c711a39080f49a631acc1d37456d19 100644 (file)
@@ -16,10 +16,23 @@ use wcf\system\user\notification\event\AbstractUserNotificationEvent;
  * @category   Community Framework
  */
 class UserProfileCommentResponseUserNotificationEvent extends AbstractUserNotificationEvent {
+       /**
+        * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+        */
+       protected $stackable = true;
+       
        /**
         * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
         */
        public function getTitle() {
+               $count = count($this->getAuthors());
+               if ($count > 1) {
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', array(
+                               'count' => $count,
+                               'timesTriggered' => $this->timesTriggered
+                       ));
+               }
+               
                return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
        }
        
@@ -29,6 +42,7 @@ class UserProfileCommentResponseUserNotificationEvent extends AbstractUserNotifi
        public function getMessage() {
                // @todo: use cache or a single query to retrieve required data
                $comment = new Comment($this->userNotificationObject->commentID);
+               $owner = new User($comment->objectID);
                if ($comment->userID) {
                        $commentAuthor = new User($comment->userID);
                }
@@ -38,9 +52,20 @@ class UserProfileCommentResponseUserNotificationEvent extends AbstractUserNotifi
                        ));
                }
                
+               $authors = array_values($this->getAuthors());
+               $count = count($authors);
+               if ($count > 1) {
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array(
+                               'authors' => $authors,
+                               'count' => $count,
+                               'others' => max($count - 1, 0),
+                               'owner' => $owner
+                       ));
+               }
+               
                return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array(
                        'author' => $this->author,
-                       'owner' => $user
+                       'owner' => $owner
                ));
        }
        
index 18ba1287b19d2f1279da062eefd1a3ceeab69cd4..09eaef60dd845f571f11e77245e6a30facb6433b 100644 (file)
@@ -16,10 +16,23 @@ use wcf\system\WCF;
  * @category   Community Framework
  */
 class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEvent {
+       /**
+        * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+        */
+       protected $stackable = true;
+       
        /**
         * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
         */
        public function getTitle() {
+               $count = count($this->getAuthors());
+               if ($count > 1) {
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', array(
+                               'count' => $count,
+                               'timesTriggered' => $this->timesTriggered
+                       ));
+               }
+               
                return $this->getLanguage()->get('wcf.user.notification.comment.title');
        }
        
@@ -27,6 +40,18 @@ class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEv
         * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
         */
        public function getMessage() {
+               $authors = array_values($this->getAuthors());
+               $count = count($authors);
+               
+               if ($count > 1) {
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', array(
+                               'author' => $this->author,
+                               'authors' => $authors,
+                               'count' => $count,
+                               'others' => max($count - 1, 0)
+                       ));
+               }
+               
                return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', array(
                        'author' => $this->author
                ));
@@ -52,4 +77,11 @@ class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEv
        public function getLink() {
                return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
        }
+       
+       /**
+        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+        */
+       public function getEventHash() {
+               return sha1($this->eventID . '-' . $this->notification->userID);
+       }
 }
index ac93d3f6a2a585cf46d2b227786540fbec81b3c9..21510b23f8ab767768f6322fbcdec1a5bf068355 100644 (file)
@@ -2856,7 +2856,9 @@ Möchten Sie diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, könn
                <item name="wcf.user.notification.com.woltlab.wcf.user"><![CDATA[Benutzer-Profile]]></item>
                <item name="wcf.user.notification.com.woltlab.wcf.user.follow.following"><![CDATA[Jemand folgt Ihnen]]></item>
                <item name="wcf.user.notification.comment.title"><![CDATA[Neuer Kommentar (Pinnwand)]]></item>
+               <item name="wcf.user.notification.comment.title.stacked"><![CDATA[{#$timesTriggered} neue Kommentare (Pinnwand)]]></item>
                <item name="wcf.user.notification.comment.message"><![CDATA[Hat einen Kommentar an Ihrer Pinnwand verfasst.]]></item>
+               <item name="wcf.user.notification.comment.message.stacked"><![CDATA[{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$count} weitere{/if} haben Kommentare an <a href="{link controller='User' object=$__wcf->getUser()}#wall{/link}">Ihrer Pinnwand</a> verfasst.]]></item>
                <item name="wcf.user.notification.comment.mail"><![CDATA[{@$author->username} hat einen Kommentar an Ihrer Pinnwand verfasst:
 {if $notificationType == 'instant'}
 ---------------------------------
@@ -2864,7 +2866,9 @@ Möchten Sie diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, könn
 ---------------------------------
 {/if}{link controller='User' object=$owner isEmail=true}{/link}#wall]]></item>
                <item name="wcf.user.notification.commentResponse.title"><![CDATA[Neue Antwort (Pinnwand)]]></item>
+               <item name="wcf.user.notification.commentResponse.title.stacked"><![CDATA[{#$timesTriggered} neue Antworten (Pinnwand)]]></item>
                <item name="wcf.user.notification.commentResponse.message"><![CDATA[Hat eine Antwort zu Ihrem Kommentar an der Pinnwand von {$owner->username} verfasst.]]></item>
+               <item name="wcf.user.notification.commentResponse.message.stacked"><![CDATA[{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$count} weitere{/if} haben auf Ihren Kommentare an der <a href="{link controller='User' object=$owner}#wall{/link}">Pinnwand von {$owner->username}</a> geantwortet.]]></item>
                <item name="wcf.user.notification.commentResponse.mail"><![CDATA[{@$author->username} hat eine Antwort zu Ihrem Kommentar an der Pinnwand von "{@$owner->username}" verfasst:
 {if $notificationType == 'instant'}
 ---------------------------------
@@ -2872,7 +2876,9 @@ Möchten Sie diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, könn
 ---------------------------------
 {/if}{link controller='User' object=$owner isEmail=true}{/link}#wall]]></item>
                <item name="wcf.user.notification.commentResponseOwner.title"><![CDATA[Neue Antwort (Pinnwand)]]></item>
+               <item name="wcf.user.notification.commentResponseOwner.title.stacked"><![CDATA[{$#timesTriggered} neue Antworten (Pinnwand)]]></item>
                <item name="wcf.user.notification.commentResponseOwner.message"><![CDATA[Hat eine Antwort zum Kommentar von {$commentAuthor->username} an Ihrer Pinnwand verfasst.]]></item>
+               <item name="wcf.user.notification.commentResponseOwner.message.stacked"><![CDATA[{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$count} weitere{/if} haben auf Kommentare an <a href="{link controller='User' object=$__wcf->getUser()}#wall{/link}">Ihrer Pinnwand</a> geantwortet.]]></item>
                <item name="wcf.user.notification.commentResponseOwner.mail"><![CDATA[{@$author->username} hat eine Antwort zum Kommentar von "{@$commentAuthor->username}" an Ihrer Pinnwand verfasst:
 {if $notificationType == 'instant'}
 ---------------------------------