Override `isAffectedUser` for comments
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 20 Mar 2024 09:59:23 +0000 (10:59 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 20 Mar 2024 09:59:23 +0000 (10:59 +0100)
wcfsetup/install/files/lib/system/moderation/queue/AbstractCommentCommentModerationQueueHandler.class.php

index 866cd9fa2d4aec9b4ec1e8840ebc4379818b5a9f..edd4f3aadb36b56e60b469733feb8a354131018d 100644 (file)
@@ -9,6 +9,7 @@ use wcf\data\moderation\queue\ModerationQueue;
 use wcf\data\moderation\queue\ViewableModerationQueue;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\system\cache\runtime\CommentRuntimeCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\comment\manager\ICommentManager;
 use wcf\system\WCF;
 
@@ -167,4 +168,22 @@ class AbstractCommentCommentModerationQueueHandler extends AbstractModerationQue
 
         return WCF::getTPL()->fetch('moderationComment');
     }
+
+    #[\Override]
+    public function isAffectedUser(ModerationQueue $queue, $userID)
+    {
+        if (!parent::isAffectedUser($queue, $userID)) {
+            return false;
+        }
+        $comment = $this->getComment($queue->objectID);
+        if ($comment === null) {
+            return false;
+        }
+
+        return $this->getCommentManager($comment)->canModerate(
+            $comment->objectTypeID,
+            $comment->objectID,
+            UserProfileRuntimeCache::getInstance()->getObject($userID)
+        );
+    }
 }