c329ba6115e12d3880d7b97a73c3377d7da664a7
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 namespace wcf\system\user\notification\event;
4
5 use wcf\data\moderation\queue\ViewableModerationQueue;
6 use wcf\data\object\type\ObjectTypeCache;
7 use wcf\system\moderation\queue\IModerationQueueHandler;
8 use wcf\system\request\LinkHandler;
9 use wcf\system\user\notification\object\ModerationQueueUserNotificationObject;
10 use wcf\system\WCF;
11
12 /**
13 * Notification event for new reports in the moderation queue.
14 *
15 * @author Olaf Braun
16 * @copyright 2001-2024 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @since 6.1
19 *
20 * @method ModerationQueueUserNotificationObject getUserNotificationObject()
21 */
22 final class ReportModerationQueueUserNotificationEvent extends AbstractUserNotificationEvent
23 {
24 private ViewableModerationQueue $viewableModerationQueue;
25 #[\Override]
26 public function getTitle(): string
27 {
28 return $this->getLanguage()->get('wcf.moderation.report.notification.title');
29 }
30
31 #[\Override]
32 public function getMessage()
33 {
34 return $this->getLanguage()->getDynamicVariable(
35 'wcf.moderation.report.notification.message',
36 [
37 'author' => $this->author,
38 'notification' => $this->notification,
39 'moderationQueue' => $this->getViewableModerationQueue(),
40 ]
41 );
42 }
43
44 #[\Override]
45 public function getEmailMessage($notificationType = 'instant')
46 {
47 // TODO
48 }
49
50 #[\Override]
51 public function getLink(): string
52 {
53 return LinkHandler::getInstance()->getLink('ModerationReport', [
54 'id' => $this->getUserNotificationObject()->queueID,
55 ]);
56 }
57
58 #[\Override]
59 public function getEventHash()
60 {
61 return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->queueID);
62 }
63
64 #[\Override]
65 public function checkAccess()
66 {
67 $objectType = ObjectTypeCache::getInstance()->getObjectType($this->getUserNotificationObject()->objectTypeID);
68 $processor = $objectType->getProcessor();
69 \assert($processor instanceof IModerationQueueHandler);
70
71 return $processor->isAffectedUser(
72 $this->getUserNotificationObject()->getDecoratedObject(),
73 WCF::getUser()->userID
74 );
75 }
76
77 private function getViewableModerationQueue(): ViewableModerationQueue
78 {
79 if (!isset($this->viewableModerationQueue)) {
80 $this->viewableModerationQueue = new ViewableModerationQueue(
81 $this->getUserNotificationObject()->getDecoratedObject()
82 );
83 $objectType = ObjectTypeCache::getInstance()->getObjectType(
84 $this->getUserNotificationObject()->objectTypeID
85 );
86 $processor = $objectType->getProcessor();
87 \assert($processor instanceof IModerationQueueHandler);
88
89 $processor->populate([$this->viewableModerationQueue]);
90 }
91 return $this->viewableModerationQueue;
92 }
93 }