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\ViewableArticleRuntimeCache;
6 use wcf\system\comment\CommentHandler;
7 use wcf\system\user\notification\object\CommentUserNotificationObject;
10 * User notification event for article 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 ArticleCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentUserNotificationEvent;
22 use TTestableArticleUserNotificationEvent;
23 use TTestableCategorizedUserNotificationEvent;
28 protected $stackable = true;
33 protected function prepare() {
34 ViewableArticleRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
40 public function getTitle() {
41 $count = count($this->getAuthors());
43 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.title.stacked', [
45 'timesTriggered' => $this->notification->timesTriggered
49 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.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.articleComment.message.stacked', [
64 'author' => $this->author,
65 'authors' => array_values($authors),
66 'commentID' => $this->getUserNotificationObject()->commentID,
67 'article' => ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID),
69 'others' => $count - 1,
70 'guestTimesTriggered' => $this->notification->guestTimesTriggered
74 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.message', [
75 'author' => $this->author,
76 'commentID' => $this->getUserNotificationObject()->commentID,
77 'article' => ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)
84 public function getEmailMessage($notificationType = 'instant') {
86 'message-id' => 'com.woltlab.wcf.user.articleComment.notification/'.$this->getUserNotificationObject()->commentID,
87 'template' => 'email_notification_comment',
88 'application' => 'wcf',
90 'commentID' => $this->getUserNotificationObject()->commentID,
91 'article' => ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID),
92 'languageVariablePrefix' => 'wcf.user.notification.articleComment'
100 public function getLink() {
101 return ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)->getLink() . '#comment'. $this->getUserNotificationObject()->commentID;
107 public function getEventHash() {
108 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
114 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
116 'objectID' => self::getTestArticle(self::createTestCategory(ArticleCategory::OBJECT_TYPE_NAME), $author)->articleID,
117 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.articleComment')