3 namespace wcf\system\user\notification\event;
5 use wcf\data\moderation\queue\ViewableModerationQueue;
6 use wcf\data\object\type\ObjectTypeCache;
7 use wcf\data\user\notification\UserNotification;
8 use wcf\data\user\UserProfile;
9 use wcf\system\comment\CommentHandler;
10 use wcf\system\email\Email;
11 use wcf\system\moderation\queue\IModerationQueueHandler;
12 use wcf\system\user\notification\object\CommentUserNotificationObject;
13 use wcf\system\user\notification\object\IUserNotificationObject;
17 * User notification event for moderation queue comments.
19 * @author Matthias Schmidt
20 * @copyright 2001-2019 WoltLab GmbH
21 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
24 * @method CommentUserNotificationObject getUserNotificationObject()
26 class ModerationQueueCommentUserNotificationEvent extends AbstractUserNotificationEvent implements
27 ITestableUserNotificationEvent
29 use TTestableCommentUserNotificationEvent;
30 use TTestableModerationQueueUserNotificationEvent;
33 * language item prefix for the notification texts
36 protected $languageItemPrefix = '';
39 * moderation queue object the notifications (indirectly) belong to
40 * @var ViewableModerationQueue
42 protected $moderationQueue;
47 protected $stackable = true;
52 public function checkAccess()
54 if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) {
58 return $this->moderationQueue->canEdit();
64 public function getEmailMessage($notificationType = 'instant')
67 'message-id' => 'com.woltlab.wcf.moderation.queue.notification/' . $this->getUserNotificationObject()->commentID,
68 'template' => 'email_notification_moderationQueueComment',
69 'application' => 'wcf',
71 '<com.woltlab.wcf.moderation.queue/' . $this->moderationQueue->queueID . '@' . Email::getHost() . '>',
74 'moderationQueue' => $this->moderationQueue,
75 'languageItemPrefix' => $this->languageItemPrefix,
83 public function getEventHash()
85 return \sha1($this->eventID . '-' . $this->moderationQueue->queueID);
91 public function getLink(): string
93 return $this->moderationQueue->getLink() . '#comments';
99 public function getMessage()
101 $authors = $this->getAuthors();
102 if (\count($authors) > 1) {
103 if (isset($authors[0])) {
106 $count = \count($authors);
108 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix . '.comment.message.stacked', [
109 'author' => $this->author,
110 'authors' => \array_values($authors),
112 'others' => $count - 1,
113 'moderationQueue' => $this->moderationQueue,
117 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix . '.comment.message', [
118 'author' => $this->author,
119 'commentID' => $this->getUserNotificationObject()->commentID,
120 'moderationQueue' => $this->moderationQueue,
127 public function getTitle(): string
129 $count = \count($this->getAuthors());
131 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix . '.comment.title.stacked', [
133 'timesTriggered' => $this->notification->timesTriggered,
137 return $this->getLanguage()->get($this->languageItemPrefix . '.comment.title');
143 public function setObject(
144 UserNotification $notification,
145 IUserNotificationObject $object,
147 array $additionalData = []
149 parent::setObject($notification, $object, $author, $additionalData);
151 // if the active user has no access, $this->moderationQueue is null
152 $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue(
153 $this->getUserNotificationObject()->objectID
156 if ($this->moderationQueue) {
157 /** @var IModerationQueueHandler $moderationHandler */
158 $moderationHandler = ObjectTypeCache::getInstance()
159 ->getObjectType($this->moderationQueue->objectTypeID)
161 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();
169 public static function canBeTriggeredByGuests()
178 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
181 'objectID' => self::getTestUserModerationQueueEntry($author, $recipient)->queueID,
182 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue'),