#[\Override]
public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool
{
+ if (!$this->canViewObject($objectID, $user)) {
+ return false;
+ }
return (bool)$user->getPermission($this->permissionCanModerate);
}
use wcf\data\article\content\ArticleContentEditor;
use wcf\data\article\content\ArticleContentList;
use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\cache\runtime\ViewableArticleContentRuntimeCache;
use wcf\system\cache\runtime\ViewableCommentResponseRuntimeCache;
return true;
}
+ #[\Override]
+ public function canViewObject(int $objectID, UserProfile $user): bool
+ {
+ $articleContent = new ArticleContent($objectID);
+ if (!$articleContent->articleContentID) {
+ return false;
+ }
+ return $articleContent->getArticle()->canRead($user);
+ }
+
/**
* @inheritDoc
*/
* @param int $objectTypeID
* @param int $objectID
* @return bool
- * @deprecated 6.1
+ * @deprecated 6.1 use `canModerateObject` instead
*/
public function canModerate($objectTypeID, $objectID);
*/
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).
*
use wcf\data\moderation\queue\ModerationQueue;
use wcf\data\moderation\queue\ModerationQueueEditor;
use wcf\data\moderation\queue\ViewableModerationQueue;
+use wcf\data\user\UserProfile;
/**
* Moderation queue comment manager implementation.
return $entry->canEdit();
}
+ #[\Override]
+ public function canViewObject(int $objectID, UserProfile $user): bool
+ {
+ $entry = new ModerationQueue($objectID);
+
+ return $entry->canEdit($user->getDecoratedObject());
+ }
+
/**
* @inheritDoc
*/
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\page\Page;
use wcf\data\page\PageList;
+use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\cache\runtime\ViewableCommentResponseRuntimeCache;
use wcf\system\cache\runtime\ViewableCommentRuntimeCache;
return true;
}
+ #[\Override]
+ public function canViewObject(int $objectID, UserProfile $user): bool
+ {
+ $page = new Page($objectID);
+ if (!$page->pageID) {
+ return false;
+ }
+ return $page->isAccessible($user->getDecoratedObject());
+ }
+
+ #[\Override]
+ public function canWriteComments(int $objectID, UserProfile $user): bool
+ {
+ return $this->canViewObject($objectID, $user);
+ }
+
+
/**
* @inheritDoc
*/
use wcf\data\comment\response\CommentResponse;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\ignore\UserIgnore;
+use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\cache\runtime\UserRuntimeCache;
use wcf\system\cache\runtime\ViewableCommentResponseRuntimeCache;
return true;
}
+ #[\Override]
+ public function canViewObject(int $objectID, UserProfile $user): bool
+ {
+ $userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
+ if ($userProfile === null) {
+ return false;
+ }
+
+ /** @see UserProfile::isProtected() */
+ return !$user->getPermission('admin.general.canViewPrivateUserOptions')
+ && !$userProfile->isAccessible('canViewProfile', $user->userID)
+ && $userProfile->userID != $user->userID;
+ }
+
/**
* @inheritDoc
*/