X Tutup
Skip to content

Commit bfa1836

Browse files
committed
Simplify code
1 parent b319f0b commit bfa1836

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

apps/files_sharing/lib/Controller/Share20OcsController.php

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -632,17 +632,13 @@ private function getSharesInDir($folder, $requestedShareTypes) {
632632
continue;
633633
}
634634

635-
if ($shareType !== Share::SHARE_TYPE_REMOTE) {
636-
$shares = \array_merge(
637-
$shares,
638-
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $node, false, -1, 0)
639-
);
640-
} elseif ($shareType === Share::SHARE_TYPE_REMOTE && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
641-
$shares = \array_merge(
642-
$shares,
643-
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $node, false, -1, 0)
644-
);
645-
}
635+
// if outgoingServer2ServerSharesAllowed is false, remote shares shouldn't be
636+
// returned. This must be checked in the caller method, so the remote share type
637+
// shouldn't be present if outgoing remotes shares aren't allowed.
638+
$shares = \array_merge(
639+
$shares,
640+
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $node, false, -1, 0)
641+
);
646642
}
647643
}
648644

@@ -707,6 +703,11 @@ public function getShares() {
707703
Share::SHARE_TYPE_LINK => false,
708704
Share::SHARE_TYPE_REMOTE => false,
709705
];
706+
707+
if ($this->shareManager->outgoingServer2ServerSharesAllowed() === false) {
708+
// if outgoing remote shares aren't allowed, the remote share type can't be chosen
709+
unset($requestedShareTypes[Share::SHARE_TYPE_REMOTE])
710+
}
710711
foreach ($shareTypes as $shareType) {
711712
if (isset($requestedShareTypes[$shareType])) {
712713
$requestedShareTypes[$shareType] = true;
@@ -763,17 +764,10 @@ public function getShares() {
763764
continue;
764765
}
765766

766-
if ($shareType !== Share::SHARE_TYPE_REMOTE) {
767-
$shares = \array_merge(
768-
$shares,
769-
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $path, $reshares, -1, 0)
770-
);
771-
} elseif ($shareType === Share::SHARE_TYPE_REMOTE && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
772-
$shares = \array_merge(
773-
$shares,
774-
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $path, $reshares, -1, 0)
775-
);
776-
}
767+
$shares = \array_merge(
768+
$shares,
769+
$this->shareManager->getSharesBy($this->userSession->getUser()->getUID(), $shareType, $path, $reshares, -1, 0)
770+
);
777771
}
778772

779773
$formatted = [];

0 commit comments

Comments
 (0)
X Tutup