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;
10 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
13 * User notification event for article comment responses.
15 * @author Joshua Ruesweg
16 * @copyright 2001-2019 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
20 * @method CommentResponseUserNotificationObject getUserNotificationObject()
22 class ArticleCommentResponseOwnerUserNotificationEvent extends AbstractCommentResponseUserNotificationEvent implements
23 ITestableUserNotificationEvent
25 use TTestableCommentResponseUserNotificationEvent;
26 use TTestableArticleCommentUserNotificationEvent;
31 protected function prepare()
33 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
39 public function getMessage()
41 $authors = $this->getAuthors();
42 if (\count($authors) > 1) {
43 if (isset($authors[0])) {
46 $count = \count($authors);
48 return $this->getLanguage()->getDynamicVariable(
49 'wcf.user.notification.articleComment.responseOwner.message.stacked',
51 'author' => $this->author,
52 'authors' => \array_values($authors),
53 'commentID' => $this->getUserNotificationObject()->commentID,
54 'article' => ViewableArticleContentRuntimeCache::getInstance()
55 ->getObject($this->additionalData['objectID']),
57 'others' => $count - 1,
58 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
59 'responseID' => $this->getUserNotificationObject()->responseID,
60 'commentAuthor' => $this->getCommentAuthorProfile(),
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.responseOwner.message', [
66 'author' => $this->author,
67 'commentID' => $this->getUserNotificationObject()->commentID,
68 'article' => ViewableArticleContentRuntimeCache::getInstance()
69 ->getObject($this->additionalData['objectID']),
70 'responseID' => $this->getUserNotificationObject()->responseID,
71 'commentAuthor' => $this->getCommentAuthorProfile(),
78 public function getEmailMessage($notificationType = 'instant')
80 $messageID = '<com.woltlab.wcf.user.articleComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
83 'template' => 'email_notification_commentResponseOwner',
84 'in-reply-to' => [$messageID],
85 'references' => [$messageID],
86 'application' => 'wcf',
88 'commentID' => $this->getUserNotificationObject()->commentID,
89 'article' => ViewableArticleContentRuntimeCache::getInstance()
90 ->getObject($this->additionalData['objectID']),
91 'languageVariablePrefix' => 'wcf.user.notification.articleComment.responseOwner',
92 'responseID' => $this->getUserNotificationObject()->responseID,
93 'commentAuthor' => $this->getCommentAuthorProfile(),
99 * Returns the comment authors profile.
101 * @return UserProfile
103 private function getCommentAuthorProfile()
105 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
107 if ($comment->userID) {
108 return UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
110 return UserProfile::getGuestUserProfile($comment->username);
117 public function getLink(): string
119 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
125 protected function getTypeName(): string
127 return $this->getLanguage()->get('wcf.user.recentActivity.com.woltlab.wcf.article.recentActivityEvent');
133 protected function getObjectTitle(): string
135 return ViewableArticleContentRuntimeCache::getInstance()
136 ->getObject($this->additionalData['objectID'])->getTitle();