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\email\Email;
8 use wcf\system\moderation\queue\IModerationQueueHandler;
9 use wcf\system\user\notification\object\CommentUserNotificationObject;
10 use wcf\system\user\notification\object\IUserNotificationObject;
14 * User notification event for moderation queue comments.
16 * @author Matthias Schmidt
17 * @copyright 2001-2016 WoltLab GmbH
18 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @package WoltLabSuite\Core\System\User\Notification\Event
22 * @method CommentUserNotificationObject getUserNotificationObject()
24 class ModerationQueueCommentUserNotificationEvent extends AbstractUserNotificationEvent {
26 * language item prefix for the notification texts
29 protected $languageItemPrefix = '';
32 * moderation queue object the notifications (indirectly) belong to
33 * @var ViewableModerationQueue
35 protected $moderationQueue = null;
40 protected $stackable = true;
45 public function checkAccess() {
46 if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) {
50 return $this->moderationQueue->canEdit();
56 public function getEmailMessage($notificationType = 'instant') {
58 'message-id' => 'com.woltlab.wcf.moderation.queue.notification/'.$this->getUserNotificationObject()->commentID,
59 'template' => 'email_notification_moderationQueueComment',
60 'application' => 'wcf',
62 '<com.woltlab.wcf.moderation.queue/'.$this->moderationQueue->queueID.'@'.Email::getHost().'>'
65 'moderationQueue' => $this->moderationQueue,
66 'languageItemPrefix' => $this->languageItemPrefix
74 public function getEventHash() {
75 return sha1($this->eventID . '-' . $this->moderationQueue->queueID);
81 public function getLink() {
82 return $this->moderationQueue->getLink() . '#comments';
88 public function getMessage() {
89 $authors = $this->getAuthors();
90 if (count($authors) > 1) {
91 if (isset($authors[0])) {
94 $count = count($authors);
96 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message.stacked', [
97 'author' => $this->author,
98 'authors' => array_values($authors),
100 'others' => $count - 1,
101 'moderationQueue' => $this->moderationQueue
105 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message', [
106 'author' => $this->author,
107 'moderationQueue' => $this->moderationQueue
114 public function getTitle() {
115 $count = count($this->getAuthors());
117 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.title.stacked', [
119 'timesTriggered' => $this->notification->timesTriggered
123 return $this->getLanguage()->get($this->languageItemPrefix.'.comment.title');
129 public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []) {
130 parent::setObject($notification, $object, $author, $additionalData);
132 // if the active user has no access, $this->moderationQueue is null
133 $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($this->getUserNotificationObject()->objectID);
135 if ($this->moderationQueue) {
136 /** @var IModerationQueueHandler $moderationHandler */
137 $moderationHandler = ObjectTypeCache::getInstance()->getObjectType($this->moderationQueue->objectTypeID)->getProcessor();
138 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();