IShareProvider.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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\ShareNotFound;
  27. use OCP\Files\Node;
  28. /**
  29. * Interface IShareProvider
  30. *
  31. * @package OCP\Share
  32. * @since 9.0.0
  33. */
  34. interface IShareProvider {
  35. /**
  36. * Return the identifier of this provider.
  37. *
  38. * @return string Containing only [a-zA-Z0-9]
  39. * @since 9.0.0
  40. */
  41. public function identifier();
  42. /**
  43. * Create a share
  44. *
  45. * @param \OCP\Share\IShare $share
  46. * @return \OCP\Share\IShare The share object
  47. * @since 9.0.0
  48. */
  49. public function create(\OCP\Share\IShare $share);
  50. /**
  51. * Update a share
  52. *
  53. * @param \OCP\Share\IShare $share
  54. * @return \OCP\Share\IShare The share object
  55. * @since 9.0.0
  56. */
  57. public function update(\OCP\Share\IShare $share);
  58. /**
  59. * Delete a share
  60. *
  61. * @param \OCP\Share\IShare $share
  62. * @since 9.0.0
  63. */
  64. public function delete(\OCP\Share\IShare $share);
  65. /**
  66. * Unshare a file from self as recipient.
  67. * This may require special handling. If a user unshares a group
  68. * share from their self then the original group share should still exist.
  69. *
  70. * @param \OCP\Share\IShare $share
  71. * @param string $recipient UserId of the recipient
  72. * @since 9.0.0
  73. */
  74. public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
  75. /**
  76. * Move a share as a recipient.
  77. * This is updating the share target. Thus the mount point of the recipient.
  78. * This may require special handling. If a user moves a group share
  79. * the target should only be changed for them.
  80. *
  81. * @param \OCP\Share\IShare $share
  82. * @param string $recipient userId of recipient
  83. * @return \OCP\Share\IShare
  84. * @since 9.0.0
  85. */
  86. public function move(\OCP\Share\IShare $share, $recipient);
  87. /**
  88. * Get all shares by the given user in a folder
  89. *
  90. * @param string $userId
  91. * @param Folder $node
  92. * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
  93. * @return \OCP\Share\IShare[]
  94. * @since 11.0.0
  95. */
  96. public function getSharesInFolder($userId, Folder $node, $reshares);
  97. /**
  98. * Get all shares by the given user
  99. *
  100. * @param string $userId
  101. * @param int $shareType
  102. * @param Node|null $node
  103. * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
  104. * @param int $limit The maximum number of shares to be returned, -1 for all shares
  105. * @param int $offset
  106. * @return \OCP\Share\IShare[]
  107. * @since 9.0.0
  108. */
  109. public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset);
  110. /**
  111. * Get share by id
  112. *
  113. * @param int $id
  114. * @param string|null $recipientId
  115. * @return \OCP\Share\IShare
  116. * @throws ShareNotFound
  117. * @since 9.0.0
  118. */
  119. public function getShareById($id, $recipientId = null);
  120. /**
  121. * Get shares for a given path
  122. *
  123. * @param Node $path
  124. * @return \OCP\Share\IShare[]
  125. * @since 9.0.0
  126. */
  127. public function getSharesByPath(Node $path);
  128. /**
  129. * Get shared with the given user
  130. *
  131. * @param string $userId get shares where this user is the recipient
  132. * @param int $shareType
  133. * @param Node|null $node
  134. * @param int $limit The max number of entries returned, -1 for all
  135. * @param int $offset
  136. * @return \OCP\Share\IShare[]
  137. * @since 9.0.0
  138. */
  139. public function getSharedWith($userId, $shareType, $node, $limit, $offset);
  140. /**
  141. * Get a share by token
  142. *
  143. * @param string $token
  144. * @return \OCP\Share\IShare
  145. * @throws ShareNotFound
  146. * @since 9.0.0
  147. */
  148. public function getShareByToken($token);
  149. /**
  150. * A user is deleted from the system
  151. * So clean up the relevant shares.
  152. *
  153. * @param string $uid
  154. * @param int $shareType
  155. * @since 9.1.0
  156. */
  157. public function userDeleted($uid, $shareType);
  158. /**
  159. * A group is deleted from the system.
  160. * We have to clean up all shares to this group.
  161. * Providers not handling group shares should just return
  162. *
  163. * @param string $gid
  164. * @since 9.1.0
  165. */
  166. public function groupDeleted($gid);
  167. /**
  168. * A user is deleted from a group
  169. * We have to clean up all the related user specific group shares
  170. * Providers not handling group shares should just return
  171. *
  172. * @param string $uid
  173. * @param string $gid
  174. * @since 9.1.0
  175. */
  176. public function userDeletedFromGroup($uid, $gid);
  177. /**
  178. * Get the access list to the array of provided nodes.
  179. *
  180. * @see IManager::getAccessList() for sample docs
  181. *
  182. * @param Node[] $nodes The list of nodes to get access for
  183. * @param bool $currentAccess If current access is required (like for removed shares that might get revived later)
  184. * @return array
  185. * @since 12
  186. */
  187. public function getAccessList($nodes, $currentAccess);
  188. }