You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCP\Share;
  27. use OCP\Files\Folder;
  28. use OCP\Files\Node;
  29. use OCP\Share\Exceptions\GenericShareException;
  30. use OCP\Share\Exceptions\ShareNotFound;
  31. /**
  32. * Interface IShareProvider
  33. *
  34. * @since 9.0.0
  35. */
  36. interface IShareProvider {
  37. /**
  38. * Return the identifier of this provider.
  39. *
  40. * @return string Containing only [a-zA-Z0-9]
  41. * @since 9.0.0
  42. */
  43. public function identifier();
  44. /**
  45. * Create a share
  46. *
  47. * @param \OCP\Share\IShare $share
  48. * @return \OCP\Share\IShare The share object
  49. * @since 9.0.0
  50. */
  51. public function create(\OCP\Share\IShare $share);
  52. /**
  53. * Update a share
  54. *
  55. * @param \OCP\Share\IShare $share
  56. * @return \OCP\Share\IShare The share object
  57. * @since 9.0.0
  58. */
  59. public function update(\OCP\Share\IShare $share);
  60. /**
  61. * Accept a share.
  62. *
  63. * @param IShare $share
  64. * @param string $recipient
  65. * @return IShare The share object
  66. * @since 17.0.0
  67. */
  68. // public function acceptShare(IShare $share, string $recipient): IShare;
  69. /**
  70. * Delete a share
  71. *
  72. * @param \OCP\Share\IShare $share
  73. * @since 9.0.0
  74. */
  75. public function delete(\OCP\Share\IShare $share);
  76. /**
  77. * Unshare a file from self as recipient.
  78. * This may require special handling. If a user unshares a group
  79. * share from their self then the original group share should still exist.
  80. *
  81. * @param \OCP\Share\IShare $share
  82. * @param string $recipient UserId of the recipient
  83. * @since 9.0.0
  84. */
  85. public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
  86. /**
  87. * Restore a share for a given recipient. The implementation could be provider independant.
  88. *
  89. * @param IShare $share
  90. * @param string $recipient
  91. * @return IShare The restored share object
  92. *
  93. * @since 14.0.0
  94. * @throws GenericShareException In case the share could not be restored
  95. */
  96. public function restore(IShare $share, string $recipient): IShare;
  97. /**
  98. * Move a share as a recipient.
  99. * This is updating the share target. Thus the mount point of the recipient.
  100. * This may require special handling. If a user moves a group share
  101. * the target should only be changed for them.
  102. *
  103. * @param \OCP\Share\IShare $share
  104. * @param string $recipient userId of recipient
  105. * @return \OCP\Share\IShare
  106. * @since 9.0.0
  107. */
  108. public function move(\OCP\Share\IShare $share, $recipient);
  109. /**
  110. * Get all shares by the given user in a folder
  111. *
  112. * @param string $userId
  113. * @param Folder $node
  114. * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
  115. * @return \OCP\Share\IShare[]
  116. * @since 11.0.0
  117. */
  118. public function getSharesInFolder($userId, Folder $node, $reshares);
  119. /**
  120. * Get all shares by the given user
  121. *
  122. * @param string $userId
  123. * @param int $shareType
  124. * @param Node|null $node
  125. * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
  126. * @param int $limit The maximum number of shares to be returned, -1 for all shares
  127. * @param int $offset
  128. * @return \OCP\Share\IShare[]
  129. * @since 9.0.0
  130. */
  131. public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset);
  132. /**
  133. * Get share by id
  134. *
  135. * @param int $id
  136. * @param string|null $recipientId
  137. * @return \OCP\Share\IShare
  138. * @throws ShareNotFound
  139. * @since 9.0.0
  140. */
  141. public function getShareById($id, $recipientId = null);
  142. /**
  143. * Get shares for a given path
  144. *
  145. * @param Node $path
  146. * @return \OCP\Share\IShare[]
  147. * @since 9.0.0
  148. */
  149. public function getSharesByPath(Node $path);
  150. /**
  151. * Get shared with the given user
  152. *
  153. * @param string $userId get shares where this user is the recipient
  154. * @param int $shareType
  155. * @param Node|null $node
  156. * @param int $limit The max number of entries returned, -1 for all
  157. * @param int $offset
  158. * @return \OCP\Share\IShare[]
  159. * @since 9.0.0
  160. */
  161. public function getSharedWith($userId, $shareType, $node, $limit, $offset);
  162. /**
  163. * Get a share by token
  164. *
  165. * @param string $token
  166. * @return \OCP\Share\IShare
  167. * @throws ShareNotFound
  168. * @since 9.0.0
  169. */
  170. public function getShareByToken($token);
  171. /**
  172. * A user is deleted from the system
  173. * So clean up the relevant shares.
  174. *
  175. * @param string $uid
  176. * @param int $shareType
  177. * @since 9.1.0
  178. */
  179. public function userDeleted($uid, $shareType);
  180. /**
  181. * A group is deleted from the system.
  182. * We have to clean up all shares to this group.
  183. * Providers not handling group shares should just return
  184. *
  185. * @param string $gid
  186. * @since 9.1.0
  187. */
  188. public function groupDeleted($gid);
  189. /**
  190. * A user is deleted from a group
  191. * We have to clean up all the related user specific group shares
  192. * Providers not handling group shares should just return
  193. *
  194. * @param string $uid
  195. * @param string $gid
  196. * @since 9.1.0
  197. */
  198. public function userDeletedFromGroup($uid, $gid);
  199. /**
  200. * Get the access list to the array of provided nodes.
  201. *
  202. * @see IManager::getAccessList() for sample docs
  203. *
  204. * @param Node[] $nodes The list of nodes to get access for
  205. * @param bool $currentAccess If current access is required (like for removed shares that might get revived later)
  206. * @return array
  207. * @since 12
  208. */
  209. public function getAccessList($nodes, $currentAccess);
  210. /**
  211. * Get all the shares in this provider returned as iterable to reduce memory
  212. * overhead
  213. *
  214. * @return iterable
  215. * @since 18.0.0
  216. */
  217. public function getAllShares(): iterable;
  218. }