IShareProvider.php 5.8 KB

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