summaryrefslogtreecommitdiffstats
path: root/lib/private/Share20
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share20')
-rw-r--r--lib/private/Share20/DefaultShareProvider.php2
-rw-r--r--lib/private/Share20/Manager.php15
-rw-r--r--lib/private/Share20/ProviderFactory.php3
-rw-r--r--lib/private/Share20/Share.php17
4 files changed, 28 insertions, 9 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index f0de39fdad3..8a39c18a495 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -733,7 +733,7 @@ class DefaultShareProvider implements IShareProvider {
* @throws InvalidShare
*/
private function createShare($data) {
- $share = new Share($this->rootFolder);
+ $share = new Share($this->rootFolder, $this->userManager);
$share->setId((int)$data['id'])
->setShareType((int)$data['share_type'])
->setPermissions((int)$data['permissions'])
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index dee9e0cdd21..3568995472a 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -201,7 +201,12 @@ class Manager implements IManager {
}
// And you can't share your rootfolder
- if ($this->rootFolder->getUserFolder($share->getSharedBy())->getPath() === $share->getNode()->getPath()) {
+ if ($this->userManager->userExists($share->getSharedBy())) {
+ $sharedPath = $this->rootFolder->getUserFolder($share->getSharedBy())->getPath();
+ } else {
+ $sharedPath = $this->rootFolder->getUserFolder($share->getShareOwner())->getPath();
+ }
+ if ($sharedPath === $share->getNode()->getPath()) {
throw new \InvalidArgumentException('You can\'t share your root folder');
}
@@ -713,7 +718,11 @@ class Manager implements IManager {
}
if ($share->getPermissions() !== $originalShare->getPermissions()) {
- $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
+ if ($this->userManager->userExists($share->getShareOwner())) {
+ $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
+ } else {
+ $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy());
+ }
\OC_Hook::emit('OCP\Share', 'post_update_permissions', array(
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(),
@@ -1107,7 +1116,7 @@ class Manager implements IManager {
* @return \OCP\Share\IShare;
*/
public function newShare() {
- return new \OC\Share20\Share($this->rootFolder);
+ return new \OC\Share20\Share($this->rootFolder, $this->userManager);
}
/**
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index 0bedfb84fc7..b436a7bc5f3 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -115,7 +115,8 @@ class ProviderFactory implements IProviderFactory {
$l,
$this->serverContainer->getLogger(),
$this->serverContainer->getLazyRootFolder(),
- $this->serverContainer->getConfig()
+ $this->serverContainer->getConfig(),
+ $this->serverContainer->getUserManager()
);
}
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)) {