diff --git a/src/Helper/GridHelperService.php b/src/Helper/GridHelperService.php index 57506b6fe..30f629bfc 100644 --- a/src/Helper/GridHelperService.php +++ b/src/Helper/GridHelperService.php @@ -616,11 +616,12 @@ public function prepareListingForGrid(array $requestParams, string $requestedLan if (!$adminUser->isAdmin()) { $userIds = $adminUser->getRoles(); $userIds[] = $adminUser->getId(); - $conditionFilters[] = ' ( - (select list from users_workspaces_object where userId in (' . implode(',', $userIds) . ') and LOCATE(CONCAT(`path`,`key`),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1 - OR - (select list from users_workspaces_object where userId in (' . implode(',', $userIds) . ') and LOCATE(cpath,CONCAT(`path`,`key`))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1 - )'; + $ids = implode(',', $userIds); + $conditionFilters[] = " ( + (select list from users_workspaces_object where userId in ($ids) AND CONCAT(`path`, `key`) LIKE CONCAT(cpath, '%') ORDER BY LENGTH(cpath) DESC LIMIT 1)=1 + OR + (select list from users_workspaces_object where userId in ($ids) AND cpath LIKE CONCAT(`path`, `key`, '%') ORDER BY LENGTH(cpath) DESC LIMIT 1)=1 + )"; } $featureJoins = []; @@ -853,11 +854,18 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M if (!$adminUser->isAdmin()) { $userIds = $adminUser->getRoles(); $userIds[] = $adminUser->getId(); - $conditionFilters[] = ' ( - (select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(CONCAT(`path`, filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1 - OR - (select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(cpath,CONCAT(`path`, filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1 - )'; + $conditionFilters[] = '( + EXISTS ( + SELECT 1 + FROM users_workspaces_asset + WHERE userId IN (' . implode(',', $userIds) . ') + AND ( + LOCATE(CONCAT(`path`, `key`), cpath) = 1 + OR LOCATE(cpath, CONCAT(`path`, `key`)) = 1 + ) + AND list = 1 + ) + )'; } //filtering for tags