* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
-class ArticleCommentManager extends AbstractCommentManager implements IViewableLikeProvider
+class ArticleCommentManager extends AbstractCommentManager implements IViewableLikeProvider, ICommentPermissionManager
{
/**
* @inheritDoc
}
#[\Override]
- public function canViewObject(int $objectID, UserProfile $user): bool
+ public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool
{
$articleContent = new ArticleContent($objectID);
if (!$articleContent->articleContentID) {
return false;
}
- return $articleContent->getArticle()->canRead($user);
+ if (!$articleContent->getArticle()->canRead($user)) {
+ return false;
+ }
+ return (bool)$user->getPermission($this->permissionCanModerate);
}
/**
* 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;
}
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
-class ModerationQueueCommentManager extends AbstractCommentManager
+class ModerationQueueCommentManager extends AbstractCommentManager implements ICommentPermissionManager
{
/**
* @inheritDoc
}
#[\Override]
- public function canViewObject(int $objectID, UserProfile $user): bool
+ public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool
{
$entry = new ModerationQueue($objectID);
-
- return $entry->canEdit($user->getDecoratedObject());
+ return ($entry->canEdit($user->getDecoratedObject()));
}
/**
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
-class PageCommentManager extends AbstractCommentManager implements IViewableLikeProvider
+class PageCommentManager extends AbstractCommentManager implements IViewableLikeProvider, ICommentPermissionManager
{
/**
* @inheritDoc
}
#[\Override]
- public function canViewObject(int $objectID, UserProfile $user): bool
+ public function canModerateObject(int $objectTypeID, 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);
+ if (!$page->isAccessible($user->getDecoratedObject())) {
+ return false;
+ }
+ return (bool)$user->getPermission($this->permissionCanModerate);
}
-
/**
* @inheritDoc
*/
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
-class UserProfileCommentManager extends AbstractCommentManager implements IViewableLikeProvider
+class UserProfileCommentManager extends AbstractCommentManager implements
+ IViewableLikeProvider,
+ ICommentPermissionManager
{
/**
* @inheritDoc
}
#[\Override]
- public function canViewObject(int $objectID, UserProfile $user): bool
+ public function canModerateObject(int $objectTypeID, int $objectID, UserProfile $user): bool
{
$userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
if ($userProfile === null) {
}
/** @see UserProfile::isProtected() */
- return $user->getPermission('admin.general.canViewPrivateUserOptions')
+ if (
+ !(
+ $user->getPermission('admin.general.canViewPrivateUserOptions')
|| $userProfile->isAccessible('canViewProfile', $user->userID)
- || $userProfile->userID === $user->userID;
+ || $userProfile->userID === $user->userID)
+ ) {
+ return false;
+ }
+ return (bool)$user->getPermission($this->permissionCanModerate);
}
/**