3 namespace wcf\system\user\activity\event
;
5 use wcf\data\article\ViewableArticleList
;
6 use wcf\data\comment\CommentList
;
7 use wcf\system\SingletonFactory
;
11 * User activity event implementation for article comments.
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\User\Activity\Event
19 class ArticleCommentUserActivityEvent
extends SingletonFactory
implements IUserActivityEvent
24 public function prepare(array $events)
27 foreach ($events as $event) {
28 $commentIDs[] = $event->objectID
;
32 $commentList = new CommentList();
33 $commentList->setObjectIDs($commentIDs);
34 $commentList->readObjects();
35 $comments = $commentList->getObjects();
38 $articleContentIDs = [];
39 foreach ($comments as $comment) {
40 $articleContentIDs[] = $comment->objectID
;
43 $articles = $articleContentToArticle = [];
44 if (!empty($articleContentIDs)) {
45 $articleList = new ViewableArticleList();
46 $articleList->getConditionBuilder()->add(
47 "article.articleID IN (SELECT articleID FROM wcf" . WCF_N
. "_article_content WHERE articleContentID IN (?))",
50 $articleList->readObjects();
51 foreach ($articleList as $article) {
52 $articles[$article->articleID
] = $article;
54 $articleContentToArticle[$article->getArticleContent()->articleContentID
] = $article->articleID
;
59 foreach ($events as $event) {
60 if (isset($comments[$event->objectID
])) {
62 $comment = $comments[$event->objectID
];
63 if (isset($articleContentToArticle[$comment->objectID
])) {
64 $article = $articles[$articleContentToArticle[$comment->objectID
]];
67 if (!$article->canRead()) {
70 $event->setIsAccessible();
73 $text = WCF
::getLanguage()->getDynamicVariable('wcf.article.recentActivity.articleComment', [
74 'article' => $article,
75 'commentID' => $comment->commentID
,
77 $event->setTitle($text);
80 $event->setDescription($comment->getExcerpt());
85 $event->setIsOrphaned();