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\UserProfileRuntimeCache;
8 use wcf\system\comment\CommentHandler;
9 use wcf\system\user\notification\object\CommentUserNotificationObject;
12 * User notification event for page comments.
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 * @method CommentUserNotificationObject getUserNotificationObject()
21 class PageCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
22 ITestableUserNotificationEvent
24 use TTestableCommentUserNotificationEvent;
25 use TTestablePageUserNotificationEvent;
30 protected $stackable = true;
35 protected function prepare()
37 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
43 public function getTitle(): string
45 $count = \count($this->getAuthors());
47 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.title.stacked', [
49 'timesTriggered' => $this->notification->timesTriggered,
53 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.title');
59 public function getMessage()
61 $authors = $this->getAuthors();
62 if (\count($authors) > 1) {
63 if (isset($authors[0])) {
66 $count = \count($authors);
68 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.message.stacked', [
69 'author' => $this->author,
70 'authors' => \array_values($authors),
71 'commentID' => $this->getUserNotificationObject()->commentID,
72 'page' => PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID),
74 'others' => $count - 1,
75 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
79 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.message', [
80 'author' => $this->author,
81 'commentID' => $this->getUserNotificationObject()->commentID,
82 'page' => PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID),
89 public function getEmailMessage($notificationType = 'instant')
92 'message-id' => 'com.woltlab.wcf.user.pageComment.notification/' . $this->getUserNotificationObject()->commentID,
93 'template' => 'email_notification_comment',
94 'application' => 'wcf',
96 'commentID' => $this->getUserNotificationObject()->commentID,
97 'page' => PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID),
98 'languageVariablePrefix' => 'wcf.user.notification.pageComment',
106 public function getLink(): string
108 return PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID)->getLink() . '#comment' . $this->getUserNotificationObject()->commentID;
114 public function getEventHash()
116 return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
122 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
125 'objectID' => self::getTestPage()->pageID,
126 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.page'),