diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index a9e358cb5..565ab026b 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -31,6 +31,7 @@ use OCA\GroupFolders\Mount\MountProvider; use OCA\GroupFolders\Versions\VersionsBackend; use OCP\Constants; +use OCP\Files\Cache\ICacheEntry; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Node; @@ -309,6 +310,8 @@ private function getTrashFolder(int $folderId): Folder { } /** + * @param IUser $user + * @param array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry}[] $folders * @return list */ private function getTrashForFolders(IUser $user, array $folders): array { @@ -326,6 +329,7 @@ private function getTrashForFolders(IUser $user, array $folders): array { $items = []; foreach ($folders as $folder) { $folderId = $folder['folder_id']; + $folderHasAcl = $folder['acl']; $mountPoint = $folder['mount_point']; $trashFolder = $this->getTrashFolder($folderId); $content = $trashFolder->getDirectoryListing(); @@ -340,20 +344,22 @@ private function getTrashForFolders(IUser $user, array $folders): array { $originalLocation = isset($indexedRows[$key]) ? $indexedRows[$key]['original_location'] : ''; - // if we for any reason lost track of the original location, hide the item for non-managers as a fail-safe - if ($originalLocation === '' && !$userCanManageAcl) { - continue; - } - if (!$this->userHasAccessToPath($user, $item->getPath())) { - continue; - } - // if a parent of the original location has also been deleted, we also need to check it based on the now-deleted parent path - foreach ($this->getParentOriginalPaths($originalLocation, $trashItemsByOriginalLocation) as $parentOriginalPath) { - $parentTrashItem = $trashItemsByOriginalLocation[$parentOriginalPath]; - $relativePath = substr($originalLocation, strlen($parentOriginalPath)); - $parentTrashItemPath = "__groupfolders/trash/{$parentTrashItem['folder_id']}/{$parentTrashItem['name']}.d{$parentTrashItem['deleted_time']}"; - if (!$this->userHasAccessToPath($user, $parentTrashItemPath . $relativePath)) { - continue 2; + if ($folderHasAcl) { + // if we for any reason lost track of the original location, hide the item for non-managers as a fail-safe + if ($originalLocation === '' && !$userCanManageAcl) { + continue; + } + if (!$this->userHasAccessToPath($user, $item->getPath())) { + continue; + } + // if a parent of the original location has also been deleted, we also need to check it based on the now-deleted parent path + foreach ($this->getParentOriginalPaths($originalLocation, $trashItemsByOriginalLocation) as $parentOriginalPath) { + $parentTrashItem = $trashItemsByOriginalLocation[$parentOriginalPath]; + $relativePath = substr($originalLocation, strlen($parentOriginalPath)); + $parentTrashItemPath = "__groupfolders/trash/{$parentTrashItem['folder_id']}/{$parentTrashItem['name']}.d{$parentTrashItem['deleted_time']}"; + if (!$this->userHasAccessToPath($user, $parentTrashItemPath . $relativePath)) { + continue 2; + } } }