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\CommentRuntimeCache;
6 use wcf\system\comment\CommentHandler;
7 use wcf\system\email\Email;
8 use wcf\system\user\notification\object\CommentUserNotificationObject;
11 * User notification event for page comments.
13 * @author Joshua Rusweg
14 * @copyright 2001-2018 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\User\Notification\Event
19 * @method CommentUserNotificationObject getUserNotificationObject()
21 class PageCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
22 use TTestableCommentResponseUserNotificationEvent;
23 use TTestablePageUserNotificationEvent;
28 protected $stackable = true;
33 protected function prepare() {
34 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
40 public function getTitle() {
41 $count = count($this->getAuthors());
43 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.responseOwner.title.stacked', [
45 'timesTriggered' => $this->notification->timesTriggered
49 return $this->getLanguage()->get('wcf.user.notification.pageComment.responseOwner.title');
55 public function getMessage() {
56 $authors = $this->getAuthors();
57 if (count($authors) > 1) {
58 if (isset($authors[0])) {
61 $count = count($authors);
63 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.responseOwner.message.stacked', [
64 'author' => $this->author,
65 'authors' => array_values($authors),
66 'commentID' => $this->getUserNotificationObject()->commentID,
67 'page' => PageCache::getInstance()->getPage($this->additionalData['objectID']),
69 'others' => $count - 1,
70 'guestTimesTriggered' => $this->notification->guestTimesTriggered
74 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.pageComment.responseOwner.message', [
75 'author' => $this->author,
76 'commentID' => $this->getUserNotificationObject()->commentID,
77 'page' => PageCache::getInstance()->getPage($this->additionalData['objectID']),
78 'responseID' => $this->getUserNotificationObject()->responseID
85 public function getEmailMessage($notificationType = 'instant') {
86 $messageID = '<com.woltlab.wcf.user.pageComment.notification/'.$this->getUserNotificationObject()->commentID.'@'.Email::getHost().'>';
89 'template' => 'email_notification_commentResponseOwner',
90 'in-reply-to' => [$messageID],
91 'references' => [$messageID],
92 'application' => 'wcf',
94 'commentID' => $this->getUserNotificationObject()->commentID,
95 'page' => PageCache::getInstance()->getPage($this->additionalData['objectID']),
96 'languageVariablePrefix' => 'wcf.user.notification.pageComment.responseOwner',
97 'responseID' => $this->getUserNotificationObject()->responseID
105 public function getLink() {
106 return PageCache::getInstance()->getPage($this->additionalData['objectID'])->getLink() . '#comment'. $this->getUserNotificationObject()->commentID;
112 public function getEventHash() {
113 return sha1($this->eventID . '-' . $this->notification->objectID);
119 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
121 'objectID' => self::getTestPage()->pageID,
122 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.page')