summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-06-07 12:50:12 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-06-07 15:09:19 +0200
commit7c040c0bf97c2d3a63051a819dc480403d3b96fb (patch)
treede2473c002ec6aaa4c4b633694d0ec2063226ae8
parent7d31ae9909d5edb2fab42ff06f725682d4e9c430 (diff)
downloadnextcloud-server-7c040c0bf97c2d3a63051a819dc480403d3b96fb.tar.gz
nextcloud-server-7c040c0bf97c2d3a63051a819dc480403d3b96fb.zip
Show the path relative to the requesting user
A share can only be requested by 3 'types' of people * owner * initiator * recipient So we have to get the path as the current user. Since that is the only path that has any meaning to the user.
-rw-r--r--apps/files_sharing/lib/API/Share20OCS.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php
index 90e1f19130c..53b27aae0b8 100644
--- a/apps/files_sharing/lib/API/Share20OCS.php
+++ b/apps/files_sharing/lib/API/Share20OCS.php
@@ -100,15 +100,8 @@ class Share20OCS {
*/
protected function formatShare(\OCP\Share\IShare $share) {
$sharedBy = $this->userManager->get($share->getSharedBy());
- // for federated shares the owner can be a remote user, in this
- // case we use the initiator
- if ($this->userManager->userExists($share->getShareOwner())) {
- $shareOwner = $this->userManager->get($share->getShareOwner());
- $localUser = $share->getShareOwner();
- } else {
- $shareOwner = $this->userManager->get($share->getSharedBy());
- $localUser = $share->getSharedBy();
- }
+ $shareOwner = $this->userManager->get($share->getShareOwner());
+
$result = [
'id' => $share->getId(),
'share_type' => $share->getShareType(),
@@ -123,8 +116,16 @@ class Share20OCS {
'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
];
- $node = $share->getNode();
- $result['path'] = $this->rootFolder->getUserFolder($localUser)->getRelativePath($node->getPath());
+ $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID());
+ $nodes = $userFolder->getById($share->getNodeId());
+
+ if (empty($nodes)) {
+ throw new NotFoundException();
+ }
+
+ $node = $nodes[0];
+
+ $result['path'] = $userFolder->getRelativePath($node->getPath());
if ($node instanceOf \OCP\Files\Folder) {
$result['item_type'] = 'folder';
} else {
@@ -536,7 +537,6 @@ class Share20OCS {
$shares = array_merge($shares, $federatedShares);
}
-
$formatted = [];
foreach ($shares as $share) {
try {