IManager.php 8.3 KB

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