diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-12-09 18:14:58 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-12-09 18:14:58 +0100 |
commit | 89eb3759a87e268b010b06c9e4ef3e3998dc81a7 (patch) | |
tree | 4d8e1e36b3ec09bf42def7c57e7eb4a22098e463 /apps/files_sharing/lib/permissions.php | |
parent | bc3650e48c7ec4f05794c2bd98a90cca3090f1e3 (diff) | |
download | nextcloud-server-89eb3759a87e268b010b06c9e4ef3e3998dc81a7.tar.gz nextcloud-server-89eb3759a87e268b010b06c9e4ef3e3998dc81a7.zip |
Fixed sharing results to include the correct permissions
Passing $includeCollections would return more than one entry which gives
mixed up file permissions.
Added a method getFile() that doesn't set $includeCollections to make
sure we only get one result which is the file itself.
Fixes #6265
Diffstat (limited to 'apps/files_sharing/lib/permissions.php')
-rw-r--r-- | apps/files_sharing/lib/permissions.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/permissions.php b/apps/files_sharing/lib/permissions.php index e2978e12bfb..1dc53428a7f 100644 --- a/apps/files_sharing/lib/permissions.php +++ b/apps/files_sharing/lib/permissions.php @@ -42,6 +42,19 @@ class Shared_Permissions extends Permissions { } } + private function getFile($fileId, $user) { + if ($fileId == -1) { + return \OCP\PERMISSION_READ; + } + $source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE, + null, false); + if ($source) { + return $source['permissions']; + } else { + return -1; + } + } + /** * set the permissions of a file * @@ -82,7 +95,7 @@ class Shared_Permissions extends Permissions { if ($parentId === -1) { return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_PERMISSIONS); } - $permissions = $this->get($parentId, $user); + $permissions = $this->getFile($parentId, $user); $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `parent` = ?'); $result = $query->execute(array($parentId)); $filePermissions = array(); |