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.

IManager.php 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCP\Share;
  27. use OCP\Files\Folder;
  28. use OCP\Files\Node;
  29. use OCP\Share\Exceptions\GenericShareException;
  30. use OCP\Share\Exceptions\ShareNotFound;
  31. /**
  32. * Interface IManager
  33. *
  34. * @package OCP\Share
  35. * @since 9.0.0
  36. */
  37. interface IManager {
  38. /**
  39. * Create a Share
  40. *
  41. * @param IShare $share
  42. * @return IShare The share object
  43. * @throws \Exception
  44. * @since 9.0.0
  45. */
  46. public function createShare(IShare $share);
  47. /**
  48. * Update a share.
  49. * The target of the share can't be changed this way: use moveShare
  50. * The share can't be removed this way (permission 0): use deleteShare
  51. *
  52. * @param IShare $share
  53. * @return IShare The share object
  54. * @throws \InvalidArgumentException
  55. * @since 9.0.0
  56. */
  57. public function updateShare(IShare $share);
  58. /**
  59. * Delete a share
  60. *
  61. * @param IShare $share
  62. * @throws ShareNotFound
  63. * @throws \InvalidArgumentException
  64. * @since 9.0.0
  65. */
  66. public function deleteShare(IShare $share);
  67. /**
  68. * Unshare a file as the recipient.
  69. * This can be different from a regular delete for example when one of
  70. * the users in a groups deletes that share. But the provider should
  71. * handle this.
  72. *
  73. * @param IShare $share
  74. * @param string $recipientId
  75. * @since 9.0.0
  76. */
  77. public function deleteFromSelf(IShare $share, $recipientId);
  78. /**
  79. * Restore the share when it has been deleted
  80. * Certain share types can be restored when they have been deleted
  81. * but the provider should properly handle this\
  82. *
  83. * @param IShare $share The share to restore
  84. * @param string $recipientId The user to restore the share for
  85. * @return IShare The restored share object
  86. * @throws GenericShareException In case restoring the share failed
  87. *
  88. * @since 14.0.0
  89. */
  90. public function restoreShare(IShare $share, string $recipientId): IShare;
  91. /**
  92. * Move the share as a recipient of the share.
  93. * This is updating the share target. So where the recipient has the share mounted.
  94. *
  95. * @param IShare $share
  96. * @param string $recipientId
  97. * @return IShare
  98. * @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
  99. * @since 9.0.0
  100. */
  101. public function moveShare(IShare $share, $recipientId);
  102. /**
  103. * Get all shares shared by (initiated) by the provided user in a folder.
  104. *
  105. * @param string $userId
  106. * @param Folder $node
  107. * @param bool $reshares
  108. * @return IShare[][] [$fileId => IShare[], ...]
  109. * @since 11.0.0
  110. */
  111. public function getSharesInFolder($userId, Folder $node, $reshares = false);
  112. /**
  113. * Get shares shared by (initiated) by the provided user.
  114. *
  115. * @param string $userId
  116. * @param int $shareType
  117. * @param Node|null $path
  118. * @param bool $reshares
  119. * @param int $limit The maximum number of returned results, -1 for all results
  120. * @param int $offset
  121. * @return IShare[]
  122. * @since 9.0.0
  123. */
  124. public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
  125. /**
  126. * Get shares shared with $user.
  127. * Filter by $node if provided
  128. *
  129. * @param string $userId
  130. * @param int $shareType
  131. * @param Node|null $node
  132. * @param int $limit The maximum number of shares returned, -1 for all
  133. * @param int $offset
  134. * @return IShare[]
  135. * @since 9.0.0
  136. */
  137. public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
  138. /**
  139. * Get deleted shares shared with $user.
  140. * Filter by $node if provided
  141. *
  142. * @param string $userId
  143. * @param int $shareType
  144. * @param Node|null $node
  145. * @param int $limit The maximum number of shares returned, -1 for all
  146. * @param int $offset
  147. * @return IShare[]
  148. * @since 14.0.0
  149. */
  150. public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
  151. /**
  152. * Retrieve a share by the share id.
  153. * If the recipient is set make sure to retrieve the file for that user.
  154. * This makes sure that if a user has moved/deleted a group share this
  155. * is reflected.
  156. *
  157. * @param string $id
  158. * @param string|null $recipient userID of the recipient
  159. * @return IShare
  160. * @throws ShareNotFound
  161. * @since 9.0.0
  162. */
  163. public function getShareById($id, $recipient = null);
  164. /**
  165. * Get the share by token possible with password
  166. *
  167. * @param string $token
  168. * @return IShare
  169. * @throws ShareNotFound
  170. * @since 9.0.0
  171. */
  172. public function getShareByToken($token);
  173. /**
  174. * Verify the password of a public share
  175. *
  176. * @param IShare $share
  177. * @param string $password
  178. * @return bool
  179. * @since 9.0.0
  180. */
  181. public function checkPassword(IShare $share, $password);
  182. /**
  183. * The user with UID is deleted.
  184. * All share providers have to cleanup the shares with this user as well
  185. * as shares owned by this user.
  186. * Shares only initiated by this user are fine.
  187. *
  188. * @param string $uid
  189. * @since 9.1.0
  190. */
  191. public function userDeleted($uid);
  192. /**
  193. * The group with $gid is deleted
  194. * We need to clear up all shares to this group
  195. *
  196. * @param string $gid
  197. * @since 9.1.0
  198. */
  199. public function groupDeleted($gid);
  200. /**
  201. * The user $uid is deleted from the group $gid
  202. * All user specific group shares have to be removed
  203. *
  204. * @param string $uid
  205. * @param string $gid
  206. * @since 9.1.0
  207. */
  208. public function userDeletedFromGroup($uid, $gid);
  209. /**
  210. * Get access list to a path. This means
  211. * all the users that can access a given path.
  212. *
  213. * Consider:
  214. * -root
  215. * |-folder1 (23)
  216. * |-folder2 (32)
  217. * |-fileA (42)
  218. *
  219. * fileA is shared with user1 and user1@server1
  220. * folder2 is shared with group2 (user4 is a member of group2)
  221. * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
  222. *
  223. * Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
  224. * [
  225. * users => [
  226. * 'user1' => ['node_id' => 42, 'node_path' => '/fileA'],
  227. * 'user4' => ['node_id' => 32, 'node_path' => '/folder2'],
  228. * 'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'],
  229. * ],
  230. * remote => [
  231. * 'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'],
  232. * 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
  233. * ],
  234. * public => bool
  235. * mail => bool
  236. * ]
  237. *
  238. * The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
  239. * [
  240. * users => ['user1', 'user2', 'user4'],
  241. * remote => bool,
  242. * public => bool
  243. * mail => bool
  244. * ]
  245. *
  246. * This is required for encryption/activity
  247. *
  248. * @param \OCP\Files\Node $path
  249. * @param bool $recursive Should we check all parent folders as well
  250. * @param bool $currentAccess Should the user have currently access to the file
  251. * @return array
  252. * @since 12
  253. */
  254. public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false);
  255. /**
  256. * Instantiates a new share object. This is to be passed to
  257. * createShare.
  258. *
  259. * @return IShare
  260. * @since 9.0.0
  261. */
  262. public function newShare();
  263. /**
  264. * Is the share API enabled
  265. *
  266. * @return bool
  267. * @since 9.0.0
  268. */
  269. public function shareApiEnabled();
  270. /**
  271. * Is public link sharing enabled
  272. *
  273. * @return bool
  274. * @since 9.0.0
  275. */
  276. public function shareApiAllowLinks();
  277. /**
  278. * Is password on public link requires
  279. *
  280. * @return bool
  281. * @since 9.0.0
  282. */
  283. public function shareApiLinkEnforcePassword();
  284. /**
  285. * Is default expire date enabled
  286. *
  287. * @return bool
  288. * @since 9.0.0
  289. */
  290. public function shareApiLinkDefaultExpireDate();
  291. /**
  292. * Is default expire date enforced
  293. *`
  294. * @return bool
  295. * @since 9.0.0
  296. */
  297. public function shareApiLinkDefaultExpireDateEnforced();
  298. /**
  299. * Number of default expire days
  300. *
  301. * @return int
  302. * @since 9.0.0
  303. */
  304. public function shareApiLinkDefaultExpireDays();
  305. /**
  306. * Allow public upload on link shares
  307. *
  308. * @return bool
  309. * @since 9.0.0
  310. */
  311. public function shareApiLinkAllowPublicUpload();
  312. /**
  313. * check if user can only share with group members
  314. * @return bool
  315. * @since 9.0.0
  316. */
  317. public function shareWithGroupMembersOnly();
  318. /**
  319. * Check if users can share with groups
  320. * @return bool
  321. * @since 9.0.1
  322. */
  323. public function allowGroupSharing();
  324. /**
  325. * Check if sharing is disabled for the given user
  326. *
  327. * @param string $userId
  328. * @return bool
  329. * @since 9.0.0
  330. */
  331. public function sharingDisabledForUser($userId);
  332. /**
  333. * Check if outgoing server2server shares are allowed
  334. * @return bool
  335. * @since 9.0.0
  336. */
  337. public function outgoingServer2ServerSharesAllowed();
  338. /**
  339. * Check if outgoing server2server shares are allowed
  340. * @return bool
  341. * @since 14.0.0
  342. */
  343. public function outgoingServer2ServerGroupSharesAllowed();
  344. /**
  345. * Check if a given share provider exists
  346. * @param int $shareType
  347. * @return bool
  348. * @since 11.0.0
  349. */
  350. public function shareProviderExists($shareType);
  351. }