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;
return WCF::getSession()->getPermission($this->permissionCanModerate) ? true : false;
}
- #[\Override]
- public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool
- {
- if (!$this->canViewObject($objectID, $user)) {
- return false;
- }
- return (bool)$user->getPermission($this->permissionCanModerate);
- }
-
/**
* Returns true if the current user may edit a comment/response.
*
use wcf\data\comment\Comment;
use wcf\data\comment\response\CommentResponse;
-use wcf\data\user\UserProfile;
/**
* Default interface for comment managers.
*/
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.
*
*/
public function isAccessible($objectID, $validateWritePermission = false);
- /**
- * Returns true if the user may read content identified by object type id and object id.
- */
- public function canViewObject(int $objectID, UserProfile $user): bool;
-
/**
* Updates total count of comments (includes responses).
*
--- /dev/null
+<?php
+
+namespace wcf\system\comment\manager;
+
+use wcf\data\user\UserProfile;
+
+/**
+ * Interface for comment managers that provide permission checks.
+ *
+ * @author Olaf Braun
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+interface ICommentPermissionManager extends ICommentManager
+{
+ /**
+ * 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 true if the user may read content identified by object type id and object id.
+ */
+ public function canViewObject(int $objectID, UserProfile $user): bool;
+}
use wcf\system\cache\runtime\CommentRuntimeCache;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\comment\manager\ICommentManager;
+use wcf\system\comment\manager\ICommentPermissionManager;
use wcf\system\WCF;
/**
if ($comment === null) {
return false;
}
+ $manager = $this->getCommentManager($comment);
+ if (!($manager instanceof ICommentPermissionManager)) {
+ return false;
+ }
- return $this->getCommentManager($comment)->canModerateObject(
+ return $manager->canModerateObject(
$comment->objectTypeID,
$comment->objectID,
UserProfileRuntimeCache::getInstance()->getObject($userID)
use wcf\system\cache\runtime\CommentResponseRuntimeCache;
use wcf\system\cache\runtime\CommentRuntimeCache;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\comment\manager\ICommentPermissionManager;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\WCF;
if ($comment === null) {
return false;
}
+ $manager = $this->getCommentManager($comment);
+ if (!($manager instanceof ICommentPermissionManager)) {
+ return false;
+ }
- return $this->getCommentManager($comment)->canModerateObject(
+ return $manager->canModerateObject(
$comment->objectTypeID,
$comment->objectID,
UserProfileRuntimeCache::getInstance()->getObject($userID)