Add notification message for reported content
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 20 Mar 2024 12:20:20 +0000 (13:20 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 20 Mar 2024 12:20:20 +0000 (13:20 +0100)
wcfsetup/install/files/lib/system/user/notification/event/ReportModerationQueueUserNotificationEvent.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 32199a0ea6edd59e5f6eed30450904aa0cb98b8d..c329ba6115e12d3880d7b97a73c3377d7da664a7 100644 (file)
@@ -2,8 +2,12 @@
 
 namespace wcf\system\user\notification\event;
 
+use wcf\data\moderation\queue\ViewableModerationQueue;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\moderation\queue\IModerationQueueHandler;
 use wcf\system\request\LinkHandler;
 use wcf\system\user\notification\object\ModerationQueueUserNotificationObject;
+use wcf\system\WCF;
 
 /**
  * Notification event for new reports in the moderation queue.
@@ -17,6 +21,7 @@ use wcf\system\user\notification\object\ModerationQueueUserNotificationObject;
  */
 final class ReportModerationQueueUserNotificationEvent extends AbstractUserNotificationEvent
 {
+    private ViewableModerationQueue $viewableModerationQueue;
     #[\Override]
     public function getTitle(): string
     {
@@ -31,7 +36,7 @@ final class ReportModerationQueueUserNotificationEvent extends AbstractUserNotif
             [
                 'author' => $this->author,
                 'notification' => $this->notification,
-                'userNotificationObject' => $this->getUserNotificationObject(),
+                'moderationQueue' => $this->getViewableModerationQueue(),
             ]
         );
     }
@@ -55,4 +60,34 @@ final class ReportModerationQueueUserNotificationEvent extends AbstractUserNotif
     {
         return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->queueID);
     }
+
+    #[\Override]
+    public function checkAccess()
+    {
+        $objectType = ObjectTypeCache::getInstance()->getObjectType($this->getUserNotificationObject()->objectTypeID);
+        $processor = $objectType->getProcessor();
+        \assert($processor instanceof IModerationQueueHandler);
+
+        return $processor->isAffectedUser(
+            $this->getUserNotificationObject()->getDecoratedObject(),
+            WCF::getUser()->userID
+        );
+    }
+
+    private function getViewableModerationQueue(): ViewableModerationQueue
+    {
+        if (!isset($this->viewableModerationQueue)) {
+            $this->viewableModerationQueue = new ViewableModerationQueue(
+                $this->getUserNotificationObject()->getDecoratedObject()
+            );
+            $objectType = ObjectTypeCache::getInstance()->getObjectType(
+                $this->getUserNotificationObject()->objectTypeID
+            );
+            $processor = $objectType->getProcessor();
+            \assert($processor instanceof IModerationQueueHandler);
+
+            $processor->populate([$this->viewableModerationQueue]);
+        }
+        return $this->viewableModerationQueue;
+    }
 }
index d01eecd5a0b494b9cc81e420110fddb30a927609..74a2ce90607239c2d3237f9f3dc158d82a75123d 100644 (file)
@@ -4390,6 +4390,7 @@ Dateianhänge:
                <item name="wcf.moderation.report.changeJustifiedStatus.markAsJustified"><![CDATA[Meldung als „Berechtigt“ markieren]]></item>
                <item name="wcf.moderation.report.changeJustifiedStatus.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den „Berechtigt“-Status dieser Meldung wirklich ändern?]]></item>
                <item name="wcf.moderation.report.notification.title"><![CDATA[Neue Meldung]]></item>
+               <item name="wcf.moderation.report.notification.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}Ein Gast{/if} hat <strong>{$moderationQueue->getTitle()}</strong>({lang}wcf.moderation.type.{@$moderationQueue->getObjectTypeName()}{/lang}) gemeldet.]]></item>
        </category>
        <category name="wcf.notice">
                <item name="wcf.notice.button.dismiss"><![CDATA[Hinweis dauerhaft ausblenden]]></item>
index e57444e47e9e7ca321b7e564050e34ef0401f541..888a9a1840cc7eb1be44a1040daddb5e892bb07c 100644 (file)
@@ -4342,6 +4342,7 @@ Attachments:
                <item name="wcf.moderation.report.changeJustifiedStatus.markAsJustified"><![CDATA[Mark report as “Justified”]]></item>
                <item name="wcf.moderation.report.changeJustifiedStatus.confirmMessage"><![CDATA[Do you really want to change the “Justified” status of this report?]]></item>
                <item name="wcf.moderation.report.notification.title"><![CDATA[New report]]></item>
+               <item name="wcf.moderation.report.notification.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}A guest{/if} has reported <strong>{$moderationQueue->getTitle()}</strong>({lang}wcf.moderation.type.{@$moderationQueue->getObjectTypeName()}{/lang}).]]></item>
        </category>
        <category name="wcf.notice">
                <item name="wcf.notice.button.dismiss"><![CDATA[Permanently dismiss this notice]]></item>