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.

180 lines
4.5 KiB

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