From d466a7b80834b6e31bfcb9d764816a01da0cbc7c Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 1 Apr 2020 15:07:35 +0200 Subject: Allow to navigate to others with access from the sidebar Signed-off-by: Roeland Jago Douma Signed-off-by: npmbuildbot[bot] --- .../lib/Controller/ShareAPIController.php | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib/Controller') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 23d5057e05e..f2feb87373d 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -853,8 +853,12 @@ class ShareAPIController extends OCSController { throw new OCSNotFoundException($this->l->t('Could not lock path')); } - // current User has resharing rights ? - $this->confirmSharingRights($node); + if (!($node->getPermissions() & Constants::PERMISSION_SHARE)) { + throw new SharingRightsException('no sharing rights on this item'); + } + + // The current top parent we have access to + $parent = $node; // initiate real owner. $owner = $node->getOwner() @@ -882,10 +886,25 @@ class ShareAPIController extends OCSController { $nodes[] = $node; } + // The user that is requesting this list + $currentUserFolder = $this->rootFolder->getUserFolder($this->currentUser); + // for each nodes, retrieve shares. $shares = []; + foreach ($nodes as $node) { $getShares = $this->getFormattedShares($owner, $node, false, true); + + $currentUserNodes = $currentUserFolder->getById($node->getId()); + if (!empty($currentUserNodes)) { + $parent = array_pop($currentUserNodes); + } + + $subPath = $currentUserFolder->getRelativePath($parent->getPath()); + foreach ($getShares as &$share) { + $share['via_fileid'] = $parent->getId(); + $share['via_path'] = $subPath; + } $this->mergeFormattedShares($shares, $getShares); } -- cgit v1.2.3