/** * @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(); } }