diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-29 10:27:39 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-02 11:34:52 +0100 |
commit | 2316cb1f8b9704621b47e6eb1c2cbf30c06c552d (patch) | |
tree | ca606e3695c30823e8967c5f875e359e5e98b4d2 /lib/private/share20/manager.php | |
parent | 8ebdfd0e05331ed557920dac915653c309424797 (diff) | |
download | nextcloud-server-2316cb1f8b9704621b47e6eb1c2cbf30c06c552d.tar.gz nextcloud-server-2316cb1f8b9704621b47e6eb1c2cbf30c06c552d.zip |
[Share 2.0] Allow moving of shares
* Only recipient can move a share
* Unit tests
Diffstat (limited to 'lib/private/share20/manager.php')
-rw-r--r-- | lib/private/share20/manager.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 3c5bd197ae8..438396501e3 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -715,6 +715,25 @@ class Manager implements IManager { } /** + * @inheritdoc + */ + public function moveShare(\OCP\Share\IShare $share, IUser $recipient) { + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { + throw new \InvalidArgumentException('Can\'t change target of link share'); + } + + if (($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipient) || + ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && !$share->getSharedWith()->inGroup($recipient))) { + throw new \InvalidArgumentException('Invalid recipient'); + } + + list($providerId, ) = $this->splitFullId($share->getId()); + $provider = $this->factory->getProvider($providerId); + + $provider->move($share, $recipient); + } + + /** * Get shares shared by (initiated) by the provided user. * * @param IUser $user |