/**
  * @see	\wcf\system\user\activity\event\IUserActivityEvent::prepare()
  */
 public function prepare(array $events)
 {
     $responseIDs = array();
     foreach ($events as $event) {
         $responseIDs[] = $event->objectID;
     }
     $responseList = new CommentResponseList();
     $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs));
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     $commentIDs = $comments = array();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     if (!empty($commentIDs)) {
         $commentList = new CommentList();
         $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
         $commentList->readObjects();
         $comments = $commentList->getObjects();
     }
     // fetch news entries
     $entryIDs = $entry = array();
     foreach ($comments as $comment) {
         $entryIDs[] = $comment->objectID;
     }
     if (!empty($entryIDs)) {
         $entryList = new ViewableEntryList();
         $entryList->getConditionBuilder()->add("news_entry.entryID IN (?)", array($entryIDs));
         $entryList->readObjects();
         $entry = $entryList->getObjects();
     }
     $userIDs = $user = array();
     foreach ($comments as $comment) {
         $userIDs[] = $comment->userID;
     }
     if (!empty($userIDs)) {
         $userList = new UserList();
         $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs));
         $userList->readObjects();
         $users = $userList->getObjects();
     }
     foreach ($events as $event) {
         if (isset($responses[$event->objectID])) {
             $response = $responses[$event->objectID];
             $comment = $comments[$response->commentID];
             if (isset($entry[$comment->objectID]) && isset($users[$comment->userID])) {
                 $newsEntry = $entry[$comment->objectID];
                 if (!$newsEntry->canRead()) {
                     continue;
                 }
                 $event->setIsAccessible();
                 $text = WCF::getLanguage()->getDynamicVariable('cms.recentActivity.newsCommentResponse', array('commentAuthor' => $users[$comment->userID], 'entry' => $newsEntry));
                 $event->setTitle($text);
                 $event->setDescription($response->getExcerpt());
                 continue;
             }
         }
         $event->setIsOrphaned();
     }
 }
 /**
  * @see	\wcf\system\user\activity\event\IUserActivityEvent::prepare()
  */
 public function prepare(array $events)
 {
     if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
         return;
     }
     $responses = $responseIDs = array();
     foreach ($events as $event) {
         $responseIDs[] = $event->objectID;
     }
     // fetch responses
     $responseList = new CommentResponseList();
     $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs));
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     // fetch comments
     $commentIDs = $comments = array();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     if (!empty($commentIDs)) {
         $commentList = new CommentList();
         $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
         $commentList->readObjects();
         $comments = $commentList->getObjects();
     }
     // fetch users
     $userIDs = $users = array();
     foreach ($comments as $comment) {
         $userIDs[] = $comment->objectID;
         $userIDs[] = $comment->userID;
     }
     if (!empty($userIDs)) {
         $userList = new UserProfileList();
         $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs));
         $userList->readObjects();
         $users = $userList->getObjects();
     }
     // set message
     foreach ($events as $event) {
         if (isset($responses[$event->objectID])) {
             $response = $responses[$event->objectID];
             $comment = $comments[$response->commentID];
             if (isset($users[$comment->objectID]) && isset($users[$comment->userID])) {
                 if (!$users[$comment->objectID]->isProtected()) {
                     $event->setIsAccessible();
                     // title
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', array('commentAuthor' => $users[$comment->userID], 'user' => $users[$comment->objectID]));
                     $event->setTitle($text);
                     // description
                     $event->setDescription($response->getExcerpt());
                 }
                 continue;
             }
         }
         $event->setIsOrphaned();
     }
 }
 public function prepare(array $events)
 {
     $objectIDs = array();
     foreach ($events as $event) {
         $objectIDs[] = $event->objectID;
     }
     // comments responses
     $responseList = new CommentResponseList();
     $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($objectIDs));
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     // comments
     $commentIDs = array();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     $commentList = new CommentList();
     $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
     $commentList->readObjects();
     $comments = $commentList->getObjects();
     // get news
     $newsIDs = array();
     foreach ($comments as $comment) {
         $newsIDs[] = $comment->objectID;
     }
     $list = new NewsList();
     $list->getConditionBuilder()->add("news.newsID IN (?)", array($newsIDs));
     $list->readObjects();
     $newss = $list->getObjects();
     foreach ($events as $event) {
         if (isset($responses[$event->objectID])) {
             $response = $responses[$event->objectID];
             if (isset($comments[$response->commentID])) {
                 $comment = $comments[$response->commentID];
                 if (isset($newss[$comment->objectID])) {
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.newsCommentResponse', array('author' => new User($comment->userID), 'news' => $newss[$comment->objectID]));
                     $event->setTitle($text);
                     $event->setDescription($response->getFormattedMessage());
                     $event->setIsAccessible();
                 }
             }
         } else {
             $event->setIsOrphaned();
         }
     }
 }
 /**
  * @see	\wcf\system\user\activity\event\IUserActivityEvent::prepare()
  */
 public function prepare(array $events)
 {
     $commentsIDs = $responseIDs = $userIDs = array();
     foreach ($events as $event) {
         $responseIDs[] = $event->objectID;
     }
     $responseList = new CommentResponseList();
     $responseList->setObjectIDs($responseIDs);
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     $commentList = new CommentList();
     $commentList->setObjectIDs($commentIDs);
     $commentList->readObjects();
     $comments = $commentList->getObjects();
     foreach ($comments as $comment) {
         if (!in_array($comment->userID, $userIDs)) {
             $userIDs[] = $comment->userID;
         }
     }
     $userList = new UserList();
     $userList->setObjectIDs($userIDs);
     $userList->readObjects();
     $users = $userList->getObjects();
     foreach ($events as $event) {
         if (isset($responses[$event->objectID])) {
             $response = $responses[$event->objectID];
             $comment = $comments[$response->commentID];
             $page = PageCache::getInstance()->getPage($comment->objectID);
             if ($page !== null && isset($users[$comment->userID])) {
                 if (!$page->canRead()) {
                     continue;
                 }
                 $event->setIsAccessible();
                 $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.pageCommentResponse', array('author' => $users[$comment->userID], 'page' => $pages[$comment->objectID]));
                 $event->setTitle($text);
                 $event->setDescription($response->getFormattedMessage());
                 continue;
             }
         } else {
             $event->setIsOrphaned();
         }
     }
 }
 /**
  * @see	\wcf\system\user\activity\event\IUserActivityEvent::prepare()
  */
 public function prepare(array $events)
 {
     $responseIDs = array();
     foreach ($events as $event) {
         $responseIDs[] = $event->objectID;
     }
     // fetch responses
     $responseList = new CommentResponseList();
     $responseList->setObjectIDs($responseIDs);
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     // fetch comments
     $commentIDs = $comments = array();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     if (!empty($commentIDs)) {
         $commentList = new CommentList();
         $commentList->setObjectIDs($commentIDs);
         $commentList->readObjects();
         $comments = $commentList->getObjects();
     }
     // fetch entries
     $entryIDs = $entries = array();
     foreach ($comments as $comment) {
         $entryIDs[] = $comment->objectID;
     }
     if (!empty($entryIDs)) {
         $entryList = new EntryList();
         $entryList->setObjectIDs($entryIDs);
         $entryList->readObjects();
         $entries = $entryList->getObjects();
     }
     // fetch users
     $userIDs = $user = array();
     foreach ($comments as $comment) {
         $userIDs[] = $comment->userID;
     }
     if (!empty($userIDs)) {
         $userList = new UserList();
         $userList->setObjectIDs($userIDs);
         $userList->readObjects();
         $users = $userList->getObjects();
     }
     // set message
     foreach ($events as $event) {
         if (isset($responses[$event->objectID])) {
             $response = $responses[$event->objectID];
             $comment = $comments[$response->commentID];
             if (isset($entries[$comment->objectID]) && isset($users[$comment->userID])) {
                 $entry = $entries[$comment->objectID];
                 // check permissions
                 if (!$entry->canRead()) {
                     continue;
                 }
                 $event->setIsAccessible();
                 // title
                 $text = WCF::getLanguage()->getDynamicVariable('linklist.recentActivity.entryCommentResponse', array('commentAuthor' => $users[$comment->userID], 'entry' => $entry));
                 $event->setTitle($text);
                 // description
                 $event->setDescription($response->getExcerpt());
                 continue;
             }
         }
         $event->setIsOrphaned();
     }
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::populate()
  */
 public function populate(array $queues)
 {
     $objectIDs = array();
     foreach ($queues as $object) {
         $objectIDs[] = $object->objectID;
     }
     // fetch responses
     $responseList = new CommentResponseList();
     $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($objectIDs));
     $responseList->readObjects();
     $responses = $responseList->getObjects();
     // fetch comments
     $commentIDs = array();
     foreach ($responses as $response) {
         $commentIDs[] = $response->commentID;
     }
     if (!empty($commentIDs)) {
         $commentList = new CommentList();
         $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
         $commentList->readObjects();
         $comments = $commentList->getObjects();
     }
     foreach ($queues as $object) {
         if (isset($responses[$object->objectID])) {
             $response = $responses[$object->objectID];
             $response->setComment($comments[$response->commentID]);
             $object->setAffectedObject($response);
         } else {
             $object->setIsOrphaned();
         }
     }
 }
 /**
  * @see    \wcf\system\like\IViewableLikeProvider::prepare()
  */
 public function prepare(array $likes)
 {
     if (!WCF::getSession()->getPermission('user.news.canReadEntry')) {
         return;
     }
     $commentLikeObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.like.likeableObject', 'com.woltlab.wcf.comment');
     $commentIDs = $responseIDs = array();
     foreach ($likes as $like) {
         if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) {
             $commentIDs[] = $like->objectID;
         } else {
             $responseIDs[] = $like->objectID;
         }
     }
     // fetch response
     $userIDs = $responses = array();
     if (!empty($responseIDs)) {
         $responseList = new CommentResponseList();
         $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs));
         $responseList->readObjects();
         $responses = $responseList->getObjects();
         foreach ($responses as $response) {
             $commentIDs[] = $response->commentID;
             if ($response->userID) {
                 $userIDs[] = $response->userID;
             }
         }
     }
     // fetch comments
     $commentList = new CommentList();
     $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs));
     $commentList->readObjects();
     $comments = $commentList->getObjects();
     // fetch users
     $users = array();
     $entryIDs = array();
     foreach ($comments as $comment) {
         $entryIDs[] = $comment->objectID;
         if ($comment->userID) {
             $userIDs[] = $comment->userID;
         }
     }
     if (!empty($userIDs)) {
         $users = UserProfile::getUserProfiles(array_unique($userIDs));
     }
     $entries = array();
     if (!empty($entryIDs)) {
         $entryList = new EntryList();
         $entryList->setObjectIDs($entryIDs);
         $entryList->readObjects();
         $entries = $entryList->getObjects();
     }
     // set message
     foreach ($likes as $like) {
         if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) {
             // comment like
             if (isset($comments[$like->objectID])) {
                 $comment = $comments[$like->objectID];
                 if (isset($entries[$comment->objectID]) && $entries[$comment->objectID]->canRead()) {
                     $like->setIsAccessible();
                     // short output
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.news.comment', array('commentAuthor' => $comment->userID ? $users[$comment->userID] : null, 'entry' => $entries[$comment->objectID], 'like' => $like));
                     $like->setTitle($text);
                     // output
                     $like->setDescription($comment->getExcerpt());
                 }
             }
         } else {
             // response like
             if (isset($responses[$like->objectID])) {
                 $response = $responses[$like->objectID];
                 $comment = $comments[$response->commentID];
                 if (isset($entries[$comment->objectID]) && $entries[$comment->objectID]->canRead()) {
                     $like->setIsAccessible();
                     // short output
                     $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.news.comment.response', array('responseAuthor' => $comment->userID ? $users[$response->userID] : null, 'commentAuthor' => $comment->userID ? $users[$comment->userID] : null, 'entry' => $entries[$comment->objectID], 'like' => $like));
                     $like->setTitle($text);
                     // output
                     $like->setDescription($response->getExcerpt());
                 }
             }
         }
     }
 }