Passed
Push — master ( 057e81...6308b7 )
by Roeland
12:03 queued 10s
created
lib/private/Preview/MarkDown.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@
 block discarded – undo
22 22
 namespace OC\Preview;
23 23
 
24 24
 class MarkDown extends TXT {
25
-	/**
26
-	 * {@inheritDoc}
27
-	 */
28
-	public function getMimeType() {
29
-		return '/text\/(x-)?markdown/';
30
-	}
25
+    /**
26
+     * {@inheritDoc}
27
+     */
28
+    public function getMimeType() {
29
+        return '/text\/(x-)?markdown/';
30
+    }
31 31
 
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/JPEG.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 namespace OC\Preview;
24 24
 
25 25
 class JPEG extends Image {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getMimeType() {
30
-		return '/image\/jpeg/';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getMimeType() {
30
+        return '/image\/jpeg/';
31
+    }
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/StarOffice.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 
24 24
 //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm
25 25
 class StarOffice extends Office {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getMimeType() {
30
-		return '/application\/vnd.sun.xml.*/';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getMimeType() {
30
+        return '/application\/vnd.sun.xml.*/';
31
+    }
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/MSOfficeDoc.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 
24 24
 //.doc, .dot
25 25
 class MSOfficeDoc extends Office {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getMimeType() {
30
-		return '/application\/msword/';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getMimeType() {
30
+        return '/application\/msword/';
31
+    }
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/Font.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
 
25 25
 // .otf, .ttf and .pfb
26 26
 class Font extends Bitmap {
27
-	/**
28
-	 * {@inheritDoc}
29
-	 */
30
-	public function getMimeType() {
31
-		return '/application\/(?:font-sfnt|x-font$)/';
32
-	}
27
+    /**
28
+     * {@inheritDoc}
29
+     */
30
+    public function getMimeType() {
31
+        return '/application\/(?:font-sfnt|x-font$)/';
32
+    }
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
lib/private/Preview/Postscript.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 //.eps
27 27
 class Postscript extends Bitmap {
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getMimeType() {
32
-		return '/application\/postscript/';
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getMimeType() {
32
+        return '/application\/postscript/';
33
+    }
34 34
 }
Please login to merge, or discard this patch.
lib/private/Preview/SVG.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 
43 43
 			$content = stream_get_contents($fileview->fopen($path, 'r'));
44 44
 			if (substr($content, 0, 5) !== '<?xml') {
45
-				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
45
+				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$content;
46 46
 			}
47 47
 
48 48
 			// Do not parse SVG files with references
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,50 +27,50 @@
 block discarded – undo
27 27
 use OCP\ILogger;
28 28
 
29 29
 class SVG extends Provider {
30
-	/**
31
-	 * {@inheritDoc}
32
-	 */
33
-	public function getMimeType() {
34
-		return '/image\/svg\+xml/';
35
-	}
30
+    /**
31
+     * {@inheritDoc}
32
+     */
33
+    public function getMimeType() {
34
+        return '/image\/svg\+xml/';
35
+    }
36 36
 
37
-	/**
38
-	 * {@inheritDoc}
39
-	 */
40
-	public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
41
-		try {
42
-			$svg = new \Imagick();
43
-			$svg->setBackgroundColor(new \ImagickPixel('transparent'));
37
+    /**
38
+     * {@inheritDoc}
39
+     */
40
+    public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
41
+        try {
42
+            $svg = new \Imagick();
43
+            $svg->setBackgroundColor(new \ImagickPixel('transparent'));
44 44
 
45
-			$content = stream_get_contents($fileview->fopen($path, 'r'));
46
-			if (substr($content, 0, 5) !== '<?xml') {
47
-				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
48
-			}
45
+            $content = stream_get_contents($fileview->fopen($path, 'r'));
46
+            if (substr($content, 0, 5) !== '<?xml') {
47
+                $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
48
+            }
49 49
 
50
-			// Do not parse SVG files with references
51
-			if (stripos($content, 'xlink:href') !== false) {
52
-				return false;
53
-			}
50
+            // Do not parse SVG files with references
51
+            if (stripos($content, 'xlink:href') !== false) {
52
+                return false;
53
+            }
54 54
 
55
-			$svg->readImageBlob($content);
56
-			$svg->setImageFormat('png32');
57
-		} catch (\Exception $e) {
58
-			\OC::$server->getLogger()->logException($e, [
59
-				'level' => ILogger::ERROR,
60
-				'app' => 'core',
61
-			]);
62
-			return false;
63
-		}
55
+            $svg->readImageBlob($content);
56
+            $svg->setImageFormat('png32');
57
+        } catch (\Exception $e) {
58
+            \OC::$server->getLogger()->logException($e, [
59
+                'level' => ILogger::ERROR,
60
+                'app' => 'core',
61
+            ]);
62
+            return false;
63
+        }
64 64
 
65
-		//new image object
66
-		$image = new \OC_Image();
67
-		$image->loadFromData($svg);
68
-		//check if image object is valid
69
-		if ($image->valid()) {
70
-			$image->scaleDownToFit($maxX, $maxY);
65
+        //new image object
66
+        $image = new \OC_Image();
67
+        $image->loadFromData($svg);
68
+        //check if image object is valid
69
+        if ($image->valid()) {
70
+            $image->scaleDownToFit($maxX, $maxY);
71 71
 
72
-			return $image;
73
-		}
74
-		return false;
75
-	}
72
+            return $image;
73
+        }
74
+        return false;
75
+    }
76 76
 }
Please login to merge, or discard this patch.
lib/private/Share20/Hooks.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@
 block discarded – undo
22 22
 namespace OC\Share20;
23 23
 
24 24
 class Hooks {
25
-	public static function post_deleteUser($arguments) {
26
-		\OC::$server->getShareManager()->userDeleted($arguments['uid']);
27
-	}
25
+    public static function post_deleteUser($arguments) {
26
+        \OC::$server->getShareManager()->userDeleted($arguments['uid']);
27
+    }
28 28
 
29
-	public static function post_deleteGroup($arguments) {
30
-		\OC::$server->getShareManager()->groupDeleted($arguments['gid']);
31
-	}
29
+    public static function post_deleteGroup($arguments) {
30
+        \OC::$server->getShareManager()->groupDeleted($arguments['gid']);
31
+    }
32 32
 
33
-	public static function post_removeFromGroup($arguments) {
34
-		\OC::$server->getShareManager()->userDeletedFromGroup($arguments['uid'], $arguments['gid']);
35
-	}
33
+    public static function post_removeFromGroup($arguments) {
34
+        \OC::$server->getShareManager()->userDeletedFromGroup($arguments['uid'], $arguments['gid']);
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Share20/Share.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function setId($id) {
88 88
 		if (is_int($id)) {
89
-			$id = (string)$id;
89
+			$id = (string) $id;
90 90
 		}
91 91
 
92
-		if(!is_string($id)) {
92
+		if (!is_string($id)) {
93 93
 			throw new \InvalidArgumentException('String expected.');
94 94
 		}
95 95
 
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 		if ($this->providerId === null || $this->id === null) {
116 116
 			throw new \UnexpectedValueException;
117 117
 		}
118
-		return $this->providerId . ':' . $this->id;
118
+		return $this->providerId.':'.$this->id;
119 119
 	}
120 120
 
121 121
 	/**
122 122
 	 * @inheritdoc
123 123
 	 */
124 124
 	public function setProviderId($id) {
125
-		if(!is_string($id)) {
125
+		if (!is_string($id)) {
126 126
 			throw new \InvalidArgumentException('String expected.');
127 127
 		}
128 128
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 			// for federated shares the owner can be a remote user, in this
158 158
 			// case we use the initiator
159
-			if($this->userManager->userExists($this->shareOwner)) {
159
+			if ($this->userManager->userExists($this->shareOwner)) {
160 160
 				$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
161 161
 			} else {
162 162
 				$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 			$nodes = $userFolder->getById($this->fileId);
166 166
 			if (empty($nodes)) {
167
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
167
+				throw new NotFoundException('Node for share not found, fileid: '.$this->fileId);
168 168
 			}
169 169
 
170 170
 			$this->node = $nodes[0];
Please login to merge, or discard this patch.
Indentation   +510 added lines, -510 removed lines patch added patch discarded remove patch
@@ -34,514 +34,514 @@
 block discarded – undo
34 34
 
35 35
 class Share implements \OCP\Share\IShare {
36 36
 
37
-	/** @var string */
38
-	private $id;
39
-	/** @var string */
40
-	private $providerId;
41
-	/** @var Node */
42
-	private $node;
43
-	/** @var int */
44
-	private $fileId;
45
-	/** @var string */
46
-	private $nodeType;
47
-	/** @var int */
48
-	private $shareType;
49
-	/** @var string */
50
-	private $sharedWith;
51
-	/** @var string */
52
-	private $sharedWithDisplayName;
53
-	/** @var string */
54
-	private $sharedWithAvatar;
55
-	/** @var string */
56
-	private $sharedBy;
57
-	/** @var string */
58
-	private $shareOwner;
59
-	/** @var int */
60
-	private $permissions;
61
-	/** @var string */
62
-	private $note = '';
63
-	/** @var \DateTime */
64
-	private $expireDate;
65
-	/** @var string */
66
-	private $password;
67
-	/** @var bool */
68
-	private $sendPasswordByTalk = false;
69
-	/** @var string */
70
-	private $token;
71
-	/** @var int */
72
-	private $parent;
73
-	/** @var string */
74
-	private $target;
75
-	/** @var \DateTime */
76
-	private $shareTime;
77
-	/** @var bool */
78
-	private $mailSend;
79
-	/** @var string */
80
-	private $label = '';
81
-
82
-	/** @var IRootFolder */
83
-	private $rootFolder;
84
-
85
-	/** @var IUserManager */
86
-	private $userManager;
87
-
88
-	/** @var ICacheEntry|null */
89
-	private $nodeCacheEntry;
90
-
91
-	/** @var bool */
92
-	private $hideDownload = false;
93
-
94
-	public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
95
-		$this->rootFolder = $rootFolder;
96
-		$this->userManager = $userManager;
97
-	}
98
-
99
-	/**
100
-	 * @inheritdoc
101
-	 */
102
-	public function setId($id) {
103
-		if (is_int($id)) {
104
-			$id = (string)$id;
105
-		}
106
-
107
-		if(!is_string($id)) {
108
-			throw new \InvalidArgumentException('String expected.');
109
-		}
110
-
111
-		if ($this->id !== null) {
112
-			throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
113
-		}
114
-
115
-		$this->id = trim($id);
116
-		return $this;
117
-	}
118
-
119
-	/**
120
-	 * @inheritdoc
121
-	 */
122
-	public function getId() {
123
-		return $this->id;
124
-	}
125
-
126
-	/**
127
-	 * @inheritdoc
128
-	 */
129
-	public function getFullId() {
130
-		if ($this->providerId === null || $this->id === null) {
131
-			throw new \UnexpectedValueException;
132
-		}
133
-		return $this->providerId . ':' . $this->id;
134
-	}
135
-
136
-	/**
137
-	 * @inheritdoc
138
-	 */
139
-	public function setProviderId($id) {
140
-		if(!is_string($id)) {
141
-			throw new \InvalidArgumentException('String expected.');
142
-		}
143
-
144
-		if ($this->providerId !== null) {
145
-			throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
146
-		}
147
-
148
-		$this->providerId = trim($id);
149
-		return $this;
150
-	}
151
-
152
-	/**
153
-	 * @inheritdoc
154
-	 */
155
-	public function setNode(Node $node) {
156
-		$this->fileId = null;
157
-		$this->nodeType = null;
158
-		$this->node = $node;
159
-		return $this;
160
-	}
161
-
162
-	/**
163
-	 * @inheritdoc
164
-	 */
165
-	public function getNode() {
166
-		if ($this->node === null) {
167
-
168
-			if ($this->shareOwner === null || $this->fileId === null) {
169
-				throw new NotFoundException();
170
-			}
171
-
172
-			// for federated shares the owner can be a remote user, in this
173
-			// case we use the initiator
174
-			if($this->userManager->userExists($this->shareOwner)) {
175
-				$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
176
-			} else {
177
-				$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
178
-			}
179
-
180
-			$nodes = $userFolder->getById($this->fileId);
181
-			if (empty($nodes)) {
182
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
183
-			}
184
-
185
-			$this->node = $nodes[0];
186
-		}
187
-
188
-		return $this->node;
189
-	}
190
-
191
-	/**
192
-	 * @inheritdoc
193
-	 */
194
-	public function setNodeId($fileId) {
195
-		$this->node = null;
196
-		$this->fileId = $fileId;
197
-		return $this;
198
-	}
199
-
200
-	/**
201
-	 * @inheritdoc
202
-	 */
203
-	public function getNodeId() {
204
-		if ($this->fileId === null) {
205
-			$this->fileId = $this->getNode()->getId();
206
-		}
207
-
208
-		return $this->fileId;
209
-	}
210
-
211
-	/**
212
-	 * @inheritdoc
213
-	 */
214
-	public function setNodeType($type) {
215
-		if ($type !== 'file' && $type !== 'folder') {
216
-			throw new \InvalidArgumentException();
217
-		}
218
-
219
-		$this->nodeType = $type;
220
-		return $this;
221
-	}
222
-
223
-	/**
224
-	 * @inheritdoc
225
-	 */
226
-	public function getNodeType() {
227
-		if ($this->nodeType === null) {
228
-			$node = $this->getNode();
229
-			$this->nodeType = $node instanceof File ? 'file' : 'folder';
230
-		}
231
-
232
-		return $this->nodeType;
233
-	}
234
-
235
-	/**
236
-	 * @inheritdoc
237
-	 */
238
-	public function setShareType($shareType) {
239
-		$this->shareType = $shareType;
240
-		return $this;
241
-	}
242
-
243
-	/**
244
-	 * @inheritdoc
245
-	 */
246
-	public function getShareType() {
247
-		return $this->shareType;
248
-	}
249
-
250
-	/**
251
-	 * @inheritdoc
252
-	 */
253
-	public function setSharedWith($sharedWith) {
254
-		if (!is_string($sharedWith)) {
255
-			throw new \InvalidArgumentException();
256
-		}
257
-		$this->sharedWith = $sharedWith;
258
-		return $this;
259
-	}
260
-
261
-	/**
262
-	 * @inheritdoc
263
-	 */
264
-	public function getSharedWith() {
265
-		return $this->sharedWith;
266
-	}
267
-
268
-	/**
269
-	 * @inheritdoc
270
-	 */
271
-	public function setSharedWithDisplayName($displayName) {
272
-		if (!is_string($displayName)) {
273
-			throw new \InvalidArgumentException();
274
-		}
275
-		$this->sharedWithDisplayName = $displayName;
276
-		return $this;
277
-	}
278
-
279
-	/**
280
-	 * @inheritdoc
281
-	 */
282
-	public function getSharedWithDisplayName() {
283
-		return $this->sharedWithDisplayName;
284
-	}
285
-
286
-	/**
287
-	 * @inheritdoc
288
-	 */
289
-	public function setSharedWithAvatar($src) {
290
-		if (!is_string($src)) {
291
-			throw new \InvalidArgumentException();
292
-		}
293
-		$this->sharedWithAvatar = $src;
294
-		return $this;
295
-	}
296
-
297
-	/**
298
-	 * @inheritdoc
299
-	 */
300
-	public function getSharedWithAvatar() {
301
-		return $this->sharedWithAvatar;
302
-	}
303
-
304
-	/**
305
-	 * @inheritdoc
306
-	 */
307
-	public function setPermissions($permissions) {
308
-		//TODO checkes
309
-
310
-		$this->permissions = $permissions;
311
-		return $this;
312
-	}
313
-
314
-	/**
315
-	 * @inheritdoc
316
-	 */
317
-	public function getPermissions() {
318
-		return $this->permissions;
319
-	}
320
-
321
-	/**
322
-	 * @inheritdoc
323
-	 */
324
-	public function setNote($note) {
325
-		$this->note = $note;
326
-		return $this;
327
-	}
328
-
329
-	/**
330
-	 * @inheritdoc
331
-	 */
332
-	public function getNote() {
333
-		if (is_string($this->note)) {
334
-			return $this->note;
335
-		}
336
-		return '';
337
-	}
338
-
339
-	/**
340
-	 * @inheritdoc
341
-	 */
342
-	public function setLabel($label) {
343
-		$this->label = $label;
344
-		return $this;
345
-	}
346
-
347
-	/**
348
-	 * @inheritdoc
349
-	 */
350
-	public function getLabel() {
351
-		return $this->label;
352
-	}
353
-
354
-	/**
355
-	 * @inheritdoc
356
-	 */
357
-	public function setExpirationDate($expireDate) {
358
-		//TODO checks
359
-
360
-		$this->expireDate = $expireDate;
361
-		return $this;
362
-	}
363
-
364
-	/**
365
-	 * @inheritdoc
366
-	 */
367
-	public function getExpirationDate() {
368
-		return $this->expireDate;
369
-	}
370
-
371
-	/**
372
-	 * @inheritdoc
373
-	 */
374
-	public function setSharedBy($sharedBy) {
375
-		if (!is_string($sharedBy)) {
376
-			throw new \InvalidArgumentException();
377
-		}
378
-		//TODO checks
379
-		$this->sharedBy = $sharedBy;
380
-
381
-		return $this;
382
-	}
383
-
384
-	/**
385
-	 * @inheritdoc
386
-	 */
387
-	public function getSharedBy() {
388
-		//TODO check if set
389
-		return $this->sharedBy;
390
-	}
391
-
392
-	/**
393
-	 * @inheritdoc
394
-	 */
395
-	public function setShareOwner($shareOwner) {
396
-		if (!is_string($shareOwner)) {
397
-			throw new \InvalidArgumentException();
398
-		}
399
-		//TODO checks
400
-
401
-		$this->shareOwner = $shareOwner;
402
-		return $this;
403
-	}
404
-
405
-	/**
406
-	 * @inheritdoc
407
-	 */
408
-	public function getShareOwner() {
409
-		//TODO check if set
410
-		return $this->shareOwner;
411
-	}
412
-
413
-	/**
414
-	 * @inheritdoc
415
-	 */
416
-	public function setPassword($password) {
417
-		$this->password = $password;
418
-		return $this;
419
-	}
420
-
421
-	/**
422
-	 * @inheritdoc
423
-	 */
424
-	public function getPassword() {
425
-		return $this->password;
426
-	}
427
-
428
-	/**
429
-	 * @inheritdoc
430
-	 */
431
-	public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
432
-		$this->sendPasswordByTalk = $sendPasswordByTalk;
433
-		return $this;
434
-	}
435
-
436
-	/**
437
-	 * @inheritdoc
438
-	 */
439
-	public function getSendPasswordByTalk(): bool {
440
-		return $this->sendPasswordByTalk;
441
-	}
442
-
443
-	/**
444
-	 * @inheritdoc
445
-	 */
446
-	public function setToken($token) {
447
-		$this->token = $token;
448
-		return $this;
449
-	}
450
-
451
-	/**
452
-	 * @inheritdoc
453
-	 */
454
-	public function getToken() {
455
-		return $this->token;
456
-	}
457
-
458
-	/**
459
-	 * Set the parent of this share
460
-	 *
461
-	 * @param int parent
462
-	 * @return \OCP\Share\IShare
463
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
464
-	 */
465
-	public function setParent($parent) {
466
-		$this->parent = $parent;
467
-		return $this;
468
-	}
469
-
470
-	/**
471
-	 * Get the parent of this share.
472
-	 *
473
-	 * @return int
474
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
475
-	 */
476
-	public function getParent() {
477
-		return $this->parent;
478
-	}
479
-
480
-	/**
481
-	 * @inheritdoc
482
-	 */
483
-	public function setTarget($target) {
484
-		$this->target = $target;
485
-		return $this;
486
-	}
487
-
488
-	/**
489
-	 * @inheritdoc
490
-	 */
491
-	public function getTarget() {
492
-		return $this->target;
493
-	}
494
-
495
-	/**
496
-	 * @inheritdoc
497
-	 */
498
-	public function setShareTime(\DateTime $shareTime) {
499
-		$this->shareTime = $shareTime;
500
-		return $this;
501
-	}
502
-
503
-	/**
504
-	 * @inheritdoc
505
-	 */
506
-	public function getShareTime() {
507
-		return $this->shareTime;
508
-	}
509
-
510
-	/**
511
-	 * @inheritdoc
512
-	 */
513
-	public function setMailSend($mailSend) {
514
-		$this->mailSend = $mailSend;
515
-		return $this;
516
-	}
517
-
518
-	/**
519
-	 * @inheritdoc
520
-	 */
521
-	public function getMailSend() {
522
-		return $this->mailSend;
523
-	}
524
-
525
-	/**
526
-	 * @inheritdoc
527
-	 */
528
-	public function setNodeCacheEntry(ICacheEntry $entry) {
529
-		$this->nodeCacheEntry = $entry;
530
-	}
531
-
532
-	/**
533
-	 * @inheritdoc
534
-	 */
535
-	public function getNodeCacheEntry() {
536
-		return $this->nodeCacheEntry;
537
-	}
538
-
539
-	public function setHideDownload(bool $hide): IShare {
540
-		$this->hideDownload = $hide;
541
-		return $this;
542
-	}
543
-
544
-	public function getHideDownload(): bool {
545
-		return $this->hideDownload;
546
-	}
37
+    /** @var string */
38
+    private $id;
39
+    /** @var string */
40
+    private $providerId;
41
+    /** @var Node */
42
+    private $node;
43
+    /** @var int */
44
+    private $fileId;
45
+    /** @var string */
46
+    private $nodeType;
47
+    /** @var int */
48
+    private $shareType;
49
+    /** @var string */
50
+    private $sharedWith;
51
+    /** @var string */
52
+    private $sharedWithDisplayName;
53
+    /** @var string */
54
+    private $sharedWithAvatar;
55
+    /** @var string */
56
+    private $sharedBy;
57
+    /** @var string */
58
+    private $shareOwner;
59
+    /** @var int */
60
+    private $permissions;
61
+    /** @var string */
62
+    private $note = '';
63
+    /** @var \DateTime */
64
+    private $expireDate;
65
+    /** @var string */
66
+    private $password;
67
+    /** @var bool */
68
+    private $sendPasswordByTalk = false;
69
+    /** @var string */
70
+    private $token;
71
+    /** @var int */
72
+    private $parent;
73
+    /** @var string */
74
+    private $target;
75
+    /** @var \DateTime */
76
+    private $shareTime;
77
+    /** @var bool */
78
+    private $mailSend;
79
+    /** @var string */
80
+    private $label = '';
81
+
82
+    /** @var IRootFolder */
83
+    private $rootFolder;
84
+
85
+    /** @var IUserManager */
86
+    private $userManager;
87
+
88
+    /** @var ICacheEntry|null */
89
+    private $nodeCacheEntry;
90
+
91
+    /** @var bool */
92
+    private $hideDownload = false;
93
+
94
+    public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
95
+        $this->rootFolder = $rootFolder;
96
+        $this->userManager = $userManager;
97
+    }
98
+
99
+    /**
100
+     * @inheritdoc
101
+     */
102
+    public function setId($id) {
103
+        if (is_int($id)) {
104
+            $id = (string)$id;
105
+        }
106
+
107
+        if(!is_string($id)) {
108
+            throw new \InvalidArgumentException('String expected.');
109
+        }
110
+
111
+        if ($this->id !== null) {
112
+            throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
113
+        }
114
+
115
+        $this->id = trim($id);
116
+        return $this;
117
+    }
118
+
119
+    /**
120
+     * @inheritdoc
121
+     */
122
+    public function getId() {
123
+        return $this->id;
124
+    }
125
+
126
+    /**
127
+     * @inheritdoc
128
+     */
129
+    public function getFullId() {
130
+        if ($this->providerId === null || $this->id === null) {
131
+            throw new \UnexpectedValueException;
132
+        }
133
+        return $this->providerId . ':' . $this->id;
134
+    }
135
+
136
+    /**
137
+     * @inheritdoc
138
+     */
139
+    public function setProviderId($id) {
140
+        if(!is_string($id)) {
141
+            throw new \InvalidArgumentException('String expected.');
142
+        }
143
+
144
+        if ($this->providerId !== null) {
145
+            throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
146
+        }
147
+
148
+        $this->providerId = trim($id);
149
+        return $this;
150
+    }
151
+
152
+    /**
153
+     * @inheritdoc
154
+     */
155
+    public function setNode(Node $node) {
156
+        $this->fileId = null;
157
+        $this->nodeType = null;
158
+        $this->node = $node;
159
+        return $this;
160
+    }
161
+
162
+    /**
163
+     * @inheritdoc
164
+     */
165
+    public function getNode() {
166
+        if ($this->node === null) {
167
+
168
+            if ($this->shareOwner === null || $this->fileId === null) {
169
+                throw new NotFoundException();
170
+            }
171
+
172
+            // for federated shares the owner can be a remote user, in this
173
+            // case we use the initiator
174
+            if($this->userManager->userExists($this->shareOwner)) {
175
+                $userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
176
+            } else {
177
+                $userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
178
+            }
179
+
180
+            $nodes = $userFolder->getById($this->fileId);
181
+            if (empty($nodes)) {
182
+                throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
183
+            }
184
+
185
+            $this->node = $nodes[0];
186
+        }
187
+
188
+        return $this->node;
189
+    }
190
+
191
+    /**
192
+     * @inheritdoc
193
+     */
194
+    public function setNodeId($fileId) {
195
+        $this->node = null;
196
+        $this->fileId = $fileId;
197
+        return $this;
198
+    }
199
+
200
+    /**
201
+     * @inheritdoc
202
+     */
203
+    public function getNodeId() {
204
+        if ($this->fileId === null) {
205
+            $this->fileId = $this->getNode()->getId();
206
+        }
207
+
208
+        return $this->fileId;
209
+    }
210
+
211
+    /**
212
+     * @inheritdoc
213
+     */
214
+    public function setNodeType($type) {
215
+        if ($type !== 'file' && $type !== 'folder') {
216
+            throw new \InvalidArgumentException();
217
+        }
218
+
219
+        $this->nodeType = $type;
220
+        return $this;
221
+    }
222
+
223
+    /**
224
+     * @inheritdoc
225
+     */
226
+    public function getNodeType() {
227
+        if ($this->nodeType === null) {
228
+            $node = $this->getNode();
229
+            $this->nodeType = $node instanceof File ? 'file' : 'folder';
230
+        }
231
+
232
+        return $this->nodeType;
233
+    }
234
+
235
+    /**
236
+     * @inheritdoc
237
+     */
238
+    public function setShareType($shareType) {
239
+        $this->shareType = $shareType;
240
+        return $this;
241
+    }
242
+
243
+    /**
244
+     * @inheritdoc
245
+     */
246
+    public function getShareType() {
247
+        return $this->shareType;
248
+    }
249
+
250
+    /**
251
+     * @inheritdoc
252
+     */
253
+    public function setSharedWith($sharedWith) {
254
+        if (!is_string($sharedWith)) {
255
+            throw new \InvalidArgumentException();
256
+        }
257
+        $this->sharedWith = $sharedWith;
258
+        return $this;
259
+    }
260
+
261
+    /**
262
+     * @inheritdoc
263
+     */
264
+    public function getSharedWith() {
265
+        return $this->sharedWith;
266
+    }
267
+
268
+    /**
269
+     * @inheritdoc
270
+     */
271
+    public function setSharedWithDisplayName($displayName) {
272
+        if (!is_string($displayName)) {
273
+            throw new \InvalidArgumentException();
274
+        }
275
+        $this->sharedWithDisplayName = $displayName;
276
+        return $this;
277
+    }
278
+
279
+    /**
280
+     * @inheritdoc
281
+     */
282
+    public function getSharedWithDisplayName() {
283
+        return $this->sharedWithDisplayName;
284
+    }
285
+
286
+    /**
287
+     * @inheritdoc
288
+     */
289
+    public function setSharedWithAvatar($src) {
290
+        if (!is_string($src)) {
291
+            throw new \InvalidArgumentException();
292
+        }
293
+        $this->sharedWithAvatar = $src;
294
+        return $this;
295
+    }
296
+
297
+    /**
298
+     * @inheritdoc
299
+     */
300
+    public function getSharedWithAvatar() {
301
+        return $this->sharedWithAvatar;
302
+    }
303
+
304
+    /**
305
+     * @inheritdoc
306
+     */
307
+    public function setPermissions($permissions) {
308
+        //TODO checkes
309
+
310
+        $this->permissions = $permissions;
311
+        return $this;
312
+    }
313
+
314
+    /**
315
+     * @inheritdoc
316
+     */
317
+    public function getPermissions() {
318
+        return $this->permissions;
319
+    }
320
+
321
+    /**
322
+     * @inheritdoc
323
+     */
324
+    public function setNote($note) {
325
+        $this->note = $note;
326
+        return $this;
327
+    }
328
+
329
+    /**
330
+     * @inheritdoc
331
+     */
332
+    public function getNote() {
333
+        if (is_string($this->note)) {
334
+            return $this->note;
335
+        }
336
+        return '';
337
+    }
338
+
339
+    /**
340
+     * @inheritdoc
341
+     */
342
+    public function setLabel($label) {
343
+        $this->label = $label;
344
+        return $this;
345
+    }
346
+
347
+    /**
348
+     * @inheritdoc
349
+     */
350
+    public function getLabel() {
351
+        return $this->label;
352
+    }
353
+
354
+    /**
355
+     * @inheritdoc
356
+     */
357
+    public function setExpirationDate($expireDate) {
358
+        //TODO checks
359
+
360
+        $this->expireDate = $expireDate;
361
+        return $this;
362
+    }
363
+
364
+    /**
365
+     * @inheritdoc
366
+     */
367
+    public function getExpirationDate() {
368
+        return $this->expireDate;
369
+    }
370
+
371
+    /**
372
+     * @inheritdoc
373
+     */
374
+    public function setSharedBy($sharedBy) {
375
+        if (!is_string($sharedBy)) {
376
+            throw new \InvalidArgumentException();
377
+        }
378
+        //TODO checks
379
+        $this->sharedBy = $sharedBy;
380
+
381
+        return $this;
382
+    }
383
+
384
+    /**
385
+     * @inheritdoc
386
+     */
387
+    public function getSharedBy() {
388
+        //TODO check if set
389
+        return $this->sharedBy;
390
+    }
391
+
392
+    /**
393
+     * @inheritdoc
394
+     */
395
+    public function setShareOwner($shareOwner) {
396
+        if (!is_string($shareOwner)) {
397
+            throw new \InvalidArgumentException();
398
+        }
399
+        //TODO checks
400
+
401
+        $this->shareOwner = $shareOwner;
402
+        return $this;
403
+    }
404
+
405
+    /**
406
+     * @inheritdoc
407
+     */
408
+    public function getShareOwner() {
409
+        //TODO check if set
410
+        return $this->shareOwner;
411
+    }
412
+
413
+    /**
414
+     * @inheritdoc
415
+     */
416
+    public function setPassword($password) {
417
+        $this->password = $password;
418
+        return $this;
419
+    }
420
+
421
+    /**
422
+     * @inheritdoc
423
+     */
424
+    public function getPassword() {
425
+        return $this->password;
426
+    }
427
+
428
+    /**
429
+     * @inheritdoc
430
+     */
431
+    public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
432
+        $this->sendPasswordByTalk = $sendPasswordByTalk;
433
+        return $this;
434
+    }
435
+
436
+    /**
437
+     * @inheritdoc
438
+     */
439
+    public function getSendPasswordByTalk(): bool {
440
+        return $this->sendPasswordByTalk;
441
+    }
442
+
443
+    /**
444
+     * @inheritdoc
445
+     */
446
+    public function setToken($token) {
447
+        $this->token = $token;
448
+        return $this;
449
+    }
450
+
451
+    /**
452
+     * @inheritdoc
453
+     */
454
+    public function getToken() {
455
+        return $this->token;
456
+    }
457
+
458
+    /**
459
+     * Set the parent of this share
460
+     *
461
+     * @param int parent
462
+     * @return \OCP\Share\IShare
463
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
464
+     */
465
+    public function setParent($parent) {
466
+        $this->parent = $parent;
467
+        return $this;
468
+    }
469
+
470
+    /**
471
+     * Get the parent of this share.
472
+     *
473
+     * @return int
474
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
475
+     */
476
+    public function getParent() {
477
+        return $this->parent;
478
+    }
479
+
480
+    /**
481
+     * @inheritdoc
482
+     */
483
+    public function setTarget($target) {
484
+        $this->target = $target;
485
+        return $this;
486
+    }
487
+
488
+    /**
489
+     * @inheritdoc
490
+     */
491
+    public function getTarget() {
492
+        return $this->target;
493
+    }
494
+
495
+    /**
496
+     * @inheritdoc
497
+     */
498
+    public function setShareTime(\DateTime $shareTime) {
499
+        $this->shareTime = $shareTime;
500
+        return $this;
501
+    }
502
+
503
+    /**
504
+     * @inheritdoc
505
+     */
506
+    public function getShareTime() {
507
+        return $this->shareTime;
508
+    }
509
+
510
+    /**
511
+     * @inheritdoc
512
+     */
513
+    public function setMailSend($mailSend) {
514
+        $this->mailSend = $mailSend;
515
+        return $this;
516
+    }
517
+
518
+    /**
519
+     * @inheritdoc
520
+     */
521
+    public function getMailSend() {
522
+        return $this->mailSend;
523
+    }
524
+
525
+    /**
526
+     * @inheritdoc
527
+     */
528
+    public function setNodeCacheEntry(ICacheEntry $entry) {
529
+        $this->nodeCacheEntry = $entry;
530
+    }
531
+
532
+    /**
533
+     * @inheritdoc
534
+     */
535
+    public function getNodeCacheEntry() {
536
+        return $this->nodeCacheEntry;
537
+    }
538
+
539
+    public function setHideDownload(bool $hide): IShare {
540
+        $this->hideDownload = $hide;
541
+        return $this;
542
+    }
543
+
544
+    public function getHideDownload(): bool {
545
+        return $this->hideDownload;
546
+    }
547 547
 }
Please login to merge, or discard this patch.