@@ -43,526 +43,526 @@ |
||
43 | 43 | */ |
44 | 44 | interface IShare { |
45 | 45 | |
46 | - /** |
|
47 | - * @since 17.0.0 |
|
48 | - */ |
|
49 | - public const TYPE_USER = 0; |
|
50 | - |
|
51 | - /** |
|
52 | - * @since 17.0.0 |
|
53 | - */ |
|
54 | - public const TYPE_GROUP = 1; |
|
55 | - |
|
56 | - /** |
|
57 | - * @internal |
|
58 | - * @since 18.0.0 |
|
59 | - */ |
|
60 | - public const TYPE_USERGROUP = 2; |
|
61 | - |
|
62 | - /** |
|
63 | - * @since 17.0.0 |
|
64 | - */ |
|
65 | - public const TYPE_LINK = 3; |
|
66 | - |
|
67 | - /** |
|
68 | - * @since 17.0.0 |
|
69 | - */ |
|
70 | - public const TYPE_EMAIL = 4; |
|
71 | - |
|
72 | - /** |
|
73 | - * ToDo Check if it is still in use otherwise remove it |
|
74 | - * @since 17.0.0 |
|
75 | - */ |
|
76 | - // public const TYPE_CONTACT = 5; |
|
77 | - |
|
78 | - /** |
|
79 | - * @since 17.0.0 |
|
80 | - */ |
|
81 | - public const TYPE_REMOTE = 6; |
|
82 | - |
|
83 | - /** |
|
84 | - * @since 17.0.0 |
|
85 | - */ |
|
86 | - public const TYPE_CIRCLE = 7; |
|
87 | - |
|
88 | - /** |
|
89 | - * @since 17.0.0 |
|
90 | - */ |
|
91 | - public const TYPE_GUEST = 8; |
|
92 | - |
|
93 | - /** |
|
94 | - * @since 17.0.0 |
|
95 | - */ |
|
96 | - public const TYPE_REMOTE_GROUP = 9; |
|
97 | - |
|
98 | - /** |
|
99 | - * @since 17.0.0 |
|
100 | - */ |
|
101 | - public const TYPE_ROOM = 10; |
|
102 | - |
|
103 | - /** |
|
104 | - * Internal type used by RoomShareProvider |
|
105 | - * @since 17.0.0 |
|
106 | - */ |
|
107 | - // const TYPE_USERROOM = 11; |
|
108 | - |
|
109 | - /** |
|
110 | - * @since 18.0.0 |
|
111 | - */ |
|
112 | - public const STATUS_PENDING = 0; |
|
113 | - |
|
114 | - /** |
|
115 | - * @since 18.0.0 |
|
116 | - */ |
|
117 | - public const STATUS_ACCEPTED = 1; |
|
118 | - |
|
119 | - /** |
|
120 | - * @since 18.0.0 |
|
121 | - */ |
|
122 | - public const STATUS_REJECTED = 2; |
|
123 | - |
|
124 | - /** |
|
125 | - * Set the internal id of the share |
|
126 | - * It is only allowed to set the internal id of a share once. |
|
127 | - * Attempts to override the internal id will result in an IllegalIDChangeException |
|
128 | - * |
|
129 | - * @param string $id |
|
130 | - * @return \OCP\Share\IShare |
|
131 | - * @throws IllegalIDChangeException |
|
132 | - * @throws \InvalidArgumentException |
|
133 | - * @since 9.1.0 |
|
134 | - */ |
|
135 | - public function setId($id); |
|
136 | - |
|
137 | - /** |
|
138 | - * Get the internal id of the share. |
|
139 | - * |
|
140 | - * @return string |
|
141 | - * @since 9.0.0 |
|
142 | - */ |
|
143 | - public function getId(); |
|
144 | - |
|
145 | - /** |
|
146 | - * Get the full share id. This is the <providerid>:<internalid>. |
|
147 | - * The full id is unique in the system. |
|
148 | - * |
|
149 | - * @return string |
|
150 | - * @since 9.0.0 |
|
151 | - * @throws \UnexpectedValueException If the fullId could not be constructed |
|
152 | - */ |
|
153 | - public function getFullId(); |
|
154 | - |
|
155 | - /** |
|
156 | - * Set the provider id of the share |
|
157 | - * It is only allowed to set the provider id of a share once. |
|
158 | - * Attempts to override the provider id will result in an IllegalIDChangeException |
|
159 | - * |
|
160 | - * @param string $id |
|
161 | - * @return \OCP\Share\IShare |
|
162 | - * @throws IllegalIDChangeException |
|
163 | - * @throws \InvalidArgumentException |
|
164 | - * @since 9.1.0 |
|
165 | - */ |
|
166 | - public function setProviderId($id); |
|
167 | - |
|
168 | - /** |
|
169 | - * Set the node of the file/folder that is shared |
|
170 | - * |
|
171 | - * @param Node $node |
|
172 | - * @return \OCP\Share\IShare The modified object |
|
173 | - * @since 9.0.0 |
|
174 | - */ |
|
175 | - public function setNode(Node $node); |
|
176 | - |
|
177 | - /** |
|
178 | - * Get the node of the file/folder that is shared |
|
179 | - * |
|
180 | - * @return File|Folder |
|
181 | - * @since 9.0.0 |
|
182 | - * @throws NotFoundException |
|
183 | - */ |
|
184 | - public function getNode(); |
|
185 | - |
|
186 | - /** |
|
187 | - * Set file id for lazy evaluation of the node |
|
188 | - * @param int $fileId |
|
189 | - * @return \OCP\Share\IShare The modified object |
|
190 | - * @since 9.0.0 |
|
191 | - */ |
|
192 | - public function setNodeId($fileId); |
|
193 | - |
|
194 | - /** |
|
195 | - * Get the fileid of the node of this share |
|
196 | - * @return int |
|
197 | - * @since 9.0.0 |
|
198 | - * @throws NotFoundException |
|
199 | - */ |
|
200 | - public function getNodeId(); |
|
201 | - |
|
202 | - /** |
|
203 | - * Set the type of node (file/folder) |
|
204 | - * |
|
205 | - * @param string $type |
|
206 | - * @return \OCP\Share\IShare The modified object |
|
207 | - * @since 9.0.0 |
|
208 | - */ |
|
209 | - public function setNodeType($type); |
|
210 | - |
|
211 | - /** |
|
212 | - * Get the type of node (file/folder) |
|
213 | - * |
|
214 | - * @return string |
|
215 | - * @since 9.0.0 |
|
216 | - * @throws NotFoundException |
|
217 | - */ |
|
218 | - public function getNodeType(); |
|
219 | - |
|
220 | - /** |
|
221 | - * Set the shareType |
|
222 | - * |
|
223 | - * @param int $shareType |
|
224 | - * @return \OCP\Share\IShare The modified object |
|
225 | - * @since 9.0.0 |
|
226 | - */ |
|
227 | - public function setShareType($shareType); |
|
228 | - |
|
229 | - /** |
|
230 | - * Get the shareType |
|
231 | - * |
|
232 | - * @return int |
|
233 | - * @since 9.0.0 |
|
234 | - */ |
|
235 | - public function getShareType(); |
|
236 | - |
|
237 | - /** |
|
238 | - * Set the receiver of this share. |
|
239 | - * |
|
240 | - * @param string $sharedWith |
|
241 | - * @return \OCP\Share\IShare The modified object |
|
242 | - * @since 9.0.0 |
|
243 | - */ |
|
244 | - public function setSharedWith($sharedWith); |
|
245 | - |
|
246 | - /** |
|
247 | - * Get the receiver of this share. |
|
248 | - * |
|
249 | - * @return string |
|
250 | - * @since 9.0.0 |
|
251 | - */ |
|
252 | - public function getSharedWith(); |
|
253 | - |
|
254 | - /** |
|
255 | - * Set the display name of the receiver of this share. |
|
256 | - * |
|
257 | - * @param string $displayName |
|
258 | - * @return \OCP\Share\IShare The modified object |
|
259 | - * @since 14.0.0 |
|
260 | - */ |
|
261 | - public function setSharedWithDisplayName($displayName); |
|
262 | - |
|
263 | - /** |
|
264 | - * Get the display name of the receiver of this share. |
|
265 | - * |
|
266 | - * @return string |
|
267 | - * @since 14.0.0 |
|
268 | - */ |
|
269 | - public function getSharedWithDisplayName(); |
|
270 | - |
|
271 | - /** |
|
272 | - * Set the avatar of the receiver of this share. |
|
273 | - * |
|
274 | - * @param string $src |
|
275 | - * @return \OCP\Share\IShare The modified object |
|
276 | - * @since 14.0.0 |
|
277 | - */ |
|
278 | - public function setSharedWithAvatar($src); |
|
279 | - |
|
280 | - /** |
|
281 | - * Get the avatar of the receiver of this share. |
|
282 | - * |
|
283 | - * @return string |
|
284 | - * @since 14.0.0 |
|
285 | - */ |
|
286 | - public function getSharedWithAvatar(); |
|
287 | - |
|
288 | - /** |
|
289 | - * Set the permissions. |
|
290 | - * See \OCP\Constants::PERMISSION_* |
|
291 | - * |
|
292 | - * @param int $permissions |
|
293 | - * @return \OCP\Share\IShare The modified object |
|
294 | - * @since 9.0.0 |
|
295 | - */ |
|
296 | - public function setPermissions($permissions); |
|
297 | - |
|
298 | - /** |
|
299 | - * Get the share permissions |
|
300 | - * See \OCP\Constants::PERMISSION_* |
|
301 | - * |
|
302 | - * @return int |
|
303 | - * @since 9.0.0 |
|
304 | - */ |
|
305 | - public function getPermissions(); |
|
306 | - |
|
307 | - /** |
|
308 | - * Set the accepted status |
|
309 | - * See self::STATUS_* |
|
310 | - * |
|
311 | - * @param int $status |
|
312 | - * @return IShare The modified object |
|
313 | - * @since 18.0.0 |
|
314 | - */ |
|
315 | - public function setStatus(int $status): IShare; |
|
316 | - |
|
317 | - /** |
|
318 | - * Get the accepted status |
|
319 | - * See self::STATUS_* |
|
320 | - * |
|
321 | - * @return int |
|
322 | - * @since 18.0.0 |
|
323 | - */ |
|
324 | - public function getStatus(): int; |
|
325 | - |
|
326 | - /** |
|
327 | - * Attach a note to a share |
|
328 | - * |
|
329 | - * @param string $note |
|
330 | - * @return \OCP\Share\IShare The modified object |
|
331 | - * @since 14.0.0 |
|
332 | - */ |
|
333 | - public function setNote($note); |
|
334 | - |
|
335 | - /** |
|
336 | - * Get note attached to a share |
|
337 | - * |
|
338 | - * @return string |
|
339 | - * @since 14.0.0 |
|
340 | - */ |
|
341 | - public function getNote(); |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * Set the expiration date |
|
346 | - * |
|
347 | - * @param null|\DateTime $expireDate |
|
348 | - * @return \OCP\Share\IShare The modified object |
|
349 | - * @since 9.0.0 |
|
350 | - */ |
|
351 | - public function setExpirationDate($expireDate); |
|
352 | - |
|
353 | - /** |
|
354 | - * Get the expiration date |
|
355 | - * |
|
356 | - * @return \DateTime |
|
357 | - * @since 9.0.0 |
|
358 | - */ |
|
359 | - public function getExpirationDate(); |
|
360 | - |
|
361 | - /** |
|
362 | - * Is the share expired ? |
|
363 | - * |
|
364 | - * @return boolean |
|
365 | - * @since 18.0.0 |
|
366 | - */ |
|
367 | - public function isExpired(); |
|
368 | - |
|
369 | - /** |
|
370 | - * set a label for a share, some shares, e.g. public links can have a label |
|
371 | - * |
|
372 | - * @param string $label |
|
373 | - * @return \OCP\Share\IShare The modified object |
|
374 | - * @since 15.0.0 |
|
375 | - */ |
|
376 | - public function setLabel($label); |
|
377 | - |
|
378 | - /** |
|
379 | - * get label for the share, some shares, e.g. public links can have a label |
|
380 | - * |
|
381 | - * @return string |
|
382 | - * @since 15.0.0 |
|
383 | - */ |
|
384 | - public function getLabel(); |
|
385 | - |
|
386 | - /** |
|
387 | - * Set the sharer of the path. |
|
388 | - * |
|
389 | - * @param string $sharedBy |
|
390 | - * @return \OCP\Share\IShare The modified object |
|
391 | - * @since 9.0.0 |
|
392 | - */ |
|
393 | - public function setSharedBy($sharedBy); |
|
394 | - |
|
395 | - /** |
|
396 | - * Get share sharer |
|
397 | - * |
|
398 | - * @return string |
|
399 | - * @since 9.0.0 |
|
400 | - */ |
|
401 | - public function getSharedBy(); |
|
402 | - |
|
403 | - /** |
|
404 | - * Set the original share owner (who owns the path that is shared) |
|
405 | - * |
|
406 | - * @param string $shareOwner |
|
407 | - * @return \OCP\Share\IShare The modified object |
|
408 | - * @since 9.0.0 |
|
409 | - */ |
|
410 | - public function setShareOwner($shareOwner); |
|
411 | - |
|
412 | - /** |
|
413 | - * Get the original share owner (who owns the path that is shared) |
|
414 | - * |
|
415 | - * @return string |
|
416 | - * @since 9.0.0 |
|
417 | - */ |
|
418 | - public function getShareOwner(); |
|
419 | - |
|
420 | - /** |
|
421 | - * Set the password for this share. |
|
422 | - * When the share is passed to the share manager to be created |
|
423 | - * or updated the password will be hashed. |
|
424 | - * |
|
425 | - * @param string $password |
|
426 | - * @return \OCP\Share\IShare The modified object |
|
427 | - * @since 9.0.0 |
|
428 | - */ |
|
429 | - public function setPassword($password); |
|
430 | - |
|
431 | - /** |
|
432 | - * Get the password of this share. |
|
433 | - * If this share is obtained via a shareprovider the password is |
|
434 | - * hashed. |
|
435 | - * |
|
436 | - * @return string |
|
437 | - * @since 9.0.0 |
|
438 | - */ |
|
439 | - public function getPassword(); |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * Set if the recipient can start a conversation with the owner to get the |
|
444 | - * password using Nextcloud Talk. |
|
445 | - * |
|
446 | - * @param bool $sendPasswordByTalk |
|
447 | - * @return \OCP\Share\IShare The modified object |
|
448 | - * @since 14.0.0 |
|
449 | - */ |
|
450 | - public function setSendPasswordByTalk(bool $sendPasswordByTalk); |
|
451 | - |
|
452 | - /** |
|
453 | - * Get if the recipient can start a conversation with the owner to get the |
|
454 | - * password using Nextcloud Talk. |
|
455 | - * The returned value does not take into account other factors, like Talk |
|
456 | - * being enabled for the owner of the share or not; it just cover whether |
|
457 | - * the option is enabled for the share itself or not. |
|
458 | - * |
|
459 | - * @return bool |
|
460 | - * @since 14.0.0 |
|
461 | - */ |
|
462 | - public function getSendPasswordByTalk(): bool; |
|
463 | - |
|
464 | - /** |
|
465 | - * Set the public link token. |
|
466 | - * |
|
467 | - * @param string $token |
|
468 | - * @return \OCP\Share\IShare The modified object |
|
469 | - * @since 9.0.0 |
|
470 | - */ |
|
471 | - public function setToken($token); |
|
472 | - |
|
473 | - /** |
|
474 | - * Get the public link token. |
|
475 | - * |
|
476 | - * @return string |
|
477 | - * @since 9.0.0 |
|
478 | - */ |
|
479 | - public function getToken(); |
|
480 | - |
|
481 | - /** |
|
482 | - * Set the target path of this share relative to the recipients user folder. |
|
483 | - * |
|
484 | - * @param string $target |
|
485 | - * @return \OCP\Share\IShare The modified object |
|
486 | - * @since 9.0.0 |
|
487 | - */ |
|
488 | - public function setTarget($target); |
|
489 | - |
|
490 | - /** |
|
491 | - * Get the target path of this share relative to the recipients user folder. |
|
492 | - * |
|
493 | - * @return string |
|
494 | - * @since 9.0.0 |
|
495 | - */ |
|
496 | - public function getTarget(); |
|
497 | - |
|
498 | - /** |
|
499 | - * Set the time this share was created |
|
500 | - * |
|
501 | - * @param \DateTime $shareTime |
|
502 | - * @return \OCP\Share\IShare The modified object |
|
503 | - * @since 9.0.0 |
|
504 | - */ |
|
505 | - public function setShareTime(\DateTime $shareTime); |
|
506 | - |
|
507 | - /** |
|
508 | - * Get the timestamp this share was created |
|
509 | - * |
|
510 | - * @return \DateTime |
|
511 | - * @since 9.0.0 |
|
512 | - */ |
|
513 | - public function getShareTime(); |
|
514 | - |
|
515 | - /** |
|
516 | - * Set if the recipient is informed by mail about the share. |
|
517 | - * |
|
518 | - * @param bool $mailSend |
|
519 | - * @return \OCP\Share\IShare The modified object |
|
520 | - * @since 9.0.0 |
|
521 | - */ |
|
522 | - public function setMailSend($mailSend); |
|
523 | - |
|
524 | - /** |
|
525 | - * Get if the recipient informed by mail about the share. |
|
526 | - * |
|
527 | - * @return bool |
|
528 | - * @since 9.0.0 |
|
529 | - */ |
|
530 | - public function getMailSend(); |
|
531 | - |
|
532 | - /** |
|
533 | - * Set the cache entry for the shared node |
|
534 | - * |
|
535 | - * @param ICacheEntry $entry |
|
536 | - * @since 11.0.0 |
|
537 | - */ |
|
538 | - public function setNodeCacheEntry(ICacheEntry $entry); |
|
539 | - |
|
540 | - /** |
|
541 | - * Get the cache entry for the shared node |
|
542 | - * |
|
543 | - * @return null|ICacheEntry |
|
544 | - * @since 11.0.0 |
|
545 | - */ |
|
546 | - public function getNodeCacheEntry(); |
|
547 | - |
|
548 | - /** |
|
549 | - * Sets a shares hide download state |
|
550 | - * This is mainly for public shares. It will signal that the share page should |
|
551 | - * hide download buttons etc. |
|
552 | - * |
|
553 | - * @param bool $hide |
|
554 | - * @return IShare |
|
555 | - * @since 15.0.0 |
|
556 | - */ |
|
557 | - public function setHideDownload(bool $hide): IShare; |
|
558 | - |
|
559 | - /** |
|
560 | - * Gets a shares hide download state |
|
561 | - * This is mainly for public shares. It will signal that the share page should |
|
562 | - * hide download buttons etc. |
|
563 | - * |
|
564 | - * @return bool |
|
565 | - * @since 15.0.0 |
|
566 | - */ |
|
567 | - public function getHideDownload(): bool; |
|
46 | + /** |
|
47 | + * @since 17.0.0 |
|
48 | + */ |
|
49 | + public const TYPE_USER = 0; |
|
50 | + |
|
51 | + /** |
|
52 | + * @since 17.0.0 |
|
53 | + */ |
|
54 | + public const TYPE_GROUP = 1; |
|
55 | + |
|
56 | + /** |
|
57 | + * @internal |
|
58 | + * @since 18.0.0 |
|
59 | + */ |
|
60 | + public const TYPE_USERGROUP = 2; |
|
61 | + |
|
62 | + /** |
|
63 | + * @since 17.0.0 |
|
64 | + */ |
|
65 | + public const TYPE_LINK = 3; |
|
66 | + |
|
67 | + /** |
|
68 | + * @since 17.0.0 |
|
69 | + */ |
|
70 | + public const TYPE_EMAIL = 4; |
|
71 | + |
|
72 | + /** |
|
73 | + * ToDo Check if it is still in use otherwise remove it |
|
74 | + * @since 17.0.0 |
|
75 | + */ |
|
76 | + // public const TYPE_CONTACT = 5; |
|
77 | + |
|
78 | + /** |
|
79 | + * @since 17.0.0 |
|
80 | + */ |
|
81 | + public const TYPE_REMOTE = 6; |
|
82 | + |
|
83 | + /** |
|
84 | + * @since 17.0.0 |
|
85 | + */ |
|
86 | + public const TYPE_CIRCLE = 7; |
|
87 | + |
|
88 | + /** |
|
89 | + * @since 17.0.0 |
|
90 | + */ |
|
91 | + public const TYPE_GUEST = 8; |
|
92 | + |
|
93 | + /** |
|
94 | + * @since 17.0.0 |
|
95 | + */ |
|
96 | + public const TYPE_REMOTE_GROUP = 9; |
|
97 | + |
|
98 | + /** |
|
99 | + * @since 17.0.0 |
|
100 | + */ |
|
101 | + public const TYPE_ROOM = 10; |
|
102 | + |
|
103 | + /** |
|
104 | + * Internal type used by RoomShareProvider |
|
105 | + * @since 17.0.0 |
|
106 | + */ |
|
107 | + // const TYPE_USERROOM = 11; |
|
108 | + |
|
109 | + /** |
|
110 | + * @since 18.0.0 |
|
111 | + */ |
|
112 | + public const STATUS_PENDING = 0; |
|
113 | + |
|
114 | + /** |
|
115 | + * @since 18.0.0 |
|
116 | + */ |
|
117 | + public const STATUS_ACCEPTED = 1; |
|
118 | + |
|
119 | + /** |
|
120 | + * @since 18.0.0 |
|
121 | + */ |
|
122 | + public const STATUS_REJECTED = 2; |
|
123 | + |
|
124 | + /** |
|
125 | + * Set the internal id of the share |
|
126 | + * It is only allowed to set the internal id of a share once. |
|
127 | + * Attempts to override the internal id will result in an IllegalIDChangeException |
|
128 | + * |
|
129 | + * @param string $id |
|
130 | + * @return \OCP\Share\IShare |
|
131 | + * @throws IllegalIDChangeException |
|
132 | + * @throws \InvalidArgumentException |
|
133 | + * @since 9.1.0 |
|
134 | + */ |
|
135 | + public function setId($id); |
|
136 | + |
|
137 | + /** |
|
138 | + * Get the internal id of the share. |
|
139 | + * |
|
140 | + * @return string |
|
141 | + * @since 9.0.0 |
|
142 | + */ |
|
143 | + public function getId(); |
|
144 | + |
|
145 | + /** |
|
146 | + * Get the full share id. This is the <providerid>:<internalid>. |
|
147 | + * The full id is unique in the system. |
|
148 | + * |
|
149 | + * @return string |
|
150 | + * @since 9.0.0 |
|
151 | + * @throws \UnexpectedValueException If the fullId could not be constructed |
|
152 | + */ |
|
153 | + public function getFullId(); |
|
154 | + |
|
155 | + /** |
|
156 | + * Set the provider id of the share |
|
157 | + * It is only allowed to set the provider id of a share once. |
|
158 | + * Attempts to override the provider id will result in an IllegalIDChangeException |
|
159 | + * |
|
160 | + * @param string $id |
|
161 | + * @return \OCP\Share\IShare |
|
162 | + * @throws IllegalIDChangeException |
|
163 | + * @throws \InvalidArgumentException |
|
164 | + * @since 9.1.0 |
|
165 | + */ |
|
166 | + public function setProviderId($id); |
|
167 | + |
|
168 | + /** |
|
169 | + * Set the node of the file/folder that is shared |
|
170 | + * |
|
171 | + * @param Node $node |
|
172 | + * @return \OCP\Share\IShare The modified object |
|
173 | + * @since 9.0.0 |
|
174 | + */ |
|
175 | + public function setNode(Node $node); |
|
176 | + |
|
177 | + /** |
|
178 | + * Get the node of the file/folder that is shared |
|
179 | + * |
|
180 | + * @return File|Folder |
|
181 | + * @since 9.0.0 |
|
182 | + * @throws NotFoundException |
|
183 | + */ |
|
184 | + public function getNode(); |
|
185 | + |
|
186 | + /** |
|
187 | + * Set file id for lazy evaluation of the node |
|
188 | + * @param int $fileId |
|
189 | + * @return \OCP\Share\IShare The modified object |
|
190 | + * @since 9.0.0 |
|
191 | + */ |
|
192 | + public function setNodeId($fileId); |
|
193 | + |
|
194 | + /** |
|
195 | + * Get the fileid of the node of this share |
|
196 | + * @return int |
|
197 | + * @since 9.0.0 |
|
198 | + * @throws NotFoundException |
|
199 | + */ |
|
200 | + public function getNodeId(); |
|
201 | + |
|
202 | + /** |
|
203 | + * Set the type of node (file/folder) |
|
204 | + * |
|
205 | + * @param string $type |
|
206 | + * @return \OCP\Share\IShare The modified object |
|
207 | + * @since 9.0.0 |
|
208 | + */ |
|
209 | + public function setNodeType($type); |
|
210 | + |
|
211 | + /** |
|
212 | + * Get the type of node (file/folder) |
|
213 | + * |
|
214 | + * @return string |
|
215 | + * @since 9.0.0 |
|
216 | + * @throws NotFoundException |
|
217 | + */ |
|
218 | + public function getNodeType(); |
|
219 | + |
|
220 | + /** |
|
221 | + * Set the shareType |
|
222 | + * |
|
223 | + * @param int $shareType |
|
224 | + * @return \OCP\Share\IShare The modified object |
|
225 | + * @since 9.0.0 |
|
226 | + */ |
|
227 | + public function setShareType($shareType); |
|
228 | + |
|
229 | + /** |
|
230 | + * Get the shareType |
|
231 | + * |
|
232 | + * @return int |
|
233 | + * @since 9.0.0 |
|
234 | + */ |
|
235 | + public function getShareType(); |
|
236 | + |
|
237 | + /** |
|
238 | + * Set the receiver of this share. |
|
239 | + * |
|
240 | + * @param string $sharedWith |
|
241 | + * @return \OCP\Share\IShare The modified object |
|
242 | + * @since 9.0.0 |
|
243 | + */ |
|
244 | + public function setSharedWith($sharedWith); |
|
245 | + |
|
246 | + /** |
|
247 | + * Get the receiver of this share. |
|
248 | + * |
|
249 | + * @return string |
|
250 | + * @since 9.0.0 |
|
251 | + */ |
|
252 | + public function getSharedWith(); |
|
253 | + |
|
254 | + /** |
|
255 | + * Set the display name of the receiver of this share. |
|
256 | + * |
|
257 | + * @param string $displayName |
|
258 | + * @return \OCP\Share\IShare The modified object |
|
259 | + * @since 14.0.0 |
|
260 | + */ |
|
261 | + public function setSharedWithDisplayName($displayName); |
|
262 | + |
|
263 | + /** |
|
264 | + * Get the display name of the receiver of this share. |
|
265 | + * |
|
266 | + * @return string |
|
267 | + * @since 14.0.0 |
|
268 | + */ |
|
269 | + public function getSharedWithDisplayName(); |
|
270 | + |
|
271 | + /** |
|
272 | + * Set the avatar of the receiver of this share. |
|
273 | + * |
|
274 | + * @param string $src |
|
275 | + * @return \OCP\Share\IShare The modified object |
|
276 | + * @since 14.0.0 |
|
277 | + */ |
|
278 | + public function setSharedWithAvatar($src); |
|
279 | + |
|
280 | + /** |
|
281 | + * Get the avatar of the receiver of this share. |
|
282 | + * |
|
283 | + * @return string |
|
284 | + * @since 14.0.0 |
|
285 | + */ |
|
286 | + public function getSharedWithAvatar(); |
|
287 | + |
|
288 | + /** |
|
289 | + * Set the permissions. |
|
290 | + * See \OCP\Constants::PERMISSION_* |
|
291 | + * |
|
292 | + * @param int $permissions |
|
293 | + * @return \OCP\Share\IShare The modified object |
|
294 | + * @since 9.0.0 |
|
295 | + */ |
|
296 | + public function setPermissions($permissions); |
|
297 | + |
|
298 | + /** |
|
299 | + * Get the share permissions |
|
300 | + * See \OCP\Constants::PERMISSION_* |
|
301 | + * |
|
302 | + * @return int |
|
303 | + * @since 9.0.0 |
|
304 | + */ |
|
305 | + public function getPermissions(); |
|
306 | + |
|
307 | + /** |
|
308 | + * Set the accepted status |
|
309 | + * See self::STATUS_* |
|
310 | + * |
|
311 | + * @param int $status |
|
312 | + * @return IShare The modified object |
|
313 | + * @since 18.0.0 |
|
314 | + */ |
|
315 | + public function setStatus(int $status): IShare; |
|
316 | + |
|
317 | + /** |
|
318 | + * Get the accepted status |
|
319 | + * See self::STATUS_* |
|
320 | + * |
|
321 | + * @return int |
|
322 | + * @since 18.0.0 |
|
323 | + */ |
|
324 | + public function getStatus(): int; |
|
325 | + |
|
326 | + /** |
|
327 | + * Attach a note to a share |
|
328 | + * |
|
329 | + * @param string $note |
|
330 | + * @return \OCP\Share\IShare The modified object |
|
331 | + * @since 14.0.0 |
|
332 | + */ |
|
333 | + public function setNote($note); |
|
334 | + |
|
335 | + /** |
|
336 | + * Get note attached to a share |
|
337 | + * |
|
338 | + * @return string |
|
339 | + * @since 14.0.0 |
|
340 | + */ |
|
341 | + public function getNote(); |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * Set the expiration date |
|
346 | + * |
|
347 | + * @param null|\DateTime $expireDate |
|
348 | + * @return \OCP\Share\IShare The modified object |
|
349 | + * @since 9.0.0 |
|
350 | + */ |
|
351 | + public function setExpirationDate($expireDate); |
|
352 | + |
|
353 | + /** |
|
354 | + * Get the expiration date |
|
355 | + * |
|
356 | + * @return \DateTime |
|
357 | + * @since 9.0.0 |
|
358 | + */ |
|
359 | + public function getExpirationDate(); |
|
360 | + |
|
361 | + /** |
|
362 | + * Is the share expired ? |
|
363 | + * |
|
364 | + * @return boolean |
|
365 | + * @since 18.0.0 |
|
366 | + */ |
|
367 | + public function isExpired(); |
|
368 | + |
|
369 | + /** |
|
370 | + * set a label for a share, some shares, e.g. public links can have a label |
|
371 | + * |
|
372 | + * @param string $label |
|
373 | + * @return \OCP\Share\IShare The modified object |
|
374 | + * @since 15.0.0 |
|
375 | + */ |
|
376 | + public function setLabel($label); |
|
377 | + |
|
378 | + /** |
|
379 | + * get label for the share, some shares, e.g. public links can have a label |
|
380 | + * |
|
381 | + * @return string |
|
382 | + * @since 15.0.0 |
|
383 | + */ |
|
384 | + public function getLabel(); |
|
385 | + |
|
386 | + /** |
|
387 | + * Set the sharer of the path. |
|
388 | + * |
|
389 | + * @param string $sharedBy |
|
390 | + * @return \OCP\Share\IShare The modified object |
|
391 | + * @since 9.0.0 |
|
392 | + */ |
|
393 | + public function setSharedBy($sharedBy); |
|
394 | + |
|
395 | + /** |
|
396 | + * Get share sharer |
|
397 | + * |
|
398 | + * @return string |
|
399 | + * @since 9.0.0 |
|
400 | + */ |
|
401 | + public function getSharedBy(); |
|
402 | + |
|
403 | + /** |
|
404 | + * Set the original share owner (who owns the path that is shared) |
|
405 | + * |
|
406 | + * @param string $shareOwner |
|
407 | + * @return \OCP\Share\IShare The modified object |
|
408 | + * @since 9.0.0 |
|
409 | + */ |
|
410 | + public function setShareOwner($shareOwner); |
|
411 | + |
|
412 | + /** |
|
413 | + * Get the original share owner (who owns the path that is shared) |
|
414 | + * |
|
415 | + * @return string |
|
416 | + * @since 9.0.0 |
|
417 | + */ |
|
418 | + public function getShareOwner(); |
|
419 | + |
|
420 | + /** |
|
421 | + * Set the password for this share. |
|
422 | + * When the share is passed to the share manager to be created |
|
423 | + * or updated the password will be hashed. |
|
424 | + * |
|
425 | + * @param string $password |
|
426 | + * @return \OCP\Share\IShare The modified object |
|
427 | + * @since 9.0.0 |
|
428 | + */ |
|
429 | + public function setPassword($password); |
|
430 | + |
|
431 | + /** |
|
432 | + * Get the password of this share. |
|
433 | + * If this share is obtained via a shareprovider the password is |
|
434 | + * hashed. |
|
435 | + * |
|
436 | + * @return string |
|
437 | + * @since 9.0.0 |
|
438 | + */ |
|
439 | + public function getPassword(); |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * Set if the recipient can start a conversation with the owner to get the |
|
444 | + * password using Nextcloud Talk. |
|
445 | + * |
|
446 | + * @param bool $sendPasswordByTalk |
|
447 | + * @return \OCP\Share\IShare The modified object |
|
448 | + * @since 14.0.0 |
|
449 | + */ |
|
450 | + public function setSendPasswordByTalk(bool $sendPasswordByTalk); |
|
451 | + |
|
452 | + /** |
|
453 | + * Get if the recipient can start a conversation with the owner to get the |
|
454 | + * password using Nextcloud Talk. |
|
455 | + * The returned value does not take into account other factors, like Talk |
|
456 | + * being enabled for the owner of the share or not; it just cover whether |
|
457 | + * the option is enabled for the share itself or not. |
|
458 | + * |
|
459 | + * @return bool |
|
460 | + * @since 14.0.0 |
|
461 | + */ |
|
462 | + public function getSendPasswordByTalk(): bool; |
|
463 | + |
|
464 | + /** |
|
465 | + * Set the public link token. |
|
466 | + * |
|
467 | + * @param string $token |
|
468 | + * @return \OCP\Share\IShare The modified object |
|
469 | + * @since 9.0.0 |
|
470 | + */ |
|
471 | + public function setToken($token); |
|
472 | + |
|
473 | + /** |
|
474 | + * Get the public link token. |
|
475 | + * |
|
476 | + * @return string |
|
477 | + * @since 9.0.0 |
|
478 | + */ |
|
479 | + public function getToken(); |
|
480 | + |
|
481 | + /** |
|
482 | + * Set the target path of this share relative to the recipients user folder. |
|
483 | + * |
|
484 | + * @param string $target |
|
485 | + * @return \OCP\Share\IShare The modified object |
|
486 | + * @since 9.0.0 |
|
487 | + */ |
|
488 | + public function setTarget($target); |
|
489 | + |
|
490 | + /** |
|
491 | + * Get the target path of this share relative to the recipients user folder. |
|
492 | + * |
|
493 | + * @return string |
|
494 | + * @since 9.0.0 |
|
495 | + */ |
|
496 | + public function getTarget(); |
|
497 | + |
|
498 | + /** |
|
499 | + * Set the time this share was created |
|
500 | + * |
|
501 | + * @param \DateTime $shareTime |
|
502 | + * @return \OCP\Share\IShare The modified object |
|
503 | + * @since 9.0.0 |
|
504 | + */ |
|
505 | + public function setShareTime(\DateTime $shareTime); |
|
506 | + |
|
507 | + /** |
|
508 | + * Get the timestamp this share was created |
|
509 | + * |
|
510 | + * @return \DateTime |
|
511 | + * @since 9.0.0 |
|
512 | + */ |
|
513 | + public function getShareTime(); |
|
514 | + |
|
515 | + /** |
|
516 | + * Set if the recipient is informed by mail about the share. |
|
517 | + * |
|
518 | + * @param bool $mailSend |
|
519 | + * @return \OCP\Share\IShare The modified object |
|
520 | + * @since 9.0.0 |
|
521 | + */ |
|
522 | + public function setMailSend($mailSend); |
|
523 | + |
|
524 | + /** |
|
525 | + * Get if the recipient informed by mail about the share. |
|
526 | + * |
|
527 | + * @return bool |
|
528 | + * @since 9.0.0 |
|
529 | + */ |
|
530 | + public function getMailSend(); |
|
531 | + |
|
532 | + /** |
|
533 | + * Set the cache entry for the shared node |
|
534 | + * |
|
535 | + * @param ICacheEntry $entry |
|
536 | + * @since 11.0.0 |
|
537 | + */ |
|
538 | + public function setNodeCacheEntry(ICacheEntry $entry); |
|
539 | + |
|
540 | + /** |
|
541 | + * Get the cache entry for the shared node |
|
542 | + * |
|
543 | + * @return null|ICacheEntry |
|
544 | + * @since 11.0.0 |
|
545 | + */ |
|
546 | + public function getNodeCacheEntry(); |
|
547 | + |
|
548 | + /** |
|
549 | + * Sets a shares hide download state |
|
550 | + * This is mainly for public shares. It will signal that the share page should |
|
551 | + * hide download buttons etc. |
|
552 | + * |
|
553 | + * @param bool $hide |
|
554 | + * @return IShare |
|
555 | + * @since 15.0.0 |
|
556 | + */ |
|
557 | + public function setHideDownload(bool $hide): IShare; |
|
558 | + |
|
559 | + /** |
|
560 | + * Gets a shares hide download state |
|
561 | + * This is mainly for public shares. It will signal that the share page should |
|
562 | + * hide download buttons etc. |
|
563 | + * |
|
564 | + * @return bool |
|
565 | + * @since 15.0.0 |
|
566 | + */ |
|
567 | + public function getHideDownload(): bool; |
|
568 | 568 | } |
@@ -40,204 +40,204 @@ |
||
40 | 40 | use OCP\Share\IShare; |
41 | 41 | |
42 | 42 | class MountProvider implements IMountProvider { |
43 | - /** |
|
44 | - * @var \OCP\IConfig |
|
45 | - */ |
|
46 | - protected $config; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var IManager |
|
50 | - */ |
|
51 | - protected $shareManager; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var ILogger |
|
55 | - */ |
|
56 | - protected $logger; |
|
57 | - |
|
58 | - /** |
|
59 | - * @param \OCP\IConfig $config |
|
60 | - * @param IManager $shareManager |
|
61 | - * @param ILogger $logger |
|
62 | - */ |
|
63 | - public function __construct(IConfig $config, IManager $shareManager, ILogger $logger) { |
|
64 | - $this->config = $config; |
|
65 | - $this->shareManager = $shareManager; |
|
66 | - $this->logger = $logger; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Get all mountpoints applicable for the user and check for shares where we need to update the etags |
|
72 | - * |
|
73 | - * @param \OCP\IUser $user |
|
74 | - * @param \OCP\Files\Storage\IStorageFactory $storageFactory |
|
75 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
76 | - */ |
|
77 | - public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { |
|
78 | - $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1); |
|
79 | - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1)); |
|
80 | - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)); |
|
81 | - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_ROOM, null, -1)); |
|
82 | - |
|
83 | - // filter out excluded shares and group shares that includes self |
|
84 | - $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { |
|
85 | - return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID(); |
|
86 | - }); |
|
87 | - |
|
88 | - $superShares = $this->buildSuperShares($shares, $user); |
|
89 | - |
|
90 | - $mounts = []; |
|
91 | - $view = new View('/' . $user->getUID() . '/files'); |
|
92 | - $ownerViews = []; |
|
93 | - $sharingDisabledForUser = $this->shareManager->sharingDisabledForUser($user->getUID()); |
|
94 | - $foldersExistCache = new CappedMemoryCache(); |
|
95 | - foreach ($superShares as $share) { |
|
96 | - try { |
|
97 | - /** @var \OCP\Share\IShare $parentShare */ |
|
98 | - $parentShare = $share[0]; |
|
99 | - |
|
100 | - if ($parentShare->getStatus() !== IShare::STATUS_ACCEPTED && |
|
101 | - ($parentShare->getShareType() === IShare::TYPE_GROUP || |
|
102 | - $parentShare->getShareType() === IShare::TYPE_USERGROUP || |
|
103 | - $parentShare->getShareType() === IShare::TYPE_USER)) { |
|
104 | - continue; |
|
105 | - } |
|
106 | - |
|
107 | - $owner = $parentShare->getShareOwner(); |
|
108 | - if (!isset($ownerViews[$owner])) { |
|
109 | - $ownerViews[$owner] = new View('/' . $parentShare->getShareOwner() . '/files'); |
|
110 | - } |
|
111 | - $mount = new SharedMount( |
|
112 | - '\OCA\Files_Sharing\SharedStorage', |
|
113 | - $mounts, |
|
114 | - [ |
|
115 | - 'user' => $user->getUID(), |
|
116 | - // parent share |
|
117 | - 'superShare' => $parentShare, |
|
118 | - // children/component of the superShare |
|
119 | - 'groupedShares' => $share[1], |
|
120 | - 'ownerView' => $ownerViews[$owner], |
|
121 | - 'sharingDisabledForUser' => $sharingDisabledForUser |
|
122 | - ], |
|
123 | - $storageFactory, |
|
124 | - $view, |
|
125 | - $foldersExistCache |
|
126 | - ); |
|
127 | - $mounts[$mount->getMountPoint()] = $mount; |
|
128 | - } catch (\Exception $e) { |
|
129 | - $this->logger->logException($e); |
|
130 | - $this->logger->error('Error while trying to create shared mount'); |
|
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - // array_filter removes the null values from the array |
|
135 | - return array_values(array_filter($mounts)); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Groups shares by path (nodeId) and target path |
|
140 | - * |
|
141 | - * @param \OCP\Share\IShare[] $shares |
|
142 | - * @return \OCP\Share\IShare[][] array of grouped shares, each element in the |
|
143 | - * array is a group which itself is an array of shares |
|
144 | - */ |
|
145 | - private function groupShares(array $shares) { |
|
146 | - $tmp = []; |
|
147 | - |
|
148 | - foreach ($shares as $share) { |
|
149 | - if (!isset($tmp[$share->getNodeId()])) { |
|
150 | - $tmp[$share->getNodeId()] = []; |
|
151 | - } |
|
152 | - $tmp[$share->getNodeId()][] = $share; |
|
153 | - } |
|
154 | - |
|
155 | - $result = []; |
|
156 | - // sort by stime, the super share will be based on the least recent share |
|
157 | - foreach ($tmp as &$tmp2) { |
|
158 | - @usort($tmp2, function ($a, $b) { |
|
159 | - $aTime = $a->getShareTime()->getTimestamp(); |
|
160 | - $bTime = $b->getShareTime()->getTimestamp(); |
|
161 | - if ($aTime === $bTime) { |
|
162 | - return $a->getId() < $b->getId() ? -1 : 1; |
|
163 | - } |
|
164 | - return $aTime < $bTime ? -1 : 1; |
|
165 | - }); |
|
166 | - $result[] = $tmp2; |
|
167 | - } |
|
168 | - |
|
169 | - return array_values($result); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Build super shares (virtual share) by grouping them by node id and target, |
|
174 | - * then for each group compute the super share and return it along with the matching |
|
175 | - * grouped shares. The most permissive permissions are used based on the permissions |
|
176 | - * of all shares within the group. |
|
177 | - * |
|
178 | - * @param \OCP\Share\IShare[] $allShares |
|
179 | - * @param \OCP\IUser $user user |
|
180 | - * @return array Tuple of [superShare, groupedShares] |
|
181 | - */ |
|
182 | - private function buildSuperShares(array $allShares, \OCP\IUser $user) { |
|
183 | - $result = []; |
|
184 | - |
|
185 | - $groupedShares = $this->groupShares($allShares); |
|
186 | - |
|
187 | - /** @var \OCP\Share\IShare[] $shares */ |
|
188 | - foreach ($groupedShares as $shares) { |
|
189 | - if (count($shares) === 0) { |
|
190 | - continue; |
|
191 | - } |
|
192 | - |
|
193 | - $superShare = $this->shareManager->newShare(); |
|
194 | - |
|
195 | - // compute super share based on first entry of the group |
|
196 | - $superShare->setId($shares[0]->getId()) |
|
197 | - ->setShareOwner($shares[0]->getShareOwner()) |
|
198 | - ->setNodeId($shares[0]->getNodeId()) |
|
199 | - ->setShareType($shares[0]->getShareType()) |
|
200 | - ->setTarget($shares[0]->getTarget()); |
|
201 | - |
|
202 | - // use most permissive permissions |
|
203 | - $permissions = 0; |
|
204 | - $status = IShare::STATUS_PENDING; |
|
205 | - foreach ($shares as $share) { |
|
206 | - $permissions |= $share->getPermissions(); |
|
207 | - $status = max($status, $share->getStatus()); |
|
208 | - |
|
209 | - if ($share->getTarget() !== $superShare->getTarget()) { |
|
210 | - // adjust target, for database consistency |
|
211 | - $share->setTarget($superShare->getTarget()); |
|
212 | - try { |
|
213 | - $this->shareManager->moveShare($share, $user->getUID()); |
|
214 | - } catch (\InvalidArgumentException $e) { |
|
215 | - // ignore as it is not important and we don't want to |
|
216 | - // block FS setup |
|
217 | - |
|
218 | - // the subsequent code anyway only uses the target of the |
|
219 | - // super share |
|
220 | - |
|
221 | - // such issue can usually happen when dealing with |
|
222 | - // null groups which usually appear with group backend |
|
223 | - // caching inconsistencies |
|
224 | - $this->logger->debug( |
|
225 | - 'Could not adjust share target for share ' . $share->getId() . ' to make it consistent: ' . $e->getMessage(), |
|
226 | - ['app' => 'files_sharing'] |
|
227 | - ); |
|
228 | - } |
|
229 | - } |
|
230 | - if (!is_null($share->getNodeCacheEntry())) { |
|
231 | - $superShare->setNodeCacheEntry($share->getNodeCacheEntry()); |
|
232 | - } |
|
233 | - } |
|
234 | - |
|
235 | - $superShare->setPermissions($permissions) |
|
236 | - ->setStatus($status); |
|
237 | - |
|
238 | - $result[] = [$superShare, $shares]; |
|
239 | - } |
|
240 | - |
|
241 | - return $result; |
|
242 | - } |
|
43 | + /** |
|
44 | + * @var \OCP\IConfig |
|
45 | + */ |
|
46 | + protected $config; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var IManager |
|
50 | + */ |
|
51 | + protected $shareManager; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var ILogger |
|
55 | + */ |
|
56 | + protected $logger; |
|
57 | + |
|
58 | + /** |
|
59 | + * @param \OCP\IConfig $config |
|
60 | + * @param IManager $shareManager |
|
61 | + * @param ILogger $logger |
|
62 | + */ |
|
63 | + public function __construct(IConfig $config, IManager $shareManager, ILogger $logger) { |
|
64 | + $this->config = $config; |
|
65 | + $this->shareManager = $shareManager; |
|
66 | + $this->logger = $logger; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Get all mountpoints applicable for the user and check for shares where we need to update the etags |
|
72 | + * |
|
73 | + * @param \OCP\IUser $user |
|
74 | + * @param \OCP\Files\Storage\IStorageFactory $storageFactory |
|
75 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
76 | + */ |
|
77 | + public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { |
|
78 | + $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1); |
|
79 | + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1)); |
|
80 | + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)); |
|
81 | + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_ROOM, null, -1)); |
|
82 | + |
|
83 | + // filter out excluded shares and group shares that includes self |
|
84 | + $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { |
|
85 | + return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID(); |
|
86 | + }); |
|
87 | + |
|
88 | + $superShares = $this->buildSuperShares($shares, $user); |
|
89 | + |
|
90 | + $mounts = []; |
|
91 | + $view = new View('/' . $user->getUID() . '/files'); |
|
92 | + $ownerViews = []; |
|
93 | + $sharingDisabledForUser = $this->shareManager->sharingDisabledForUser($user->getUID()); |
|
94 | + $foldersExistCache = new CappedMemoryCache(); |
|
95 | + foreach ($superShares as $share) { |
|
96 | + try { |
|
97 | + /** @var \OCP\Share\IShare $parentShare */ |
|
98 | + $parentShare = $share[0]; |
|
99 | + |
|
100 | + if ($parentShare->getStatus() !== IShare::STATUS_ACCEPTED && |
|
101 | + ($parentShare->getShareType() === IShare::TYPE_GROUP || |
|
102 | + $parentShare->getShareType() === IShare::TYPE_USERGROUP || |
|
103 | + $parentShare->getShareType() === IShare::TYPE_USER)) { |
|
104 | + continue; |
|
105 | + } |
|
106 | + |
|
107 | + $owner = $parentShare->getShareOwner(); |
|
108 | + if (!isset($ownerViews[$owner])) { |
|
109 | + $ownerViews[$owner] = new View('/' . $parentShare->getShareOwner() . '/files'); |
|
110 | + } |
|
111 | + $mount = new SharedMount( |
|
112 | + '\OCA\Files_Sharing\SharedStorage', |
|
113 | + $mounts, |
|
114 | + [ |
|
115 | + 'user' => $user->getUID(), |
|
116 | + // parent share |
|
117 | + 'superShare' => $parentShare, |
|
118 | + // children/component of the superShare |
|
119 | + 'groupedShares' => $share[1], |
|
120 | + 'ownerView' => $ownerViews[$owner], |
|
121 | + 'sharingDisabledForUser' => $sharingDisabledForUser |
|
122 | + ], |
|
123 | + $storageFactory, |
|
124 | + $view, |
|
125 | + $foldersExistCache |
|
126 | + ); |
|
127 | + $mounts[$mount->getMountPoint()] = $mount; |
|
128 | + } catch (\Exception $e) { |
|
129 | + $this->logger->logException($e); |
|
130 | + $this->logger->error('Error while trying to create shared mount'); |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + // array_filter removes the null values from the array |
|
135 | + return array_values(array_filter($mounts)); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Groups shares by path (nodeId) and target path |
|
140 | + * |
|
141 | + * @param \OCP\Share\IShare[] $shares |
|
142 | + * @return \OCP\Share\IShare[][] array of grouped shares, each element in the |
|
143 | + * array is a group which itself is an array of shares |
|
144 | + */ |
|
145 | + private function groupShares(array $shares) { |
|
146 | + $tmp = []; |
|
147 | + |
|
148 | + foreach ($shares as $share) { |
|
149 | + if (!isset($tmp[$share->getNodeId()])) { |
|
150 | + $tmp[$share->getNodeId()] = []; |
|
151 | + } |
|
152 | + $tmp[$share->getNodeId()][] = $share; |
|
153 | + } |
|
154 | + |
|
155 | + $result = []; |
|
156 | + // sort by stime, the super share will be based on the least recent share |
|
157 | + foreach ($tmp as &$tmp2) { |
|
158 | + @usort($tmp2, function ($a, $b) { |
|
159 | + $aTime = $a->getShareTime()->getTimestamp(); |
|
160 | + $bTime = $b->getShareTime()->getTimestamp(); |
|
161 | + if ($aTime === $bTime) { |
|
162 | + return $a->getId() < $b->getId() ? -1 : 1; |
|
163 | + } |
|
164 | + return $aTime < $bTime ? -1 : 1; |
|
165 | + }); |
|
166 | + $result[] = $tmp2; |
|
167 | + } |
|
168 | + |
|
169 | + return array_values($result); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Build super shares (virtual share) by grouping them by node id and target, |
|
174 | + * then for each group compute the super share and return it along with the matching |
|
175 | + * grouped shares. The most permissive permissions are used based on the permissions |
|
176 | + * of all shares within the group. |
|
177 | + * |
|
178 | + * @param \OCP\Share\IShare[] $allShares |
|
179 | + * @param \OCP\IUser $user user |
|
180 | + * @return array Tuple of [superShare, groupedShares] |
|
181 | + */ |
|
182 | + private function buildSuperShares(array $allShares, \OCP\IUser $user) { |
|
183 | + $result = []; |
|
184 | + |
|
185 | + $groupedShares = $this->groupShares($allShares); |
|
186 | + |
|
187 | + /** @var \OCP\Share\IShare[] $shares */ |
|
188 | + foreach ($groupedShares as $shares) { |
|
189 | + if (count($shares) === 0) { |
|
190 | + continue; |
|
191 | + } |
|
192 | + |
|
193 | + $superShare = $this->shareManager->newShare(); |
|
194 | + |
|
195 | + // compute super share based on first entry of the group |
|
196 | + $superShare->setId($shares[0]->getId()) |
|
197 | + ->setShareOwner($shares[0]->getShareOwner()) |
|
198 | + ->setNodeId($shares[0]->getNodeId()) |
|
199 | + ->setShareType($shares[0]->getShareType()) |
|
200 | + ->setTarget($shares[0]->getTarget()); |
|
201 | + |
|
202 | + // use most permissive permissions |
|
203 | + $permissions = 0; |
|
204 | + $status = IShare::STATUS_PENDING; |
|
205 | + foreach ($shares as $share) { |
|
206 | + $permissions |= $share->getPermissions(); |
|
207 | + $status = max($status, $share->getStatus()); |
|
208 | + |
|
209 | + if ($share->getTarget() !== $superShare->getTarget()) { |
|
210 | + // adjust target, for database consistency |
|
211 | + $share->setTarget($superShare->getTarget()); |
|
212 | + try { |
|
213 | + $this->shareManager->moveShare($share, $user->getUID()); |
|
214 | + } catch (\InvalidArgumentException $e) { |
|
215 | + // ignore as it is not important and we don't want to |
|
216 | + // block FS setup |
|
217 | + |
|
218 | + // the subsequent code anyway only uses the target of the |
|
219 | + // super share |
|
220 | + |
|
221 | + // such issue can usually happen when dealing with |
|
222 | + // null groups which usually appear with group backend |
|
223 | + // caching inconsistencies |
|
224 | + $this->logger->debug( |
|
225 | + 'Could not adjust share target for share ' . $share->getId() . ' to make it consistent: ' . $e->getMessage(), |
|
226 | + ['app' => 'files_sharing'] |
|
227 | + ); |
|
228 | + } |
|
229 | + } |
|
230 | + if (!is_null($share->getNodeCacheEntry())) { |
|
231 | + $superShare->setNodeCacheEntry($share->getNodeCacheEntry()); |
|
232 | + } |
|
233 | + } |
|
234 | + |
|
235 | + $superShare->setPermissions($permissions) |
|
236 | + ->setStatus($status); |
|
237 | + |
|
238 | + $result[] = [$superShare, $shares]; |
|
239 | + } |
|
240 | + |
|
241 | + return $result; |
|
242 | + } |
|
243 | 243 | } |