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/dav/lib | |
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/dav/lib')
-rw-r--r-- | apps/dav/lib/connector/sabre/filesplugin.php | 8 | ||||
-rw-r--r-- | apps/dav/lib/connector/sabre/node.php | 29 |
2 files changed, 33 insertions, 4 deletions
diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php index dd4670da5fa..8822deb1661 100644 --- a/apps/dav/lib/connector/sabre/filesplugin.php +++ b/apps/dav/lib/connector/sabre/filesplugin.php @@ -246,6 +246,8 @@ class FilesPlugin extends ServerPlugin { */ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) { + $httpRequest = $this->server->httpRequest; + if ($node instanceof \OCA\DAV\Connector\Sabre\Node) { $propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) { @@ -265,8 +267,10 @@ class FilesPlugin extends ServerPlugin { return $perms; }); - $propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node) { - return $node->getSharePermissions(); + $propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest) { + return $node->getSharePermissions( + $httpRequest->getRawServerValue('PHP_AUTH_USER') + ); }); $propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) { diff --git a/apps/dav/lib/connector/sabre/node.php b/apps/dav/lib/connector/sabre/node.php index 979149fc937..ccc035063cd 100644 --- a/apps/dav/lib/connector/sabre/node.php +++ b/apps/dav/lib/connector/sabre/node.php @@ -32,6 +32,8 @@ namespace OCA\DAV\Connector\Sabre; use OC\Files\Mount\MoveableMount; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; +use OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\IManager; abstract class Node implements \Sabre\DAV\INode { @@ -61,15 +63,26 @@ abstract class Node implements \Sabre\DAV\INode { protected $info; /** + * @var IManager + */ + protected $shareManager; + + /** * Sets up the node, expects a full path name * * @param \OC\Files\View $view * @param \OCP\Files\FileInfo $info + * @param IManager $shareManager */ - public function __construct($view, $info) { + public function __construct($view, $info, IManager $shareManager = null) { $this->fileView = $view; $this->path = $this->fileView->getRelativePath($info->getPath()); $this->info = $info; + if ($shareManager) { + $this->shareManager = $shareManager; + } else { + $this->shareManager = \OC::$server->getShareManager(); + } } protected function refreshInfo() { @@ -215,9 +228,21 @@ abstract class Node implements \Sabre\DAV\INode { } /** + * @param string $user * @return int */ - public function getSharePermissions() { + public function getSharePermissions($user) { + + // check of we access a federated share + if ($user !== null) { + try { + $share = $this->shareManager->getShareByToken($user); + return $share->getPermissions(); + } catch (ShareNotFound $e) { + // ignore + } + } + $storage = $this->info->getStorage(); $path = $this->info->getInternalPath(); |