Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
jvillafanez committed Oct 28, 2020
1 parent b319f0b commit 95fc0aa
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions apps/files_sharing/lib/Controller/Share20OcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,13 @@ private function getSharesInDir($folder, $requestedShareTypes) {
continue;
}

if ($shareType !== Share::SHARE_TYPE_REMOTE) {
$shares = \array_merge(
$shares,
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $node, false, -1, 0)
);
} elseif ($shareType === Share::SHARE_TYPE_REMOTE && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
$shares = \array_merge(
$shares,
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $node, false, -1, 0)
);
}
// if outgoingServer2ServerSharesAllowed is false, remote shares shouldn't be
// returned. This must be checked in the caller method, so the remote share type
// shouldn't be present if outgoing remotes shares aren't allowed.
$shares = \array_merge(
$shares,
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $node, false, -1, 0)
);
}
}

Expand Down Expand Up @@ -707,6 +703,11 @@ public function getShares() {
Share::SHARE_TYPE_LINK => false,
Share::SHARE_TYPE_REMOTE => false,
];

if ($this->shareManager->outgoingServer2ServerSharesAllowed() === false) {
// if outgoing remote shares aren't allowed, the remote share type can't be chosen
unset($requestedShareTypes[Share::SHARE_TYPE_REMOTE]);
}
foreach ($shareTypes as $shareType) {
if (isset($requestedShareTypes[$shareType])) {
$requestedShareTypes[$shareType] = true;
Expand Down Expand Up @@ -763,17 +764,10 @@ public function getShares() {
continue;
}

if ($shareType !== Share::SHARE_TYPE_REMOTE) {
$shares = \array_merge(
$shares,
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $path, $reshares, -1, 0)
);
} elseif ($shareType === Share::SHARE_TYPE_REMOTE && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
$shares = \array_merge(
$shares,
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $path, $reshares, -1, 0)
);
}
$shares = \array_merge(
$shares,
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $path, $reshares, -1, 0)
);
}

$formatted = [];
Expand Down

0 comments on commit 95fc0aa

Please sign in to comment.