aclManager->getPermissionsForPathFromRules($path, $rules); } else { $permissions = $this->aclManager->getACLPermissionsForPath($this->getNumericStorageId(), $path); } // if there is no read permissions, than deny everything if ($this->inShare) { $minPermissions = Constants::PERMISSION_READ + Constants::PERMISSION_SHARE; } else { $minPermissions = Constants::PERMISSION_READ; } $canRead = ($permissions & $minPermissions) === $minPermissions; return $canRead ? $permissions : 0; } protected function formatCacheEntry($entry, array $rules = []): ICacheEntry|false { if (isset($entry['permissions'])) { $entry['scan_permissions'] ??= $entry['permissions']; $entry['permissions'] &= $this->getACLPermissionsForPath($entry['path'], $rules); if (!$entry['permissions']) { return false; } } return $entry; } public function getFolderContentsById($fileId): array { $results = $this->getCache()->getFolderContentsById($fileId); $rules = $this->preloadEntries($results); return array_filter(array_map(fn (ICacheEntry $entry): ICacheEntry|false => $this->formatCacheEntry($entry, $rules), $results)); } public function search($pattern): array { $results = $this->getCache()->search($pattern); $this->preloadEntries($results); return array_filter(array_map($this->formatCacheEntry(...), $results)); } public function searchByMime($mimetype): array { $results = $this->getCache()->searchByMime($mimetype); $this->preloadEntries($results); return array_filter(array_map($this->formatCacheEntry(...), $results)); } public function searchQuery(ISearchQuery $query): array { $results = $this->getCache()->searchQuery($query); $this->preloadEntries($results); return array_filter(array_map($this->formatCacheEntry(...), $results)); } /** * @param ICacheEntry[] $entries * @return array */ private function preloadEntries(array $entries): array { $paths = array_map(fn (ICacheEntry $entry): string => $entry->getPath(), $entries); return $this->aclManager->getRelevantRulesForPath($this->getNumericStorageId(), $paths, false); } }