IManager.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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\Node;
  24. use OCP\Share\Exceptions\ShareNotFound;
  25. /**
  26. * Interface IManager
  27. *
  28. * @package OCP\Share
  29. * @since 9.0.0
  30. */
  31. interface IManager {
  32. /**
  33. * Create a Share
  34. *
  35. * @param IShare $share
  36. * @return IShare The share object
  37. * @since 9.0.0
  38. */
  39. public function createShare(IShare $share);
  40. /**
  41. * Update a share.
  42. * The target of the share can't be changed this way: use moveShare
  43. * The share can't be removed this way (permission 0): use deleteShare
  44. *
  45. * @param IShare $share
  46. * @return IShare The share object
  47. * @since 9.0.0
  48. */
  49. public function updateShare(IShare $share);
  50. /**
  51. * Delete a share
  52. *
  53. * @param IShare $share
  54. * @throws ShareNotFound
  55. * @since 9.0.0
  56. */
  57. public function deleteShare(IShare $share);
  58. /**
  59. * Unshare a file as the recipient.
  60. * This can be different from a regular delete for example when one of
  61. * the users in a groups deletes that share. But the provider should
  62. * handle this.
  63. *
  64. * @param IShare $share
  65. * @param string $recipientId
  66. * @since 9.0.0
  67. */
  68. public function deleteFromSelf(IShare $share, $recipientId);
  69. /**
  70. * Move the share as a recipient of the share.
  71. * This is updating the share target. So where the recipient has the share mounted.
  72. *
  73. * @param IShare $share
  74. * @param string $recipientId
  75. * @return IShare
  76. * @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
  77. * @since 9.0.0
  78. */
  79. public function moveShare(IShare $share, $recipientId);
  80. /**
  81. * Get shares shared by (initiated) by the provided user.
  82. *
  83. * @param string $userId
  84. * @param int $shareType
  85. * @param Node|null $path
  86. * @param bool $reshares
  87. * @param int $limit The maximum number of returned results, -1 for all results
  88. * @param int $offset
  89. * @return IShare[]
  90. * @since 9.0.0
  91. */
  92. public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
  93. /**
  94. * Get shares shared with $user.
  95. * Filter by $node if provided
  96. *
  97. * @param string $userId
  98. * @param int $shareType
  99. * @param Node|null $node
  100. * @param int $limit The maximum number of shares returned, -1 for all
  101. * @param int $offset
  102. * @return IShare[]
  103. * @since 9.0.0
  104. */
  105. public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
  106. /**
  107. * Retrieve a share by the share id.
  108. * If the recipient is set make sure to retrieve the file for that user.
  109. * This makes sure that if a user has moved/deleted a group share this
  110. * is reflected.
  111. *
  112. * @param string $id
  113. * @param string|null $recipient userID of the recipient
  114. * @return IShare
  115. * @throws ShareNotFound
  116. * @since 9.0.0
  117. */
  118. public function getShareById($id, $recipient = null);
  119. /**
  120. * Get the share by token possible with password
  121. *
  122. * @param string $token
  123. * @return IShare
  124. * @throws ShareNotFound
  125. * @since 9.0.0
  126. */
  127. public function getShareByToken($token);
  128. /**
  129. * Verify the password of a public share
  130. *
  131. * @param IShare $share
  132. * @param string $password
  133. * @return bool
  134. * @since 9.0.0
  135. */
  136. public function checkPassword(IShare $share, $password);
  137. /**
  138. * The user with UID is deleted.
  139. * All share providers have to cleanup the shares with this user as well
  140. * as shares owned by this user.
  141. * Shares only initiated by this user are fine.
  142. *
  143. * @param string $uid
  144. * @since 9.1.0
  145. */
  146. public function userDeleted($uid);
  147. /**
  148. * The group with $gid is deleted
  149. * We need to clear up all shares to this group
  150. *
  151. * @param string $gid
  152. * @since 9.1.0
  153. */
  154. public function groupDeleted($gid);
  155. /**
  156. * The user $uid is deleted from the group $gid
  157. * All user specific group shares have to be removed
  158. *
  159. * @param string $uid
  160. * @param string $gid
  161. * @since 9.1.0
  162. */
  163. public function userDeletedFromGroup($uid, $gid);
  164. /**
  165. * Instantiates a new share object. This is to be passed to
  166. * createShare.
  167. *
  168. * @return IShare
  169. * @since 9.0.0
  170. */
  171. public function newShare();
  172. /**
  173. * Is the share API enabled
  174. *
  175. * @return bool
  176. * @since 9.0.0
  177. */
  178. public function shareApiEnabled();
  179. /**
  180. * Is public link sharing enabled
  181. *
  182. * @return bool
  183. * @since 9.0.0
  184. */
  185. public function shareApiAllowLinks();
  186. /**
  187. * Is password on public link requires
  188. *
  189. * @return bool
  190. * @since 9.0.0
  191. */
  192. public function shareApiLinkEnforcePassword();
  193. /**
  194. * Is default expire date enabled
  195. *
  196. * @return bool
  197. * @since 9.0.0
  198. */
  199. public function shareApiLinkDefaultExpireDate();
  200. /**
  201. * Is default expire date enforced
  202. *`
  203. * @return bool
  204. * @since 9.0.0
  205. */
  206. public function shareApiLinkDefaultExpireDateEnforced();
  207. /**
  208. * Number of default expire days
  209. *
  210. * @return int
  211. * @since 9.0.0
  212. */
  213. public function shareApiLinkDefaultExpireDays();
  214. /**
  215. * Allow public upload on link shares
  216. *
  217. * @return bool
  218. * @since 9.0.0
  219. */
  220. public function shareApiLinkAllowPublicUpload();
  221. /**
  222. * check if user can only share with group members
  223. * @return bool
  224. * @since 9.0.0
  225. */
  226. public function shareWithGroupMembersOnly();
  227. /**
  228. * Check if users can share with groups
  229. * @return bool
  230. * @since 9.0.1
  231. */
  232. public function allowGroupSharing();
  233. /**
  234. * Check if sharing is disabled for the given user
  235. *
  236. * @param string $userId
  237. * @return bool
  238. * @since 9.0.0
  239. */
  240. public function sharingDisabledForUser($userId);
  241. /**
  242. * Check if outgoing server2server shares are allowed
  243. * @return bool
  244. * @since 9.0.0
  245. */
  246. public function outgoingServer2ServerSharesAllowed();
  247. }