From: Cyperghost Date: Thu, 21 Mar 2024 09:28:56 +0000 (+0100) Subject: Add new function `canModerateObject`to `ICommentManager` X-Git-Tag: 6.1.0_Alpha_1~142^2~20 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=57a527750b1bc59d24cb64aa00fbf78e7714d4f4;p=GitHub%2FWoltLab%2FWCF.git Add new function `canModerateObject`to `ICommentManager` --- 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..b2fb5fd579 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; @@ -160,6 +161,12 @@ abstract class AbstractCommentManager extends SingletonFactory implements IComme return WCF::getSession()->getPermission($this->permissionCanModerate) ? true : false; } + #[\Override] + public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool + { + return (bool)$user->getPermission($this->permissionCanModerate); + } + /** * Returns true if the current user may edit a comment/response. * 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..5500208cd3 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. @@ -68,9 +69,16 @@ interface ICommentManager * @param int $objectTypeID * @param int $objectID * @return bool + * @deprecated 6.1 */ public function canModerate($objectTypeID, $objectID); + /** + * Returns true if the user may moderate content identified by + * object type id and object id. + */ + public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool; + /** * Returns the amount of comments per page. *