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 'notificationType' => $notificationType,
64 'languageItemPrefix' => $this->languageItemPrefix
72 public function getEventHash() {
73 return sha1($this->eventID . '-' . $this->moderationQueue->queueID);
79 public function getLink() {
80 return $this->moderationQueue->getLink() . '#comments';
86 public function getMessage() {
87 $authors = $this->getAuthors();
88 if (count($authors) > 1) {
89 if (isset($authors[0])) {
92 $count = count($authors);
94 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message.stacked', [
95 'author' => $this->author,
96 'authors' => array_values($authors),
98 'others' => $count - 1,
99 'moderationQueue' => $this->moderationQueue
103 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message', [
104 'author' => $this->author,
105 'moderationQueue' => $this->moderationQueue
112 public function getTitle() {
113 $count = count($this->getAuthors());
115 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.title.stacked', [
117 'timesTriggered' => $this->notification->timesTriggered
121 return $this->getLanguage()->get($this->languageItemPrefix.'.comment.title');
127 public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []) {
128 parent::setObject($notification, $object, $author, $additionalData);
130 // if the active user has no access, $this->moderationQueue is null
131 $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($this->userNotificationObject->objectID);
133 if ($this->moderationQueue) {
134 /** @var IModerationQueueHandler $moderationHandler */
135 $moderationHandler = ObjectTypeCache::getInstance()->getObjectType($this->moderationQueue->objectTypeID)->getProcessor();
136 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();