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\IUserNotificationObject;
13 * User notification event for moderation queue comments.
15 * @author Matthias Schmidt
16 * @copyright 2001-2016 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @package WoltLabSuite\Core\System\User\Notification\Event
21 class ModerationQueueCommentUserNotificationEvent extends AbstractUserNotificationEvent {
23 * language item prefix for the notification texts
26 protected $languageItemPrefix = '';
29 * moderation queue object the notifications (indirectly) belong to
30 * @var ViewableModerationQueue
32 protected $moderationQueue = null;
37 protected $stackable = true;
42 public function checkAccess() {
43 if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) {
47 return $this->moderationQueue->canEdit();
53 public function getEmailMessage($notificationType = 'instant') {
55 'message-id' => 'com.woltlab.wcf.moderation.queue.notification/'.$this->getUserNotificationObject()->commentID,
56 'template' => 'email_notification_moderationQueueComment',
57 'application' => 'wcf',
59 '<com.woltlab.wcf.moderation.queue/'.$this->moderationQueue->queueID.'@'.Email::getHost().'>'
62 'moderationQueue' => $this->moderationQueue,
63 'languageItemPrefix' => $this->languageItemPrefix
71 public function getEventHash() {
72 return sha1($this->eventID . '-' . $this->moderationQueue->queueID);
78 public function getLink() {
79 return $this->moderationQueue->getLink() . '#comments';
85 public function getMessage() {
86 $authors = $this->getAuthors();
87 if (count($authors) > 1) {
88 if (isset($authors[0])) {
91 $count = count($authors);
93 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message.stacked', [
94 'author' => $this->author,
95 'authors' => array_values($authors),
97 'others' => $count - 1,
98 'moderationQueue' => $this->moderationQueue
102 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message', [
103 'author' => $this->author,
104 'moderationQueue' => $this->moderationQueue
111 public function getTitle() {
112 $count = count($this->getAuthors());
114 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.title.stacked', [
116 'timesTriggered' => $this->notification->timesTriggered
120 return $this->getLanguage()->get($this->languageItemPrefix.'.comment.title');
126 public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []) {
127 parent::setObject($notification, $object, $author, $additionalData);
129 // if the active user has no access, $this->moderationQueue is null
130 $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($this->userNotificationObject->objectID);
132 if ($this->moderationQueue) {
133 /** @var IModerationQueueHandler $moderationHandler */
134 $moderationHandler = ObjectTypeCache::getInstance()->getObjectType($this->moderationQueue->objectTypeID)->getProcessor();
135 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();