3 namespace wcf\system\user\notification\event;
5 use wcf\data\moderation\queue\ModerationQueue;
6 use wcf\data\moderation\queue\ViewableModerationQueue;
7 use wcf\data\object\type\ObjectTypeCache;
8 use wcf\data\user\notification\UserNotification;
9 use wcf\data\user\UserProfile;
10 use wcf\system\comment\CommentHandler;
11 use wcf\system\email\Email;
12 use wcf\system\moderation\queue\IModerationQueueHandler;
13 use wcf\system\user\notification\object\CommentUserNotificationObject;
14 use wcf\system\user\notification\object\IUserNotificationObject;
18 * User notification event for moderation queue comments.
20 * @author Matthias Schmidt
21 * @copyright 2001-2019 WoltLab GmbH
22 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
25 * @method CommentUserNotificationObject getUserNotificationObject()
27 class ModerationQueueCommentUserNotificationEvent extends AbstractCommentUserNotificationEvent implements
28 ITestableUserNotificationEvent
30 use TTestableCommentUserNotificationEvent;
31 use TTestableModerationQueueUserNotificationEvent;
34 * language item prefix for the notification texts
37 protected $languageItemPrefix = '';
40 * language item for the type name
42 protected string $typeName;
45 * moderation queue object the notifications (indirectly) belong to
46 * @var ViewableModerationQueue
48 protected $moderationQueue;
53 public function checkAccess()
55 if (!WCF::getSession()->getPermission('mod.general.canUseModeration')) {
59 return $this->moderationQueue->canEdit();
65 public function getEmailMessage($notificationType = 'instant')
68 'message-id' => 'com.woltlab.wcf.moderation.queue.notification/' . $this->getUserNotificationObject()->commentID,
69 'template' => 'email_notification_moderationQueueComment',
70 'application' => 'wcf',
72 '<com.woltlab.wcf.moderation.queue/' . $this->moderationQueue->queueID . '@' . Email::getHost() . '>',
75 'moderationQueue' => $this->moderationQueue,
76 'languageItemPrefix' => $this->languageItemPrefix,
84 public function getEventHash()
86 return \sha1($this->eventID . '-' . $this->moderationQueue->queueID);
92 public function getLink(): string
94 return $this->moderationQueue->getLink() . '#comments';
100 public function getMessage()
102 $authors = $this->getAuthors();
103 if (\count($authors) > 1) {
104 if (isset($authors[0])) {
107 $count = \count($authors);
109 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix . '.comment.message.stacked', [
110 'author' => $this->author,
111 'authors' => \array_values($authors),
113 'others' => $count - 1,
114 'moderationQueue' => $this->moderationQueue,
118 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix . '.comment.message', [
119 'author' => $this->author,
120 'commentID' => $this->getUserNotificationObject()->commentID,
121 'moderationQueue' => $this->moderationQueue,
128 protected function prepare()
135 public function setObject(
136 UserNotification $notification,
137 IUserNotificationObject $object,
139 array $additionalData = []
141 parent::setObject($notification, $object, $author, $additionalData);
143 $this->moderationQueue = new ViewableModerationQueue(
144 new ModerationQueue($this->getUserNotificationObject()->objectID)
147 /** @var IModerationQueueHandler $moderationHandler */
148 $moderationHandler = ObjectTypeCache::getInstance()
149 ->getObjectType($this->moderationQueue->objectTypeID)
151 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();
152 $this->typeName = $this->getLanguage()->get($moderationHandler->getCommentNotificationTypeNameLanguageItem());
159 public static function canBeTriggeredByGuests()
168 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
171 'objectID' => self::getTestUserModerationQueueEntry($author, $recipient)->queueID,
172 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue'),
179 protected function getTypeName(): string
181 return $this->typeName;
187 protected function getObjectTitle(): string
189 return $this->moderationQueue->getTitle();