3 namespace wcf\system\user\notification\event;
5 use wcf\system\cache\runtime\CommentRuntimeCache;
6 use wcf\system\cache\runtime\ViewableArticleContentRuntimeCache;
7 use wcf\system\email\Email;
8 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
11 * User notification event for article comment responses.
13 * @author Joshua Ruesweg
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @method CommentResponseUserNotificationObject getUserNotificationObject()
20 class ArticleCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
21 ITestableUserNotificationEvent
23 use TTestableCommentResponseUserNotificationEvent;
24 use TTestableArticleCommentUserNotificationEvent;
29 protected $stackable = true;
34 protected function prepare()
36 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
42 public function getTitle(): string
44 $count = \count($this->getAuthors());
46 return $this->getLanguage()->getDynamicVariable(
47 'wcf.user.notification.articleComment.response.title.stacked',
50 'timesTriggered' => $this->notification->timesTriggered,
55 return $this->getLanguage()->get('wcf.user.notification.articleComment.response.title');
61 public function getMessage()
63 $authors = $this->getAuthors();
64 if (\count($authors) > 1) {
65 if (isset($authors[0])) {
68 $count = \count($authors);
70 return $this->getLanguage()->getDynamicVariable(
71 'wcf.user.notification.articleComment.response.message.stacked',
73 'author' => $this->author,
74 'authors' => \array_values($authors),
75 'commentID' => $this->getUserNotificationObject()->commentID,
76 'article' => ViewableArticleContentRuntimeCache::getInstance()
77 ->getObject($this->additionalData['objectID']),
79 'others' => $count - 1,
80 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
81 'responseID' => $this->getUserNotificationObject()->responseID,
86 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.message', [
87 'author' => $this->author,
88 'commentID' => $this->getUserNotificationObject()->commentID,
89 'article' => ViewableArticleContentRuntimeCache::getInstance()
90 ->getObject($this->additionalData['objectID']),
91 'responseID' => $this->getUserNotificationObject()->responseID,
98 public function getEmailMessage($notificationType = 'instant')
100 $messageID = '<com.woltlab.wcf.user.articleComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
103 'template' => 'email_notification_commentResponse',
104 'in-reply-to' => [$messageID],
105 'references' => [$messageID],
106 'application' => 'wcf',
108 'commentID' => $this->getUserNotificationObject()->commentID,
109 'article' => ViewableArticleContentRuntimeCache::getInstance()
110 ->getObject($this->additionalData['objectID']),
111 'languageVariablePrefix' => 'wcf.user.notification.articleComment.response',
112 'responseID' => $this->getUserNotificationObject()->responseID,
120 public function getLink(): string
122 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
128 public function getEventHash()
130 return \sha1($this->eventID . '-' . $this->notification->objectID);