summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api/share20ocs.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/api/share20ocs.php')
-rw-r--r--apps/files_sharing/api/share20ocs.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 331c6d9e780..67a94aaf8aa 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -165,6 +165,10 @@ class Share20OCS {
}
if ($share === null) {
+ if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
+ }
+
try {
$share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
} catch (ShareNotFound $e) {
@@ -199,6 +203,10 @@ class Share20OCS {
// Could not find the share as internal share... maybe it is a federated share
if ($share === null) {
+ if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
+ }
+
try {
$share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
} catch (ShareNotFound $e) {
@@ -321,6 +329,10 @@ class Share20OCS {
}
} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
+ if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ return new \OC_OCS_Result(null, 403, 'Sharing '.$path.' failed, because the backend does not allow shares from type '.$shareType);
+ }
+
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
} else {
@@ -379,7 +391,9 @@ class Share20OCS {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
- $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
+ if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
+ }
}
$formatted = [];
@@ -434,9 +448,13 @@ class Share20OCS {
$userShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
$groupShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
$linkShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
- $federatedShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
+ $shares = array_merge($userShares, $groupShares, $linkShares);
+
+ if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ $federatedShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
+ $shares = array_merge($shares, $federatedShares);
+ }
- $shares = array_merge($userShares, $groupShares, $linkShares, $federatedShares);
$formatted = [];
foreach ($shares as $share) {
@@ -463,6 +481,10 @@ class Share20OCS {
// Could not find the share as internal share... maybe it is a federated share
if ($share === null) {
+ if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
+ return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
+ }
+
try {
$share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
} catch (ShareNotFound $e) {