From: Cyperghost Date: Wed, 20 Mar 2024 09:56:14 +0000 (+0100) Subject: Add a user parameter to check whether the user is allowed to moderate this comment. X-Git-Tag: 6.1.0_Alpha_1~142^2~37 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8005d38adb57834864e7c7736193568d80d83813;p=GitHub%2FWoltLab%2FWCF.git Add a user parameter to check whether the user is allowed to moderate this comment. --- diff --git a/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php index 33c2ac4466..7a1a8d0163 100644 --- a/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php +++ b/wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php @@ -5,6 +5,7 @@ namespace wcf\system\comment\manager; use wcf\data\comment\Comment; use wcf\data\comment\response\CommentResponse; use wcf\data\DatabaseObjectDecorator; +use wcf\data\user\UserProfile; use wcf\system\bbcode\BBCodeHandler; use wcf\system\SingletonFactory; use wcf\system\WCF; @@ -153,10 +154,14 @@ abstract class AbstractCommentManager extends SingletonFactory implements IComme } /** + * @param UserProfile|null $user * @inheritDoc */ - public function canModerate($objectTypeID, $objectID) + public function canModerate($objectTypeID, $objectID, ?UserProfile $user = null) { + if ($user !== null) { + return $user->getPermission($this->permissionCanModerate) ? true : false; + } return WCF::getSession()->getPermission($this->permissionCanModerate) ? true : false; } diff --git a/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php index 90bb0602d2..91b502e11c 100644 --- a/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php +++ b/wcfsetup/install/files/lib/system/comment/manager/ICommentManager.class.php @@ -4,6 +4,7 @@ namespace wcf\system\comment\manager; use wcf\data\comment\Comment; use wcf\data\comment\response\CommentResponse; +use wcf\data\user\UserProfile; /** * Default interface for comment managers. @@ -62,14 +63,15 @@ interface ICommentManager public function canDeleteResponse(CommentResponse $response); /** - * Returns true if the current user may moderated content identified by + * Returns true if the current or given user may moderated content identified by * object type id and object id. * * @param int $objectTypeID * @param int $objectID + * @param UserProfile|null $user * @return bool */ - public function canModerate($objectTypeID, $objectID); + public function canModerate($objectTypeID, $objectID, ?UserProfile $user = null); /** * Returns the amount of comments per page.