3 namespace wcf\system\user\notification\event;
5 use wcf\data\user\UserProfile;
6 use wcf\system\cache\runtime\CommentRuntimeCache;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache;
8 use wcf\system\cache\runtime\ViewableArticleContentRuntimeCache;
9 use wcf\system\email\Email;
12 * User notification event for article comment responses.
14 * @author Joshua Ruesweg
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 class ArticleCommentResponseOwnerUserNotificationEvent extends AbstractCommentResponseUserNotificationEvent implements
20 ITestableUserNotificationEvent
22 use TTestableCommentResponseUserNotificationEvent;
23 use TTestableArticleCommentUserNotificationEvent;
28 public function getMessage()
30 $authors = $this->getAuthors();
31 if (\count($authors) > 1) {
32 if (isset($authors[0])) {
35 $count = \count($authors);
37 return $this->getLanguage()->getDynamicVariable(
38 'wcf.user.notification.articleComment.responseOwner.message.stacked',
40 'author' => $this->author,
41 'authors' => \array_values($authors),
42 'commentID' => $this->getUserNotificationObject()->commentID,
43 'article' => ViewableArticleContentRuntimeCache::getInstance()
44 ->getObject($this->additionalData['objectID']),
46 'others' => $count - 1,
47 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
48 'responseID' => $this->getUserNotificationObject()->responseID,
49 'commentAuthor' => $this->getCommentAuthorProfile(),
54 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.responseOwner.message', [
55 'author' => $this->author,
56 'commentID' => $this->getUserNotificationObject()->commentID,
57 'article' => ViewableArticleContentRuntimeCache::getInstance()
58 ->getObject($this->additionalData['objectID']),
59 'responseID' => $this->getUserNotificationObject()->responseID,
60 'commentAuthor' => $this->getCommentAuthorProfile(),
67 public function getEmailMessage($notificationType = 'instant')
69 $messageID = '<com.woltlab.wcf.user.articleComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
72 'template' => 'email_notification_commentResponseOwner',
73 'in-reply-to' => [$messageID],
74 'references' => [$messageID],
75 'application' => 'wcf',
77 'commentID' => $this->getUserNotificationObject()->commentID,
78 'article' => ViewableArticleContentRuntimeCache::getInstance()
79 ->getObject($this->additionalData['objectID']),
80 'languageVariablePrefix' => 'wcf.user.notification.articleComment.responseOwner',
81 'responseID' => $this->getUserNotificationObject()->responseID,
82 'commentAuthor' => $this->getCommentAuthorProfile(),
88 * Returns the comment authors profile.
92 private function getCommentAuthorProfile()
94 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
96 if ($comment->userID) {
97 return UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
99 return UserProfile::getGuestUserProfile($comment->username);
106 public function getLink(): string
108 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
114 protected function getTypeName(): string
116 return $this->getLanguage()->get('wcf.user.recentActivity.com.woltlab.wcf.article.recentActivityEvent');
122 protected function getObjectTitle(): string
124 return ViewableArticleContentRuntimeCache::getInstance()
125 ->getObject($this->additionalData['objectID'])->getTitle();