IShareProvider.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Share;
  8. use OCP\Files\Folder;
  9. use OCP\Files\Node;
  10. use OCP\Share\Exceptions\GenericShareException;
  11. use OCP\Share\Exceptions\ShareNotFound;
  12. /**
  13. * Interface IShareProvider
  14. *
  15. * @since 9.0.0
  16. */
  17. interface IShareProvider {
  18. /**
  19. * Return the identifier of this provider.
  20. *
  21. * @return string Containing only [a-zA-Z0-9]
  22. * @since 9.0.0
  23. */
  24. public function identifier();
  25. /**
  26. * Create a share
  27. *
  28. * @param \OCP\Share\IShare $share
  29. * @return \OCP\Share\IShare The share object
  30. * @since 9.0.0
  31. */
  32. public function create(\OCP\Share\IShare $share);
  33. /**
  34. * Update a share
  35. *
  36. * @param \OCP\Share\IShare $share
  37. * @return \OCP\Share\IShare The share object
  38. * @since 9.0.0
  39. */
  40. public function update(\OCP\Share\IShare $share);
  41. /**
  42. * Accept a share.
  43. *
  44. * @param IShare $share
  45. * @param string $recipient
  46. * @return IShare The share object
  47. * @since 17.0.0
  48. */
  49. // public function acceptShare(IShare $share, string $recipient): IShare;
  50. /**
  51. * Delete a share
  52. *
  53. * @param \OCP\Share\IShare $share
  54. * @since 9.0.0
  55. */
  56. public function delete(\OCP\Share\IShare $share);
  57. /**
  58. * Unshare a file from self as recipient.
  59. * This may require special handling. If a user unshares a group
  60. * share from their self then the original group share should still exist.
  61. *
  62. * @param \OCP\Share\IShare $share
  63. * @param string $recipient UserId of the recipient
  64. * @since 9.0.0
  65. */
  66. public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
  67. /**
  68. * Restore a share for a given recipient. The implementation could be provider independant.
  69. *
  70. * @param IShare $share
  71. * @param string $recipient
  72. * @return IShare The restored share object
  73. *
  74. * @since 14.0.0
  75. * @throws GenericShareException In case the share could not be restored
  76. */
  77. public function restore(IShare $share, string $recipient): IShare;
  78. /**
  79. * Move a share as a recipient.
  80. * This is updating the share target. Thus the mount point of the recipient.
  81. * This may require special handling. If a user moves a group share
  82. * the target should only be changed for them.
  83. *
  84. * @param \OCP\Share\IShare $share
  85. * @param string $recipient userId of recipient
  86. * @return \OCP\Share\IShare
  87. * @since 9.0.0
  88. */
  89. public function move(\OCP\Share\IShare $share, $recipient);
  90. /**
  91. * Get all shares by the given user in a folder
  92. *
  93. * @param string $userId
  94. * @param Folder $node
  95. * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
  96. * @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
  97. * @return \OCP\Share\IShare[][]
  98. * @since 11.0.0
  99. */
  100. public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true);
  101. /**
  102. * Get all shares by the given user
  103. *
  104. * @param string $userId
  105. * @param int $shareType
  106. * @param Node|null $node
  107. * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
  108. * @param int $limit The maximum number of shares to be returned, -1 for all shares
  109. * @param int $offset
  110. * @return \OCP\Share\IShare[]
  111. * @since 9.0.0
  112. */
  113. public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset);
  114. /**
  115. * Get share by id
  116. *
  117. * @param int $id
  118. * @param string|null $recipientId
  119. * @return \OCP\Share\IShare
  120. * @throws ShareNotFound
  121. * @since 9.0.0
  122. */
  123. public function getShareById($id, $recipientId = null);
  124. /**
  125. * Get shares for a given path
  126. *
  127. * @param Node $path
  128. * @return \OCP\Share\IShare[]
  129. * @since 9.0.0
  130. */
  131. public function getSharesByPath(Node $path);
  132. /**
  133. * Get shared with the given user
  134. *
  135. * @param string $userId get shares where this user is the recipient
  136. * @param int $shareType
  137. * @param Node|null $node
  138. * @param int $limit The max number of entries returned, -1 for all
  139. * @param int $offset
  140. * @return \OCP\Share\IShare[]
  141. * @since 9.0.0
  142. */
  143. public function getSharedWith($userId, $shareType, $node, $limit, $offset);
  144. /**
  145. * Get a share by token
  146. *
  147. * @param string $token
  148. * @return \OCP\Share\IShare
  149. * @throws ShareNotFound
  150. * @since 9.0.0
  151. */
  152. public function getShareByToken($token);
  153. /**
  154. * A user is deleted from the system
  155. * So clean up the relevant shares.
  156. *
  157. * @param string $uid
  158. * @param int $shareType
  159. * @since 9.1.0
  160. */
  161. public function userDeleted($uid, $shareType);
  162. /**
  163. * A group is deleted from the system.
  164. * We have to clean up all shares to this group.
  165. * Providers not handling group shares should just return
  166. *
  167. * @param string $gid
  168. * @since 9.1.0
  169. */
  170. public function groupDeleted($gid);
  171. /**
  172. * A user is deleted from a group
  173. * We have to clean up all the related user specific group shares
  174. * Providers not handling group shares should just return
  175. *
  176. * @param string $uid
  177. * @param string $gid
  178. * @since 9.1.0
  179. */
  180. public function userDeletedFromGroup($uid, $gid);
  181. /**
  182. * Get the access list to the array of provided nodes.
  183. *
  184. * @see IManager::getAccessList() for sample docs
  185. *
  186. * @param Node[] $nodes The list of nodes to get access for
  187. * @param bool $currentAccess If current access is required (like for removed shares that might get revived later)
  188. * @return array
  189. * @since 12
  190. */
  191. public function getAccessList($nodes, $currentAccess);
  192. /**
  193. * Get all the shares in this provider returned as iterable to reduce memory
  194. * overhead
  195. *
  196. * @return iterable
  197. * @since 18.0.0
  198. */
  199. public function getAllShares(): iterable;
  200. }