3 namespace wcf\system\user\activity\event;
5 use wcf\data\article\ViewableArticleList;
6 use wcf\system\SingletonFactory;
10 * User activity event implementation for responses to article comments.
13 * @copyright 2001-2020 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\User\Activity\Event
18 class ArticleCommentResponseUserActivityEvent extends SingletonFactory implements IUserActivityEvent
20 use TCommentResponseUserActivityEvent;
25 public function prepare(array $events)
27 $this->readResponseData($events);
30 $articles = $articleContentToArticle = [];
31 if (!empty($this->commentObjectIDs)) {
32 $articleList = new ViewableArticleList();
33 $articleList->getConditionBuilder()->add(
34 "article.articleID IN (SELECT articleID FROM wcf" . WCF_N . "_article_content WHERE articleContentID IN (?))",
35 [$this->commentObjectIDs]
37 $articleList->readObjects();
38 foreach ($articleList as $article) {
39 $articles[$article->articleID] = $article;
41 $articleContentToArticle[$article->getArticleContent()->articleContentID] = $article->articleID;
46 foreach ($events as $event) {
47 if (isset($this->responses[$event->objectID])) {
48 $response = $this->responses[$event->objectID];
49 $comment = $this->comments[$response->commentID];
51 isset($articleContentToArticle[$comment->objectID])
52 && isset($this->commentAuthors[$comment->userID])
54 $article = $articles[$articleContentToArticle[$comment->objectID]];
57 if (!$article->canRead()) {
60 $event->setIsAccessible();
63 $text = WCF::getLanguage()->getDynamicVariable(
64 'wcf.article.recentActivity.articleCommentResponse',
66 'commentAuthor' => $this->commentAuthors[$comment->userID],
67 'commentID' => $comment->commentID,
68 'responseID' => $response->responseID,
69 'article' => $article,
72 $event->setTitle($text);
75 $event->setDescription($response->getExcerpt());
80 $event->setIsOrphaned();