fix(Categories): admin should always see all categories

This commit is contained in:
2025-11-23 23:18:04 +02:00
parent 3ed74eea8f
commit f4530ae2a3

View File

@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace OCA\Forum\Db;
use OCA\Forum\AppInfo\Application;
use OCA\Forum\Service\UserRoleService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
@@ -84,9 +85,15 @@ class CategoryMapper extends QBMapper {
return [];
}
$categoryIds = array_map(fn ($cat) => $cat->getId(), $categories);
$userRoleIds = $this->getUserRoleIds();
// Admin role has access to all categories - skip filtering
if (in_array(UserRoleService::ROLE_ADMIN, $userRoleIds)) {
return $categories;
}
$categoryIds = array_map(fn ($cat) => $cat->getId(), $categories);
// Get all permissions for these categories
$qb = $this->db->getQueryBuilder();
$qb->select('category_id', 'role_id', 'can_view')