aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-27 10:01:20 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-27 10:01:20 +0200
commit695405dfeb4da3733df1b1be239a97100f2ce66f (patch)
treeb1e4aefe0bb45ab9ba25171eb595da4ada2148d2 /lib
parent99534271977ef5a4fd35ce119d6627bbcde45096 (diff)
downloadnextcloud-server-695405dfeb4da3733df1b1be239a97100f2ce66f.tar.gz
nextcloud-server-695405dfeb4da3733df1b1be239a97100f2ce66f.zip
add permissions data to the results of the cache api
Diffstat (limited to 'lib')
-rw-r--r--lib/files/cache/cache.php15
-rw-r--r--lib/files/cache/scanner.php3
-rw-r--r--lib/files/view.php12
3 files changed, 28 insertions, 2 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 7e0c5cb21f9..5efc7d67c4a 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -286,4 +286,19 @@ class Cache {
}
return $files;
}
+
+ /**
+ * get all file ids on the files on the storage
+ *
+ * @return int[]
+ */
+ public function getAll() {
+ $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ?');
+ $result = $query->execute(array($this->storageId));
+ $ids = array();
+ while ($row = $result->fetchRow()) {
+ $ids[] = $row['fileid'];
+ }
+ return $ids;
+ }
}
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index e8f54c34be7..0adde1d354d 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -66,7 +66,8 @@ class Scanner {
$this->scanFile($parent);
}
}
- $this->cache->put($file, $data);
+ $id = $this->cache->put($file, $data);
+ Permissions::set($id, \OC_User::getUser(), $data['permissions']);
return $data;
}
diff --git a/lib/files/view.php b/lib/files/view.php
index 04b7dca8afc..82455d582eb 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -686,6 +686,8 @@ class View {
}
}
+ $data['permissions'] = Cache\Permissions::get($data['fileid'], \OC_User::getUser());
+
return $data;
}
@@ -733,8 +735,16 @@ class View {
}
}
- foreach($files as $i => $file){
+ $ids = array();
+
+ foreach ($files as $i => $file) {
$files[$i]['type'] = $file['mimetype'] === 'httpd/unix-directory' ? 'dir' : 'file';
+ $ids[] = $file['fileid'];
+ }
+
+ $permissions = Cache\Permissions::getMultiple($ids, \OC_User::getUser());
+ foreach ($files as $i => $file) {
+ $files[$i]['permissions'] = $permissions[$file['fileid']];
}
usort($files, "fileCmp"); //TODO: remove this once ajax is merged