Merge remote-tracking branch 'refs/remotes/origin/2.1'
authorMarcel Werk <burntime@woltlab.com>
Wed, 18 Jan 2017 17:34:13 +0000 (18:34 +0100)
committerMarcel Werk <burntime@woltlab.com>
Wed, 18 Jan 2017 17:34:13 +0000 (18:34 +0100)
# Conflicts:
# wcfsetup/install/files/lib/data/comment/CommentAction.class.php

1  2 
wcfsetup/install/files/lib/data/comment/CommentAction.class.php

index 1fb16333f259b4093256f2b83a2bee27c2373b65,2918c9cbc91f59d06cfc5fa937f304ed339e60b6..d9c65eab36b25a219c584b7ed548062c0fa8ca7b
@@@ -383,65 -355,29 +383,65 @@@ class CommentAction extends AbstractDat
                }
                
                // fire notification event
-               if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.notification')) {
-                       $notificationObjectType = UserNotificationHandler::getInstance()->getObjectTypeProcessor($objectType->objectType.'.response.notification');
+               if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.notification') && UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
+                       $notificationObjectType = UserNotificationHandler::getInstance()->getObjectTypeProcessor($objectType->objectType.'.notification');
 -                      $userID = $notificationObjectType->getOwnerID($this->comment->commentID);
 -                      
                        $notificationObject = new CommentResponseUserNotificationObject($this->createdResponse);
 -                      if ($this->comment->userID != WCF::getUser()->userID) {
 -                              UserNotificationHandler::getInstance()->fireEvent('commentResponse', $objectType->objectType.'.response.notification', $notificationObject, array($this->comment->userID), array(
 -                                      'commentID' => $this->comment->commentID,
 -                                      'objectID' => $this->comment->objectID,
 -                                      'objectUserID' => $userID,
 -                                      'userID' => $this->comment->userID
 -                              ));
 -                      }
                        
 -                      // notify the container owner
 -                      if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
 -                              if ($userID != $this->comment->userID && $userID != WCF::getUser()->userID) {
 -                                      UserNotificationHandler::getInstance()->fireEvent('commentResponseOwner', $objectType->objectType.'.response.notification', $notificationObject, array($userID), array(
 -                                              'commentID' => $this->comment->commentID,
 -                                              'objectID' => $this->comment->objectID,
 -                                              'objectUserID' => $userID,
 -                                              'userID' => $this->comment->userID
 -                                      ));
 +                      if ($notificationObjectType instanceof IMultiRecipientCommentUserNotificationObjectType) {
 +                              $recipientIDs = $notificationObjectType->getRecipientIDs($this->comment);
 +                              
 +                              // make sure that the active user gets no notification
 +                              $recipientIDs = array_diff($recipientIDs, [WCF::getUser()->userID]);
 +                              
 +                              if (!empty($recipientIDs)) {
 +                                      UserNotificationHandler::getInstance()->fireEvent(
 +                                              'commentResponse',
 +                                              $objectType->objectType . '.response.notification',
 +                                              $notificationObject,
 +                                              $recipientIDs,
 +                                              [
 +                                                      'commentID' => $this->comment->commentID,
 +                                                      'objectID' => $this->comment->objectID,
 +                                                      'userID' => $this->comment->userID
 +                                              ]
 +                                      );
 +                              }
 +                      }
 +                      else {
 +                              /** @var ICommentUserNotificationObjectType $notificationObjectType */
 +                              
 +                              $userID = $notificationObjectType->getOwnerID($this->comment->commentID);
 +                              
 +                              if ($this->comment->userID != WCF::getUser()->userID) {
 +                                      UserNotificationHandler::getInstance()->fireEvent(
 +                                              'commentResponse',
 +                                              $objectType->objectType . '.response.notification',
 +                                              $notificationObject,
 +                                              [$this->comment->userID],
 +                                              [
 +                                                      'commentID' => $this->comment->commentID,
 +                                                      'objectID' => $this->comment->objectID,
 +                                                      'objectUserID' => $userID,
 +                                                      'userID' => $this->comment->userID
 +                                              ]
 +                                      );
 +                              }
 +                              
 +                              // notify the container owner
 +                              if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
 +                                      if ($userID != $this->comment->userID && $userID != WCF::getUser()->userID) {
 +                                              UserNotificationHandler::getInstance()->fireEvent(
 +                                                      'commentResponseOwner',
 +                                                      $objectType->objectType . '.response.notification',
 +                                                      $notificationObject,
 +                                                      [$userID], [
 +                                                              'commentID' => $this->comment->commentID,
 +                                                              'objectID' => $this->comment->objectID,
 +                                                              'objectUserID' => $userID,
 +                                                              'userID' => $this->comment->userID
 +                                                      ]
 +                                              );
 +                                      }
                                }
                        }
                }