summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/ajax/shareinfo.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/ajax/shareinfo.php')
-rw-r--r--apps/files_sharing/ajax/shareinfo.php13
1 files changed, 5 insertions, 8 deletions
diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php
index 31b8e00f496..b9b29022cc3 100644
--- a/apps/files_sharing/ajax/shareinfo.php
+++ b/apps/files_sharing/ajax/shareinfo.php
@@ -53,11 +53,12 @@ if (isset($_GET['dir'])) {
$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password);
-$linkItem = $data['linkItem'];
+/** @var \OCP\Share\IShare $share */
+$share = $data['share'];
// Load the files
$path = $data['realPath'];
-$isWritable = $linkItem['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
+$isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
if (!$isWritable) {
\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
@@ -67,10 +68,6 @@ 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();
-
if($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
OCP\JSON::error(array('data' => 'Share is not readable.'));
exit();
@@ -98,11 +95,11 @@ function getChildInfo($dir, $view, $sharePermissions) {
$result = \OCA\Files\Helper::formatFileInfo($rootInfo);
$result['mtime'] = $result['mtime'] / 1000;
-$result['permissions'] = (int)$result['permissions'] & $sharePermissions;
+$result['permissions'] = (int)$result['permissions'] & $share->getPermissions();
if ($rootInfo->getType() === 'dir') {
- $result['children'] = getChildInfo($rootInfo, $rootView, $sharePermissions);
+ $result['children'] = getChildInfo($rootInfo, $rootView, $share->getPermissions());
}
OCP\JSON::success(array('data' => $result));