IManager.php 6.6 KB

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