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 AbstractSharedUserNotificationEvent implements
23 ITestableUserNotificationEvent
25 use TTestableCommentResponseUserNotificationEvent;
26 use TTestableArticleCommentUserNotificationEvent;
31 protected $stackable = true;
36 protected function prepare()
38 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
44 public function getTitle(): string
46 $count = \count($this->getAuthors());
48 return $this->getLanguage()->getDynamicVariable(
49 'wcf.user.notification.articleComment.responseOwner.title.stacked',
52 'timesTriggered' => $this->notification->timesTriggered,
57 return $this->getLanguage()->get('wcf.user.notification.articleComment.responseOwner.title');
63 public function getMessage()
65 $authors = $this->getAuthors();
66 if (\count($authors) > 1) {
67 if (isset($authors[0])) {
70 $count = \count($authors);
72 return $this->getLanguage()->getDynamicVariable(
73 'wcf.user.notification.articleComment.responseOwner.message.stacked',
75 'author' => $this->author,
76 'authors' => \array_values($authors),
77 'commentID' => $this->getUserNotificationObject()->commentID,
78 'article' => ViewableArticleContentRuntimeCache::getInstance()
79 ->getObject($this->additionalData['objectID']),
81 'others' => $count - 1,
82 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
83 'responseID' => $this->getUserNotificationObject()->responseID,
84 'commentAuthor' => $this->getCommentAuthorProfile(),
89 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.responseOwner.message', [
90 'author' => $this->author,
91 'commentID' => $this->getUserNotificationObject()->commentID,
92 'article' => ViewableArticleContentRuntimeCache::getInstance()
93 ->getObject($this->additionalData['objectID']),
94 'responseID' => $this->getUserNotificationObject()->responseID,
95 'commentAuthor' => $this->getCommentAuthorProfile(),
102 public function getEmailMessage($notificationType = 'instant')
104 $messageID = '<com.woltlab.wcf.user.articleComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
107 'template' => 'email_notification_commentResponseOwner',
108 'in-reply-to' => [$messageID],
109 'references' => [$messageID],
110 'application' => 'wcf',
112 'commentID' => $this->getUserNotificationObject()->commentID,
113 'article' => ViewableArticleContentRuntimeCache::getInstance()
114 ->getObject($this->additionalData['objectID']),
115 'languageVariablePrefix' => 'wcf.user.notification.articleComment.responseOwner',
116 'responseID' => $this->getUserNotificationObject()->responseID,
117 'commentAuthor' => $this->getCommentAuthorProfile(),
123 * Returns the comment authors profile.
125 * @return UserProfile
127 private function getCommentAuthorProfile()
129 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
131 if ($comment->userID) {
132 return UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
134 return UserProfile::getGuestUserProfile($comment->username);
141 public function getLink(): string
143 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
149 public function getEventHash()
151 return \sha1($this->eventID . '-' . $this->notification->objectID);