diff options
author | Björn Schießle <schiessle@owncloud.com> | 2016-04-22 14:50:42 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2016-04-22 14:50:42 +0200 |
commit | 606b756a94643eaae87e18b39f6c75e6d18fec7e (patch) | |
tree | 6128dd0ed676164bbfb8a4aa10a56cc511728edd /apps/files_sharing | |
parent | cc4efc4c03f4d4f7ec9e6cf9beac570254bef3c1 (diff) | |
parent | 2a6a336e873db394e9912de20478645f3e4b8fc4 (diff) | |
download | nextcloud-server-606b756a94643eaae87e18b39f6c75e6d18fec7e.tar.gz nextcloud-server-606b756a94643eaae87e18b39f6c75e6d18fec7e.zip |
Merge pull request #23918 from owncloud/cruds-for-federated-shares
bring back CRUDS permissions for federated shares
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/ajax/shareinfo.php | 14 | ||||
-rw-r--r-- | apps/files_sharing/lib/external/storage.php | 16 |
2 files changed, 27 insertions, 3 deletions
diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php index e15e12fd287..47bc061c136 100644 --- a/apps/files_sharing/ajax/shareinfo.php +++ b/apps/files_sharing/ajax/shareinfo.php @@ -62,20 +62,25 @@ if (!$isWritable) { $rootInfo = \OC\Files\Filesystem::getFileInfo($path); $rootView = new \OC\Files\View(''); +$shareManager = \OC::$server->getShareManager(); +$share = $shareManager->getShareByToken($token); +$sharePermissions= (int)$share->getPermissions(); + /** * @param \OCP\Files\FileInfo $dir * @param \OC\Files\View $view * @return array */ -function getChildInfo($dir, $view) { +function getChildInfo($dir, $view, $sharePermissions) { $children = $view->getDirectoryContent($dir->getPath()); $result = array(); foreach ($children as $child) { $formatted = \OCA\Files\Helper::formatFileInfo($child); if ($child->getType() === 'dir') { - $formatted['children'] = getChildInfo($child, $view); + $formatted['children'] = getChildInfo($child, $view, $sharePermissions); } $formatted['mtime'] = $formatted['mtime'] / 1000; + $formatted['permissions'] = $sharePermissions & (int)$formatted['permissions']; $result[] = $formatted; } return $result; @@ -83,8 +88,11 @@ function getChildInfo($dir, $view) { $result = \OCA\Files\Helper::formatFileInfo($rootInfo); $result['mtime'] = $result['mtime'] / 1000; +$result['permissions'] = (int)$result['permissions'] & $sharePermissions; + + if ($rootInfo->getType() === 'dir') { - $result['children'] = getChildInfo($rootInfo, $rootView); + $result['children'] = getChildInfo($rootInfo, $rootView, $sharePermissions); } OCP\JSON::success(array('data' => $result)); diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index 8fe7af66044..4382dcab0c3 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -319,5 +319,21 @@ class Storage extends DAV implements ISharedStorage { } return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); } + + public function getPermissions($path) { + $response = $this->propfind($path); + if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { + $permissions = $response['{http://open-collaboration-services.org/ns}share-permissions']; + } else { + // use default permission if remote server doesn't provide the share permissions + if ($this->is_dir($path)) { + $permissions = \OCP\Constants::PERMISSION_ALL; + } else { + $permissions = \OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_CREATE; + } + } + + return $permissions; + } } |