diff options
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r-- | apps/files_sharing/api/share20ocs.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 309e1159fff..4abd821f2ae 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -271,6 +271,15 @@ class Share20OCS { $permissions &= ~\OCP\Constants::PERMISSION_CREATE; } + /* + * Hack for https://github.com/owncloud/core/issues/22587 + * We check the permissions via webdav. But the permissions of the mount point + * do not equal the share permissions. Here we fix that for federated mounts. + */ + if ($path->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + $permissions &= ~($permissions & ~$path->getPermissions()); + } + $shareWith = $this->request->getParam('shareWith', null); $shareType = (int)$this->request->getParam('shareType', '-1'); @@ -294,6 +303,15 @@ class Share20OCS { return new \OC_OCS_Result(null, 404, 'public link sharing is disabled by the administrator'); } + /* + * For now we only allow 1 link share. + * Return the existing link share if this is a duplicate + */ + $existingShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, false, 1, 0); + if (!empty($existingShares)) { + return new \OC_OCS_Result($this->formatShare($existingShares[0])); + } + $publicUpload = $this->request->getParam('publicUpload', null); if ($publicUpload === 'true') { // Check if public upload is allowed @@ -585,6 +603,22 @@ class Share20OCS { } } + if ($permissions !== null) { + /* Check if this is an incomming share */ + $incomingShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0); + $incomingShares = array_merge($incomingShares, $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0)); + + if (!empty($incomingShares)) { + $maxPermissions = 0; + foreach ($incomingShares as $incomingShare) { + $maxPermissions |= $incomingShare->getPermissions(); + } + + if ($share->getPermissions() & ~$maxPermissions) { + return new \OC_OCS_Result(null, 404, 'Cannot increase permissions'); + } + } + } try { |