2 namespace wcf\system\user\notification\event;
3 use wcf\data\article\category\ArticleCategory;
4 use wcf\data\user\UserProfile;
5 use wcf\system\cache\runtime\CommentRuntimeCache;
6 use wcf\system\cache\runtime\ViewableArticleRuntimeCache;
7 use wcf\system\comment\CommentHandler;
8 use wcf\system\email\Email;
9 use wcf\system\user\notification\object\CommentUserNotificationObject;
12 * User notification event for article comment responses.
14 * @author Joshua Ruesweg
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\User\Notification\Event
20 * @method CommentUserNotificationObject getUserNotificationObject()
22 class ArticleCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
23 use TTestableCommentResponseUserNotificationEvent;
24 use TTestableArticleUserNotificationEvent;
25 use TTestableCategorizedUserNotificationEvent;
30 protected $stackable = true;
35 protected function prepare() {
36 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
42 public function getTitle() {
43 $count = count($this->getAuthors());
45 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.title.stacked', [
47 'timesTriggered' => $this->notification->timesTriggered
51 return $this->getLanguage()->get('wcf.user.notification.articleComment.response.title');
57 public function getMessage() {
58 $authors = $this->getAuthors();
59 if (count($authors) > 1) {
60 if (isset($authors[0])) {
63 $count = count($authors);
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.message.stacked', [
66 'author' => $this->author,
67 'authors' => array_values($authors),
68 'commentID' => $this->getUserNotificationObject()->commentID,
69 'article' => ViewableArticleRuntimeCache::getInstance()->getObject($this->additionalData['objectID']),
71 'others' => $count - 1,
72 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
73 'responseID' => $this->getUserNotificationObject()->responseID
77 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.message', [
78 'author' => $this->author,
79 'commentID' => $this->getUserNotificationObject()->commentID,
80 'article' => ViewableArticleRuntimeCache::getInstance()->getObject($this->additionalData['objectID']),
81 'responseID' => $this->getUserNotificationObject()->responseID
88 public function getEmailMessage($notificationType = 'instant') {
89 $messageID = '<com.woltlab.wcf.user.articleComment.notification/'.$this->getUserNotificationObject()->commentID.'@'.Email::getHost().'>';
92 'template' => 'email_notification_commentResponse',
93 'in-reply-to' => [$messageID],
94 'references' => [$messageID],
95 'application' => 'wcf',
97 'commentID' => $this->getUserNotificationObject()->commentID,
98 'article' => ViewableArticleRuntimeCache::getInstance()->getObject($this->additionalData['objectID']),
99 'languageVariablePrefix' => 'wcf.user.notification.articleComment.response',
100 'responseID' => $this->getUserNotificationObject()->responseID
108 public function getLink() {
109 return ViewableArticleRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment'. $this->getUserNotificationObject()->commentID;
115 public function getEventHash() {
116 return sha1($this->eventID . '-' . $this->notification->objectID);
122 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
124 'objectID' => self::getTestArticle(self::createTestCategory(ArticleCategory::OBJECT_TYPE_NAME), $author)->articleID,
125 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.articleComment')