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 comments.
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 WoltLabSuite\Core\System\User\Notification\Event
20 class ModerationQueueCommentUserNotificationEvent extends AbstractUserNotificationEvent {
22 * language item prefix for the notification texts
25 protected $languageItemPrefix = '';
28 * moderation queue object the notifications (indirectly) belong to
29 * @var ViewableModerationQueue
31 protected $moderationQueue = null;
36 protected $stackable = true;
41 public function checkAccess() {
42 if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) {
46 return $this->moderationQueue->canEdit();
52 public function getEmailMessage($notificationType = 'instant') {
53 $authors = $this->getAuthors();
54 if (count($authors) > 1) {
55 if (isset($authors[0])) {
58 $count = count($authors);
60 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.mail.stacked', [
61 'author' => $this->author,
62 'authors' => array_values($authors),
64 'others' => $count - 1,
65 'moderationQueue' => $this->moderationQueue,
66 'notificationType' => $notificationType
70 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.mail', [
71 'comment' => $this->userNotificationObject,
72 'author' => $this->author,
73 'moderationQueue' => $this->moderationQueue,
74 'notificationType' => $notificationType
81 public function getEventHash() {
82 return sha1($this->eventID . '-' . $this->moderationQueue->queueID);
88 public function getLink() {
89 return $this->moderationQueue->getLink() . '#comments';
95 public function getMessage() {
96 $authors = $this->getAuthors();
97 if (count($authors) > 1) {
98 if (isset($authors[0])) {
101 $count = count($authors);
103 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message.stacked', [
104 'author' => $this->author,
105 'authors' => array_values($authors),
107 'others' => $count - 1,
108 'moderationQueue' => $this->moderationQueue
112 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.message', [
113 'author' => $this->author,
114 'moderationQueue' => $this->moderationQueue
121 public function getTitle() {
122 $count = count($this->getAuthors());
124 return $this->getLanguage()->getDynamicVariable($this->languageItemPrefix.'.comment.title.stacked', [
126 'timesTriggered' => $this->notification->timesTriggered
130 return $this->getLanguage()->get($this->languageItemPrefix.'.comment.title');
136 public function setObject(UserNotification $notification, IUserNotificationObject $object, UserProfile $author, array $additionalData = []) {
137 parent::setObject($notification, $object, $author, $additionalData);
139 // if the active user has no access, $this->moderationQueue is null
140 $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($this->userNotificationObject->objectID);
142 if ($this->moderationQueue) {
143 /** @var IModerationQueueHandler $moderationHandler */
144 $moderationHandler = ObjectTypeCache::getInstance()->getObjectType($this->moderationQueue->objectTypeID)->getProcessor();
145 $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();