/**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (!MODULE_USER_NOTIFICATION) {
         return;
     }
     try {
         $notificationObject = $this->getNotificationObject($eventObj->eventName, $eventObj->placeholders + array('contestID' => $eventObj->contestID));
     } catch (Exception $e) {
         // just fun, errors don't need to be handled
         return;
     }
     switch ($eventName) {
         case 'create':
             foreach ($notificationObject->getRecipients() as $recipientUserID) {
                 // remove current user from recipient list
                 if ($recipientUserID == WCF::getUser()->userID) {
                     continue;
                 }
                 NotificationHandler::fireEvent($eventObj->eventName, self::OBJECT_TYPE, $notificationObject, $recipientUserID);
             }
             break;
         case 'delete':
             NotificationHandler::revokeEvent(array($eventObj->eventName), self::OBJECT_TYPE, array($notificationObject));
             break;
         case 'confirm':
             // anybody affected by current confirmation?
             $objectIDScope = array();
             foreach ($notificationObject->getObjects() as $objectID) {
                 $objectIDScope[] = $objectID;
             }
             $recipientUserID = WCF::getUser()->userID;
             NotificationEditor::markConfirmedByObjectVisit($recipientUserID, array($eventObj->eventName), self::OBJECT_TYPE, $objectIDScope);
             break;
     }
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (MODULE_USER_NOTIFICATION) {
         if ($className === 'PostActionPage') {
             $markedPostIDs = WCF::getSession()->getVar('markedPosts');
             if ($eventObj->post !== null && $eventObj->post->userID != WCF::getUser()->userID) {
                 if ($eventObj->action === 'trash') {
                     if (!THREAD_ENABLE_RECYCLE_BIN || !$eventObj->board->getModeratorPermission('canDeletePost') || $eventObj->post->isDeleted) {
                         return;
                     }
                     NotificationHandler::fireEvent('trashed', 'postDelete', $eventObj->post->postID, $eventObj->post->userID, array('trashedByUserID' => WCF::getUser()->userID, 'trashedByUsername' => WCF::getUser()->username, 'trashReason' => $eventObj->reason, 'threadID' => $eventObj->thread->threadID, 'threadTopic' => $eventObj->thread->topic));
                     return true;
                 } else {
                     if ($eventObj->action === 'delete') {
                         if (!$eventObj->board->getModeratorPermission('canDeletePostCompletely')) {
                             return;
                         }
                         NotificationHandler::revokeEvent(array('trashed'), 'postDelete', $eventObj->post->postID);
                         NotificationHandler::fireEvent('deleted', 'postDelete', $eventObj->post->postID, $eventObj->post->userID, array('deletedByUserID' => WCF::getUser()->userID, 'deletedByUsername' => WCF::getUser()->username, 'threadID' => $eventObj->thread->threadID, 'threadTopic' => $eventObj->thread->topic));
                         return true;
                     } else {
                         if ($eventObj->action === 'recover') {
                             if (!$eventObj->board->getModeratorPermission('canDeletePostCompletely') || !$eventObj->post->isDeleted) {
                                 return;
                             }
                             NotificationHandler::revokeEvent(array('trashed'), 'postDelete', $eventObj->post);
                             return true;
                         }
                     }
                 }
             }
             if ($markedPostIDs !== null && count($markedPostIDs)) {
                 if ($eventObj->action === 'deleteAll') {
                     $trashPosts = array();
                     $trashPostsThreadIDs = array();
                     $deletePosts = array();
                     $deletePostsThreadIDs = array();
                     $sql = "SELECT\t\tpost.*, thread.threadID, thread.topic\n\t\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\t\t\t\tON\t\t(post.threadID = thread.threadID)\n\t\t\t\t\t\t\tWHERE\t\tpost.postID IN (" . implode(',', $markedPostIDs) . ")";
                     $result = WCF::getDB()->sendQuery($sql);
                     while ($row = WCF::getDB()->fetchArray($result)) {
                         if ($row['userID'] != WCF::getUser()->userID) {
                             if ($row['isDeleted'] || !THREAD_ENABLE_RECYCLE_BIN) {
                                 $deletePosts[$row['postID']] = new PostDeleteNotificationObject(null, $row);
                                 $deletePostsThreadIDs[] = $row['threadID'];
                             } else {
                                 $trashPosts[$row['postID']] = new PostDeleteNotificationObject(null, $row);
                                 $trashPostsThreadIDs[] = $row['threadID'];
                             }
                         }
                     }
                     list($trashPostsBoards, $trashPostsBoardIDs) = ThreadEditor::getBoards(implode(',', $trashPostsThreadIDs));
                     list($deletePostsBoards, $deletePostsBoardIDs) = ThreadEditor::getBoards(implode(',', $deletePostsThreadIDs));
                     foreach ($trashPostsBoards as $trashPostsBoard) {
                         $trashPostsBoard->checkModeratorPermission('canDeletePost');
                     }
                     foreach ($deletePostsBoards as $deletePostsBoard) {
                         $deletePostsBoard->checkModeratorPermission('canDeletePostCompletely');
                     }
                     unset($trashPostsThreadIDs, $deletePostsThreadIDs, $trashPostsBoards, $deletePostsBoards, $trashPostsBoardIDs, $deletePostsBoardIDs);
                     foreach ($trashPosts as $trashPost) {
                         NotificationHandler::fireEvent('trashed', 'postDelete', $trashPost, $trashPost->userID, array('trashedByUserID' => WCF::getUser()->userID, 'trashedByUsername' => WCF::getUser()->username, 'trashReason' => $eventObj->reason, 'threadID' => $trashPost->threadID, 'threadTopic' => $trashPost->topic));
                     }
                     foreach ($deletePosts as $deletePost) {
                         NotificationHandler::revokeEvent(array('trashed'), 'postDelete', $deletePost);
                         NotificationHandler::fireEvent('deleted', 'postDelete', $deletePost, $deletePost->userID, array('deletedByUserID' => WCF::getUser()->userID, 'deletedByUsername' => WCF::getUser()->username, 'threadID' => $deletePost->threadID, 'threadTopic' => $deletePost->topic));
                     }
                     return true;
                 } else {
                     if ($eventObj->action === 'recoverAll') {
                         $threadIDs = PostEditor::getThreadIDs(implode(',', $markedPostIDs));
                         $notificationObjectObjects = NotificationHandler::getNotificationObjectTypeObject('postDelete')->getObjects($markedPostIDs);
                         list($boards, $boardIDs) = ThreadEditor::getBoards($threadIDs);
                         foreach ($boards as $board) {
                             $board->checkModeratorPermission('canDeletePostCompletely');
                         }
                         unset($threadIDs, $boards, $boardIDs);
                         foreach ($notificationObjectObjects as $notificationObjectObject) {
                             NotificationHandler::revokeEvent(array('trashed'), 'postDelete', $notificationObjectObject);
                         }
                         return true;
                     }
                 }
             }
         } else {
             if ($className === 'ThreadPage') {
                 $posts = $eventObj->postList->posts;
                 $postIDs = array();
                 $user = new NotificationUser(null, WCF::getUser(), false);
                 $packageID = NotificationHandler::getNotificationObjectTypeObject('postDelete')->getPackageID();
                 foreach ($posts as $post) {
                     if ($post->isDeleted && $post->userID == $user->userID) {
                         $postIDs[] = $post->postID;
                     }
                 }
                 unset($posts);
                 if (isset($user->notificationFlags[$packageID]) && $user->notificationFlags[$packageID] > 0) {
                     $count = NotificationEditor::markConfirmedByObjectVisit($user->userID, array('trashed'), 'postDelete', $postIDs);
                     $user->removeOutstandingNotification($packageID, $count);
                 }
             } else {
                 if ($className === 'PostEditForm' && $eventObj->post->userID != WCF::getUser()->userID && isset($_POST['deletePost']) && isset($_POST['sure'])) {
                     if ((!THREAD_ENABLE_RECYCLE_BIN || THREAD_ENABLE_RECYCLE_BIN && $eventObj->post->isDeleted) && $eventObj->board->getModeratorPermission('canDeletePostCompletely')) {
                         NotificationHandler::revokeEvent(array('trashed'), 'postDelete', $eventObj->post->postID);
                         NotificationHandler::fireEvent('deleted', 'postDelete', $eventObj->post->postID, $eventObj->post->userID, array('deletedByUserID' => WCF::getUser()->userID, 'deletedByUsername' => WCF::getUser()->username, 'threadID' => $eventObj->thread->threadID, 'threadTopic' => $eventObj->thread->topic));
                     } else {
                         if (!$eventObj->post->isDeleted && THREAD_ENABLE_RECYCLE_BIN && $eventObj->board->getModeratorPermission('canDeletePost')) {
                             NotificationHandler::fireEvent('trashed', 'postDelete', $eventObj->post->postID, $eventObj->post->userID, array('trashedByUserID' => WCF::getUser()->userID, 'trashedByUsername' => WCF::getUser()->username, 'trashReason' => $eventObj->deleteReason, 'threadID' => $eventObj->thread->threadID, 'threadTopic' => $eventObj->thread->topic));
                         }
                     }
                 }
             }
         }
     }
 }