2016-01-27 14:31:10 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2016-07-21 18:07:57 +03:00
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2016-07-21 18:07:57 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
2016-01-27 14:31:10 +03:00
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-01-27 14:31:10 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCP\Share;
|
|
|
|
|
2016-10-31 22:19:00 +03:00
|
|
|
use OCP\Files\Folder;
|
2016-03-11 10:51:07 +03:00
|
|
|
use OCP\Files\Node;
|
2016-01-27 14:31:10 +03:00
|
|
|
|
2018-06-19 10:20:35 +03:00
|
|
|
use OCP\Share\Exceptions\GenericShareException;
|
2016-03-10 23:35:22 +03:00
|
|
|
use OCP\Share\Exceptions\ShareNotFound;
|
2016-01-27 14:31:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface IManager
|
|
|
|
*
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
interface IManager {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a Share
|
|
|
|
*
|
|
|
|
* @param IShare $share
|
2016-01-29 12:27:39 +03:00
|
|
|
* @return IShare The share object
|
2017-09-10 21:01:15 +03:00
|
|
|
* @throws \Exception
|
2016-01-27 14:31:10 +03:00
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function createShare(IShare $share);
|
|
|
|
|
|
|
|
/**
|
2016-01-29 12:27:39 +03:00
|
|
|
* Update a share.
|
|
|
|
* The target of the share can't be changed this way: use moveShare
|
|
|
|
* The share can't be removed this way (permission 0): use deleteShare
|
2019-09-04 17:50:52 +03:00
|
|
|
* The state can't be changed this way: use acceptShare
|
2016-01-27 14:31:10 +03:00
|
|
|
*
|
|
|
|
* @param IShare $share
|
|
|
|
* @return IShare The share object
|
2017-09-10 21:01:15 +03:00
|
|
|
* @throws \InvalidArgumentException
|
2016-01-27 14:31:10 +03:00
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function updateShare(IShare $share);
|
|
|
|
|
|
|
|
/**
|
2019-09-04 17:50:52 +03:00
|
|
|
* Accept a share.
|
|
|
|
*
|
|
|
|
* @param IShare $share
|
|
|
|
* @param string $recipientId
|
|
|
|
* @return IShare The share object
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @since 18.0.0
|
|
|
|
*/
|
|
|
|
public function acceptShare(IShare $share, string $recipientId): IShare;
|
|
|
|
|
|
|
|
/**
|
2016-01-27 14:31:10 +03:00
|
|
|
* Delete a share
|
|
|
|
*
|
|
|
|
* @param IShare $share
|
|
|
|
* @throws ShareNotFound
|
2017-09-10 21:01:15 +03:00
|
|
|
* @throws \InvalidArgumentException
|
2016-01-27 14:31:10 +03:00
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function deleteShare(IShare $share);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unshare a file as the recipient.
|
|
|
|
* This can be different from a regular delete for example when one of
|
|
|
|
* the users in a groups deletes that share. But the provider should
|
|
|
|
* handle this.
|
|
|
|
*
|
|
|
|
* @param IShare $share
|
2016-02-02 23:02:09 +03:00
|
|
|
* @param string $recipientId
|
2016-01-27 14:31:10 +03:00
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2016-02-02 23:02:09 +03:00
|
|
|
public function deleteFromSelf(IShare $share, $recipientId);
|
2016-01-27 14:31:10 +03:00
|
|
|
|
2018-06-19 10:20:35 +03:00
|
|
|
/**
|
|
|
|
* Restore the share when it has been deleted
|
|
|
|
* Certain share types can be restored when they have been deleted
|
|
|
|
* but the provider should properly handle this\
|
|
|
|
*
|
|
|
|
* @param IShare $share The share to restore
|
|
|
|
* @param string $recipientId The user to restore the share for
|
|
|
|
* @return IShare The restored share object
|
|
|
|
* @throws GenericShareException In case restoring the share failed
|
|
|
|
*
|
|
|
|
* @since 14.0.0
|
|
|
|
*/
|
|
|
|
public function restoreShare(IShare $share, string $recipientId): IShare;
|
|
|
|
|
2016-01-29 12:27:39 +03:00
|
|
|
/**
|
|
|
|
* Move the share as a recipient of the share.
|
|
|
|
* This is updating the share target. So where the recipient has the share mounted.
|
|
|
|
*
|
|
|
|
* @param IShare $share
|
2016-02-02 23:02:09 +03:00
|
|
|
* @param string $recipientId
|
2016-01-29 12:27:39 +03:00
|
|
|
* @return IShare
|
|
|
|
* @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2016-02-02 23:02:09 +03:00
|
|
|
public function moveShare(IShare $share, $recipientId);
|
2016-01-29 12:27:39 +03:00
|
|
|
|
2016-06-18 23:04:56 +03:00
|
|
|
/**
|
|
|
|
* Get all shares shared by (initiated) by the provided user in a folder.
|
|
|
|
*
|
|
|
|
* @param string $userId
|
2016-10-31 22:19:00 +03:00
|
|
|
* @param Folder $node
|
2016-06-18 23:04:56 +03:00
|
|
|
* @param bool $reshares
|
2016-11-09 18:59:03 +03:00
|
|
|
* @return IShare[][] [$fileId => IShare[], ...]
|
2016-11-15 20:51:52 +03:00
|
|
|
* @since 11.0.0
|
2016-06-18 23:04:56 +03:00
|
|
|
*/
|
2016-10-31 22:19:00 +03:00
|
|
|
public function getSharesInFolder($userId, Folder $node, $reshares = false);
|
2016-06-18 23:04:56 +03:00
|
|
|
|
2016-01-27 14:31:10 +03:00
|
|
|
/**
|
|
|
|
* Get shares shared by (initiated) by the provided user.
|
|
|
|
*
|
2016-02-02 23:02:09 +03:00
|
|
|
* @param string $userId
|
2016-01-27 14:31:10 +03:00
|
|
|
* @param int $shareType
|
2016-03-11 10:51:07 +03:00
|
|
|
* @param Node|null $path
|
2016-01-27 14:31:10 +03:00
|
|
|
* @param bool $reshares
|
|
|
|
* @param int $limit The maximum number of returned results, -1 for all results
|
|
|
|
* @param int $offset
|
|
|
|
* @return IShare[]
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2016-02-02 23:02:09 +03:00
|
|
|
public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
|
2016-01-27 14:31:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get shares shared with $user.
|
2016-01-29 17:26:04 +03:00
|
|
|
* Filter by $node if provided
|
2016-01-27 14:31:10 +03:00
|
|
|
*
|
2016-02-02 23:02:09 +03:00
|
|
|
* @param string $userId
|
2016-01-27 14:31:10 +03:00
|
|
|
* @param int $shareType
|
2016-03-11 10:51:07 +03:00
|
|
|
* @param Node|null $node
|
2016-01-27 14:31:10 +03:00
|
|
|
* @param int $limit The maximum number of shares returned, -1 for all
|
|
|
|
* @param int $offset
|
|
|
|
* @return IShare[]
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2016-02-02 23:02:09 +03:00
|
|
|
public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
|
2016-01-27 14:31:10 +03:00
|
|
|
|
2018-06-19 18:44:20 +03:00
|
|
|
/**
|
|
|
|
* Get deleted shares shared with $user.
|
|
|
|
* Filter by $node if provided
|
|
|
|
*
|
|
|
|
* @param string $userId
|
|
|
|
* @param int $shareType
|
|
|
|
* @param Node|null $node
|
|
|
|
* @param int $limit The maximum number of shares returned, -1 for all
|
|
|
|
* @param int $offset
|
|
|
|
* @return IShare[]
|
2018-06-26 09:59:59 +03:00
|
|
|
* @since 14.0.0
|
2018-06-19 18:44:20 +03:00
|
|
|
*/
|
|
|
|
public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
|
|
|
|
|
2016-01-27 14:31:10 +03:00
|
|
|
/**
|
2016-01-29 12:07:28 +03:00
|
|
|
* Retrieve a share by the share id.
|
|
|
|
* If the recipient is set make sure to retrieve the file for that user.
|
|
|
|
* This makes sure that if a user has moved/deleted a group share this
|
|
|
|
* is reflected.
|
2016-01-27 14:31:10 +03:00
|
|
|
*
|
|
|
|
* @param string $id
|
2016-05-10 13:43:35 +03:00
|
|
|
* @param string|null $recipient userID of the recipient
|
2016-01-29 12:07:28 +03:00
|
|
|
* @return IShare
|
2016-01-27 14:31:10 +03:00
|
|
|
* @throws ShareNotFound
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2016-01-29 12:07:28 +03:00
|
|
|
public function getShareById($id, $recipient = null);
|
2016-01-27 14:31:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the share by token possible with password
|
|
|
|
*
|
|
|
|
* @param string $token
|
2016-01-29 12:27:39 +03:00
|
|
|
* @return IShare
|
2016-01-27 14:31:10 +03:00
|
|
|
* @throws ShareNotFound
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getShareByToken($token);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify the password of a public share
|
|
|
|
*
|
|
|
|
* @param IShare $share
|
|
|
|
* @param string $password
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function checkPassword(IShare $share, $password);
|
|
|
|
|
2016-04-04 13:28:19 +03:00
|
|
|
/**
|
|
|
|
* The user with UID is deleted.
|
|
|
|
* All share providers have to cleanup the shares with this user as well
|
|
|
|
* as shares owned by this user.
|
|
|
|
* Shares only initiated by this user are fine.
|
|
|
|
*
|
|
|
|
* @param string $uid
|
|
|
|
* @since 9.1.0
|
|
|
|
*/
|
|
|
|
public function userDeleted($uid);
|
|
|
|
|
2016-04-12 10:46:25 +03:00
|
|
|
/**
|
|
|
|
* The group with $gid is deleted
|
|
|
|
* We need to clear up all shares to this group
|
|
|
|
*
|
2016-04-13 16:00:12 +03:00
|
|
|
* @param string $gid
|
2016-04-12 10:46:25 +03:00
|
|
|
* @since 9.1.0
|
|
|
|
*/
|
|
|
|
public function groupDeleted($gid);
|
|
|
|
|
2016-04-13 16:00:12 +03:00
|
|
|
/**
|
|
|
|
* The user $uid is deleted from the group $gid
|
|
|
|
* All user specific group shares have to be removed
|
|
|
|
*
|
|
|
|
* @param string $uid
|
|
|
|
* @param string $gid
|
|
|
|
* @since 9.1.0
|
|
|
|
*/
|
|
|
|
public function userDeletedFromGroup($uid, $gid);
|
|
|
|
|
2016-10-19 22:27:07 +03:00
|
|
|
/**
|
|
|
|
* Get access list to a path. This means
|
|
|
|
* all the users that can access a given path.
|
|
|
|
*
|
|
|
|
* Consider:
|
|
|
|
* -root
|
2017-04-11 13:40:36 +03:00
|
|
|
* |-folder1 (23)
|
|
|
|
* |-folder2 (32)
|
|
|
|
* |-fileA (42)
|
2016-10-19 22:27:07 +03:00
|
|
|
*
|
2017-04-11 13:40:36 +03:00
|
|
|
* fileA is shared with user1 and user1@server1
|
2016-10-19 22:27:07 +03:00
|
|
|
* folder2 is shared with group2 (user4 is a member of group2)
|
2017-04-11 13:40:36 +03:00
|
|
|
* folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
|
2016-10-19 22:27:07 +03:00
|
|
|
*
|
2017-04-11 13:40:36 +03:00
|
|
|
* Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
|
2016-10-19 22:27:07 +03:00
|
|
|
* [
|
2017-04-11 13:40:36 +03:00
|
|
|
* users => [
|
|
|
|
* 'user1' => ['node_id' => 42, 'node_path' => '/fileA'],
|
|
|
|
* 'user4' => ['node_id' => 32, 'node_path' => '/folder2'],
|
|
|
|
* 'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'],
|
|
|
|
* ],
|
|
|
|
* remote => [
|
|
|
|
* 'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'],
|
|
|
|
* 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
|
|
|
|
* ],
|
|
|
|
* public => bool
|
|
|
|
* mail => bool
|
|
|
|
* ]
|
|
|
|
*
|
|
|
|
* The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
|
|
|
|
* [
|
|
|
|
* users => ['user1', 'user2', 'user4'],
|
|
|
|
* remote => bool,
|
2016-10-19 22:27:07 +03:00
|
|
|
* public => bool
|
2017-03-27 17:06:31 +03:00
|
|
|
* mail => bool
|
2016-10-19 22:27:07 +03:00
|
|
|
* ]
|
|
|
|
*
|
|
|
|
* This is required for encryption/activity
|
|
|
|
*
|
|
|
|
* @param \OCP\Files\Node $path
|
|
|
|
* @param bool $recursive Should we check all parent folders as well
|
2017-03-20 16:22:06 +03:00
|
|
|
* @param bool $currentAccess Should the user have currently access to the file
|
2016-10-19 22:27:07 +03:00
|
|
|
* @return array
|
2017-03-20 16:22:06 +03:00
|
|
|
* @since 12
|
2016-10-19 22:27:07 +03:00
|
|
|
*/
|
2017-03-20 16:22:06 +03:00
|
|
|
public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false);
|
2016-10-19 22:27:07 +03:00
|
|
|
|
2016-01-27 14:31:10 +03:00
|
|
|
/**
|
2016-01-27 22:51:26 +03:00
|
|
|
* Instantiates a new share object. This is to be passed to
|
|
|
|
* createShare.
|
|
|
|
*
|
2016-01-27 14:31:10 +03:00
|
|
|
* @return IShare
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function newShare();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the share API enabled
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiEnabled();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is public link sharing enabled
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiAllowLinks();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is password on public link requires
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiLinkEnforcePassword();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is default expire date enabled
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiLinkDefaultExpireDate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is default expire date enforced
|
|
|
|
*`
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiLinkDefaultExpireDateEnforced();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of default expire days
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiLinkDefaultExpireDays();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allow public upload on link shares
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareApiLinkAllowPublicUpload();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* check if user can only share with group members
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function shareWithGroupMembersOnly();
|
|
|
|
|
2016-03-18 18:34:23 +03:00
|
|
|
/**
|
|
|
|
* Check if users can share with groups
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.1
|
|
|
|
*/
|
|
|
|
public function allowGroupSharing();
|
|
|
|
|
2020-02-20 20:51:35 +03:00
|
|
|
/**
|
|
|
|
* Check if user enumeration is allowed
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function allowEnumeration(): bool;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if user enumeration is limited to the users groups
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function limitEnumerationToGroups(): bool;
|
|
|
|
|
2021-03-09 23:48:48 +03:00
|
|
|
/**
|
|
|
|
* Check if user enumeration is limited to the phonebook matches
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 21.0.1
|
|
|
|
*/
|
|
|
|
public function limitEnumerationToPhone(): bool;
|
|
|
|
|
2016-01-27 14:31:10 +03:00
|
|
|
/**
|
|
|
|
* Check if sharing is disabled for the given user
|
|
|
|
*
|
2016-02-02 23:02:09 +03:00
|
|
|
* @param string $userId
|
2016-01-27 14:31:10 +03:00
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2016-02-02 23:02:09 +03:00
|
|
|
public function sharingDisabledForUser($userId);
|
2016-01-27 14:31:10 +03:00
|
|
|
|
2016-02-04 13:13:06 +03:00
|
|
|
/**
|
|
|
|
* Check if outgoing server2server shares are allowed
|
|
|
|
* @return bool
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function outgoingServer2ServerSharesAllowed();
|
|
|
|
|
2018-06-13 15:19:59 +03:00
|
|
|
/**
|
|
|
|
* Check if outgoing server2server shares are allowed
|
|
|
|
* @return bool
|
|
|
|
* @since 14.0.0
|
|
|
|
*/
|
|
|
|
public function outgoingServer2ServerGroupSharesAllowed();
|
|
|
|
|
|
|
|
|
2016-10-24 18:03:36 +03:00
|
|
|
/**
|
|
|
|
* Check if a given share provider exists
|
|
|
|
* @param int $shareType
|
|
|
|
* @return bool
|
2016-11-15 20:51:52 +03:00
|
|
|
* @since 11.0.0
|
2016-10-24 18:03:36 +03:00
|
|
|
*/
|
|
|
|
public function shareProviderExists($shareType);
|
|
|
|
|
2020-12-03 17:51:58 +03:00
|
|
|
/**
|
|
|
|
* @param string $shareProviderClass
|
|
|
|
* @since 21.0.0
|
|
|
|
*/
|
|
|
|
public function registerShareProvider(string $shareProviderClass): void;
|
|
|
|
|
2019-10-29 18:56:06 +03:00
|
|
|
/**
|
|
|
|
* @Internal
|
|
|
|
*
|
|
|
|
* Get all the shares as iterable to reduce memory overhead
|
|
|
|
* Note, since this opens up database cursors the iterable should
|
|
|
|
* be fully itterated.
|
|
|
|
*
|
|
|
|
* @return iterable
|
2019-10-30 16:26:37 +03:00
|
|
|
* @since 18.0.0
|
2019-10-29 18:56:06 +03:00
|
|
|
*/
|
|
|
|
public function getAllShares(): iterable;
|
2016-01-27 14:31:10 +03:00
|
|
|
}
|