diff options
author | Joas Schilling <coding@schilljs.com> | 2017-03-28 17:06:26 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-13 12:58:51 +0200 |
commit | 3c1365c0d12a626e8c2b8e1ab35b105f4b88ad2e (patch) | |
tree | 23935b8b8c0df29875cdd1c6d2133bf399a2b724 /lib/private/Share20 | |
parent | 4bcb7d88b5cbb8d2c83176062dc76c6213a13c48 (diff) | |
download | nextcloud-server-3c1365c0d12a626e8c2b8e1ab35b105f4b88ad2e.tar.gz nextcloud-server-3c1365c0d12a626e8c2b8e1ab35b105f4b88ad2e.zip |
Fix returned paths for remote shares
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/ShareHelper.php | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/lib/private/Share20/ShareHelper.php b/lib/private/Share20/ShareHelper.php index b5640d04552..ba3f64dbc1a 100644 --- a/lib/private/Share20/ShareHelper.php +++ b/lib/private/Share20/ShareHelper.php @@ -37,7 +37,7 @@ class ShareHelper implements IShareHelper { /** * @param Node $node - * @return array [ users => [Mapping $uid => $path], remotes => [Mapping $cloudId => $path]] + * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]] */ public function getPathsForAccessList(Node $node) { $result = [ @@ -103,26 +103,10 @@ class ShareHelper implements IShareHelper { $byId[$info['node_id']][$cloudId] = $info['token']; } - if (isset($byId[$node->getId()])) { - foreach ($byId[$node->getId()] as $cloudId => $token) { - $results[$cloudId] = [ - 'node_path' => '/' . $node->getName(), - 'token' => $token, - ]; - } - unset($byId[$node->getId()]); - } - - if (empty($byId)) { - return $results; - } - $item = $node; - $path = '/' . $node->getName(); while (!empty($byId)) { - $item = $item->getParent(); - if (!empty($byId[$item->getId()])) { + $path = $this->getMountedPath($item); foreach ($byId[$item->getId()] as $uid => $token) { $results[$uid] = [ 'node_path' => $path, @@ -131,10 +115,15 @@ class ShareHelper implements IShareHelper { } unset($byId[$item->getId()]); } - - $path = '/' . $item->getName() . $path; + $item = $item->getParent(); } return $results; } + + protected function getMountedPath(Node $node) { + $path = $node->getPath(); + $sections = explode('/', $path, 4); + return '/' . $sections[3]; + } } |