From 44d217c42529c3f4a0df0a56255887450d37e00b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 29 May 2013 15:25:42 +0200 Subject: Cache: provide a function to get the permissions of all files in a folder with one query --- lib/files/cache/permissions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/files/cache/permissions.php') diff --git a/lib/files/cache/permissions.php b/lib/files/cache/permissions.php index faa5ff5eacc..73473142c74 100644 --- a/lib/files/cache/permissions.php +++ b/lib/files/cache/permissions.php @@ -85,6 +85,25 @@ class Permissions { return $filePermissions; } + /** + * get the permissions for all files in a folder + * + * @param int $parentId + * @return int[] + */ + public function getDirectoryPermissions($parentId) { + $query = \OC_DB::prepare('SELECT `*PREFIX*permissions`.`fileid`, `permissions` + FROM `*PREFIX*permissions` INNER JOIN `*PREFIX*filecache` ON `*PREFIX*permissions`.fileid = `*PREFIX*filecache`.fileid + WHERE `*PREFIX*filecache`.parent = ?'); + + $result = $query->execute(array($parentId)); + $filePermissions = array(); + while ($row = $result->fetchRow()) { + $filePermissions[$row['fileid']] = $row['permissions']; + } + return $filePermissions; + } + /** * remove the permissions for a file * -- cgit v1.2.3