diff options
author | Björn Schießle <schiessle@owncloud.com> | 2016-05-11 20:48:27 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2016-05-20 21:15:15 +0200 |
commit | 7b25839bd51b3b6cd920209c254f014c03437113 (patch) | |
tree | 2e9885bdb068d56ff7bb9fde344c4da0cc95e2d3 /lib/private/Share20/Share.php | |
parent | 81e3787f9cb4936f186b25e0dccb07b4e6dcce83 (diff) | |
download | nextcloud-server-7b25839bd51b3b6cd920209c254f014c03437113.tar.gz nextcloud-server-7b25839bd51b3b6cd920209c254f014c03437113.zip |
use share initiator as fall back to access the file
in case of federated re-shares the owner can be a remote user.
Therefore we can't always use to owner to access the local file
Diffstat (limited to 'lib/private/Share20/Share.php')
-rw-r--r-- | lib/private/Share20/Share.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index c361f01216f..f56fd94b409 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -24,8 +24,7 @@ use OCP\Files\File; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; -use OCP\IUser; -use OCP\IGroup; +use OCP\IUserManager; use OCP\Share\Exceptions\IllegalIDChangeException; class Share implements \OCP\Share\IShare { @@ -68,8 +67,12 @@ class Share implements \OCP\Share\IShare { /** @var IRootFolder */ private $rootFolder; - public function __construct(IRootFolder $rootFolder) { + /** @var IUserManager */ + private $userManager; + + public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { $this->rootFolder = $rootFolder; + $this->userManager = $userManager; } /** @@ -145,7 +148,13 @@ class Share implements \OCP\Share\IShare { throw new NotFoundException(); } - $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); + // for federated shares the owner can be a remote user, in this + // case we use the initiator + if($this->userManager->userExists($this->shareOwner)) { + $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); + } else { + $userFolder = $this->rootFolder->getUserFolder($this->sharedBy); + } $nodes = $userFolder->getById($this->fileId); if (empty($nodes)) { |