From 2316cb1f8b9704621b47e6eb1c2cbf30c06c552d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 29 Jan 2016 10:27:39 +0100 Subject: [Share 2.0] Allow moving of shares * Only recipient can move a share * Unit tests --- lib/private/share20/manager.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/private/share20/manager.php') 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 @@ -714,6 +714,25 @@ class Manager implements IManager { $provider->deleteFromSelf($share, $recipient); } + /** + * @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. * -- cgit v1.2.3