2 namespace wcf\system\user\notification\event;
3 use wcf\data\page\PageCache;
4 use wcf\data\user\UserProfile;
5 use wcf\system\cache\runtime\UserProfileRuntimeCache;
6 use wcf\system\comment\CommentHandler;
7 use wcf\system\user\notification\object\CommentUserNotificationObject;
10 * User notification event for page comments.
12 * @author Joshua Rusweg
13 * @copyright 2001-2018 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\User\Notification\Event
18 * @method CommentUserNotificationObject getUserNotificationObject()
20 class PageCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentUserNotificationEvent;
22 use TTestablePageUserNotificationEvent;
27 protected $stackable = true;
32 protected function prepare() {
33 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
39 public function getTitle() {
40 $count = count($this->getAuthors());
42 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.title.stacked', [
44 'timesTriggered' => $this->notification->timesTriggered
48 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.title');
54 public function getMessage() {
55 $authors = $this->getAuthors();
56 if (count($authors) > 1) {
57 if (isset($authors[0])) {
60 $count = count($authors);
62 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.message.stacked', [
63 'author' => $this->author,
64 'authors' => array_values($authors),
65 'commentID' => $this->getUserNotificationObject()->commentID,
66 'page' => PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID),
68 'others' => $count - 1,
69 'guestTimesTriggered' => $this->notification->guestTimesTriggered
73 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.message', [
74 'author' => $this->author,
75 'commentID' => $this->getUserNotificationObject()->commentID,
76 'page' => PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID)
83 public function getEmailMessage($notificationType = 'instant') {
85 'message-id' => 'com.woltlab.wcf.user.pageComment.notification/'.$this->getUserNotificationObject()->commentID,
86 'template' => 'email_notification_comment',
87 'application' => 'wcf',
89 'commentID' => $this->getUserNotificationObject()->commentID,
90 'page' => PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID),
91 'languageVariablePrefix' => 'wcf.user.notification.pageComment'
99 public function getLink() {
100 return PageCache::getInstance()->getPage($this->getUserNotificationObject()->objectID)->getLink() . '#comment'. $this->getUserNotificationObject()->commentID;
106 public function getEventHash() {
107 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
113 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
115 'objectID' => self::getTestPage()->pageID,
116 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.page')