3 namespace wcf\system\user\notification\event;
5 use wcf\data\page\PageCache;
6 use wcf\data\user\UserProfile;
7 use wcf\system\cache\runtime\CommentRuntimeCache;
8 use wcf\system\comment\CommentHandler;
9 use wcf\system\email\Email;
10 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
13 * User notification event for page comments.
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 PageCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
23 ITestableUserNotificationEvent
25 use TTestableCommentResponseUserNotificationEvent;
26 use TTestablePageUserNotificationEvent;
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.pageComment.responseOwner.title.stacked',
52 'timesTriggered' => $this->notification->timesTriggered,
57 return $this->getLanguage()->get('wcf.user.notification.pageComment.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.pageComment.responseOwner.message.stacked',
75 'author' => $this->author,
76 'authors' => \array_values($authors),
77 'commentID' => $this->getUserNotificationObject()->commentID,
78 'page' => PageCache::getInstance()->getPage($this->additionalData['objectID']),
80 'others' => $count - 1,
81 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
86 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.responseOwner.message', [
87 'author' => $this->author,
88 'commentID' => $this->getUserNotificationObject()->commentID,
89 'page' => PageCache::getInstance()->getPage($this->additionalData['objectID']),
90 'responseID' => $this->getUserNotificationObject()->responseID,
97 public function getEmailMessage($notificationType = 'instant')
99 $messageID = '<com.woltlab.wcf.user.pageComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
102 'template' => 'email_notification_commentResponseOwner',
103 'in-reply-to' => [$messageID],
104 'references' => [$messageID],
105 'application' => 'wcf',
107 'commentID' => $this->getUserNotificationObject()->commentID,
108 'page' => PageCache::getInstance()->getPage($this->additionalData['objectID']),
109 'languageVariablePrefix' => 'wcf.user.notification.pageComment.responseOwner',
110 'responseID' => $this->getUserNotificationObject()->responseID,
118 public function getLink(): string
120 return PageCache::getInstance()->getPage($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID;
126 public function getEventHash()
128 return \sha1($this->eventID . '-' . $this->notification->objectID);
134 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
137 'objectID' => self::getTestPage()->pageID,
138 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.page'),