Browse Source

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.
tags/v9.1.0RC1
Roeland Jago Douma 8 years ago
parent
commit
7c040c0bf9
No account linked to committer's email address
1 changed files with 12 additions and 12 deletions
  1. 12
    12
      apps/files_sharing/lib/API/Share20OCS.php

+ 12
- 12
apps/files_sharing/lib/API/Share20OCS.php View File

@@ -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 {

Loading…
Cancel
Save