diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-29 10:07:28 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-02 10:41:57 +0100 |
commit | 403547f0ea9f34b82fa0ea5e9d7ebc1144ffa0e7 (patch) | |
tree | 21cf2f654f4a368b50fa7c7ac10a88777d545b69 /lib/private | |
parent | 4777f78187cb758413db1b11f11ccb9304f12482 (diff) | |
download | nextcloud-server-403547f0ea9f34b82fa0ea5e9d7ebc1144ffa0e7.tar.gz nextcloud-server-403547f0ea9f34b82fa0ea5e9d7ebc1144ffa0e7.zip |
[Share 2.0] Allow recipient to be passed in to getShareById
* This allows us to retrieve usergroup shares for a given id.
If the user deleted a share or moved it this will be a different share
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/share20/defaultshareprovider.php | 24 | ||||
-rw-r--r-- | lib/private/share20/manager.php | 11 |
2 files changed, 15 insertions, 20 deletions
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php index 0fa1552a1e7..261ba5d4884 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/share20/defaultshareprovider.php @@ -448,13 +448,9 @@ class DefaultShareProvider implements IShareProvider { } /** - * Get share by id - * - * @param int $id - * @return \OCP\Share\IShare - * @throws ShareNotFound + * @inheritdoc */ - public function getShareById($id) { + public function getShareById($id, $recipient = null) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') @@ -463,12 +459,11 @@ class DefaultShareProvider implements IShareProvider { ->andWhere( $qb->expr()->in( 'share_type', - [ - $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), - $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), - $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), - $qb->expr()->literal(self::SHARE_TYPE_USERGROUP), - ] + $qb->createNamedParameter([ + \OCP\Share::SHARE_TYPE_USER, + \OCP\Share::SHARE_TYPE_GROUP, + \OCP\Share::SHARE_TYPE_LINK, + ], IQueryBuilder::PARAM_INT_ARRAY) ) ); @@ -486,6 +481,11 @@ class DefaultShareProvider implements IShareProvider { throw new ShareNotFound(); } + // If the recipient is set for a group share resolve to that user + if ($recipient !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + $share = $this->resolveGroupShare($share, $recipient); + } + return $share; } diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index e45fa4b40f9..3c65f67e486 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -746,14 +746,9 @@ class Manager implements IManager { } /** - * Retrieve a share by the share id - * - * @param string $id - * @return Share - * - * @throws ShareNotFound + * @inheritdoc */ - public function getShareById($id) { + public function getShareById($id, $recipient = null) { if ($id === null) { throw new ShareNotFound(); } @@ -761,7 +756,7 @@ class Manager implements IManager { list($providerId, $id) = $this->splitFullId($id); $provider = $this->factory->getProvider($providerId); - $share = $provider->getShareById($id); + $share = $provider->getShareById($id, $recipient); return $share; } |