2 namespace wcf\system\user\notification\event;
3 use wcf\data\moderation\queue\ViewableModerationQueue;
4 use wcf\data\object\type\ObjectTypeCache;
5 use wcf\data\user\notification\UserNotification;
6 use wcf\data\user\UserProfile;
7 use wcf\system\moderation\queue\IModerationQueueHandler;
8 use wcf\system\user\notification\object\IUserNotificationObject;
12 * User notification event for moderation queue commments.
14 * @author Matthias Schmidt
15 * @copyright 2001-2016 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package com.woltlab.wcf
18 * @subpackage system.user.notification.event
19 * @category Community Framework
22 class ModerationQueueCommentUserNotificationEvent extends AbstractUserNotificationEvent {
24 * language item prefix for the notification texts
27 protected $languageItemPrefix = '';
30 * moderation queue object the notifications (indirectly) belong to
31 * @var ViewableModerationQueue
33 protected $moderationQueue = null;
38 protected $stackable = true;
43 public function checkAccess() {
44 if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) {
48 return $this->moderationQueue->canEdit();
54 public function getEmailMessage($notificationType = 'instant') {
55 $authors = $this->getAuthors();
56 if (count($authors) > 1) {
57 if (isset($authors[0])) {
60 $count = count($authors);
62 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.mail.stacked', [
63 'author' => $this->author,
64 'authors' => array_values($authors),
66 'others' => $count - 1,
67 'moderationQueue' => $this->moderationQueue,
68 'notificationType' => $notificationType
72 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.mail', [
73 'comment' => $this->userNotificationObject,
74 'author' => $this->author,
75 'moderationQueue' => $this->moderationQueue,
76 'notificationType' => $notificationType
83 public function getEventHash() {
84 return sha1($this->eventID . '-' . $this->moderationQueue->queueID);
90 public function getLink() {
91 return $this->moderationQueue->getLink() . '#comments';
97 public function getMessage() {
98 $authors = $this->getAuthors();
99 if (count($authors) > 1) {
100 if (isset($authors[0])) {
103 $count = count($authors);
105 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message.stacked', [
106 'author' => $this->author,
107 'authors' => array_values($authors),
109 'others' => $count - 1,
110 'moderationQueue' => $this->moderationQueue
114 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message', [
115 'author' => $this->author,
116 'moderationQueue' => $this->moderationQueue
123 public function getTitle() {
124 $count = count($this->getAuthors());
126 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.title.stacked', [
128 'timesTriggered' => $this->notification->timesTriggered
132 return $this->getLanguage()->get($this->languageItemPrefix.'.comment.title');
138 public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []) {
139 parent::setObject($notification, $object, $author, $additionalData);
141 // if the active user has no access, $this->moderationQueue is null
142 $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($this->userNotificationObject->objectID);
144 if ($this->moderationQueue) {
145 /** @var IModerationQueueHandler $moderationHandler */
146 $moderationHandler = ObjectTypeCache::getInstance()->getObjectType($this->moderationQueue->objectTypeID)->getProcessor();
147 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();