IShareProvider.php 4.9 KB

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