123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- <?php
- /**
- * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
- * SPDX-License-Identifier: AGPL-3.0-only
- */
- namespace OCP\Share;
- use OCP\Files\Folder;
- use OCP\Files\Node;
- use OCP\IUser;
- use OCP\Share\Exceptions\GenericShareException;
- use OCP\Share\Exceptions\ShareNotFound;
- /**
- * This interface allows to manage sharing files between users and groups.
- *
- * This interface must not be implemented in your application but
- * instead should be used as a service and injected in your code with
- * dependency injection.
- *
- * @since 9.0.0
- */
- interface IManager {
- /**
- * Create a Share
- *
- * @param IShare $share
- * @return IShare The share object
- * @throws \Exception
- * @since 9.0.0
- */
- public function createShare(IShare $share);
- /**
- * 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
- * The state can't be changed this way: use acceptShare
- *
- * @param IShare $share
- * @return IShare The share object
- * @throws \InvalidArgumentException
- * @since 9.0.0
- */
- public function updateShare(IShare $share);
- /**
- * 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;
- /**
- * Delete a share
- *
- * @param IShare $share
- * @throws ShareNotFound
- * @throws \InvalidArgumentException
- * @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
- * @param string $recipientId
- * @since 9.0.0
- */
- public function deleteFromSelf(IShare $share, $recipientId);
- /**
- * 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;
- /**
- * 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
- * @param string $recipientId
- * @return IShare
- * @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
- * @since 9.0.0
- */
- public function moveShare(IShare $share, $recipientId);
- /**
- * Get all shares shared by (initiated) by the provided user in a folder.
- *
- * @param string $userId
- * @param Folder $node
- * @param bool $reshares
- * @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
- * @return IShare[][] [$fileId => IShare[], ...]
- * @since 11.0.0
- */
- public function getSharesInFolder($userId, Folder $node, $reshares = false, $shallow = true);
- /**
- * Get shares shared by (initiated) by the provided user.
- *
- * @param string $userId
- * @param int $shareType
- * @param Node|null $path
- * @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
- */
- public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
- /**
- * Get 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[]
- * @since 9.0.0
- */
- public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
- /**
- * 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[]
- * @since 14.0.0
- */
- public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
- /**
- * 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.
- *
- * @param string $id
- * @param string|null $recipient userID of the recipient
- * @return IShare
- * @throws ShareNotFound
- * @since 9.0.0
- */
- public function getShareById($id, $recipient = null);
- /**
- * Get the share by token possible with password
- *
- * @param string $token
- * @return IShare
- * @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);
- /**
- * 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);
- /**
- * The group with $gid is deleted
- * We need to clear up all shares to this group
- *
- * @param string $gid
- * @since 9.1.0
- */
- public function groupDeleted($gid);
- /**
- * 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);
- /**
- * Get access list to a path. This means
- * all the users that can access a given path.
- *
- * Consider:
- * -root
- * |-folder1 (23)
- * |-folder2 (32)
- * |-fileA (42)
- *
- * fileA is shared with user1 and user1@server1 and email1@maildomain1
- * folder2 is shared with group2 (user4 is a member of group2)
- * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
- * and email2@maildomain2
- *
- * Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
- * [
- * 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 => [
- * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'],
- * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'],
- * ]
- *
- * The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
- * [
- * users => ['user1', 'user2', 'user4'],
- * remote => bool,
- * public => bool
- * mail => ['email1@maildomain1', 'email2@maildomain2']
- * ]
- *
- * This is required for encryption/activity
- *
- * @param \OCP\Files\Node $path
- * @param bool $recursive Should we check all parent folders as well
- * @param bool $currentAccess Should the user have currently access to the file
- * @return array
- * @since 12
- */
- public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false);
- /**
- * Instantiates a new share object. This is to be passed to
- * createShare.
- *
- * @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 required
- *
- * @param bool $checkGroupMembership Check group membership exclusion
- * @return bool
- * @since 9.0.0
- * @since 24.0.0 Added optional $checkGroupMembership parameter
- */
- public function shareApiLinkEnforcePassword(bool $checkGroupMembership = true);
- /**
- * 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();
- /**
- * Is default internal expire date enabled
- *
- * @return bool
- * @since 22.0.0
- */
- public function shareApiInternalDefaultExpireDate(): bool;
- /**
- * Is default remote expire date enabled
- *
- * @return bool
- * @since 22.0.0
- */
- public function shareApiRemoteDefaultExpireDate(): bool;
- /**
- * Is default expire date enforced
- *
- * @return bool
- * @since 22.0.0
- */
- public function shareApiInternalDefaultExpireDateEnforced(): bool;
- /**
- * Is default expire date enforced for remote shares
- *
- * @return bool
- * @since 22.0.0
- */
- public function shareApiRemoteDefaultExpireDateEnforced(): bool;
- /**
- * Number of default expire days
- *
- * @return int
- * @since 22.0.0
- */
- public function shareApiInternalDefaultExpireDays(): int;
- /**
- * Number of default expire days for remote shares
- *
- * @return int
- * @since 22.0.0
- */
- public function shareApiRemoteDefaultExpireDays(): int;
- /**
- * 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();
- /**
- * If shareWithGroupMembersOnly is enabled, return an optional
- * list of groups that must be excluded from the principle of
- * belonging to the same group.
- * @return array
- * @since 27.0.0
- */
- public function shareWithGroupMembersOnlyExcludeGroupsList();
- /**
- * Check if users can share with groups
- * @return bool
- * @since 9.0.1
- */
- public function allowGroupSharing();
- /**
- * 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;
- /**
- * Check if user enumeration is limited to the phonebook matches
- *
- * @return bool
- * @since 21.0.1
- */
- public function limitEnumerationToPhone(): bool;
- /**
- * Check if user enumeration is allowed to return on full match
- *
- * @return bool
- * @since 21.0.1
- */
- public function allowEnumerationFullMatch(): bool;
- /**
- * Check if the search should match the email
- *
- * @return bool
- * @since 25.0.0
- */
- public function matchEmail(): bool;
- /**
- * Check if the search should ignore the second in parentheses display name if there is any
- *
- * @return bool
- * @since 25.0.0
- */
- public function ignoreSecondDisplayName(): bool;
- /**
- * Check if the current user can enumerate the target user
- *
- * @param IUser|null $currentUser
- * @param IUser $targetUser
- * @return bool
- * @since 23.0.0
- */
- public function currentUserCanEnumerateTargetUser(?IUser $currentUser, IUser $targetUser): bool;
- /**
- * Check if sharing is disabled for the given user
- *
- * @param string $userId
- * @return bool
- * @since 9.0.0
- */
- public function sharingDisabledForUser($userId);
- /**
- * Check if outgoing server2server shares are allowed
- * @return bool
- * @since 9.0.0
- */
- public function outgoingServer2ServerSharesAllowed();
- /**
- * Check if outgoing server2server shares are allowed
- * @return bool
- * @since 14.0.0
- */
- public function outgoingServer2ServerGroupSharesAllowed();
- /**
- * Check if a given share provider exists
- * @param int $shareType
- * @return bool
- * @since 11.0.0
- */
- public function shareProviderExists($shareType);
- /**
- * @param string $shareProviderClass
- * @since 21.0.0
- */
- public function registerShareProvider(string $shareProviderClass): void;
- /**
- * @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
- * @since 18.0.0
- */
- public function getAllShares(): iterable;
- }
|