diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-07-03 23:13:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-03 23:13:47 +0200 |
commit | 7025f160176ea1440290b4deea8d59eeab1ec83c (patch) | |
tree | 3db69d031b1a9695de89b65bc64299c43bfdfe86 /apps/dav | |
parent | 8b683feca2e003bd50913bb4951012d7c7cc8d4f (diff) | |
parent | 7ff74ae8eda8feb232a9b2c2094ec98641543721 (diff) | |
download | nextcloud-server-7025f160176ea1440290b4deea8d59eeab1ec83c.tar.gz nextcloud-server-7025f160176ea1440290b4deea8d59eeab1ec83c.zip |
Merge pull request #9345 from nextcloud/federation20
Federation 2.0
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FilesPlugin.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index f36ebe5636c..f53f13c5687 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -33,6 +33,7 @@ namespace OCA\DAV\Connector\Sabre; use OC\AppFramework\Http\Request; +use OCP\Constants; use OCP\Files\ForbiddenException; use OCP\IPreview; use Sabre\DAV\Exception\Forbidden; @@ -57,6 +58,7 @@ class FilesPlugin extends ServerPlugin { const INTERNAL_FILEID_PROPERTYNAME = '{http://owncloud.org/ns}fileid'; const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions'; const SHARE_PERMISSIONS_PROPERTYNAME = '{http://open-collaboration-services.org/ns}share-permissions'; + const OCM_SHARE_PERMISSIONS_PROPERTYNAME = '{http://open-cloud-mesh.org/ns}share-permissions'; const DOWNLOADURL_PROPERTYNAME = '{http://owncloud.org/ns}downloadURL'; const SIZE_PROPERTYNAME = '{http://owncloud.org/ns}size'; const GETETAG_PROPERTYNAME = '{DAV:}getetag'; @@ -149,6 +151,7 @@ class FilesPlugin extends ServerPlugin { $server->protectedProperties[] = self::INTERNAL_FILEID_PROPERTYNAME; $server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME; $server->protectedProperties[] = self::SHARE_PERMISSIONS_PROPERTYNAME; + $server->protectedProperties[] = self::OCM_SHARE_PERMISSIONS_PROPERTYNAME; $server->protectedProperties[] = self::SIZE_PROPERTYNAME; $server->protectedProperties[] = self::DOWNLOADURL_PROPERTYNAME; $server->protectedProperties[] = self::OWNER_ID_PROPERTYNAME; @@ -318,6 +321,14 @@ class FilesPlugin extends ServerPlugin { ); }); + $propFind->handle(self::OCM_SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest) { + $ncPermissions = $node->getSharePermissions( + $httpRequest->getRawServerValue('PHP_AUTH_USER') + ); + $ocmPermissions = $this->ncPermissions2ocmPermissions($ncPermissions); + return json_encode($ocmPermissions); + }); + $propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) { return $node->getETag(); }); @@ -395,6 +406,33 @@ class FilesPlugin extends ServerPlugin { } /** + * translate Nextcloud permissions to OCM Permissions + * + * @param $ncPermissions + * @return array + */ + protected function ncPermissions2ocmPermissions($ncPermissions) { + + $ocmPermissions = []; + + if ($ncPermissions & Constants::PERMISSION_SHARE) { + $ocmPermissions[] = 'share'; + } + + if ($ncPermissions & Constants::PERMISSION_READ) { + $ocmPermissions[] = 'read'; + } + + if (($ncPermissions & Constants::PERMISSION_CREATE) || + ($ncPermissions & Constants::PERMISSION_UPDATE)) { + $ocmPermissions[] = 'write'; + } + + return $ocmPermissions; + + } + + /** * Update ownCloud-specific properties * * @param string $path |