aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-05-29 18:22:54 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2013-05-29 18:22:54 -0400
commit5a47054505bfca3c3ba6e947cac6b963cd45b416 (patch)
treecb996d07e8a2041b0b2f47df5b3ee8eb94bc1b72 /apps
parentdbbf195727d698a5ba46d7cfee06eb9ea7916d96 (diff)
downloadnextcloud-server-5a47054505bfca3c3ba6e947cac6b963cd45b416.tar.gz
nextcloud-server-5a47054505bfca3c3ba6e947cac6b963cd45b416.zip
Implement getDirectoryPermissions() in Shared Permissions, fixes #2846
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/permissions.php25
-rw-r--r--apps/files_sharing/lib/share/file.php7
2 files changed, 31 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/permissions.php b/apps/files_sharing/lib/permissions.php
index 6747faa4d43..b6638564cd8 100644
--- a/apps/files_sharing/lib/permissions.php
+++ b/apps/files_sharing/lib/permissions.php
@@ -71,6 +71,28 @@ class Shared_Permissions extends Permissions {
}
/**
+ * get the permissions for all files in a folder
+ *
+ * @param int $parentId
+ * @param string $user
+ * @return int[]
+ */
+ public function getDirectoryPermissions($parentId, $user) {
+ // Root of the Shared folder
+ if ($parentId === -1) {
+ return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_PERMISSIONS);
+ }
+ $permissions = $this->get($parentId, $user);
+ $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `parent` = ?');
+ $result = $query->execute(array($parentId));
+ $filePermissions = array();
+ while ($row = $result->fetchRow()) {
+ $filePermissions[$row['fileid']] = $permissions;
+ }
+ return $filePermissions;
+ }
+
+ /**
* remove the permissions for a file
*
* @param int $fileId
@@ -83,4 +105,5 @@ class Shared_Permissions extends Permissions {
public function removeMultiple($fileIds, $user) {
// Not a valid action for Shared Permissions
}
-}
+
+} \ No newline at end of file
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 62948651806..07e7a4ca0c5 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -26,6 +26,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
const FORMAT_FILE_APP_ROOT = 2;
const FORMAT_OPENDIR = 3;
const FORMAT_GET_ALL = 4;
+ const FORMAT_PERMISSIONS = 5;
private $path;
@@ -125,6 +126,12 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
$ids[] = $item['file_source'];
}
return $ids;
+ } else if ($format === self::FORMAT_PERMISSIONS) {
+ $filePermissions = array();
+ foreach ($items as $item) {
+ $filePermissions[$item['file_source']] = $item['permissions'];
+ }
+ return $filePermissions;
}
return array();
}