From 78be766cf543d738a3822a3cd614634acb7262d0 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 2 Feb 2016 16:55:41 +0100 Subject: [PATCH] [Share 2.0] Use strings for ids * sharedWith * sharedBy * shareOwner Now all set/get strings with the id. (userId, groupId, federatedsharerId). This to avoid a huge amount of if statements --- lib/private/share20/share.php | 9 +++++++++ lib/public/share/ishare.php | 12 ++++++------ lib/public/share/ishareprovider.php | 22 +++++++++++----------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php index f9cba10a07..db91ad4a91 100644 --- a/lib/private/share20/share.php +++ b/lib/private/share20/share.php @@ -121,6 +121,9 @@ class Share implements \OCP\Share\IShare { * @inheritdoc */ public function setSharedWith($sharedWith) { + if (!is_string($sharedWith)) { + throw new \InvalidArgumentException(); + } $this->sharedWith = $sharedWith; return $this; } @@ -170,6 +173,9 @@ class Share implements \OCP\Share\IShare { * @inheritdoc */ public function setSharedBy($sharedBy) { + if (!is_string($sharedBy)) { + throw new \InvalidArgumentException(); + } //TODO checks $this->sharedBy = $sharedBy; @@ -188,6 +194,9 @@ class Share implements \OCP\Share\IShare { * @inheritdoc */ public function setShareOwner($shareOwner) { + if (!is_string($shareOwner)) { + throw new \InvalidArgumentException(); + } //TODO checks $this->shareOwner = $shareOwner; diff --git a/lib/public/share/ishare.php b/lib/public/share/ishare.php index 80e7f7f56e..5a82436c72 100644 --- a/lib/public/share/ishare.php +++ b/lib/public/share/ishare.php @@ -89,7 +89,7 @@ interface IShare { /** * Set the receiver of this share. * - * @param IUser|IGroup + * @param string $sharedWith * @return \OCP\Share\IShare The modified object * @since 9.0.0 */ @@ -98,7 +98,7 @@ interface IShare { /** * Get the receiver of this share. * - * @return IUser|IGroup + * @return string * @since 9.0.0 */ public function getSharedWith(); @@ -142,7 +142,7 @@ interface IShare { /** * Set the sharer of the path. * - * @param IUser $sharedBy + * @param string $sharedBy * @return \OCP\Share\IShare The modified object * @since 9.0.0 */ @@ -151,7 +151,7 @@ interface IShare { /** * Get share sharer * - * @return IUser + * @return string * @since 9.0.0 */ public function getSharedBy(); @@ -159,7 +159,7 @@ interface IShare { /** * Set the original share owner (who owns the path that is shared) * - * @param IUser + * @param string $shareOwner * @return \OCP\Share\IShare The modified object * @since 9.0.0 */ @@ -168,7 +168,7 @@ interface IShare { /** * Get the original share owner (who owns the path that is shared) * - * @return IUser + * @return string * @since 9.0.0 */ public function getShareOwner(); diff --git a/lib/public/share/ishareprovider.php b/lib/public/share/ishareprovider.php index 42a2881718..a14d58734b 100644 --- a/lib/public/share/ishareprovider.php +++ b/lib/public/share/ishareprovider.php @@ -74,10 +74,10 @@ interface IShareProvider { * share from their self then the original group share should still exist. * * @param \OCP\Share\IShare $share - * @param IUser $recipient + * @param string $recipient UserId of the recipient * @since 9.0.0 */ - public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient); + public function deleteFromSelf(\OCP\Share\IShare $share, $recipient); /** * Move a share as a recipient. @@ -86,36 +86,36 @@ interface IShareProvider { * the target should only be changed for them. * * @param \OCP\Share\IShare $share - * @param IUser $recipient + * @param string $recipient userId of recipient * @return \OCP\Share\IShare * @since 9.0.0 */ - public function move(\OCP\Share\IShare $share, IUser $recipient); + public function move(\OCP\Share\IShare $share, $recipient); /** * Get all shares by the given user * - * @param IUser $user + * @param string $userId * @param int $shareType * @param \OCP\Files\File|\OCP\Files\Folder $node * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator * @param int $limit The maximum number of shares to be returned, -1 for all shares * @param int $offset - * @return \OCP\Share\I Share[] + * @return \OCP\Share\IShare Share[] * @since 9.0.0 */ - public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset); + public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset); /** * Get share by id * * @param int $id - * @param IUser|null $recipient + * @param string|null $recipientId * @return \OCP\Share\IShare * @throws ShareNotFound * @since 9.0.0 */ - public function getShareById($id, $recipient = null); + public function getShareById($id, $recipientId = null); /** * Get shares for a given path @@ -129,7 +129,7 @@ interface IShareProvider { /** * Get shared with the given user * - * @param IUser $user get shares where this user is the recipient + * @param stromg $userId get shares where this user is the recipient * @param int $shareType * @param Node|null $node * @param int $limit The max number of entries returned, -1 for all @@ -137,7 +137,7 @@ interface IShareProvider { * @return \OCP\Share\IShare[] * @since 9.0.0 */ - public function getSharedWith(IUser $user, $shareType, $node, $limit, $offset); + public function getSharedWith($userId, $shareType, $node, $limit, $offset); /** * Get a share by token