[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
This commit is contained in:
Roeland Jago Douma 2016-02-02 16:55:41 +01:00
parent c0322b3f98
commit 78be766cf5
3 changed files with 26 additions and 17 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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