Completed
Pull Request — master (#5280)
by Morris
46:13 queued 27:39
created
lib/private/Share20/Share.php 1 patch
Indentation   +444 added lines, -444 removed lines patch added patch discarded remove patch
@@ -32,448 +32,448 @@
 block discarded – undo
32 32
 
33 33
 class Share implements \OCP\Share\IShare {
34 34
 
35
-	/** @var string */
36
-	private $id;
37
-	/** @var string */
38
-	private $providerId;
39
-	/** @var Node */
40
-	private $node;
41
-	/** @var int */
42
-	private $fileId;
43
-	/** @var string */
44
-	private $nodeType;
45
-	/** @var int */
46
-	private $shareType;
47
-	/** @var string */
48
-	private $sharedWith;
49
-	/** @var string */
50
-	private $sharedWithDisplayName;
51
-	/** @var string */
52
-	private $sharedWithAvatar;
53
-	/** @var string */
54
-	private $sharedBy;
55
-	/** @var string */
56
-	private $shareOwner;
57
-	/** @var int */
58
-	private $permissions;
59
-	/** @var \DateTime */
60
-	private $expireDate;
61
-	/** @var string */
62
-	private $password;
63
-	/** @var string */
64
-	private $token;
65
-	/** @var int */
66
-	private $parent;
67
-	/** @var string */
68
-	private $target;
69
-	/** @var \DateTime */
70
-	private $shareTime;
71
-	/** @var bool */
72
-	private $mailSend;
73
-
74
-	/** @var IRootFolder */
75
-	private $rootFolder;
76
-
77
-	/** @var IUserManager */
78
-	private $userManager;
79
-
80
-	/** @var ICacheEntry|null */
81
-	private $nodeCacheEntry;
82
-
83
-	public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
84
-		$this->rootFolder = $rootFolder;
85
-		$this->userManager = $userManager;
86
-	}
87
-
88
-	/**
89
-	 * @inheritdoc
90
-	 */
91
-	public function setId($id) {
92
-		if (is_int($id)) {
93
-			$id = (string)$id;
94
-		}
95
-
96
-		if(!is_string($id)) {
97
-			throw new \InvalidArgumentException('String expected.');
98
-		}
99
-
100
-		if ($this->id !== null) {
101
-			throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
102
-		}
103
-
104
-		$this->id = trim($id);
105
-		return $this;
106
-	}
107
-
108
-	/**
109
-	 * @inheritdoc
110
-	 */
111
-	public function getId() {
112
-		return $this->id;
113
-	}
114
-
115
-	/**
116
-	 * @inheritdoc
117
-	 */
118
-	public function getFullId() {
119
-		if ($this->providerId === null || $this->id === null) {
120
-			throw new \UnexpectedValueException;
121
-		}
122
-		return $this->providerId . ':' . $this->id;
123
-	}
124
-
125
-	/**
126
-	 * @inheritdoc
127
-	 */
128
-	public function setProviderId($id) {
129
-		if(!is_string($id)) {
130
-			throw new \InvalidArgumentException('String expected.');
131
-		}
132
-
133
-		if ($this->providerId !== null) {
134
-			throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
135
-		}
136
-
137
-		$this->providerId = trim($id);
138
-		return $this;
139
-	}
140
-
141
-	/**
142
-	 * @inheritdoc
143
-	 */
144
-	public function setNode(Node $node) {
145
-		$this->fileId = null;
146
-		$this->nodeType = null;
147
-		$this->node = $node;
148
-		return $this;
149
-	}
150
-
151
-	/**
152
-	 * @inheritdoc
153
-	 */
154
-	public function getNode() {
155
-		if ($this->node === null) {
156
-
157
-			if ($this->shareOwner === null || $this->fileId === null) {
158
-				throw new NotFoundException();
159
-			}
160
-
161
-			// for federated shares the owner can be a remote user, in this
162
-			// case we use the initiator
163
-			if($this->userManager->userExists($this->shareOwner)) {
164
-				$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
165
-			} else {
166
-				$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
167
-			}
168
-
169
-			$nodes = $userFolder->getById($this->fileId);
170
-			if (empty($nodes)) {
171
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
172
-			}
173
-
174
-			$this->node = $nodes[0];
175
-		}
176
-
177
-		return $this->node;
178
-	}
179
-
180
-	/**
181
-	 * @inheritdoc
182
-	 */
183
-	public function setNodeId($fileId) {
184
-		$this->node = null;
185
-		$this->fileId = $fileId;
186
-		return $this;
187
-	}
188
-
189
-	/**
190
-	 * @inheritdoc
191
-	 */
192
-	public function getNodeId() {
193
-		if ($this->fileId === null) {
194
-			$this->fileId = $this->getNode()->getId();
195
-		}
196
-
197
-		return $this->fileId;
198
-	}
199
-
200
-	/**
201
-	 * @inheritdoc
202
-	 */
203
-	public function setNodeType($type) {
204
-		if ($type !== 'file' && $type !== 'folder') {
205
-			throw new \InvalidArgumentException();
206
-		}
207
-
208
-		$this->nodeType = $type;
209
-		return $this;
210
-	}
211
-
212
-	/**
213
-	 * @inheritdoc
214
-	 */
215
-	public function getNodeType() {
216
-		if ($this->nodeType === null) {
217
-			$node = $this->getNode();
218
-			$this->nodeType = $node instanceof File ? 'file' : 'folder';
219
-		}
220
-
221
-		return $this->nodeType;
222
-	}
223
-
224
-	/**
225
-	 * @inheritdoc
226
-	 */
227
-	public function setShareType($shareType) {
228
-		$this->shareType = $shareType;
229
-		return $this;
230
-	}
231
-
232
-	/**
233
-	 * @inheritdoc
234
-	 */
235
-	public function getShareType() {
236
-		return $this->shareType;
237
-	}
238
-
239
-	/**
240
-	 * @inheritdoc
241
-	 */
242
-	public function setSharedWith($sharedWith) {
243
-		if (!is_string($sharedWith)) {
244
-			throw new \InvalidArgumentException();
245
-		}
246
-		$this->sharedWith = $sharedWith;
247
-		return $this;
248
-	}
249
-
250
-	/**
251
-	 * @inheritdoc
252
-	 */
253
-	public function getSharedWith() {
254
-		return $this->sharedWith;
255
-	}
256
-
257
-	/**
258
-	 * @inheritdoc
259
-	 */
260
-	public function setSharedWithDisplayName($displayName) {
261
-		if (!is_string($displayName)) {
262
-			throw new \InvalidArgumentException();
263
-		}
264
-		$this->sharedWithDisplayName = $displayName;
265
-		return $this;
266
-	}
267
-
268
-	/**
269
-	 * @inheritdoc
270
-	 */
271
-	public function getSharedWithDisplayName() {
272
-		return $this->sharedWithDisplayName;
273
-	}
274
-
275
-	/**
276
-	 * @inheritdoc
277
-	 */
278
-	public function setSharedWithAvatar($src) {
279
-		if (!is_string($src)) {
280
-			throw new \InvalidArgumentException();
281
-		}
282
-		$this->sharedWithAvatar = $src;
283
-		return $this;
284
-	}
285
-
286
-	/**
287
-	 * @inheritdoc
288
-	 */
289
-	public function getSharedWithAvatar() {
290
-		return $this->sharedWithAvatar;
291
-	}
292
-
293
-	/**
294
-	 * @inheritdoc
295
-	 */
296
-	public function setPermissions($permissions) {
297
-		//TODO checkes
298
-
299
-		$this->permissions = $permissions;
300
-		return $this;
301
-	}
302
-
303
-	/**
304
-	 * @inheritdoc
305
-	 */
306
-	public function getPermissions() {
307
-		return $this->permissions;
308
-	}
309
-
310
-	/**
311
-	 * @inheritdoc
312
-	 */
313
-	public function setExpirationDate($expireDate) {
314
-		//TODO checks
315
-
316
-		$this->expireDate = $expireDate;
317
-		return $this;
318
-	}
319
-
320
-	/**
321
-	 * @inheritdoc
322
-	 */
323
-	public function getExpirationDate() {
324
-		return $this->expireDate;
325
-	}
326
-
327
-	/**
328
-	 * @inheritdoc
329
-	 */
330
-	public function setSharedBy($sharedBy) {
331
-		if (!is_string($sharedBy)) {
332
-			throw new \InvalidArgumentException();
333
-		}
334
-		//TODO checks
335
-		$this->sharedBy = $sharedBy;
336
-
337
-		return $this;
338
-	}
339
-
340
-	/**
341
-	 * @inheritdoc
342
-	 */
343
-	public function getSharedBy() {
344
-		//TODO check if set
345
-		return $this->sharedBy;
346
-	}
347
-
348
-	/**
349
-	 * @inheritdoc
350
-	 */
351
-	public function setShareOwner($shareOwner) {
352
-		if (!is_string($shareOwner)) {
353
-			throw new \InvalidArgumentException();
354
-		}
355
-		//TODO checks
356
-
357
-		$this->shareOwner = $shareOwner;
358
-		return $this;
359
-	}
360
-
361
-	/**
362
-	 * @inheritdoc
363
-	 */
364
-	public function getShareOwner() {
365
-		//TODO check if set
366
-		return $this->shareOwner;
367
-	}
368
-
369
-	/**
370
-	 * @inheritdoc
371
-	 */
372
-	public function setPassword($password) {
373
-		$this->password = $password;
374
-		return $this;
375
-	}
376
-
377
-	/**
378
-	 * @inheritdoc
379
-	 */
380
-	public function getPassword() {
381
-		return $this->password;
382
-	}
383
-
384
-	/**
385
-	 * @inheritdoc
386
-	 */
387
-	public function setToken($token) {
388
-		$this->token = $token;
389
-		return $this;
390
-	}
391
-
392
-	/**
393
-	 * @inheritdoc
394
-	 */
395
-	public function getToken() {
396
-		return $this->token;
397
-	}
398
-
399
-	/**
400
-	 * Set the parent of this share
401
-	 *
402
-	 * @param int parent
403
-	 * @return \OCP\Share\IShare
404
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
405
-	 */
406
-	public function setParent($parent) {
407
-		$this->parent = $parent;
408
-		return $this;
409
-	}
410
-
411
-	/**
412
-	 * Get the parent of this share.
413
-	 *
414
-	 * @return int
415
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
416
-	 */
417
-	public function getParent() {
418
-		return $this->parent;
419
-	}
420
-
421
-	/**
422
-	 * @inheritdoc
423
-	 */
424
-	public function setTarget($target) {
425
-		$this->target = $target;
426
-		return $this;
427
-	}
428
-
429
-	/**
430
-	 * @inheritdoc
431
-	 */
432
-	public function getTarget() {
433
-		return $this->target;
434
-	}
435
-
436
-	/**
437
-	 * @inheritdoc
438
-	 */
439
-	public function setShareTime(\DateTime $shareTime) {
440
-		$this->shareTime = $shareTime;
441
-		return $this;
442
-	}
443
-
444
-	/**
445
-	 * @inheritdoc
446
-	 */
447
-	public function getShareTime() {
448
-		return $this->shareTime;
449
-	}
450
-
451
-	/**
452
-	 * @inheritdoc
453
-	 */
454
-	public function setMailSend($mailSend) {
455
-		$this->mailSend = $mailSend;
456
-		return $this;
457
-	}
458
-
459
-	/**
460
-	 * @inheritdoc
461
-	 */
462
-	public function getMailSend() {
463
-		return $this->mailSend;
464
-	}
465
-
466
-	/**
467
-	 * @inheritdoc
468
-	 */
469
-	public function setNodeCacheEntry(ICacheEntry $entry) {
470
-		$this->nodeCacheEntry = $entry;
471
-	}
472
-
473
-	/**
474
-	 * @inheritdoc
475
-	 */
476
-	public function getNodeCacheEntry() {
477
-		return $this->nodeCacheEntry;
478
-	}
35
+    /** @var string */
36
+    private $id;
37
+    /** @var string */
38
+    private $providerId;
39
+    /** @var Node */
40
+    private $node;
41
+    /** @var int */
42
+    private $fileId;
43
+    /** @var string */
44
+    private $nodeType;
45
+    /** @var int */
46
+    private $shareType;
47
+    /** @var string */
48
+    private $sharedWith;
49
+    /** @var string */
50
+    private $sharedWithDisplayName;
51
+    /** @var string */
52
+    private $sharedWithAvatar;
53
+    /** @var string */
54
+    private $sharedBy;
55
+    /** @var string */
56
+    private $shareOwner;
57
+    /** @var int */
58
+    private $permissions;
59
+    /** @var \DateTime */
60
+    private $expireDate;
61
+    /** @var string */
62
+    private $password;
63
+    /** @var string */
64
+    private $token;
65
+    /** @var int */
66
+    private $parent;
67
+    /** @var string */
68
+    private $target;
69
+    /** @var \DateTime */
70
+    private $shareTime;
71
+    /** @var bool */
72
+    private $mailSend;
73
+
74
+    /** @var IRootFolder */
75
+    private $rootFolder;
76
+
77
+    /** @var IUserManager */
78
+    private $userManager;
79
+
80
+    /** @var ICacheEntry|null */
81
+    private $nodeCacheEntry;
82
+
83
+    public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
84
+        $this->rootFolder = $rootFolder;
85
+        $this->userManager = $userManager;
86
+    }
87
+
88
+    /**
89
+     * @inheritdoc
90
+     */
91
+    public function setId($id) {
92
+        if (is_int($id)) {
93
+            $id = (string)$id;
94
+        }
95
+
96
+        if(!is_string($id)) {
97
+            throw new \InvalidArgumentException('String expected.');
98
+        }
99
+
100
+        if ($this->id !== null) {
101
+            throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
102
+        }
103
+
104
+        $this->id = trim($id);
105
+        return $this;
106
+    }
107
+
108
+    /**
109
+     * @inheritdoc
110
+     */
111
+    public function getId() {
112
+        return $this->id;
113
+    }
114
+
115
+    /**
116
+     * @inheritdoc
117
+     */
118
+    public function getFullId() {
119
+        if ($this->providerId === null || $this->id === null) {
120
+            throw new \UnexpectedValueException;
121
+        }
122
+        return $this->providerId . ':' . $this->id;
123
+    }
124
+
125
+    /**
126
+     * @inheritdoc
127
+     */
128
+    public function setProviderId($id) {
129
+        if(!is_string($id)) {
130
+            throw new \InvalidArgumentException('String expected.');
131
+        }
132
+
133
+        if ($this->providerId !== null) {
134
+            throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
135
+        }
136
+
137
+        $this->providerId = trim($id);
138
+        return $this;
139
+    }
140
+
141
+    /**
142
+     * @inheritdoc
143
+     */
144
+    public function setNode(Node $node) {
145
+        $this->fileId = null;
146
+        $this->nodeType = null;
147
+        $this->node = $node;
148
+        return $this;
149
+    }
150
+
151
+    /**
152
+     * @inheritdoc
153
+     */
154
+    public function getNode() {
155
+        if ($this->node === null) {
156
+
157
+            if ($this->shareOwner === null || $this->fileId === null) {
158
+                throw new NotFoundException();
159
+            }
160
+
161
+            // for federated shares the owner can be a remote user, in this
162
+            // case we use the initiator
163
+            if($this->userManager->userExists($this->shareOwner)) {
164
+                $userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
165
+            } else {
166
+                $userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
167
+            }
168
+
169
+            $nodes = $userFolder->getById($this->fileId);
170
+            if (empty($nodes)) {
171
+                throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
172
+            }
173
+
174
+            $this->node = $nodes[0];
175
+        }
176
+
177
+        return $this->node;
178
+    }
179
+
180
+    /**
181
+     * @inheritdoc
182
+     */
183
+    public function setNodeId($fileId) {
184
+        $this->node = null;
185
+        $this->fileId = $fileId;
186
+        return $this;
187
+    }
188
+
189
+    /**
190
+     * @inheritdoc
191
+     */
192
+    public function getNodeId() {
193
+        if ($this->fileId === null) {
194
+            $this->fileId = $this->getNode()->getId();
195
+        }
196
+
197
+        return $this->fileId;
198
+    }
199
+
200
+    /**
201
+     * @inheritdoc
202
+     */
203
+    public function setNodeType($type) {
204
+        if ($type !== 'file' && $type !== 'folder') {
205
+            throw new \InvalidArgumentException();
206
+        }
207
+
208
+        $this->nodeType = $type;
209
+        return $this;
210
+    }
211
+
212
+    /**
213
+     * @inheritdoc
214
+     */
215
+    public function getNodeType() {
216
+        if ($this->nodeType === null) {
217
+            $node = $this->getNode();
218
+            $this->nodeType = $node instanceof File ? 'file' : 'folder';
219
+        }
220
+
221
+        return $this->nodeType;
222
+    }
223
+
224
+    /**
225
+     * @inheritdoc
226
+     */
227
+    public function setShareType($shareType) {
228
+        $this->shareType = $shareType;
229
+        return $this;
230
+    }
231
+
232
+    /**
233
+     * @inheritdoc
234
+     */
235
+    public function getShareType() {
236
+        return $this->shareType;
237
+    }
238
+
239
+    /**
240
+     * @inheritdoc
241
+     */
242
+    public function setSharedWith($sharedWith) {
243
+        if (!is_string($sharedWith)) {
244
+            throw new \InvalidArgumentException();
245
+        }
246
+        $this->sharedWith = $sharedWith;
247
+        return $this;
248
+    }
249
+
250
+    /**
251
+     * @inheritdoc
252
+     */
253
+    public function getSharedWith() {
254
+        return $this->sharedWith;
255
+    }
256
+
257
+    /**
258
+     * @inheritdoc
259
+     */
260
+    public function setSharedWithDisplayName($displayName) {
261
+        if (!is_string($displayName)) {
262
+            throw new \InvalidArgumentException();
263
+        }
264
+        $this->sharedWithDisplayName = $displayName;
265
+        return $this;
266
+    }
267
+
268
+    /**
269
+     * @inheritdoc
270
+     */
271
+    public function getSharedWithDisplayName() {
272
+        return $this->sharedWithDisplayName;
273
+    }
274
+
275
+    /**
276
+     * @inheritdoc
277
+     */
278
+    public function setSharedWithAvatar($src) {
279
+        if (!is_string($src)) {
280
+            throw new \InvalidArgumentException();
281
+        }
282
+        $this->sharedWithAvatar = $src;
283
+        return $this;
284
+    }
285
+
286
+    /**
287
+     * @inheritdoc
288
+     */
289
+    public function getSharedWithAvatar() {
290
+        return $this->sharedWithAvatar;
291
+    }
292
+
293
+    /**
294
+     * @inheritdoc
295
+     */
296
+    public function setPermissions($permissions) {
297
+        //TODO checkes
298
+
299
+        $this->permissions = $permissions;
300
+        return $this;
301
+    }
302
+
303
+    /**
304
+     * @inheritdoc
305
+     */
306
+    public function getPermissions() {
307
+        return $this->permissions;
308
+    }
309
+
310
+    /**
311
+     * @inheritdoc
312
+     */
313
+    public function setExpirationDate($expireDate) {
314
+        //TODO checks
315
+
316
+        $this->expireDate = $expireDate;
317
+        return $this;
318
+    }
319
+
320
+    /**
321
+     * @inheritdoc
322
+     */
323
+    public function getExpirationDate() {
324
+        return $this->expireDate;
325
+    }
326
+
327
+    /**
328
+     * @inheritdoc
329
+     */
330
+    public function setSharedBy($sharedBy) {
331
+        if (!is_string($sharedBy)) {
332
+            throw new \InvalidArgumentException();
333
+        }
334
+        //TODO checks
335
+        $this->sharedBy = $sharedBy;
336
+
337
+        return $this;
338
+    }
339
+
340
+    /**
341
+     * @inheritdoc
342
+     */
343
+    public function getSharedBy() {
344
+        //TODO check if set
345
+        return $this->sharedBy;
346
+    }
347
+
348
+    /**
349
+     * @inheritdoc
350
+     */
351
+    public function setShareOwner($shareOwner) {
352
+        if (!is_string($shareOwner)) {
353
+            throw new \InvalidArgumentException();
354
+        }
355
+        //TODO checks
356
+
357
+        $this->shareOwner = $shareOwner;
358
+        return $this;
359
+    }
360
+
361
+    /**
362
+     * @inheritdoc
363
+     */
364
+    public function getShareOwner() {
365
+        //TODO check if set
366
+        return $this->shareOwner;
367
+    }
368
+
369
+    /**
370
+     * @inheritdoc
371
+     */
372
+    public function setPassword($password) {
373
+        $this->password = $password;
374
+        return $this;
375
+    }
376
+
377
+    /**
378
+     * @inheritdoc
379
+     */
380
+    public function getPassword() {
381
+        return $this->password;
382
+    }
383
+
384
+    /**
385
+     * @inheritdoc
386
+     */
387
+    public function setToken($token) {
388
+        $this->token = $token;
389
+        return $this;
390
+    }
391
+
392
+    /**
393
+     * @inheritdoc
394
+     */
395
+    public function getToken() {
396
+        return $this->token;
397
+    }
398
+
399
+    /**
400
+     * Set the parent of this share
401
+     *
402
+     * @param int parent
403
+     * @return \OCP\Share\IShare
404
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
405
+     */
406
+    public function setParent($parent) {
407
+        $this->parent = $parent;
408
+        return $this;
409
+    }
410
+
411
+    /**
412
+     * Get the parent of this share.
413
+     *
414
+     * @return int
415
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
416
+     */
417
+    public function getParent() {
418
+        return $this->parent;
419
+    }
420
+
421
+    /**
422
+     * @inheritdoc
423
+     */
424
+    public function setTarget($target) {
425
+        $this->target = $target;
426
+        return $this;
427
+    }
428
+
429
+    /**
430
+     * @inheritdoc
431
+     */
432
+    public function getTarget() {
433
+        return $this->target;
434
+    }
435
+
436
+    /**
437
+     * @inheritdoc
438
+     */
439
+    public function setShareTime(\DateTime $shareTime) {
440
+        $this->shareTime = $shareTime;
441
+        return $this;
442
+    }
443
+
444
+    /**
445
+     * @inheritdoc
446
+     */
447
+    public function getShareTime() {
448
+        return $this->shareTime;
449
+    }
450
+
451
+    /**
452
+     * @inheritdoc
453
+     */
454
+    public function setMailSend($mailSend) {
455
+        $this->mailSend = $mailSend;
456
+        return $this;
457
+    }
458
+
459
+    /**
460
+     * @inheritdoc
461
+     */
462
+    public function getMailSend() {
463
+        return $this->mailSend;
464
+    }
465
+
466
+    /**
467
+     * @inheritdoc
468
+     */
469
+    public function setNodeCacheEntry(ICacheEntry $entry) {
470
+        $this->nodeCacheEntry = $entry;
471
+    }
472
+
473
+    /**
474
+     * @inheritdoc
475
+     */
476
+    public function getNodeCacheEntry() {
477
+        return $this->nodeCacheEntry;
478
+    }
479 479
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Controller/ShareAPIController.php 1 patch
Indentation   +890 added lines, -890 removed lines patch added patch discarded remove patch
@@ -59,903 +59,903 @@
 block discarded – undo
59 59
  */
60 60
 class ShareAPIController extends OCSController {
61 61
 
62
-	/** @var IManager */
63
-	private $shareManager;
64
-	/** @var IGroupManager */
65
-	private $groupManager;
66
-	/** @var IUserManager */
67
-	private $userManager;
68
-	/** @var IRequest */
69
-	protected $request;
70
-	/** @var IRootFolder */
71
-	private $rootFolder;
72
-	/** @var IURLGenerator */
73
-	private $urlGenerator;
74
-	/** @var string */
75
-	private $currentUser;
76
-	/** @var IL10N */
77
-	private $l;
78
-	/** @var \OCP\Files\Node */
79
-	private $lockedNode;
80
-	/** @var IConfig */
81
-	private $config;
82
-
83
-	/**
84
-	 * Share20OCS constructor.
85
-	 *
86
-	 * @param string $appName
87
-	 * @param IRequest $request
88
-	 * @param IManager $shareManager
89
-	 * @param IGroupManager $groupManager
90
-	 * @param IUserManager $userManager
91
-	 * @param IRootFolder $rootFolder
92
-	 * @param IURLGenerator $urlGenerator
93
-	 * @param string $userId
94
-	 * @param IL10N $l10n
95
-	 * @param IConfig $config
96
-	 */
97
-	public function __construct(
98
-		$appName,
99
-		IRequest $request,
100
-		IManager $shareManager,
101
-		IGroupManager $groupManager,
102
-		IUserManager $userManager,
103
-		IRootFolder $rootFolder,
104
-		IURLGenerator $urlGenerator,
105
-		$userId,
106
-		IL10N $l10n,
107
-		IConfig $config
108
-	) {
109
-		parent::__construct($appName, $request);
110
-
111
-		$this->shareManager = $shareManager;
112
-		$this->userManager = $userManager;
113
-		$this->groupManager = $groupManager;
114
-		$this->request = $request;
115
-		$this->rootFolder = $rootFolder;
116
-		$this->urlGenerator = $urlGenerator;
117
-		$this->currentUser = $userId;
118
-		$this->l = $l10n;
119
-		$this->config = $config;
120
-	}
121
-
122
-	/**
123
-	 * Convert an IShare to an array for OCS output
124
-	 *
125
-	 * @param \OCP\Share\IShare $share
126
-	 * @param Node|null $recipientNode
127
-	 * @return array
128
-	 * @throws NotFoundException In case the node can't be resolved.
129
-	 */
130
-	protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = null) {
131
-		$sharedBy = $this->userManager->get($share->getSharedBy());
132
-		$shareOwner = $this->userManager->get($share->getShareOwner());
133
-
134
-		$result = [
135
-			'id' => $share->getId(),
136
-			'share_type' => $share->getShareType(),
137
-			'uid_owner' => $share->getSharedBy(),
138
-			'displayname_owner' => $sharedBy !== null ? $sharedBy->getDisplayName() : $share->getSharedBy(),
139
-			'permissions' => $share->getPermissions(),
140
-			'stime' => $share->getShareTime()->getTimestamp(),
141
-			'parent' => null,
142
-			'expiration' => null,
143
-			'token' => null,
144
-			'uid_file_owner' => $share->getShareOwner(),
145
-			'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
146
-		];
147
-
148
-		$userFolder = $this->rootFolder->getUserFolder($this->currentUser);
149
-		if ($recipientNode) {
150
-			$node = $recipientNode;
151
-		} else {
152
-			$nodes = $userFolder->getById($share->getNodeId());
153
-
154
-			if (empty($nodes)) {
155
-				// fallback to guessing the path
156
-				$node = $userFolder->get($share->getTarget());
157
-				if ($node === null) {
158
-					throw new NotFoundException();
159
-				}
160
-			} else {
161
-				$node = $nodes[0];
162
-			}
163
-		}
164
-
165
-		$result['path'] = $userFolder->getRelativePath($node->getPath());
166
-		if ($node instanceOf \OCP\Files\Folder) {
167
-			$result['item_type'] = 'folder';
168
-		} else {
169
-			$result['item_type'] = 'file';
170
-		}
171
-		$result['mimetype'] = $node->getMimetype();
172
-		$result['storage_id'] = $node->getStorage()->getId();
173
-		$result['storage'] = $node->getStorage()->getCache()->getNumericStorageId();
174
-		$result['item_source'] = $node->getId();
175
-		$result['file_source'] = $node->getId();
176
-		$result['file_parent'] = $node->getParent()->getId();
177
-		$result['file_target'] = $share->getTarget();
178
-
179
-		$expiration = $share->getExpirationDate();
180
-		if ($expiration !== null) {
181
-			$result['expiration'] = $expiration->format('Y-m-d 00:00:00');
182
-		}
183
-
184
-		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
185
-			$sharedWith = $this->userManager->get($share->getSharedWith());
186
-			$result['share_with'] = $share->getSharedWith();
187
-			$result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
188
-		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
189
-			$group = $this->groupManager->get($share->getSharedWith());
190
-			$result['share_with'] = $share->getSharedWith();
191
-			$result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith();
192
-		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
193
-
194
-			$result['share_with'] = $share->getPassword();
195
-			$result['share_with_displayname'] = $share->getPassword();
196
-
197
-			$result['token'] = $share->getToken();
198
-			$result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);
199
-
200
-		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
201
-			$result['share_with'] = $share->getSharedWith();
202
-			$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'CLOUD');
203
-			$result['token'] = $share->getToken();
204
-		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
205
-			$result['share_with'] = $share->getSharedWith();
206
-			$result['password'] = $share->getPassword();
207
-			$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
208
-			$result['token'] = $share->getToken();
209
-		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
210
-			if ($share->getSharedWithDisplayName() !== '') {
211
-				$result['share_with_displayname'] = $share->getSharedWithDisplayName();
212
-				$result['share_with_avatar'] = $share->getSharedWithAvatar();
213
-				$result['share_with'] = $share->getSharedWith();
214
-			} else {
215
-				$result['share_with_displayname'] = $share->getSharedWith();
216
-				$result['share_with'] = explode(' ', $share->getSharedWith(), 2)[0];
217
-			}
218
-		}
219
-
220
-
221
-		$result['mail_send'] = $share->getMailSend() ? 1 : 0;
222
-
223
-		return $result;
224
-	}
225
-
226
-	/**
227
-	 * Check if one of the users address books knows the exact property, if
228
-	 * yes we return the full name.
229
-	 *
230
-	 * @param string $query
231
-	 * @param string $property
232
-	 * @return string
233
-	 */
234
-	private function getDisplayNameFromAddressBook($query, $property) {
235
-		// FIXME: If we inject the contacts manager it gets initialized bofore any address books are registered
236
-		$result = \OC::$server->getContactsManager()->search($query, [$property]);
237
-		foreach ($result as $r) {
238
-			foreach($r[$property] as $value) {
239
-				if ($value === $query) {
240
-					return $r['FN'];
241
-				}
242
-			}
243
-		}
244
-
245
-		return $query;
246
-	}
247
-
248
-	/**
249
-	 * Get a specific share by id
250
-	 *
251
-	 * @NoAdminRequired
252
-	 *
253
-	 * @param string $id
254
-	 * @return DataResponse
255
-	 * @throws OCSNotFoundException
256
-	 */
257
-	public function getShare($id) {
258
-		try {
259
-			$share = $this->getShareById($id);
260
-		} catch (ShareNotFound $e) {
261
-			throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
262
-		}
263
-
264
-		if ($this->canAccessShare($share)) {
265
-			try {
266
-				$share = $this->formatShare($share);
267
-				return new DataResponse([$share]);
268
-			} catch (NotFoundException $e) {
269
-				//Fall trough
270
-			}
271
-		}
272
-
273
-		throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
274
-	}
275
-
276
-	/**
277
-	 * Delete a share
278
-	 *
279
-	 * @NoAdminRequired
280
-	 *
281
-	 * @param string $id
282
-	 * @return DataResponse
283
-	 * @throws OCSNotFoundException
284
-	 */
285
-	public function deleteShare($id) {
286
-		try {
287
-			$share = $this->getShareById($id);
288
-		} catch (ShareNotFound $e) {
289
-			throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
290
-		}
291
-
292
-		try {
293
-			$this->lock($share->getNode());
294
-		} catch (LockedException $e) {
295
-			throw new OCSNotFoundException($this->l->t('could not delete share'));
296
-		}
297
-
298
-		if (!$this->canAccessShare($share)) {
299
-			throw new OCSNotFoundException($this->l->t('Could not delete share'));
300
-		}
301
-
302
-		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
303
-			$share->getShareOwner() !== $this->currentUser &&
304
-			$share->getSharedBy() !== $this->currentUser) {
305
-			$this->shareManager->deleteFromSelf($share, $this->currentUser);
306
-		} else {
307
-			$this->shareManager->deleteShare($share);
308
-		}
309
-
310
-		return new DataResponse();
311
-	}
312
-
313
-	/**
314
-	 * @NoAdminRequired
315
-	 *
316
-	 * @param string $path
317
-	 * @param int $permissions
318
-	 * @param int $shareType
319
-	 * @param string $shareWith
320
-	 * @param string $publicUpload
321
-	 * @param string $password
322
-	 * @param string $expireDate
323
-	 *
324
-	 * @return DataResponse
325
-	 * @throws OCSNotFoundException
326
-	 * @throws OCSForbiddenException
327
-	 * @throws OCSBadRequestException
328
-	 * @throws OCSException
329
-	 *
330
-	 * @suppress PhanUndeclaredClassMethod
331
-	 */
332
-	public function createShare(
333
-		$path = null,
334
-		$permissions = null,
335
-		$shareType = -1,
336
-		$shareWith = null,
337
-		$publicUpload = 'false',
338
-		$password = '',
339
-		$expireDate = ''
340
-	) {
341
-		$share = $this->shareManager->newShare();
342
-
343
-		if ($permissions === null) {
344
-			$permissions = $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL);
345
-		}
346
-
347
-		// Verify path
348
-		if ($path === null) {
349
-			throw new OCSNotFoundException($this->l->t('Please specify a file or folder path'));
350
-		}
351
-
352
-		$userFolder = $this->rootFolder->getUserFolder($this->currentUser);
353
-		try {
354
-			$path = $userFolder->get($path);
355
-		} catch (NotFoundException $e) {
356
-			throw new OCSNotFoundException($this->l->t('Wrong path, file/folder doesn\'t exist'));
357
-		}
358
-
359
-		$share->setNode($path);
360
-
361
-		try {
362
-			$this->lock($share->getNode());
363
-		} catch (LockedException $e) {
364
-			throw new OCSNotFoundException($this->l->t('Could not create share'));
365
-		}
366
-
367
-		if ($permissions < 0 || $permissions > Constants::PERMISSION_ALL) {
368
-			throw new OCSNotFoundException($this->l->t('invalid permissions'));
369
-		}
370
-
371
-		// Shares always require read permissions
372
-		$permissions |= Constants::PERMISSION_READ;
373
-
374
-		if ($path instanceof \OCP\Files\File) {
375
-			// Single file shares should never have delete or create permissions
376
-			$permissions &= ~Constants::PERMISSION_DELETE;
377
-			$permissions &= ~Constants::PERMISSION_CREATE;
378
-		}
379
-
380
-		/*
62
+    /** @var IManager */
63
+    private $shareManager;
64
+    /** @var IGroupManager */
65
+    private $groupManager;
66
+    /** @var IUserManager */
67
+    private $userManager;
68
+    /** @var IRequest */
69
+    protected $request;
70
+    /** @var IRootFolder */
71
+    private $rootFolder;
72
+    /** @var IURLGenerator */
73
+    private $urlGenerator;
74
+    /** @var string */
75
+    private $currentUser;
76
+    /** @var IL10N */
77
+    private $l;
78
+    /** @var \OCP\Files\Node */
79
+    private $lockedNode;
80
+    /** @var IConfig */
81
+    private $config;
82
+
83
+    /**
84
+     * Share20OCS constructor.
85
+     *
86
+     * @param string $appName
87
+     * @param IRequest $request
88
+     * @param IManager $shareManager
89
+     * @param IGroupManager $groupManager
90
+     * @param IUserManager $userManager
91
+     * @param IRootFolder $rootFolder
92
+     * @param IURLGenerator $urlGenerator
93
+     * @param string $userId
94
+     * @param IL10N $l10n
95
+     * @param IConfig $config
96
+     */
97
+    public function __construct(
98
+        $appName,
99
+        IRequest $request,
100
+        IManager $shareManager,
101
+        IGroupManager $groupManager,
102
+        IUserManager $userManager,
103
+        IRootFolder $rootFolder,
104
+        IURLGenerator $urlGenerator,
105
+        $userId,
106
+        IL10N $l10n,
107
+        IConfig $config
108
+    ) {
109
+        parent::__construct($appName, $request);
110
+
111
+        $this->shareManager = $shareManager;
112
+        $this->userManager = $userManager;
113
+        $this->groupManager = $groupManager;
114
+        $this->request = $request;
115
+        $this->rootFolder = $rootFolder;
116
+        $this->urlGenerator = $urlGenerator;
117
+        $this->currentUser = $userId;
118
+        $this->l = $l10n;
119
+        $this->config = $config;
120
+    }
121
+
122
+    /**
123
+     * Convert an IShare to an array for OCS output
124
+     *
125
+     * @param \OCP\Share\IShare $share
126
+     * @param Node|null $recipientNode
127
+     * @return array
128
+     * @throws NotFoundException In case the node can't be resolved.
129
+     */
130
+    protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = null) {
131
+        $sharedBy = $this->userManager->get($share->getSharedBy());
132
+        $shareOwner = $this->userManager->get($share->getShareOwner());
133
+
134
+        $result = [
135
+            'id' => $share->getId(),
136
+            'share_type' => $share->getShareType(),
137
+            'uid_owner' => $share->getSharedBy(),
138
+            'displayname_owner' => $sharedBy !== null ? $sharedBy->getDisplayName() : $share->getSharedBy(),
139
+            'permissions' => $share->getPermissions(),
140
+            'stime' => $share->getShareTime()->getTimestamp(),
141
+            'parent' => null,
142
+            'expiration' => null,
143
+            'token' => null,
144
+            'uid_file_owner' => $share->getShareOwner(),
145
+            'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
146
+        ];
147
+
148
+        $userFolder = $this->rootFolder->getUserFolder($this->currentUser);
149
+        if ($recipientNode) {
150
+            $node = $recipientNode;
151
+        } else {
152
+            $nodes = $userFolder->getById($share->getNodeId());
153
+
154
+            if (empty($nodes)) {
155
+                // fallback to guessing the path
156
+                $node = $userFolder->get($share->getTarget());
157
+                if ($node === null) {
158
+                    throw new NotFoundException();
159
+                }
160
+            } else {
161
+                $node = $nodes[0];
162
+            }
163
+        }
164
+
165
+        $result['path'] = $userFolder->getRelativePath($node->getPath());
166
+        if ($node instanceOf \OCP\Files\Folder) {
167
+            $result['item_type'] = 'folder';
168
+        } else {
169
+            $result['item_type'] = 'file';
170
+        }
171
+        $result['mimetype'] = $node->getMimetype();
172
+        $result['storage_id'] = $node->getStorage()->getId();
173
+        $result['storage'] = $node->getStorage()->getCache()->getNumericStorageId();
174
+        $result['item_source'] = $node->getId();
175
+        $result['file_source'] = $node->getId();
176
+        $result['file_parent'] = $node->getParent()->getId();
177
+        $result['file_target'] = $share->getTarget();
178
+
179
+        $expiration = $share->getExpirationDate();
180
+        if ($expiration !== null) {
181
+            $result['expiration'] = $expiration->format('Y-m-d 00:00:00');
182
+        }
183
+
184
+        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
185
+            $sharedWith = $this->userManager->get($share->getSharedWith());
186
+            $result['share_with'] = $share->getSharedWith();
187
+            $result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
188
+        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
189
+            $group = $this->groupManager->get($share->getSharedWith());
190
+            $result['share_with'] = $share->getSharedWith();
191
+            $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith();
192
+        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
193
+
194
+            $result['share_with'] = $share->getPassword();
195
+            $result['share_with_displayname'] = $share->getPassword();
196
+
197
+            $result['token'] = $share->getToken();
198
+            $result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);
199
+
200
+        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
201
+            $result['share_with'] = $share->getSharedWith();
202
+            $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'CLOUD');
203
+            $result['token'] = $share->getToken();
204
+        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
205
+            $result['share_with'] = $share->getSharedWith();
206
+            $result['password'] = $share->getPassword();
207
+            $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
208
+            $result['token'] = $share->getToken();
209
+        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
210
+            if ($share->getSharedWithDisplayName() !== '') {
211
+                $result['share_with_displayname'] = $share->getSharedWithDisplayName();
212
+                $result['share_with_avatar'] = $share->getSharedWithAvatar();
213
+                $result['share_with'] = $share->getSharedWith();
214
+            } else {
215
+                $result['share_with_displayname'] = $share->getSharedWith();
216
+                $result['share_with'] = explode(' ', $share->getSharedWith(), 2)[0];
217
+            }
218
+        }
219
+
220
+
221
+        $result['mail_send'] = $share->getMailSend() ? 1 : 0;
222
+
223
+        return $result;
224
+    }
225
+
226
+    /**
227
+     * Check if one of the users address books knows the exact property, if
228
+     * yes we return the full name.
229
+     *
230
+     * @param string $query
231
+     * @param string $property
232
+     * @return string
233
+     */
234
+    private function getDisplayNameFromAddressBook($query, $property) {
235
+        // FIXME: If we inject the contacts manager it gets initialized bofore any address books are registered
236
+        $result = \OC::$server->getContactsManager()->search($query, [$property]);
237
+        foreach ($result as $r) {
238
+            foreach($r[$property] as $value) {
239
+                if ($value === $query) {
240
+                    return $r['FN'];
241
+                }
242
+            }
243
+        }
244
+
245
+        return $query;
246
+    }
247
+
248
+    /**
249
+     * Get a specific share by id
250
+     *
251
+     * @NoAdminRequired
252
+     *
253
+     * @param string $id
254
+     * @return DataResponse
255
+     * @throws OCSNotFoundException
256
+     */
257
+    public function getShare($id) {
258
+        try {
259
+            $share = $this->getShareById($id);
260
+        } catch (ShareNotFound $e) {
261
+            throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
262
+        }
263
+
264
+        if ($this->canAccessShare($share)) {
265
+            try {
266
+                $share = $this->formatShare($share);
267
+                return new DataResponse([$share]);
268
+            } catch (NotFoundException $e) {
269
+                //Fall trough
270
+            }
271
+        }
272
+
273
+        throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
274
+    }
275
+
276
+    /**
277
+     * Delete a share
278
+     *
279
+     * @NoAdminRequired
280
+     *
281
+     * @param string $id
282
+     * @return DataResponse
283
+     * @throws OCSNotFoundException
284
+     */
285
+    public function deleteShare($id) {
286
+        try {
287
+            $share = $this->getShareById($id);
288
+        } catch (ShareNotFound $e) {
289
+            throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
290
+        }
291
+
292
+        try {
293
+            $this->lock($share->getNode());
294
+        } catch (LockedException $e) {
295
+            throw new OCSNotFoundException($this->l->t('could not delete share'));
296
+        }
297
+
298
+        if (!$this->canAccessShare($share)) {
299
+            throw new OCSNotFoundException($this->l->t('Could not delete share'));
300
+        }
301
+
302
+        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
303
+            $share->getShareOwner() !== $this->currentUser &&
304
+            $share->getSharedBy() !== $this->currentUser) {
305
+            $this->shareManager->deleteFromSelf($share, $this->currentUser);
306
+        } else {
307
+            $this->shareManager->deleteShare($share);
308
+        }
309
+
310
+        return new DataResponse();
311
+    }
312
+
313
+    /**
314
+     * @NoAdminRequired
315
+     *
316
+     * @param string $path
317
+     * @param int $permissions
318
+     * @param int $shareType
319
+     * @param string $shareWith
320
+     * @param string $publicUpload
321
+     * @param string $password
322
+     * @param string $expireDate
323
+     *
324
+     * @return DataResponse
325
+     * @throws OCSNotFoundException
326
+     * @throws OCSForbiddenException
327
+     * @throws OCSBadRequestException
328
+     * @throws OCSException
329
+     *
330
+     * @suppress PhanUndeclaredClassMethod
331
+     */
332
+    public function createShare(
333
+        $path = null,
334
+        $permissions = null,
335
+        $shareType = -1,
336
+        $shareWith = null,
337
+        $publicUpload = 'false',
338
+        $password = '',
339
+        $expireDate = ''
340
+    ) {
341
+        $share = $this->shareManager->newShare();
342
+
343
+        if ($permissions === null) {
344
+            $permissions = $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL);
345
+        }
346
+
347
+        // Verify path
348
+        if ($path === null) {
349
+            throw new OCSNotFoundException($this->l->t('Please specify a file or folder path'));
350
+        }
351
+
352
+        $userFolder = $this->rootFolder->getUserFolder($this->currentUser);
353
+        try {
354
+            $path = $userFolder->get($path);
355
+        } catch (NotFoundException $e) {
356
+            throw new OCSNotFoundException($this->l->t('Wrong path, file/folder doesn\'t exist'));
357
+        }
358
+
359
+        $share->setNode($path);
360
+
361
+        try {
362
+            $this->lock($share->getNode());
363
+        } catch (LockedException $e) {
364
+            throw new OCSNotFoundException($this->l->t('Could not create share'));
365
+        }
366
+
367
+        if ($permissions < 0 || $permissions > Constants::PERMISSION_ALL) {
368
+            throw new OCSNotFoundException($this->l->t('invalid permissions'));
369
+        }
370
+
371
+        // Shares always require read permissions
372
+        $permissions |= Constants::PERMISSION_READ;
373
+
374
+        if ($path instanceof \OCP\Files\File) {
375
+            // Single file shares should never have delete or create permissions
376
+            $permissions &= ~Constants::PERMISSION_DELETE;
377
+            $permissions &= ~Constants::PERMISSION_CREATE;
378
+        }
379
+
380
+        /*
381 381
 		 * Hack for https://github.com/owncloud/core/issues/22587
382 382
 		 * We check the permissions via webdav. But the permissions of the mount point
383 383
 		 * do not equal the share permissions. Here we fix that for federated mounts.
384 384
 		 */
385
-		if ($path->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
386
-			$permissions &= ~($permissions & ~$path->getPermissions());
387
-		}
388
-
389
-		if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
390
-			// Valid user is required to share
391
-			if ($shareWith === null || !$this->userManager->userExists($shareWith)) {
392
-				throw new OCSNotFoundException($this->l->t('Please specify a valid user'));
393
-			}
394
-			$share->setSharedWith($shareWith);
395
-			$share->setPermissions($permissions);
396
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
397
-			if (!$this->shareManager->allowGroupSharing()) {
398
-				throw new OCSNotFoundException($this->l->t('Group sharing is disabled by the administrator'));
399
-			}
400
-
401
-			// Valid group is required to share
402
-			if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) {
403
-				throw new OCSNotFoundException($this->l->t('Please specify a valid group'));
404
-			}
405
-			$share->setSharedWith($shareWith);
406
-			$share->setPermissions($permissions);
407
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) {
408
-			//Can we even share links?
409
-			if (!$this->shareManager->shareApiAllowLinks()) {
410
-				throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
411
-			}
412
-
413
-			/*
385
+        if ($path->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
386
+            $permissions &= ~($permissions & ~$path->getPermissions());
387
+        }
388
+
389
+        if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
390
+            // Valid user is required to share
391
+            if ($shareWith === null || !$this->userManager->userExists($shareWith)) {
392
+                throw new OCSNotFoundException($this->l->t('Please specify a valid user'));
393
+            }
394
+            $share->setSharedWith($shareWith);
395
+            $share->setPermissions($permissions);
396
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
397
+            if (!$this->shareManager->allowGroupSharing()) {
398
+                throw new OCSNotFoundException($this->l->t('Group sharing is disabled by the administrator'));
399
+            }
400
+
401
+            // Valid group is required to share
402
+            if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) {
403
+                throw new OCSNotFoundException($this->l->t('Please specify a valid group'));
404
+            }
405
+            $share->setSharedWith($shareWith);
406
+            $share->setPermissions($permissions);
407
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) {
408
+            //Can we even share links?
409
+            if (!$this->shareManager->shareApiAllowLinks()) {
410
+                throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
411
+            }
412
+
413
+            /*
414 414
 			 * For now we only allow 1 link share.
415 415
 			 * Return the existing link share if this is a duplicate
416 416
 			 */
417
-			$existingShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, false, 1, 0);
418
-			if (!empty($existingShares)) {
419
-				return new DataResponse($this->formatShare($existingShares[0]));
420
-			}
421
-
422
-			if ($publicUpload === 'true') {
423
-				// Check if public upload is allowed
424
-				if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
425
-					throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
426
-				}
427
-
428
-				// Public upload can only be set for folders
429
-				if ($path instanceof \OCP\Files\File) {
430
-					throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders'));
431
-				}
432
-
433
-				$share->setPermissions(
434
-					Constants::PERMISSION_READ |
435
-					Constants::PERMISSION_CREATE |
436
-					Constants::PERMISSION_UPDATE |
437
-					Constants::PERMISSION_DELETE
438
-				);
439
-			} else {
440
-				$share->setPermissions(Constants::PERMISSION_READ);
441
-			}
442
-
443
-			// Set password
444
-			if ($password !== '') {
445
-				$share->setPassword($password);
446
-			}
447
-
448
-			//Expire date
449
-			if ($expireDate !== '') {
450
-				try {
451
-					$expireDate = $this->parseDate($expireDate);
452
-					$share->setExpirationDate($expireDate);
453
-				} catch (\Exception $e) {
454
-					throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
455
-				}
456
-			}
457
-
458
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
459
-			if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
460
-				throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not allow shares from type %s', [$path->getPath(), $shareType]));
461
-			}
462
-
463
-			$share->setSharedWith($shareWith);
464
-			$share->setPermissions($permissions);
465
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
466
-			if ($share->getNodeType() === 'file') {
467
-				$share->setPermissions(Constants::PERMISSION_READ);
468
-			} else {
469
-				$share->setPermissions($permissions);
470
-			}
471
-			$share->setSharedWith($shareWith);
472
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
473
-			if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
474
-				throw new OCSNotFoundException($this->l->t('You cannot share to a Circle if the app is not enabled'));
475
-			}
476
-
477
-			$circle = \OCA\Circles\Api\v1\Circles::detailsCircle($shareWith);
478
-
479
-			// Valid circle is required to share
480
-			if ($circle === null) {
481
-				throw new OCSNotFoundException($this->l->t('Please specify a valid circle'));
482
-			}
483
-			$share->setSharedWith($shareWith);
484
-			$share->setPermissions($permissions);
485
-		} else {
486
-			throw new OCSBadRequestException($this->l->t('Unknown share type'));
487
-		}
488
-
489
-		$share->setShareType($shareType);
490
-		$share->setSharedBy($this->currentUser);
491
-
492
-		try {
493
-			$share = $this->shareManager->createShare($share);
494
-		} catch (GenericShareException $e) {
495
-			$code = $e->getCode() === 0 ? 403 : $e->getCode();
496
-			throw new OCSException($e->getHint(), $code);
497
-		} catch (\Exception $e) {
498
-			throw new OCSForbiddenException($e->getMessage(), $e);
499
-		}
500
-
501
-		$output = $this->formatShare($share);
502
-
503
-		return new DataResponse($output);
504
-	}
505
-
506
-	/**
507
-	 * @param \OCP\Files\File|\OCP\Files\Folder $node
508
-	 * @param boolean $includeTags
509
-	 * @return DataResponse
510
-	 */
511
-	private function getSharedWithMe($node = null, $includeTags) {
512
-
513
-		$userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
514
-		$groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
515
-		$circleShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_CIRCLE, $node, -1, 0);
516
-
517
-		$shares = array_merge($userShares, $groupShares, $circleShares);
518
-
519
-		$shares = array_filter($shares, function (IShare $share) {
520
-			return $share->getShareOwner() !== $this->currentUser;
521
-		});
522
-
523
-		$formatted = [];
524
-		foreach ($shares as $share) {
525
-			if ($this->canAccessShare($share)) {
526
-				try {
527
-					$formatted[] = $this->formatShare($share);
528
-				} catch (NotFoundException $e) {
529
-					// Ignore this share
530
-				}
531
-			}
532
-		}
533
-
534
-		if ($includeTags) {
535
-			$formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
536
-		}
537
-
538
-		return new DataResponse($formatted);
539
-	}
540
-
541
-	/**
542
-	 * @param \OCP\Files\Folder $folder
543
-	 * @return DataResponse
544
-	 * @throws OCSBadRequestException
545
-	 */
546
-	private function getSharesInDir($folder) {
547
-		if (!($folder instanceof \OCP\Files\Folder)) {
548
-			throw new OCSBadRequestException($this->l->t('Not a directory'));
549
-		}
550
-
551
-		$nodes = $folder->getDirectoryListing();
552
-		/** @var \OCP\Share\IShare[] $shares */
553
-		$shares = [];
554
-		foreach ($nodes as $node) {
555
-			$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
556
-			$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
557
-			$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
558
-			if($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
559
-				$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $node, false, -1, 0));
560
-			}
561
-			if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
562
-				$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
563
-			}
564
-		}
565
-
566
-		$formatted = [];
567
-		foreach ($shares as $share) {
568
-			try {
569
-				$formatted[] = $this->formatShare($share);
570
-			} catch (NotFoundException $e) {
571
-				//Ignore this share
572
-			}
573
-		}
574
-
575
-		return new DataResponse($formatted);
576
-	}
577
-
578
-	/**
579
-	 * The getShares function.
580
-	 *
581
-	 * @NoAdminRequired
582
-	 *
583
-	 * @param string $shared_with_me
584
-	 * @param string $reshares
585
-	 * @param string $subfiles
586
-	 * @param string $path
587
-	 *
588
-	 * - Get shares by the current user
589
-	 * - Get shares by the current user and reshares (?reshares=true)
590
-	 * - Get shares with the current user (?shared_with_me=true)
591
-	 * - Get shares for a specific path (?path=...)
592
-	 * - Get all shares in a folder (?subfiles=true&path=..)
593
-	 *
594
-	 * @return DataResponse
595
-	 * @throws OCSNotFoundException
596
-	 */
597
-	public function getShares(
598
-		$shared_with_me = 'false',
599
-		$reshares = 'false',
600
-		$subfiles = 'false',
601
-		$path = null,
602
-		$include_tags = 'false'
603
-	) {
604
-
605
-		if ($path !== null) {
606
-			$userFolder = $this->rootFolder->getUserFolder($this->currentUser);
607
-			try {
608
-				$path = $userFolder->get($path);
609
-				$this->lock($path);
610
-			} catch (\OCP\Files\NotFoundException $e) {
611
-				throw new OCSNotFoundException($this->l->t('Wrong path, file/folder doesn\'t exist'));
612
-			} catch (LockedException $e) {
613
-				throw new OCSNotFoundException($this->l->t('Could not lock path'));
614
-			}
615
-		}
616
-
617
-		if ($shared_with_me === 'true') {
618
-			$result = $this->getSharedWithMe($path, $include_tags);
619
-			return $result;
620
-		}
621
-
622
-		if ($subfiles === 'true') {
623
-			$result = $this->getSharesInDir($path);
624
-			return $result;
625
-		}
626
-
627
-		if ($reshares === 'true') {
628
-			$reshares = true;
629
-		} else {
630
-			$reshares = false;
631
-		}
632
-
633
-		// Get all shares
634
-		$userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
635
-		$groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
636
-		$linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
637
-		if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
638
-			$mailShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
639
-		} else {
640
-			$mailShares = [];
641
-		}
642
-		if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
643
-			$circleShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
644
-		} else {
645
-			$circleShares = [];
646
-		}
647
-
648
-		$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares);
649
-
650
-		if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
651
-			$federatedShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
652
-			$shares = array_merge($shares, $federatedShares);
653
-		}
654
-
655
-		$formatted = [];
656
-		foreach ($shares as $share) {
657
-			try {
658
-				$formatted[] = $this->formatShare($share, $path);
659
-			} catch (NotFoundException $e) {
660
-				//Ignore share
661
-			}
662
-		}
663
-
664
-		if ($include_tags) {
665
-			$formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
666
-		}
667
-
668
-		return new DataResponse($formatted);
669
-	}
670
-
671
-	/**
672
-	 * @NoAdminRequired
673
-	 *
674
-	 * @param int $id
675
-	 * @param int $permissions
676
-	 * @param string $password
677
-	 * @param string $publicUpload
678
-	 * @param string $expireDate
679
-	 * @return DataResponse
680
-	 * @throws OCSNotFoundException
681
-	 * @throws OCSBadRequestException
682
-	 * @throws OCSForbiddenException
683
-	 */
684
-	public function updateShare(
685
-		$id,
686
-		$permissions = null,
687
-		$password = null,
688
-		$publicUpload = null,
689
-		$expireDate = null
690
-	) {
691
-		try {
692
-			$share = $this->getShareById($id);
693
-		} catch (ShareNotFound $e) {
694
-			throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
695
-		}
696
-
697
-		$this->lock($share->getNode());
698
-
699
-		if (!$this->canAccessShare($share, false)) {
700
-			throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
701
-		}
702
-
703
-		if ($permissions === null && $password === null && $publicUpload === null && $expireDate === null) {
704
-			throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given'));
705
-		}
706
-
707
-		/*
417
+            $existingShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, false, 1, 0);
418
+            if (!empty($existingShares)) {
419
+                return new DataResponse($this->formatShare($existingShares[0]));
420
+            }
421
+
422
+            if ($publicUpload === 'true') {
423
+                // Check if public upload is allowed
424
+                if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
425
+                    throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
426
+                }
427
+
428
+                // Public upload can only be set for folders
429
+                if ($path instanceof \OCP\Files\File) {
430
+                    throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders'));
431
+                }
432
+
433
+                $share->setPermissions(
434
+                    Constants::PERMISSION_READ |
435
+                    Constants::PERMISSION_CREATE |
436
+                    Constants::PERMISSION_UPDATE |
437
+                    Constants::PERMISSION_DELETE
438
+                );
439
+            } else {
440
+                $share->setPermissions(Constants::PERMISSION_READ);
441
+            }
442
+
443
+            // Set password
444
+            if ($password !== '') {
445
+                $share->setPassword($password);
446
+            }
447
+
448
+            //Expire date
449
+            if ($expireDate !== '') {
450
+                try {
451
+                    $expireDate = $this->parseDate($expireDate);
452
+                    $share->setExpirationDate($expireDate);
453
+                } catch (\Exception $e) {
454
+                    throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
455
+                }
456
+            }
457
+
458
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
459
+            if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
460
+                throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not allow shares from type %s', [$path->getPath(), $shareType]));
461
+            }
462
+
463
+            $share->setSharedWith($shareWith);
464
+            $share->setPermissions($permissions);
465
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
466
+            if ($share->getNodeType() === 'file') {
467
+                $share->setPermissions(Constants::PERMISSION_READ);
468
+            } else {
469
+                $share->setPermissions($permissions);
470
+            }
471
+            $share->setSharedWith($shareWith);
472
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
473
+            if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
474
+                throw new OCSNotFoundException($this->l->t('You cannot share to a Circle if the app is not enabled'));
475
+            }
476
+
477
+            $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($shareWith);
478
+
479
+            // Valid circle is required to share
480
+            if ($circle === null) {
481
+                throw new OCSNotFoundException($this->l->t('Please specify a valid circle'));
482
+            }
483
+            $share->setSharedWith($shareWith);
484
+            $share->setPermissions($permissions);
485
+        } else {
486
+            throw new OCSBadRequestException($this->l->t('Unknown share type'));
487
+        }
488
+
489
+        $share->setShareType($shareType);
490
+        $share->setSharedBy($this->currentUser);
491
+
492
+        try {
493
+            $share = $this->shareManager->createShare($share);
494
+        } catch (GenericShareException $e) {
495
+            $code = $e->getCode() === 0 ? 403 : $e->getCode();
496
+            throw new OCSException($e->getHint(), $code);
497
+        } catch (\Exception $e) {
498
+            throw new OCSForbiddenException($e->getMessage(), $e);
499
+        }
500
+
501
+        $output = $this->formatShare($share);
502
+
503
+        return new DataResponse($output);
504
+    }
505
+
506
+    /**
507
+     * @param \OCP\Files\File|\OCP\Files\Folder $node
508
+     * @param boolean $includeTags
509
+     * @return DataResponse
510
+     */
511
+    private function getSharedWithMe($node = null, $includeTags) {
512
+
513
+        $userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
514
+        $groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
515
+        $circleShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_CIRCLE, $node, -1, 0);
516
+
517
+        $shares = array_merge($userShares, $groupShares, $circleShares);
518
+
519
+        $shares = array_filter($shares, function (IShare $share) {
520
+            return $share->getShareOwner() !== $this->currentUser;
521
+        });
522
+
523
+        $formatted = [];
524
+        foreach ($shares as $share) {
525
+            if ($this->canAccessShare($share)) {
526
+                try {
527
+                    $formatted[] = $this->formatShare($share);
528
+                } catch (NotFoundException $e) {
529
+                    // Ignore this share
530
+                }
531
+            }
532
+        }
533
+
534
+        if ($includeTags) {
535
+            $formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
536
+        }
537
+
538
+        return new DataResponse($formatted);
539
+    }
540
+
541
+    /**
542
+     * @param \OCP\Files\Folder $folder
543
+     * @return DataResponse
544
+     * @throws OCSBadRequestException
545
+     */
546
+    private function getSharesInDir($folder) {
547
+        if (!($folder instanceof \OCP\Files\Folder)) {
548
+            throw new OCSBadRequestException($this->l->t('Not a directory'));
549
+        }
550
+
551
+        $nodes = $folder->getDirectoryListing();
552
+        /** @var \OCP\Share\IShare[] $shares */
553
+        $shares = [];
554
+        foreach ($nodes as $node) {
555
+            $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
556
+            $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
557
+            $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
558
+            if($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
559
+                $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $node, false, -1, 0));
560
+            }
561
+            if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
562
+                $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
563
+            }
564
+        }
565
+
566
+        $formatted = [];
567
+        foreach ($shares as $share) {
568
+            try {
569
+                $formatted[] = $this->formatShare($share);
570
+            } catch (NotFoundException $e) {
571
+                //Ignore this share
572
+            }
573
+        }
574
+
575
+        return new DataResponse($formatted);
576
+    }
577
+
578
+    /**
579
+     * The getShares function.
580
+     *
581
+     * @NoAdminRequired
582
+     *
583
+     * @param string $shared_with_me
584
+     * @param string $reshares
585
+     * @param string $subfiles
586
+     * @param string $path
587
+     *
588
+     * - Get shares by the current user
589
+     * - Get shares by the current user and reshares (?reshares=true)
590
+     * - Get shares with the current user (?shared_with_me=true)
591
+     * - Get shares for a specific path (?path=...)
592
+     * - Get all shares in a folder (?subfiles=true&path=..)
593
+     *
594
+     * @return DataResponse
595
+     * @throws OCSNotFoundException
596
+     */
597
+    public function getShares(
598
+        $shared_with_me = 'false',
599
+        $reshares = 'false',
600
+        $subfiles = 'false',
601
+        $path = null,
602
+        $include_tags = 'false'
603
+    ) {
604
+
605
+        if ($path !== null) {
606
+            $userFolder = $this->rootFolder->getUserFolder($this->currentUser);
607
+            try {
608
+                $path = $userFolder->get($path);
609
+                $this->lock($path);
610
+            } catch (\OCP\Files\NotFoundException $e) {
611
+                throw new OCSNotFoundException($this->l->t('Wrong path, file/folder doesn\'t exist'));
612
+            } catch (LockedException $e) {
613
+                throw new OCSNotFoundException($this->l->t('Could not lock path'));
614
+            }
615
+        }
616
+
617
+        if ($shared_with_me === 'true') {
618
+            $result = $this->getSharedWithMe($path, $include_tags);
619
+            return $result;
620
+        }
621
+
622
+        if ($subfiles === 'true') {
623
+            $result = $this->getSharesInDir($path);
624
+            return $result;
625
+        }
626
+
627
+        if ($reshares === 'true') {
628
+            $reshares = true;
629
+        } else {
630
+            $reshares = false;
631
+        }
632
+
633
+        // Get all shares
634
+        $userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
635
+        $groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
636
+        $linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
637
+        if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
638
+            $mailShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
639
+        } else {
640
+            $mailShares = [];
641
+        }
642
+        if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
643
+            $circleShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
644
+        } else {
645
+            $circleShares = [];
646
+        }
647
+
648
+        $shares = array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares);
649
+
650
+        if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
651
+            $federatedShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
652
+            $shares = array_merge($shares, $federatedShares);
653
+        }
654
+
655
+        $formatted = [];
656
+        foreach ($shares as $share) {
657
+            try {
658
+                $formatted[] = $this->formatShare($share, $path);
659
+            } catch (NotFoundException $e) {
660
+                //Ignore share
661
+            }
662
+        }
663
+
664
+        if ($include_tags) {
665
+            $formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
666
+        }
667
+
668
+        return new DataResponse($formatted);
669
+    }
670
+
671
+    /**
672
+     * @NoAdminRequired
673
+     *
674
+     * @param int $id
675
+     * @param int $permissions
676
+     * @param string $password
677
+     * @param string $publicUpload
678
+     * @param string $expireDate
679
+     * @return DataResponse
680
+     * @throws OCSNotFoundException
681
+     * @throws OCSBadRequestException
682
+     * @throws OCSForbiddenException
683
+     */
684
+    public function updateShare(
685
+        $id,
686
+        $permissions = null,
687
+        $password = null,
688
+        $publicUpload = null,
689
+        $expireDate = null
690
+    ) {
691
+        try {
692
+            $share = $this->getShareById($id);
693
+        } catch (ShareNotFound $e) {
694
+            throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
695
+        }
696
+
697
+        $this->lock($share->getNode());
698
+
699
+        if (!$this->canAccessShare($share, false)) {
700
+            throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
701
+        }
702
+
703
+        if ($permissions === null && $password === null && $publicUpload === null && $expireDate === null) {
704
+            throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given'));
705
+        }
706
+
707
+        /*
708 708
 		 * expirationdate, password and publicUpload only make sense for link shares
709 709
 		 */
710
-		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
711
-
712
-			$newPermissions = null;
713
-			if ($publicUpload === 'true') {
714
-				$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
715
-			} else if ($publicUpload === 'false') {
716
-				$newPermissions = Constants::PERMISSION_READ;
717
-			}
718
-
719
-			if ($permissions !== null) {
720
-				$newPermissions = (int)$permissions;
721
-				$newPermissions = $newPermissions & ~Constants::PERMISSION_SHARE;
722
-			}
723
-
724
-			if ($newPermissions !== null &&
725
-				!in_array($newPermissions, [
726
-					Constants::PERMISSION_READ,
727
-					Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE, // legacy
728
-					Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE, // correct
729
-					Constants::PERMISSION_CREATE, // hidden file list
730
-					Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE, // allow to edit single files
731
-				])
732
-			) {
733
-				throw new OCSBadRequestException($this->l->t('Can\'t change permissions for public share links'));
734
-			}
735
-
736
-			if (
737
-				// legacy
738
-				$newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE) ||
739
-				// correct
740
-				$newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
741
-			) {
742
-				if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
743
-					throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
744
-				}
745
-
746
-				if (!($share->getNode() instanceof \OCP\Files\Folder)) {
747
-					throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
748
-				}
749
-
750
-				// normalize to correct public upload permissions
751
-				$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
752
-			}
753
-
754
-			if ($newPermissions !== null) {
755
-				$share->setPermissions($newPermissions);
756
-				$permissions = $newPermissions;
757
-			}
758
-
759
-			if ($expireDate === '') {
760
-				$share->setExpirationDate(null);
761
-			} else if ($expireDate !== null) {
762
-				try {
763
-					$expireDate = $this->parseDate($expireDate);
764
-				} catch (\Exception $e) {
765
-					throw new OCSBadRequestException($e->getMessage(), $e);
766
-				}
767
-				$share->setExpirationDate($expireDate);
768
-			}
769
-
770
-			if ($password === '') {
771
-				$share->setPassword(null);
772
-			} else if ($password !== null) {
773
-				$share->setPassword($password);
774
-			}
775
-
776
-		} else {
777
-			if ($permissions !== null) {
778
-				$permissions = (int)$permissions;
779
-				$share->setPermissions($permissions);
780
-			}
781
-
782
-			if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
783
-				if ($password === '') {
784
-					$share->setPassword(null);
785
-				} else if ($password !== null) {
786
-					$share->setPassword($password);
787
-				}
788
-			}
789
-
790
-			if ($expireDate === '') {
791
-				$share->setExpirationDate(null);
792
-			} else if ($expireDate !== null) {
793
-				try {
794
-					$expireDate = $this->parseDate($expireDate);
795
-				} catch (\Exception $e) {
796
-					throw new OCSBadRequestException($e->getMessage(), $e);
797
-				}
798
-				$share->setExpirationDate($expireDate);
799
-			}
800
-
801
-		}
802
-
803
-		if ($permissions !== null && $share->getShareOwner() !== $this->currentUser) {
804
-			/* Check if this is an incomming share */
805
-			$incomingShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0);
806
-			$incomingShares = array_merge($incomingShares, $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0));
807
-
808
-			/** @var \OCP\Share\IShare[] $incomingShares */
809
-			if (!empty($incomingShares)) {
810
-				$maxPermissions = 0;
811
-				foreach ($incomingShares as $incomingShare) {
812
-					$maxPermissions |= $incomingShare->getPermissions();
813
-				}
814
-
815
-				if ($share->getPermissions() & ~$maxPermissions) {
816
-					throw new OCSNotFoundException($this->l->t('Cannot increase permissions'));
817
-				}
818
-			}
819
-		}
820
-
821
-
822
-		try {
823
-			$share = $this->shareManager->updateShare($share);
824
-		} catch (\Exception $e) {
825
-			throw new OCSBadRequestException($e->getMessage(), $e);
826
-		}
827
-
828
-		return new DataResponse($this->formatShare($share));
829
-	}
830
-
831
-	/**
832
-	 * @param \OCP\Share\IShare $share
833
-	 * @return bool
834
-	 */
835
-	protected function canAccessShare(\OCP\Share\IShare $share, $checkGroups = true) {
836
-		// A file with permissions 0 can't be accessed by us. So Don't show it
837
-		if ($share->getPermissions() === 0) {
838
-			return false;
839
-		}
840
-
841
-		// Owner of the file and the sharer of the file can always get share
842
-		if ($share->getShareOwner() === $this->currentUser ||
843
-			$share->getSharedBy() === $this->currentUser
844
-		) {
845
-			return true;
846
-		}
847
-
848
-		// If the share is shared with you (or a group you are a member of)
849
-		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
850
-			$share->getSharedWith() === $this->currentUser
851
-		) {
852
-			return true;
853
-		}
854
-
855
-		if ($checkGroups && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
856
-			$sharedWith = $this->groupManager->get($share->getSharedWith());
857
-			$user = $this->userManager->get($this->currentUser);
858
-			if ($user !== null && $sharedWith !== null && $sharedWith->inGroup($user)) {
859
-				return true;
860
-			}
861
-		}
862
-
863
-		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
864
-			// TODO: have a sanity check like above?
865
-			return true;
866
-		}
867
-
868
-		return false;
869
-	}
870
-
871
-	/**
872
-	 * Make sure that the passed date is valid ISO 8601
873
-	 * So YYYY-MM-DD
874
-	 * If not throw an exception
875
-	 *
876
-	 * @param string $expireDate
877
-	 *
878
-	 * @throws \Exception
879
-	 * @return \DateTime
880
-	 */
881
-	private function parseDate($expireDate) {
882
-		try {
883
-			$date = new \DateTime($expireDate);
884
-		} catch (\Exception $e) {
885
-			throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
886
-		}
887
-
888
-		if ($date === false) {
889
-			throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
890
-		}
891
-
892
-		$date->setTime(0, 0, 0);
893
-
894
-		return $date;
895
-	}
896
-
897
-	/**
898
-	 * Since we have multiple providers but the OCS Share API v1 does
899
-	 * not support this we need to check all backends.
900
-	 *
901
-	 * @param string $id
902
-	 * @return \OCP\Share\IShare
903
-	 * @throws ShareNotFound
904
-	 */
905
-	private function getShareById($id) {
906
-		$share = null;
907
-
908
-		// First check if it is an internal share.
909
-		try {
910
-			$share = $this->shareManager->getShareById('ocinternal:' . $id);
911
-			return $share;
912
-		} catch (ShareNotFound $e) {
913
-			// Do nothing, just try the other share type
914
-		}
915
-
916
-
917
-		try {
918
-			if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
919
-				$share = $this->shareManager->getShareById('ocCircleShare:' . $id);
920
-				return $share;
921
-			}
922
-		} catch (ShareNotFound $e) {
923
-			// Do nothing, just try the other share type
924
-		}
925
-
926
-		try {
927
-			if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
928
-				$share = $this->shareManager->getShareById('ocMailShare:' . $id);
929
-				return $share;
930
-			}
931
-		} catch (ShareNotFound $e) {
932
-			// Do nothing, just try the other share type
933
-		}
934
-
935
-		if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
936
-			throw new ShareNotFound();
937
-		}
938
-		$share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
939
-
940
-		return $share;
941
-	}
942
-
943
-	/**
944
-	 * Lock a Node
945
-	 *
946
-	 * @param \OCP\Files\Node $node
947
-	 */
948
-	private function lock(\OCP\Files\Node $node) {
949
-		$node->lock(ILockingProvider::LOCK_SHARED);
950
-		$this->lockedNode = $node;
951
-	}
952
-
953
-	/**
954
-	 * Cleanup the remaining locks
955
-	 */
956
-	public function cleanup() {
957
-		if ($this->lockedNode !== null) {
958
-			$this->lockedNode->unlock(ILockingProvider::LOCK_SHARED);
959
-		}
960
-	}
710
+        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
711
+
712
+            $newPermissions = null;
713
+            if ($publicUpload === 'true') {
714
+                $newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
715
+            } else if ($publicUpload === 'false') {
716
+                $newPermissions = Constants::PERMISSION_READ;
717
+            }
718
+
719
+            if ($permissions !== null) {
720
+                $newPermissions = (int)$permissions;
721
+                $newPermissions = $newPermissions & ~Constants::PERMISSION_SHARE;
722
+            }
723
+
724
+            if ($newPermissions !== null &&
725
+                !in_array($newPermissions, [
726
+                    Constants::PERMISSION_READ,
727
+                    Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE, // legacy
728
+                    Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE, // correct
729
+                    Constants::PERMISSION_CREATE, // hidden file list
730
+                    Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE, // allow to edit single files
731
+                ])
732
+            ) {
733
+                throw new OCSBadRequestException($this->l->t('Can\'t change permissions for public share links'));
734
+            }
735
+
736
+            if (
737
+                // legacy
738
+                $newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE) ||
739
+                // correct
740
+                $newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
741
+            ) {
742
+                if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
743
+                    throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
744
+                }
745
+
746
+                if (!($share->getNode() instanceof \OCP\Files\Folder)) {
747
+                    throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
748
+                }
749
+
750
+                // normalize to correct public upload permissions
751
+                $newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
752
+            }
753
+
754
+            if ($newPermissions !== null) {
755
+                $share->setPermissions($newPermissions);
756
+                $permissions = $newPermissions;
757
+            }
758
+
759
+            if ($expireDate === '') {
760
+                $share->setExpirationDate(null);
761
+            } else if ($expireDate !== null) {
762
+                try {
763
+                    $expireDate = $this->parseDate($expireDate);
764
+                } catch (\Exception $e) {
765
+                    throw new OCSBadRequestException($e->getMessage(), $e);
766
+                }
767
+                $share->setExpirationDate($expireDate);
768
+            }
769
+
770
+            if ($password === '') {
771
+                $share->setPassword(null);
772
+            } else if ($password !== null) {
773
+                $share->setPassword($password);
774
+            }
775
+
776
+        } else {
777
+            if ($permissions !== null) {
778
+                $permissions = (int)$permissions;
779
+                $share->setPermissions($permissions);
780
+            }
781
+
782
+            if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
783
+                if ($password === '') {
784
+                    $share->setPassword(null);
785
+                } else if ($password !== null) {
786
+                    $share->setPassword($password);
787
+                }
788
+            }
789
+
790
+            if ($expireDate === '') {
791
+                $share->setExpirationDate(null);
792
+            } else if ($expireDate !== null) {
793
+                try {
794
+                    $expireDate = $this->parseDate($expireDate);
795
+                } catch (\Exception $e) {
796
+                    throw new OCSBadRequestException($e->getMessage(), $e);
797
+                }
798
+                $share->setExpirationDate($expireDate);
799
+            }
800
+
801
+        }
802
+
803
+        if ($permissions !== null && $share->getShareOwner() !== $this->currentUser) {
804
+            /* Check if this is an incomming share */
805
+            $incomingShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0);
806
+            $incomingShares = array_merge($incomingShares, $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0));
807
+
808
+            /** @var \OCP\Share\IShare[] $incomingShares */
809
+            if (!empty($incomingShares)) {
810
+                $maxPermissions = 0;
811
+                foreach ($incomingShares as $incomingShare) {
812
+                    $maxPermissions |= $incomingShare->getPermissions();
813
+                }
814
+
815
+                if ($share->getPermissions() & ~$maxPermissions) {
816
+                    throw new OCSNotFoundException($this->l->t('Cannot increase permissions'));
817
+                }
818
+            }
819
+        }
820
+
821
+
822
+        try {
823
+            $share = $this->shareManager->updateShare($share);
824
+        } catch (\Exception $e) {
825
+            throw new OCSBadRequestException($e->getMessage(), $e);
826
+        }
827
+
828
+        return new DataResponse($this->formatShare($share));
829
+    }
830
+
831
+    /**
832
+     * @param \OCP\Share\IShare $share
833
+     * @return bool
834
+     */
835
+    protected function canAccessShare(\OCP\Share\IShare $share, $checkGroups = true) {
836
+        // A file with permissions 0 can't be accessed by us. So Don't show it
837
+        if ($share->getPermissions() === 0) {
838
+            return false;
839
+        }
840
+
841
+        // Owner of the file and the sharer of the file can always get share
842
+        if ($share->getShareOwner() === $this->currentUser ||
843
+            $share->getSharedBy() === $this->currentUser
844
+        ) {
845
+            return true;
846
+        }
847
+
848
+        // If the share is shared with you (or a group you are a member of)
849
+        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
850
+            $share->getSharedWith() === $this->currentUser
851
+        ) {
852
+            return true;
853
+        }
854
+
855
+        if ($checkGroups && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
856
+            $sharedWith = $this->groupManager->get($share->getSharedWith());
857
+            $user = $this->userManager->get($this->currentUser);
858
+            if ($user !== null && $sharedWith !== null && $sharedWith->inGroup($user)) {
859
+                return true;
860
+            }
861
+        }
862
+
863
+        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
864
+            // TODO: have a sanity check like above?
865
+            return true;
866
+        }
867
+
868
+        return false;
869
+    }
870
+
871
+    /**
872
+     * Make sure that the passed date is valid ISO 8601
873
+     * So YYYY-MM-DD
874
+     * If not throw an exception
875
+     *
876
+     * @param string $expireDate
877
+     *
878
+     * @throws \Exception
879
+     * @return \DateTime
880
+     */
881
+    private function parseDate($expireDate) {
882
+        try {
883
+            $date = new \DateTime($expireDate);
884
+        } catch (\Exception $e) {
885
+            throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
886
+        }
887
+
888
+        if ($date === false) {
889
+            throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
890
+        }
891
+
892
+        $date->setTime(0, 0, 0);
893
+
894
+        return $date;
895
+    }
896
+
897
+    /**
898
+     * Since we have multiple providers but the OCS Share API v1 does
899
+     * not support this we need to check all backends.
900
+     *
901
+     * @param string $id
902
+     * @return \OCP\Share\IShare
903
+     * @throws ShareNotFound
904
+     */
905
+    private function getShareById($id) {
906
+        $share = null;
907
+
908
+        // First check if it is an internal share.
909
+        try {
910
+            $share = $this->shareManager->getShareById('ocinternal:' . $id);
911
+            return $share;
912
+        } catch (ShareNotFound $e) {
913
+            // Do nothing, just try the other share type
914
+        }
915
+
916
+
917
+        try {
918
+            if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
919
+                $share = $this->shareManager->getShareById('ocCircleShare:' . $id);
920
+                return $share;
921
+            }
922
+        } catch (ShareNotFound $e) {
923
+            // Do nothing, just try the other share type
924
+        }
925
+
926
+        try {
927
+            if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
928
+                $share = $this->shareManager->getShareById('ocMailShare:' . $id);
929
+                return $share;
930
+            }
931
+        } catch (ShareNotFound $e) {
932
+            // Do nothing, just try the other share type
933
+        }
934
+
935
+        if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
936
+            throw new ShareNotFound();
937
+        }
938
+        $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
939
+
940
+        return $share;
941
+    }
942
+
943
+    /**
944
+     * Lock a Node
945
+     *
946
+     * @param \OCP\Files\Node $node
947
+     */
948
+    private function lock(\OCP\Files\Node $node) {
949
+        $node->lock(ILockingProvider::LOCK_SHARED);
950
+        $this->lockedNode = $node;
951
+    }
952
+
953
+    /**
954
+     * Cleanup the remaining locks
955
+     */
956
+    public function cleanup() {
957
+        if ($this->lockedNode !== null) {
958
+            $this->lockedNode->unlock(ILockingProvider::LOCK_SHARED);
959
+        }
960
+    }
961 961
 }
Please login to merge, or discard this patch.
lib/public/Share/IShare.php 1 patch
Indentation   +338 added lines, -338 removed lines patch added patch discarded remove patch
@@ -39,342 +39,342 @@
 block discarded – undo
39 39
  */
40 40
 interface IShare {
41 41
 
42
-	/**
43
-	 * Set the internal id of the share
44
-	 * It is only allowed to set the internal id of a share once.
45
-	 * Attempts to override the internal id will result in an IllegalIDChangeException
46
-	 *
47
-	 * @param string $id
48
-	 * @return \OCP\Share\IShare
49
-	 * @throws IllegalIDChangeException
50
-	 * @throws \InvalidArgumentException
51
-	 * @since 9.1.0
52
-	 */
53
-	public function setId($id);
54
-
55
-	/**
56
-	 * Get the internal id of the share.
57
-	 *
58
-	 * @return string
59
-	 * @since 9.0.0
60
-	 */
61
-	public function getId();
62
-
63
-	/**
64
-	 * Get the full share id. This is the <providerid>:<internalid>.
65
-	 * The full id is unique in the system.
66
-	 *
67
-	 * @return string
68
-	 * @since 9.0.0
69
-	 * @throws \UnexpectedValueException If the fullId could not be constructed
70
-	 */
71
-	public function getFullId();
72
-
73
-	/**
74
-	 * Set the provider id of the share
75
-	 * It is only allowed to set the provider id of a share once.
76
-	 * Attempts to override the provider id will result in an IllegalIDChangeException
77
-	 *
78
-	 * @param string $id
79
-	 * @return \OCP\Share\IShare
80
-	 * @throws IllegalIDChangeException
81
-	 * @throws \InvalidArgumentException
82
-	 * @since 9.1.0
83
-	 */
84
-	public function setProviderId($id);
85
-
86
-	/**
87
-	 * Set the node of the file/folder that is shared
88
-	 *
89
-	 * @param Node $node
90
-	 * @return \OCP\Share\IShare The modified object
91
-	 * @since 9.0.0
92
-	 */
93
-	public function setNode(Node $node);
94
-
95
-	/**
96
-	 * Get the node of the file/folder that is shared
97
-	 *
98
-	 * @return File|Folder
99
-	 * @since 9.0.0
100
-	 * @throws NotFoundException
101
-	 */
102
-	public function getNode();
103
-
104
-	/**
105
-	 * Set file id for lazy evaluation of the node
106
-	 * @param int $fileId
107
-	 * @return \OCP\Share\IShare The modified object
108
-	 * @since 9.0.0
109
-	 */
110
-	public function setNodeId($fileId);
111
-
112
-	/**
113
-	 * Get the fileid of the node of this share
114
-	 * @return int
115
-	 * @since 9.0.0
116
-	 * @throws NotFoundException
117
-	 */
118
-	public function getNodeId();
119
-
120
-	/**
121
-	 * Set the type of node (file/folder)
122
-	 *
123
-	 * @param string $type
124
-	 * @return \OCP\Share\IShare The modified object
125
-	 * @since 9.0.0
126
-	 */
127
-	public function setNodeType($type);
128
-
129
-	/**
130
-	 * Get the type of node (file/folder)
131
-	 *
132
-	 * @return string
133
-	 * @since 9.0.0
134
-	 * @throws NotFoundException
135
-	 */
136
-	public function getNodeType();
137
-
138
-	/**
139
-	 * Set the shareType
140
-	 *
141
-	 * @param int $shareType
142
-	 * @return \OCP\Share\IShare The modified object
143
-	 * @since 9.0.0
144
-	 */
145
-	public function setShareType($shareType);
146
-
147
-	/**
148
-	 * Get the shareType
149
-	 *
150
-	 * @return int
151
-	 * @since 9.0.0
152
-	 */
153
-	public function getShareType();
154
-
155
-	/**
156
-	 * Set the receiver of this share.
157
-	 *
158
-	 * @param string $sharedWith
159
-	 * @return \OCP\Share\IShare The modified object
160
-	 * @since 9.0.0
161
-	 */
162
-	public function setSharedWith($sharedWith);
163
-
164
-	/**
165
-	 * Get the receiver of this share.
166
-	 *
167
-	 * @return string
168
-	 * @since 9.0.0
169
-	 */
170
-	public function getSharedWith();
171
-
172
-	/**
173
-	 * Set the display name of the receiver of this share.
174
-	 *
175
-	 * @param string $displayName
176
-	 * @return \OCP\Share\IShare The modified object
177
-	 * @since 14.0.0
178
-	 */
179
-	public function setSharedWithDisplayName($displayName);
180
-
181
-	/**
182
-	 * Get the display name of the receiver of this share.
183
-	 *
184
-	 * @return string
185
-	 * @since 14.0.0
186
-	 */
187
-	public function getSharedWithDisplayName();
188
-
189
-	/**
190
-	 * Set the avatar of the receiver of this share.
191
-	 *
192
-	 * @param string $src
193
-	 * @return \OCP\Share\IShare The modified object
194
-	 * @since 14.0.0
195
-	 */
196
-	public function setSharedWithAvatar($src);
197
-
198
-	/**
199
-	 * Get the avatar of the receiver of this share.
200
-	 *
201
-	 * @return string
202
-	 * @since 14.0.0
203
-	 */
204
-	public function getSharedWithAvatar();
205
-
206
-	/**
207
-	 * Set the permissions.
208
-	 * See \OCP\Constants::PERMISSION_*
209
-	 *
210
-	 * @param int $permissions
211
-	 * @return \OCP\Share\IShare The modified object
212
-	 * @since 9.0.0
213
-	 */
214
-	public function setPermissions($permissions);
215
-
216
-	/**
217
-	 * Get the share permissions
218
-	 * See \OCP\Constants::PERMISSION_*
219
-	 *
220
-	 * @return int
221
-	 * @since 9.0.0
222
-	 */
223
-	public function getPermissions();
224
-
225
-	/**
226
-	 * Set the expiration date
227
-	 *
228
-	 * @param null|\DateTime $expireDate
229
-	 * @return \OCP\Share\IShare The modified object
230
-	 * @since 9.0.0
231
-	 */
232
-	public function setExpirationDate($expireDate);
233
-
234
-	/**
235
-	 * Get the expiration date
236
-	 *
237
-	 * @return \DateTime
238
-	 * @since 9.0.0
239
-	 */
240
-	public function getExpirationDate();
241
-
242
-	/**
243
-	 * Set the sharer of the path.
244
-	 *
245
-	 * @param string $sharedBy
246
-	 * @return \OCP\Share\IShare The modified object
247
-	 * @since 9.0.0
248
-	 */
249
-	public function setSharedBy($sharedBy);
250
-
251
-	/**
252
-	 * Get share sharer
253
-	 *
254
-	 * @return string
255
-	 * @since 9.0.0
256
-	 */
257
-	public function getSharedBy();
258
-
259
-	/**
260
-	 * Set the original share owner (who owns the path that is shared)
261
-	 *
262
-	 * @param string $shareOwner
263
-	 * @return \OCP\Share\IShare The modified object
264
-	 * @since 9.0.0
265
-	 */
266
-	public function setShareOwner($shareOwner);
267
-
268
-	/**
269
-	 * Get the original share owner (who owns the path that is shared)
270
-	 *
271
-	 * @return string
272
-	 * @since 9.0.0
273
-	 */
274
-	public function getShareOwner();
275
-
276
-	/**
277
-	 * Set the password for this share.
278
-	 * When the share is passed to the share manager to be created
279
-	 * or updated the password will be hashed.
280
-	 *
281
-	 * @param string $password
282
-	 * @return \OCP\Share\IShare The modified object
283
-	 * @since 9.0.0
284
-	 */
285
-	public function setPassword($password);
286
-
287
-	/**
288
-	 * Get the password of this share.
289
-	 * If this share is obtained via a shareprovider the password is
290
-	 * hashed.
291
-	 *
292
-	 * @return string
293
-	 * @since 9.0.0
294
-	 */
295
-	public function getPassword();
296
-
297
-	/**
298
-	 * Set the public link token.
299
-	 *
300
-	 * @param string $token
301
-	 * @return \OCP\Share\IShare The modified object
302
-	 * @since 9.0.0
303
-	 */
304
-	public function setToken($token);
305
-
306
-	/**
307
-	 * Get the public link token.
308
-	 *
309
-	 * @return string
310
-	 * @since 9.0.0
311
-	 */
312
-	public function getToken();
313
-
314
-	/**
315
-	 * Set the target path of this share relative to the recipients user folder.
316
-	 *
317
-	 * @param string $target
318
-	 * @return \OCP\Share\IShare The modified object
319
-	 * @since 9.0.0
320
-	 */
321
-	public function setTarget($target);
322
-
323
-	/**
324
-	 * Get the target path of this share relative to the recipients user folder.
325
-	 *
326
-	 * @return string
327
-	 * @since 9.0.0
328
-	 */
329
-	public function getTarget();
330
-
331
-	/**
332
-	 * Set the time this share was created
333
-	 *
334
-	 * @param \DateTime $shareTime
335
-	 * @return \OCP\Share\IShare The modified object
336
-	 * @since 9.0.0
337
-	 */
338
-	public function setShareTime(\DateTime $shareTime);
339
-
340
-	/**
341
-	 * Get the timestamp this share was created
342
-	 *
343
-	 * @return \DateTime
344
-	 * @since 9.0.0
345
-	 */
346
-	public function getShareTime();
347
-
348
-	/**
349
-	 * Set if the recipient is informed by mail about the share.
350
-	 *
351
-	 * @param bool $mailSend
352
-	 * @return \OCP\Share\IShare The modified object
353
-	 * @since 9.0.0
354
-	 */
355
-	public function setMailSend($mailSend);
356
-
357
-	/**
358
-	 * Get if the recipient informed by mail about the share.
359
-	 *
360
-	 * @return bool
361
-	 * @since 9.0.0
362
-	 */
363
-	public function getMailSend();
364
-
365
-	/**
366
-	 * Set the cache entry for the shared node
367
-	 *
368
-	 * @param ICacheEntry $entry
369
-	 * @since 11.0.0
370
-	 */
371
-	public function setNodeCacheEntry(ICacheEntry $entry);
372
-
373
-	/**
374
-	 * Get the cache entry for the shared node
375
-	 *
376
-	 * @return null|ICacheEntry
377
-	 * @since 11.0.0
378
-	 */
379
-	public function getNodeCacheEntry();
42
+    /**
43
+     * Set the internal id of the share
44
+     * It is only allowed to set the internal id of a share once.
45
+     * Attempts to override the internal id will result in an IllegalIDChangeException
46
+     *
47
+     * @param string $id
48
+     * @return \OCP\Share\IShare
49
+     * @throws IllegalIDChangeException
50
+     * @throws \InvalidArgumentException
51
+     * @since 9.1.0
52
+     */
53
+    public function setId($id);
54
+
55
+    /**
56
+     * Get the internal id of the share.
57
+     *
58
+     * @return string
59
+     * @since 9.0.0
60
+     */
61
+    public function getId();
62
+
63
+    /**
64
+     * Get the full share id. This is the <providerid>:<internalid>.
65
+     * The full id is unique in the system.
66
+     *
67
+     * @return string
68
+     * @since 9.0.0
69
+     * @throws \UnexpectedValueException If the fullId could not be constructed
70
+     */
71
+    public function getFullId();
72
+
73
+    /**
74
+     * Set the provider id of the share
75
+     * It is only allowed to set the provider id of a share once.
76
+     * Attempts to override the provider id will result in an IllegalIDChangeException
77
+     *
78
+     * @param string $id
79
+     * @return \OCP\Share\IShare
80
+     * @throws IllegalIDChangeException
81
+     * @throws \InvalidArgumentException
82
+     * @since 9.1.0
83
+     */
84
+    public function setProviderId($id);
85
+
86
+    /**
87
+     * Set the node of the file/folder that is shared
88
+     *
89
+     * @param Node $node
90
+     * @return \OCP\Share\IShare The modified object
91
+     * @since 9.0.0
92
+     */
93
+    public function setNode(Node $node);
94
+
95
+    /**
96
+     * Get the node of the file/folder that is shared
97
+     *
98
+     * @return File|Folder
99
+     * @since 9.0.0
100
+     * @throws NotFoundException
101
+     */
102
+    public function getNode();
103
+
104
+    /**
105
+     * Set file id for lazy evaluation of the node
106
+     * @param int $fileId
107
+     * @return \OCP\Share\IShare The modified object
108
+     * @since 9.0.0
109
+     */
110
+    public function setNodeId($fileId);
111
+
112
+    /**
113
+     * Get the fileid of the node of this share
114
+     * @return int
115
+     * @since 9.0.0
116
+     * @throws NotFoundException
117
+     */
118
+    public function getNodeId();
119
+
120
+    /**
121
+     * Set the type of node (file/folder)
122
+     *
123
+     * @param string $type
124
+     * @return \OCP\Share\IShare The modified object
125
+     * @since 9.0.0
126
+     */
127
+    public function setNodeType($type);
128
+
129
+    /**
130
+     * Get the type of node (file/folder)
131
+     *
132
+     * @return string
133
+     * @since 9.0.0
134
+     * @throws NotFoundException
135
+     */
136
+    public function getNodeType();
137
+
138
+    /**
139
+     * Set the shareType
140
+     *
141
+     * @param int $shareType
142
+     * @return \OCP\Share\IShare The modified object
143
+     * @since 9.0.0
144
+     */
145
+    public function setShareType($shareType);
146
+
147
+    /**
148
+     * Get the shareType
149
+     *
150
+     * @return int
151
+     * @since 9.0.0
152
+     */
153
+    public function getShareType();
154
+
155
+    /**
156
+     * Set the receiver of this share.
157
+     *
158
+     * @param string $sharedWith
159
+     * @return \OCP\Share\IShare The modified object
160
+     * @since 9.0.0
161
+     */
162
+    public function setSharedWith($sharedWith);
163
+
164
+    /**
165
+     * Get the receiver of this share.
166
+     *
167
+     * @return string
168
+     * @since 9.0.0
169
+     */
170
+    public function getSharedWith();
171
+
172
+    /**
173
+     * Set the display name of the receiver of this share.
174
+     *
175
+     * @param string $displayName
176
+     * @return \OCP\Share\IShare The modified object
177
+     * @since 14.0.0
178
+     */
179
+    public function setSharedWithDisplayName($displayName);
180
+
181
+    /**
182
+     * Get the display name of the receiver of this share.
183
+     *
184
+     * @return string
185
+     * @since 14.0.0
186
+     */
187
+    public function getSharedWithDisplayName();
188
+
189
+    /**
190
+     * Set the avatar of the receiver of this share.
191
+     *
192
+     * @param string $src
193
+     * @return \OCP\Share\IShare The modified object
194
+     * @since 14.0.0
195
+     */
196
+    public function setSharedWithAvatar($src);
197
+
198
+    /**
199
+     * Get the avatar of the receiver of this share.
200
+     *
201
+     * @return string
202
+     * @since 14.0.0
203
+     */
204
+    public function getSharedWithAvatar();
205
+
206
+    /**
207
+     * Set the permissions.
208
+     * See \OCP\Constants::PERMISSION_*
209
+     *
210
+     * @param int $permissions
211
+     * @return \OCP\Share\IShare The modified object
212
+     * @since 9.0.0
213
+     */
214
+    public function setPermissions($permissions);
215
+
216
+    /**
217
+     * Get the share permissions
218
+     * See \OCP\Constants::PERMISSION_*
219
+     *
220
+     * @return int
221
+     * @since 9.0.0
222
+     */
223
+    public function getPermissions();
224
+
225
+    /**
226
+     * Set the expiration date
227
+     *
228
+     * @param null|\DateTime $expireDate
229
+     * @return \OCP\Share\IShare The modified object
230
+     * @since 9.0.0
231
+     */
232
+    public function setExpirationDate($expireDate);
233
+
234
+    /**
235
+     * Get the expiration date
236
+     *
237
+     * @return \DateTime
238
+     * @since 9.0.0
239
+     */
240
+    public function getExpirationDate();
241
+
242
+    /**
243
+     * Set the sharer of the path.
244
+     *
245
+     * @param string $sharedBy
246
+     * @return \OCP\Share\IShare The modified object
247
+     * @since 9.0.0
248
+     */
249
+    public function setSharedBy($sharedBy);
250
+
251
+    /**
252
+     * Get share sharer
253
+     *
254
+     * @return string
255
+     * @since 9.0.0
256
+     */
257
+    public function getSharedBy();
258
+
259
+    /**
260
+     * Set the original share owner (who owns the path that is shared)
261
+     *
262
+     * @param string $shareOwner
263
+     * @return \OCP\Share\IShare The modified object
264
+     * @since 9.0.0
265
+     */
266
+    public function setShareOwner($shareOwner);
267
+
268
+    /**
269
+     * Get the original share owner (who owns the path that is shared)
270
+     *
271
+     * @return string
272
+     * @since 9.0.0
273
+     */
274
+    public function getShareOwner();
275
+
276
+    /**
277
+     * Set the password for this share.
278
+     * When the share is passed to the share manager to be created
279
+     * or updated the password will be hashed.
280
+     *
281
+     * @param string $password
282
+     * @return \OCP\Share\IShare The modified object
283
+     * @since 9.0.0
284
+     */
285
+    public function setPassword($password);
286
+
287
+    /**
288
+     * Get the password of this share.
289
+     * If this share is obtained via a shareprovider the password is
290
+     * hashed.
291
+     *
292
+     * @return string
293
+     * @since 9.0.0
294
+     */
295
+    public function getPassword();
296
+
297
+    /**
298
+     * Set the public link token.
299
+     *
300
+     * @param string $token
301
+     * @return \OCP\Share\IShare The modified object
302
+     * @since 9.0.0
303
+     */
304
+    public function setToken($token);
305
+
306
+    /**
307
+     * Get the public link token.
308
+     *
309
+     * @return string
310
+     * @since 9.0.0
311
+     */
312
+    public function getToken();
313
+
314
+    /**
315
+     * Set the target path of this share relative to the recipients user folder.
316
+     *
317
+     * @param string $target
318
+     * @return \OCP\Share\IShare The modified object
319
+     * @since 9.0.0
320
+     */
321
+    public function setTarget($target);
322
+
323
+    /**
324
+     * Get the target path of this share relative to the recipients user folder.
325
+     *
326
+     * @return string
327
+     * @since 9.0.0
328
+     */
329
+    public function getTarget();
330
+
331
+    /**
332
+     * Set the time this share was created
333
+     *
334
+     * @param \DateTime $shareTime
335
+     * @return \OCP\Share\IShare The modified object
336
+     * @since 9.0.0
337
+     */
338
+    public function setShareTime(\DateTime $shareTime);
339
+
340
+    /**
341
+     * Get the timestamp this share was created
342
+     *
343
+     * @return \DateTime
344
+     * @since 9.0.0
345
+     */
346
+    public function getShareTime();
347
+
348
+    /**
349
+     * Set if the recipient is informed by mail about the share.
350
+     *
351
+     * @param bool $mailSend
352
+     * @return \OCP\Share\IShare The modified object
353
+     * @since 9.0.0
354
+     */
355
+    public function setMailSend($mailSend);
356
+
357
+    /**
358
+     * Get if the recipient informed by mail about the share.
359
+     *
360
+     * @return bool
361
+     * @since 9.0.0
362
+     */
363
+    public function getMailSend();
364
+
365
+    /**
366
+     * Set the cache entry for the shared node
367
+     *
368
+     * @param ICacheEntry $entry
369
+     * @since 11.0.0
370
+     */
371
+    public function setNodeCacheEntry(ICacheEntry $entry);
372
+
373
+    /**
374
+     * Get the cache entry for the shared node
375
+     *
376
+     * @return null|ICacheEntry
377
+     * @since 11.0.0
378
+     */
379
+    public function getNodeCacheEntry();
380 380
 }
Please login to merge, or discard this patch.