Completed
Push — master ( 02e326...506f7f )
by Joas
14:02
created
lib/private/Activity/Manager.php 1 patch
Indentation   +659 added lines, -659 removed lines patch added patch discarded remove patch
@@ -40,663 +40,663 @@
 block discarded – undo
40 40
 use OCP\RichObjectStrings\IValidator;
41 41
 
42 42
 class Manager implements IManager {
43
-	/** @var IRequest */
44
-	protected $request;
45
-
46
-	/** @var IUserSession */
47
-	protected $session;
48
-
49
-	/** @var IConfig */
50
-	protected $config;
51
-
52
-	/** @var IValidator */
53
-	protected $validator;
54
-
55
-	/** @var string */
56
-	protected $formattingObjectType;
57
-
58
-	/** @var int */
59
-	protected $formattingObjectId;
60
-
61
-	/** @var bool */
62
-	protected $requirePNG;
63
-
64
-	/** @var string */
65
-	protected $currentUserId;
66
-
67
-	/**
68
-	 * constructor of the controller
69
-	 *
70
-	 * @param IRequest $request
71
-	 * @param IUserSession $session
72
-	 * @param IConfig $config
73
-	 * @param IValidator $validator
74
-	 */
75
-	public function __construct(IRequest $request,
76
-								IUserSession $session,
77
-								IConfig $config,
78
-								IValidator $validator) {
79
-		$this->request = $request;
80
-		$this->session = $session;
81
-		$this->config = $config;
82
-		$this->validator = $validator;
83
-	}
84
-
85
-	/** @var \Closure[] */
86
-	private $consumersClosures = array();
87
-
88
-	/** @var IConsumer[] */
89
-	private $consumers = array();
90
-
91
-	/** @var \Closure[] */
92
-	private $extensionsClosures = array();
93
-
94
-	/** @var IExtension[] */
95
-	private $extensions = array();
96
-
97
-	/** @var array list of filters "name" => "is valid" */
98
-	protected $validFilters = array(
99
-		'all'	=> true,
100
-		'by'	=> true,
101
-		'self'	=> true,
102
-	);
103
-
104
-	/** @var array list of type icons "type" => "css class" */
105
-	protected $typeIcons = array();
106
-
107
-	/** @var array list of special parameters "app" => ["text" => ["parameter" => "type"]] */
108
-	protected $specialParameters = array();
109
-
110
-	/**
111
-	 * @return \OCP\Activity\IConsumer[]
112
-	 */
113
-	protected function getConsumers() {
114
-		if (!empty($this->consumers)) {
115
-			return $this->consumers;
116
-		}
117
-
118
-		$this->consumers = [];
119
-		foreach($this->consumersClosures as $consumer) {
120
-			$c = $consumer();
121
-			if ($c instanceof IConsumer) {
122
-				$this->consumers[] = $c;
123
-			} else {
124
-				throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface');
125
-			}
126
-		}
127
-
128
-		return $this->consumers;
129
-	}
130
-
131
-	/**
132
-	 * @return \OCP\Activity\IExtension[]
133
-	 */
134
-	protected function getExtensions() {
135
-		if (!empty($this->extensions)) {
136
-			return $this->extensions;
137
-		}
138
-
139
-		$this->extensions = [];
140
-		foreach($this->extensionsClosures as $extension) {
141
-			$e = $extension();
142
-			if ($e instanceof IExtension) {
143
-				$this->extensions[] = $e;
144
-			} else {
145
-				throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface');
146
-			}
147
-		}
148
-
149
-		return $this->extensions;
150
-	}
151
-
152
-	/**
153
-	 * Generates a new IEvent object
154
-	 *
155
-	 * Make sure to call at least the following methods before sending it to the
156
-	 * app with via the publish() method:
157
-	 *  - setApp()
158
-	 *  - setType()
159
-	 *  - setAffectedUser()
160
-	 *  - setSubject()
161
-	 *
162
-	 * @return IEvent
163
-	 */
164
-	public function generateEvent() {
165
-		return new Event($this->validator);
166
-	}
167
-
168
-	/**
169
-	 * Publish an event to the activity consumers
170
-	 *
171
-	 * Make sure to call at least the following methods before sending an Event:
172
-	 *  - setApp()
173
-	 *  - setType()
174
-	 *  - setAffectedUser()
175
-	 *  - setSubject()
176
-	 *
177
-	 * @param IEvent $event
178
-	 * @throws \BadMethodCallException if required values have not been set
179
-	 */
180
-	public function publish(IEvent $event) {
181
-		if ($event->getAuthor() === '') {
182
-			if ($this->session->getUser() instanceof IUser) {
183
-				$event->setAuthor($this->session->getUser()->getUID());
184
-			}
185
-		}
186
-
187
-		if (!$event->getTimestamp()) {
188
-			$event->setTimestamp(time());
189
-		}
190
-
191
-		if (!$event->isValid()) {
192
-			throw new \BadMethodCallException('The given event is invalid');
193
-		}
194
-
195
-		foreach ($this->getConsumers() as $c) {
196
-			$c->receive($event);
197
-		}
198
-	}
199
-
200
-	/**
201
-	 * In order to improve lazy loading a closure can be registered which will be called in case
202
-	 * activity consumers are actually requested
203
-	 *
204
-	 * $callable has to return an instance of OCA\Activity\IConsumer
205
-	 *
206
-	 * @param \Closure $callable
207
-	 */
208
-	public function registerConsumer(\Closure $callable) {
209
-		$this->consumersClosures[] = $callable;
210
-		$this->consumers = [];
211
-	}
212
-
213
-	/**
214
-	 * In order to improve lazy loading a closure can be registered which will be called in case
215
-	 * activity consumers are actually requested
216
-	 *
217
-	 * $callable has to return an instance of OCA\Activity\IExtension
218
-	 *
219
-	 * @param \Closure $callable
220
-	 */
221
-	public function registerExtension(\Closure $callable) {
222
-		$this->extensionsClosures[] = $callable;
223
-		$this->extensions = [];
224
-	}
225
-
226
-	/** @var string[] */
227
-	protected $filterClasses = [];
228
-
229
-	/** @var IFilter[] */
230
-	protected $filters = [];
231
-
232
-	/** @var bool */
233
-	protected $loadedLegacyFilters = false;
234
-
235
-	/**
236
-	 * @param string $filter Class must implement OCA\Activity\IFilter
237
-	 * @return void
238
-	 */
239
-	public function registerFilter($filter) {
240
-		$this->filterClasses[$filter] = false;
241
-	}
242
-
243
-	/**
244
-	 * @return IFilter[]
245
-	 * @throws \InvalidArgumentException
246
-	 */
247
-	public function getFilters() {
248
-		if (!$this->loadedLegacyFilters) {
249
-			$legacyFilters = $this->getNavigation();
250
-
251
-			foreach ($legacyFilters['top'] as $filter => $data) {
252
-				$this->filters[$filter] = new LegacyFilter(
253
-					$this, $filter, $data['name'], true
254
-				);
255
-			}
256
-
257
-			foreach ($legacyFilters['apps'] as $filter => $data) {
258
-				$this->filters[$filter] = new LegacyFilter(
259
-					$this, $filter, $data['name'], false
260
-				);
261
-			}
262
-			$this->loadedLegacyFilters = true;
263
-		}
264
-
265
-		foreach ($this->filterClasses as $class => $false) {
266
-			/** @var IFilter $filter */
267
-			$filter = \OC::$server->query($class);
268
-
269
-			if (!$filter instanceof IFilter) {
270
-				throw new \InvalidArgumentException('Invalid activity filter registered');
271
-			}
272
-
273
-			$this->filters[$filter->getIdentifier()] = $filter;
274
-
275
-			unset($this->filterClasses[$class]);
276
-		}
277
-		return $this->filters;
278
-	}
279
-
280
-	/**
281
-	 * @param string $id
282
-	 * @return IFilter
283
-	 * @throws \InvalidArgumentException when the filter was not found
284
-	 * @since 11.0.0
285
-	 */
286
-	public function getFilterById($id) {
287
-		$filters = $this->getFilters();
288
-
289
-		if (isset($filters[$id])) {
290
-			return $filters[$id];
291
-		}
292
-
293
-		throw new \InvalidArgumentException('Requested filter does not exist');
294
-	}
295
-
296
-	/** @var string[] */
297
-	protected $providerClasses = [];
298
-
299
-	/** @var IProvider[] */
300
-	protected $providers = [];
301
-
302
-	/**
303
-	 * @param string $provider Class must implement OCA\Activity\IProvider
304
-	 * @return void
305
-	 */
306
-	public function registerProvider($provider) {
307
-		$this->providerClasses[$provider] = false;
308
-	}
309
-
310
-	/**
311
-	 * @return IProvider[]
312
-	 * @throws \InvalidArgumentException
313
-	 */
314
-	public function getProviders() {
315
-		foreach ($this->providerClasses as $class => $false) {
316
-			/** @var IProvider $provider */
317
-			$provider = \OC::$server->query($class);
318
-
319
-			if (!$provider instanceof IProvider) {
320
-				throw new \InvalidArgumentException('Invalid activity provider registered');
321
-			}
322
-
323
-			$this->providers[] = $provider;
324
-
325
-			unset($this->providerClasses[$class]);
326
-		}
327
-		return $this->providers;
328
-	}
329
-
330
-	/** @var string[] */
331
-	protected $settingsClasses = [];
332
-
333
-	/** @var ISetting[] */
334
-	protected $settings = [];
335
-
336
-	/** @var bool */
337
-	protected $loadedLegacyTypes = false;
338
-
339
-	/**
340
-	 * @param string $setting Class must implement OCA\Activity\ISetting
341
-	 * @return void
342
-	 */
343
-	public function registerSetting($setting) {
344
-		$this->settingsClasses[$setting] = false;
345
-	}
346
-
347
-	/**
348
-	 * @return ISetting[]
349
-	 * @throws \InvalidArgumentException
350
-	 */
351
-	public function getSettings() {
352
-		if (!$this->loadedLegacyTypes) {
353
-			$l = \OC::$server->getL10N('core');
354
-			$legacyTypes = $this->getNotificationTypes($l->getLanguageCode());
355
-			$streamTypes = $this->getDefaultTypes(IExtension::METHOD_STREAM);
356
-			$mailTypes = $this->getDefaultTypes(IExtension::METHOD_MAIL);
357
-			foreach ($legacyTypes as $type => $data) {
358
-				if (is_string($data)) {
359
-					$desc = $data;
360
-					$canChangeStream = true;
361
-					$canChangeMail = true;
362
-				} else {
363
-					$desc = $data['desc'];
364
-					$canChangeStream = in_array(IExtension::METHOD_STREAM, $data['methods']);
365
-					$canChangeMail = in_array(IExtension::METHOD_MAIL, $data['methods']);
366
-				}
367
-
368
-				$this->settings[$type] = new LegacySetting(
369
-					$type, $desc,
370
-					$canChangeStream, in_array($type, $streamTypes),
371
-					$canChangeMail, in_array($type, $mailTypes)
372
-				);
373
-			}
374
-			$this->loadedLegacyTypes = true;
375
-		}
376
-
377
-		foreach ($this->settingsClasses as $class => $false) {
378
-			/** @var ISetting $setting */
379
-			$setting = \OC::$server->query($class);
380
-
381
-			if (!$setting instanceof ISetting) {
382
-				throw new \InvalidArgumentException('Invalid activity filter registered');
383
-			}
384
-
385
-			$this->settings[$setting->getIdentifier()] = $setting;
386
-
387
-			unset($this->settingsClasses[$class]);
388
-		}
389
-		return $this->settings;
390
-	}
391
-
392
-	/**
393
-	 * @param string $id
394
-	 * @return ISetting
395
-	 * @throws \InvalidArgumentException when the setting was not found
396
-	 * @since 11.0.0
397
-	 */
398
-	public function getSettingById($id) {
399
-		$settings = $this->getSettings();
400
-
401
-		if (isset($settings[$id])) {
402
-			return $settings[$id];
403
-		}
404
-
405
-		throw new \InvalidArgumentException('Requested setting does not exist');
406
-	}
407
-
408
-	/**
409
-	 * @param string $type
410
-	 * @return string
411
-	 */
412
-	public function getTypeIcon($type) {
413
-		if (isset($this->typeIcons[$type])) {
414
-			return $this->typeIcons[$type];
415
-		}
416
-
417
-		foreach ($this->getExtensions() as $c) {
418
-			$icon = $c->getTypeIcon($type);
419
-			if (is_string($icon)) {
420
-				$this->typeIcons[$type] = $icon;
421
-				return $icon;
422
-			}
423
-		}
424
-
425
-		$this->typeIcons[$type] = '';
426
-		return '';
427
-	}
428
-
429
-	/**
430
-	 * @param string $type
431
-	 * @param string $id
432
-	 */
433
-	public function setFormattingObject($type, $id) {
434
-		$this->formattingObjectType = $type;
435
-		$this->formattingObjectId = (string) $id;
436
-	}
437
-
438
-	/**
439
-	 * @return bool
440
-	 */
441
-	public function isFormattingFilteredObject() {
442
-		return $this->formattingObjectType !== null && $this->formattingObjectId !== null
443
-			&& $this->formattingObjectType === $this->request->getParam('object_type')
444
-			&& $this->formattingObjectId === $this->request->getParam('object_id');
445
-	}
446
-
447
-	/**
448
-	 * @param bool $status Set to true, when parsing events should not use SVG icons
449
-	 */
450
-	public function setRequirePNG($status) {
451
-		$this->requirePNG = $status;
452
-	}
453
-
454
-	/**
455
-	 * @return bool
456
-	 */
457
-	public function getRequirePNG() {
458
-		return $this->requirePNG;
459
-	}
460
-
461
-	/**
462
-	 * @param string $app
463
-	 * @param string $text
464
-	 * @param array $params
465
-	 * @param boolean $stripPath
466
-	 * @param boolean $highlightParams
467
-	 * @param string $languageCode
468
-	 * @return string|false
469
-	 */
470
-	public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
471
-		foreach ($this->getExtensions() as $c) {
472
-			$translation = $c->translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
473
-			if (is_string($translation)) {
474
-				return $translation;
475
-			}
476
-		}
477
-
478
-		return false;
479
-	}
480
-
481
-	/**
482
-	 * @param string $app
483
-	 * @param string $text
484
-	 * @return array|false
485
-	 */
486
-	public function getSpecialParameterList($app, $text) {
487
-		if (isset($this->specialParameters[$app][$text])) {
488
-			return $this->specialParameters[$app][$text];
489
-		}
490
-
491
-		if (!isset($this->specialParameters[$app])) {
492
-			$this->specialParameters[$app] = array();
493
-		}
494
-
495
-		foreach ($this->getExtensions() as $c) {
496
-			$specialParameter = $c->getSpecialParameterList($app, $text);
497
-			if (is_array($specialParameter)) {
498
-				$this->specialParameters[$app][$text] = $specialParameter;
499
-				return $specialParameter;
500
-			}
501
-		}
502
-
503
-		$this->specialParameters[$app][$text] = false;
504
-		return false;
505
-	}
506
-
507
-	/**
508
-	 * @param array $activity
509
-	 * @return integer|false
510
-	 */
511
-	public function getGroupParameter($activity) {
512
-		foreach ($this->getExtensions() as $c) {
513
-			$parameter = $c->getGroupParameter($activity);
514
-			if ($parameter !== false) {
515
-				return $parameter;
516
-			}
517
-		}
518
-
519
-		return false;
520
-	}
521
-
522
-	/**
523
-	 * Set the user we need to use
524
-	 *
525
-	 * @param string|null $currentUserId
526
-	 * @throws \UnexpectedValueException If the user is invalid
527
-	 */
528
-	public function setCurrentUserId($currentUserId) {
529
-		if (!is_string($currentUserId) && $currentUserId !== null) {
530
-			throw new \UnexpectedValueException('The given current user is invalid');
531
-		}
532
-		$this->currentUserId = $currentUserId;
533
-	}
534
-
535
-	/**
536
-	 * Get the user we need to use
537
-	 *
538
-	 * Either the user is logged in, or we try to get it from the token
539
-	 *
540
-	 * @return string
541
-	 * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
542
-	 */
543
-	public function getCurrentUserId() {
544
-		if ($this->currentUserId !== null) {
545
-			return $this->currentUserId;
546
-		} else if (!$this->session->isLoggedIn()) {
547
-			return $this->getUserFromToken();
548
-		} else {
549
-			return $this->session->getUser()->getUID();
550
-		}
551
-	}
552
-
553
-	/**
554
-	 * Get the user for the token
555
-	 *
556
-	 * @return string
557
-	 * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
558
-	 */
559
-	protected function getUserFromToken() {
560
-		$token = (string) $this->request->getParam('token', '');
561
-		if (strlen($token) !== 30) {
562
-			throw new \UnexpectedValueException('The token is invalid');
563
-		}
564
-
565
-		$users = $this->config->getUsersForUserValue('activity', 'rsstoken', $token);
566
-
567
-		if (count($users) !== 1) {
568
-			// No unique user found
569
-			throw new \UnexpectedValueException('The token is invalid');
570
-		}
571
-
572
-		// Token found login as that user
573
-		return array_shift($users);
574
-	}
575
-
576
-	/**
577
-	 * @return array
578
-	 * @deprecated 11.0.0 - Use getFilters() instead
579
-	 */
580
-	public function getNavigation() {
581
-		$entries = array(
582
-			'apps' => array(),
583
-			'top' => array(),
584
-		);
585
-		foreach ($this->getExtensions() as $c) {
586
-			$additionalEntries = $c->getNavigation();
587
-			if (is_array($additionalEntries)) {
588
-				$entries['apps'] = array_merge($entries['apps'], $additionalEntries['apps']);
589
-				$entries['top'] = array_merge($entries['top'], $additionalEntries['top']);
590
-			}
591
-		}
592
-
593
-		return $entries;
594
-	}
595
-
596
-	/**
597
-	 * @param string $filterValue
598
-	 * @return boolean
599
-	 * @deprecated 11.0.0 - Use getFilterById() instead
600
-	 */
601
-	public function isFilterValid($filterValue) {
602
-		if (isset($this->validFilters[$filterValue])) {
603
-			return $this->validFilters[$filterValue];
604
-		}
605
-
606
-		foreach ($this->getExtensions() as $c) {
607
-			if ($c->isFilterValid($filterValue) === true) {
608
-				$this->validFilters[$filterValue] = true;
609
-				return true;
610
-			}
611
-		}
612
-
613
-		$this->validFilters[$filterValue] = false;
614
-		return false;
615
-	}
616
-
617
-	/**
618
-	 * @param array $types
619
-	 * @param string $filter
620
-	 * @return array
621
-	 * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead
622
-	 */
623
-	public function filterNotificationTypes($types, $filter) {
624
-		if (!$this->isFilterValid($filter)) {
625
-			return $types;
626
-		}
627
-
628
-		foreach ($this->getExtensions() as $c) {
629
-			$result = $c->filterNotificationTypes($types, $filter);
630
-			if (is_array($result)) {
631
-				$types = $result;
632
-			}
633
-		}
634
-		return $types;
635
-	}
636
-
637
-	/**
638
-	 * @param string $filter
639
-	 * @return array
640
-	 * @deprecated 11.0.0 - Use getFilterById() instead
641
-	 */
642
-	public function getQueryForFilter($filter) {
643
-		if (!$this->isFilterValid($filter)) {
644
-			return [null, null];
645
-		}
646
-
647
-		$conditions = array();
648
-		$parameters = array();
649
-
650
-		foreach ($this->getExtensions() as $c) {
651
-			$result = $c->getQueryForFilter($filter);
652
-			if (is_array($result)) {
653
-				list($condition, $parameter) = $result;
654
-				if ($condition && is_array($parameter)) {
655
-					$conditions[] = $condition;
656
-					$parameters = array_merge($parameters, $parameter);
657
-				}
658
-			}
659
-		}
660
-
661
-		if (empty($conditions)) {
662
-			return array(null, null);
663
-		}
664
-
665
-		return array(' and ((' . implode(') or (', $conditions) . '))', $parameters);
666
-	}
667
-
668
-	/**
669
-	 * Will return additional notification types as specified by other apps
670
-	 *
671
-	 * @param string $languageCode
672
-	 * @return array
673
-	 * @deprecated 11.0.0 - Use getSettings() instead
674
-	 */
675
-	public function getNotificationTypes($languageCode) {
676
-		$notificationTypes = $sharingNotificationTypes = [];
677
-		foreach ($this->getExtensions() as $c) {
678
-			$result = $c->getNotificationTypes($languageCode);
679
-			if (is_array($result)) {
680
-				$notificationTypes = array_merge($notificationTypes, $result);
681
-			}
682
-		}
683
-
684
-		return array_merge($sharingNotificationTypes, $notificationTypes);
685
-	}
686
-
687
-	/**
688
-	 * @param string $method
689
-	 * @return array
690
-	 * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead
691
-	 */
692
-	public function getDefaultTypes($method) {
693
-		$defaultTypes = array();
694
-		foreach ($this->getExtensions() as $c) {
695
-			$types = $c->getDefaultTypes($method);
696
-			if (is_array($types)) {
697
-				$defaultTypes = array_merge($types, $defaultTypes);
698
-			}
699
-		}
700
-		return $defaultTypes;
701
-	}
43
+    /** @var IRequest */
44
+    protected $request;
45
+
46
+    /** @var IUserSession */
47
+    protected $session;
48
+
49
+    /** @var IConfig */
50
+    protected $config;
51
+
52
+    /** @var IValidator */
53
+    protected $validator;
54
+
55
+    /** @var string */
56
+    protected $formattingObjectType;
57
+
58
+    /** @var int */
59
+    protected $formattingObjectId;
60
+
61
+    /** @var bool */
62
+    protected $requirePNG;
63
+
64
+    /** @var string */
65
+    protected $currentUserId;
66
+
67
+    /**
68
+     * constructor of the controller
69
+     *
70
+     * @param IRequest $request
71
+     * @param IUserSession $session
72
+     * @param IConfig $config
73
+     * @param IValidator $validator
74
+     */
75
+    public function __construct(IRequest $request,
76
+                                IUserSession $session,
77
+                                IConfig $config,
78
+                                IValidator $validator) {
79
+        $this->request = $request;
80
+        $this->session = $session;
81
+        $this->config = $config;
82
+        $this->validator = $validator;
83
+    }
84
+
85
+    /** @var \Closure[] */
86
+    private $consumersClosures = array();
87
+
88
+    /** @var IConsumer[] */
89
+    private $consumers = array();
90
+
91
+    /** @var \Closure[] */
92
+    private $extensionsClosures = array();
93
+
94
+    /** @var IExtension[] */
95
+    private $extensions = array();
96
+
97
+    /** @var array list of filters "name" => "is valid" */
98
+    protected $validFilters = array(
99
+        'all'	=> true,
100
+        'by'	=> true,
101
+        'self'	=> true,
102
+    );
103
+
104
+    /** @var array list of type icons "type" => "css class" */
105
+    protected $typeIcons = array();
106
+
107
+    /** @var array list of special parameters "app" => ["text" => ["parameter" => "type"]] */
108
+    protected $specialParameters = array();
109
+
110
+    /**
111
+     * @return \OCP\Activity\IConsumer[]
112
+     */
113
+    protected function getConsumers() {
114
+        if (!empty($this->consumers)) {
115
+            return $this->consumers;
116
+        }
117
+
118
+        $this->consumers = [];
119
+        foreach($this->consumersClosures as $consumer) {
120
+            $c = $consumer();
121
+            if ($c instanceof IConsumer) {
122
+                $this->consumers[] = $c;
123
+            } else {
124
+                throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface');
125
+            }
126
+        }
127
+
128
+        return $this->consumers;
129
+    }
130
+
131
+    /**
132
+     * @return \OCP\Activity\IExtension[]
133
+     */
134
+    protected function getExtensions() {
135
+        if (!empty($this->extensions)) {
136
+            return $this->extensions;
137
+        }
138
+
139
+        $this->extensions = [];
140
+        foreach($this->extensionsClosures as $extension) {
141
+            $e = $extension();
142
+            if ($e instanceof IExtension) {
143
+                $this->extensions[] = $e;
144
+            } else {
145
+                throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface');
146
+            }
147
+        }
148
+
149
+        return $this->extensions;
150
+    }
151
+
152
+    /**
153
+     * Generates a new IEvent object
154
+     *
155
+     * Make sure to call at least the following methods before sending it to the
156
+     * app with via the publish() method:
157
+     *  - setApp()
158
+     *  - setType()
159
+     *  - setAffectedUser()
160
+     *  - setSubject()
161
+     *
162
+     * @return IEvent
163
+     */
164
+    public function generateEvent() {
165
+        return new Event($this->validator);
166
+    }
167
+
168
+    /**
169
+     * Publish an event to the activity consumers
170
+     *
171
+     * Make sure to call at least the following methods before sending an Event:
172
+     *  - setApp()
173
+     *  - setType()
174
+     *  - setAffectedUser()
175
+     *  - setSubject()
176
+     *
177
+     * @param IEvent $event
178
+     * @throws \BadMethodCallException if required values have not been set
179
+     */
180
+    public function publish(IEvent $event) {
181
+        if ($event->getAuthor() === '') {
182
+            if ($this->session->getUser() instanceof IUser) {
183
+                $event->setAuthor($this->session->getUser()->getUID());
184
+            }
185
+        }
186
+
187
+        if (!$event->getTimestamp()) {
188
+            $event->setTimestamp(time());
189
+        }
190
+
191
+        if (!$event->isValid()) {
192
+            throw new \BadMethodCallException('The given event is invalid');
193
+        }
194
+
195
+        foreach ($this->getConsumers() as $c) {
196
+            $c->receive($event);
197
+        }
198
+    }
199
+
200
+    /**
201
+     * In order to improve lazy loading a closure can be registered which will be called in case
202
+     * activity consumers are actually requested
203
+     *
204
+     * $callable has to return an instance of OCA\Activity\IConsumer
205
+     *
206
+     * @param \Closure $callable
207
+     */
208
+    public function registerConsumer(\Closure $callable) {
209
+        $this->consumersClosures[] = $callable;
210
+        $this->consumers = [];
211
+    }
212
+
213
+    /**
214
+     * In order to improve lazy loading a closure can be registered which will be called in case
215
+     * activity consumers are actually requested
216
+     *
217
+     * $callable has to return an instance of OCA\Activity\IExtension
218
+     *
219
+     * @param \Closure $callable
220
+     */
221
+    public function registerExtension(\Closure $callable) {
222
+        $this->extensionsClosures[] = $callable;
223
+        $this->extensions = [];
224
+    }
225
+
226
+    /** @var string[] */
227
+    protected $filterClasses = [];
228
+
229
+    /** @var IFilter[] */
230
+    protected $filters = [];
231
+
232
+    /** @var bool */
233
+    protected $loadedLegacyFilters = false;
234
+
235
+    /**
236
+     * @param string $filter Class must implement OCA\Activity\IFilter
237
+     * @return void
238
+     */
239
+    public function registerFilter($filter) {
240
+        $this->filterClasses[$filter] = false;
241
+    }
242
+
243
+    /**
244
+     * @return IFilter[]
245
+     * @throws \InvalidArgumentException
246
+     */
247
+    public function getFilters() {
248
+        if (!$this->loadedLegacyFilters) {
249
+            $legacyFilters = $this->getNavigation();
250
+
251
+            foreach ($legacyFilters['top'] as $filter => $data) {
252
+                $this->filters[$filter] = new LegacyFilter(
253
+                    $this, $filter, $data['name'], true
254
+                );
255
+            }
256
+
257
+            foreach ($legacyFilters['apps'] as $filter => $data) {
258
+                $this->filters[$filter] = new LegacyFilter(
259
+                    $this, $filter, $data['name'], false
260
+                );
261
+            }
262
+            $this->loadedLegacyFilters = true;
263
+        }
264
+
265
+        foreach ($this->filterClasses as $class => $false) {
266
+            /** @var IFilter $filter */
267
+            $filter = \OC::$server->query($class);
268
+
269
+            if (!$filter instanceof IFilter) {
270
+                throw new \InvalidArgumentException('Invalid activity filter registered');
271
+            }
272
+
273
+            $this->filters[$filter->getIdentifier()] = $filter;
274
+
275
+            unset($this->filterClasses[$class]);
276
+        }
277
+        return $this->filters;
278
+    }
279
+
280
+    /**
281
+     * @param string $id
282
+     * @return IFilter
283
+     * @throws \InvalidArgumentException when the filter was not found
284
+     * @since 11.0.0
285
+     */
286
+    public function getFilterById($id) {
287
+        $filters = $this->getFilters();
288
+
289
+        if (isset($filters[$id])) {
290
+            return $filters[$id];
291
+        }
292
+
293
+        throw new \InvalidArgumentException('Requested filter does not exist');
294
+    }
295
+
296
+    /** @var string[] */
297
+    protected $providerClasses = [];
298
+
299
+    /** @var IProvider[] */
300
+    protected $providers = [];
301
+
302
+    /**
303
+     * @param string $provider Class must implement OCA\Activity\IProvider
304
+     * @return void
305
+     */
306
+    public function registerProvider($provider) {
307
+        $this->providerClasses[$provider] = false;
308
+    }
309
+
310
+    /**
311
+     * @return IProvider[]
312
+     * @throws \InvalidArgumentException
313
+     */
314
+    public function getProviders() {
315
+        foreach ($this->providerClasses as $class => $false) {
316
+            /** @var IProvider $provider */
317
+            $provider = \OC::$server->query($class);
318
+
319
+            if (!$provider instanceof IProvider) {
320
+                throw new \InvalidArgumentException('Invalid activity provider registered');
321
+            }
322
+
323
+            $this->providers[] = $provider;
324
+
325
+            unset($this->providerClasses[$class]);
326
+        }
327
+        return $this->providers;
328
+    }
329
+
330
+    /** @var string[] */
331
+    protected $settingsClasses = [];
332
+
333
+    /** @var ISetting[] */
334
+    protected $settings = [];
335
+
336
+    /** @var bool */
337
+    protected $loadedLegacyTypes = false;
338
+
339
+    /**
340
+     * @param string $setting Class must implement OCA\Activity\ISetting
341
+     * @return void
342
+     */
343
+    public function registerSetting($setting) {
344
+        $this->settingsClasses[$setting] = false;
345
+    }
346
+
347
+    /**
348
+     * @return ISetting[]
349
+     * @throws \InvalidArgumentException
350
+     */
351
+    public function getSettings() {
352
+        if (!$this->loadedLegacyTypes) {
353
+            $l = \OC::$server->getL10N('core');
354
+            $legacyTypes = $this->getNotificationTypes($l->getLanguageCode());
355
+            $streamTypes = $this->getDefaultTypes(IExtension::METHOD_STREAM);
356
+            $mailTypes = $this->getDefaultTypes(IExtension::METHOD_MAIL);
357
+            foreach ($legacyTypes as $type => $data) {
358
+                if (is_string($data)) {
359
+                    $desc = $data;
360
+                    $canChangeStream = true;
361
+                    $canChangeMail = true;
362
+                } else {
363
+                    $desc = $data['desc'];
364
+                    $canChangeStream = in_array(IExtension::METHOD_STREAM, $data['methods']);
365
+                    $canChangeMail = in_array(IExtension::METHOD_MAIL, $data['methods']);
366
+                }
367
+
368
+                $this->settings[$type] = new LegacySetting(
369
+                    $type, $desc,
370
+                    $canChangeStream, in_array($type, $streamTypes),
371
+                    $canChangeMail, in_array($type, $mailTypes)
372
+                );
373
+            }
374
+            $this->loadedLegacyTypes = true;
375
+        }
376
+
377
+        foreach ($this->settingsClasses as $class => $false) {
378
+            /** @var ISetting $setting */
379
+            $setting = \OC::$server->query($class);
380
+
381
+            if (!$setting instanceof ISetting) {
382
+                throw new \InvalidArgumentException('Invalid activity filter registered');
383
+            }
384
+
385
+            $this->settings[$setting->getIdentifier()] = $setting;
386
+
387
+            unset($this->settingsClasses[$class]);
388
+        }
389
+        return $this->settings;
390
+    }
391
+
392
+    /**
393
+     * @param string $id
394
+     * @return ISetting
395
+     * @throws \InvalidArgumentException when the setting was not found
396
+     * @since 11.0.0
397
+     */
398
+    public function getSettingById($id) {
399
+        $settings = $this->getSettings();
400
+
401
+        if (isset($settings[$id])) {
402
+            return $settings[$id];
403
+        }
404
+
405
+        throw new \InvalidArgumentException('Requested setting does not exist');
406
+    }
407
+
408
+    /**
409
+     * @param string $type
410
+     * @return string
411
+     */
412
+    public function getTypeIcon($type) {
413
+        if (isset($this->typeIcons[$type])) {
414
+            return $this->typeIcons[$type];
415
+        }
416
+
417
+        foreach ($this->getExtensions() as $c) {
418
+            $icon = $c->getTypeIcon($type);
419
+            if (is_string($icon)) {
420
+                $this->typeIcons[$type] = $icon;
421
+                return $icon;
422
+            }
423
+        }
424
+
425
+        $this->typeIcons[$type] = '';
426
+        return '';
427
+    }
428
+
429
+    /**
430
+     * @param string $type
431
+     * @param string $id
432
+     */
433
+    public function setFormattingObject($type, $id) {
434
+        $this->formattingObjectType = $type;
435
+        $this->formattingObjectId = (string) $id;
436
+    }
437
+
438
+    /**
439
+     * @return bool
440
+     */
441
+    public function isFormattingFilteredObject() {
442
+        return $this->formattingObjectType !== null && $this->formattingObjectId !== null
443
+            && $this->formattingObjectType === $this->request->getParam('object_type')
444
+            && $this->formattingObjectId === $this->request->getParam('object_id');
445
+    }
446
+
447
+    /**
448
+     * @param bool $status Set to true, when parsing events should not use SVG icons
449
+     */
450
+    public function setRequirePNG($status) {
451
+        $this->requirePNG = $status;
452
+    }
453
+
454
+    /**
455
+     * @return bool
456
+     */
457
+    public function getRequirePNG() {
458
+        return $this->requirePNG;
459
+    }
460
+
461
+    /**
462
+     * @param string $app
463
+     * @param string $text
464
+     * @param array $params
465
+     * @param boolean $stripPath
466
+     * @param boolean $highlightParams
467
+     * @param string $languageCode
468
+     * @return string|false
469
+     */
470
+    public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
471
+        foreach ($this->getExtensions() as $c) {
472
+            $translation = $c->translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
473
+            if (is_string($translation)) {
474
+                return $translation;
475
+            }
476
+        }
477
+
478
+        return false;
479
+    }
480
+
481
+    /**
482
+     * @param string $app
483
+     * @param string $text
484
+     * @return array|false
485
+     */
486
+    public function getSpecialParameterList($app, $text) {
487
+        if (isset($this->specialParameters[$app][$text])) {
488
+            return $this->specialParameters[$app][$text];
489
+        }
490
+
491
+        if (!isset($this->specialParameters[$app])) {
492
+            $this->specialParameters[$app] = array();
493
+        }
494
+
495
+        foreach ($this->getExtensions() as $c) {
496
+            $specialParameter = $c->getSpecialParameterList($app, $text);
497
+            if (is_array($specialParameter)) {
498
+                $this->specialParameters[$app][$text] = $specialParameter;
499
+                return $specialParameter;
500
+            }
501
+        }
502
+
503
+        $this->specialParameters[$app][$text] = false;
504
+        return false;
505
+    }
506
+
507
+    /**
508
+     * @param array $activity
509
+     * @return integer|false
510
+     */
511
+    public function getGroupParameter($activity) {
512
+        foreach ($this->getExtensions() as $c) {
513
+            $parameter = $c->getGroupParameter($activity);
514
+            if ($parameter !== false) {
515
+                return $parameter;
516
+            }
517
+        }
518
+
519
+        return false;
520
+    }
521
+
522
+    /**
523
+     * Set the user we need to use
524
+     *
525
+     * @param string|null $currentUserId
526
+     * @throws \UnexpectedValueException If the user is invalid
527
+     */
528
+    public function setCurrentUserId($currentUserId) {
529
+        if (!is_string($currentUserId) && $currentUserId !== null) {
530
+            throw new \UnexpectedValueException('The given current user is invalid');
531
+        }
532
+        $this->currentUserId = $currentUserId;
533
+    }
534
+
535
+    /**
536
+     * Get the user we need to use
537
+     *
538
+     * Either the user is logged in, or we try to get it from the token
539
+     *
540
+     * @return string
541
+     * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
542
+     */
543
+    public function getCurrentUserId() {
544
+        if ($this->currentUserId !== null) {
545
+            return $this->currentUserId;
546
+        } else if (!$this->session->isLoggedIn()) {
547
+            return $this->getUserFromToken();
548
+        } else {
549
+            return $this->session->getUser()->getUID();
550
+        }
551
+    }
552
+
553
+    /**
554
+     * Get the user for the token
555
+     *
556
+     * @return string
557
+     * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
558
+     */
559
+    protected function getUserFromToken() {
560
+        $token = (string) $this->request->getParam('token', '');
561
+        if (strlen($token) !== 30) {
562
+            throw new \UnexpectedValueException('The token is invalid');
563
+        }
564
+
565
+        $users = $this->config->getUsersForUserValue('activity', 'rsstoken', $token);
566
+
567
+        if (count($users) !== 1) {
568
+            // No unique user found
569
+            throw new \UnexpectedValueException('The token is invalid');
570
+        }
571
+
572
+        // Token found login as that user
573
+        return array_shift($users);
574
+    }
575
+
576
+    /**
577
+     * @return array
578
+     * @deprecated 11.0.0 - Use getFilters() instead
579
+     */
580
+    public function getNavigation() {
581
+        $entries = array(
582
+            'apps' => array(),
583
+            'top' => array(),
584
+        );
585
+        foreach ($this->getExtensions() as $c) {
586
+            $additionalEntries = $c->getNavigation();
587
+            if (is_array($additionalEntries)) {
588
+                $entries['apps'] = array_merge($entries['apps'], $additionalEntries['apps']);
589
+                $entries['top'] = array_merge($entries['top'], $additionalEntries['top']);
590
+            }
591
+        }
592
+
593
+        return $entries;
594
+    }
595
+
596
+    /**
597
+     * @param string $filterValue
598
+     * @return boolean
599
+     * @deprecated 11.0.0 - Use getFilterById() instead
600
+     */
601
+    public function isFilterValid($filterValue) {
602
+        if (isset($this->validFilters[$filterValue])) {
603
+            return $this->validFilters[$filterValue];
604
+        }
605
+
606
+        foreach ($this->getExtensions() as $c) {
607
+            if ($c->isFilterValid($filterValue) === true) {
608
+                $this->validFilters[$filterValue] = true;
609
+                return true;
610
+            }
611
+        }
612
+
613
+        $this->validFilters[$filterValue] = false;
614
+        return false;
615
+    }
616
+
617
+    /**
618
+     * @param array $types
619
+     * @param string $filter
620
+     * @return array
621
+     * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead
622
+     */
623
+    public function filterNotificationTypes($types, $filter) {
624
+        if (!$this->isFilterValid($filter)) {
625
+            return $types;
626
+        }
627
+
628
+        foreach ($this->getExtensions() as $c) {
629
+            $result = $c->filterNotificationTypes($types, $filter);
630
+            if (is_array($result)) {
631
+                $types = $result;
632
+            }
633
+        }
634
+        return $types;
635
+    }
636
+
637
+    /**
638
+     * @param string $filter
639
+     * @return array
640
+     * @deprecated 11.0.0 - Use getFilterById() instead
641
+     */
642
+    public function getQueryForFilter($filter) {
643
+        if (!$this->isFilterValid($filter)) {
644
+            return [null, null];
645
+        }
646
+
647
+        $conditions = array();
648
+        $parameters = array();
649
+
650
+        foreach ($this->getExtensions() as $c) {
651
+            $result = $c->getQueryForFilter($filter);
652
+            if (is_array($result)) {
653
+                list($condition, $parameter) = $result;
654
+                if ($condition && is_array($parameter)) {
655
+                    $conditions[] = $condition;
656
+                    $parameters = array_merge($parameters, $parameter);
657
+                }
658
+            }
659
+        }
660
+
661
+        if (empty($conditions)) {
662
+            return array(null, null);
663
+        }
664
+
665
+        return array(' and ((' . implode(') or (', $conditions) . '))', $parameters);
666
+    }
667
+
668
+    /**
669
+     * Will return additional notification types as specified by other apps
670
+     *
671
+     * @param string $languageCode
672
+     * @return array
673
+     * @deprecated 11.0.0 - Use getSettings() instead
674
+     */
675
+    public function getNotificationTypes($languageCode) {
676
+        $notificationTypes = $sharingNotificationTypes = [];
677
+        foreach ($this->getExtensions() as $c) {
678
+            $result = $c->getNotificationTypes($languageCode);
679
+            if (is_array($result)) {
680
+                $notificationTypes = array_merge($notificationTypes, $result);
681
+            }
682
+        }
683
+
684
+        return array_merge($sharingNotificationTypes, $notificationTypes);
685
+    }
686
+
687
+    /**
688
+     * @param string $method
689
+     * @return array
690
+     * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead
691
+     */
692
+    public function getDefaultTypes($method) {
693
+        $defaultTypes = array();
694
+        foreach ($this->getExtensions() as $c) {
695
+            $types = $c->getDefaultTypes($method);
696
+            if (is_array($types)) {
697
+                $defaultTypes = array_merge($types, $defaultTypes);
698
+            }
699
+        }
700
+        return $defaultTypes;
701
+    }
702 702
 }
Please login to merge, or discard this patch.
lib/public/Activity/IManager.php 1 patch
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -40,246 +40,246 @@
 block discarded – undo
40 40
  * @since 6.0.0
41 41
  */
42 42
 interface IManager {
43
-	/**
44
-	 * Generates a new IEvent object
45
-	 *
46
-	 * Make sure to call at least the following methods before sending it to the
47
-	 * app with via the publish() method:
48
-	 *  - setApp()
49
-	 *  - setType()
50
-	 *  - setAffectedUser()
51
-	 *  - setSubject()
52
-	 *
53
-	 * @return IEvent
54
-	 * @since 8.2.0
55
-	 */
56
-	public function generateEvent();
43
+    /**
44
+     * Generates a new IEvent object
45
+     *
46
+     * Make sure to call at least the following methods before sending it to the
47
+     * app with via the publish() method:
48
+     *  - setApp()
49
+     *  - setType()
50
+     *  - setAffectedUser()
51
+     *  - setSubject()
52
+     *
53
+     * @return IEvent
54
+     * @since 8.2.0
55
+     */
56
+    public function generateEvent();
57 57
 
58
-	/**
59
-	 * Publish an event to the activity consumers
60
-	 *
61
-	 * Make sure to call at least the following methods before sending an Event:
62
-	 *  - setApp()
63
-	 *  - setType()
64
-	 *  - setAffectedUser()
65
-	 *  - setSubject()
66
-	 *
67
-	 * @param IEvent $event
68
-	 * @throws \BadMethodCallException if required values have not been set
69
-	 * @since 8.2.0
70
-	 */
71
-	public function publish(IEvent $event);
58
+    /**
59
+     * Publish an event to the activity consumers
60
+     *
61
+     * Make sure to call at least the following methods before sending an Event:
62
+     *  - setApp()
63
+     *  - setType()
64
+     *  - setAffectedUser()
65
+     *  - setSubject()
66
+     *
67
+     * @param IEvent $event
68
+     * @throws \BadMethodCallException if required values have not been set
69
+     * @since 8.2.0
70
+     */
71
+    public function publish(IEvent $event);
72 72
 
73
-	/**
74
-	 * In order to improve lazy loading a closure can be registered which will be called in case
75
-	 * activity consumers are actually requested
76
-	 *
77
-	 * $callable has to return an instance of \OCP\Activity\IConsumer
78
-	 *
79
-	 * @param \Closure $callable
80
-	 * @return void
81
-	 * @since 6.0.0
82
-	 */
83
-	public function registerConsumer(\Closure $callable);
73
+    /**
74
+     * In order to improve lazy loading a closure can be registered which will be called in case
75
+     * activity consumers are actually requested
76
+     *
77
+     * $callable has to return an instance of \OCP\Activity\IConsumer
78
+     *
79
+     * @param \Closure $callable
80
+     * @return void
81
+     * @since 6.0.0
82
+     */
83
+    public function registerConsumer(\Closure $callable);
84 84
 
85
-	/**
86
-	 * In order to improve lazy loading a closure can be registered which will be called in case
87
-	 * activity consumers are actually requested
88
-	 *
89
-	 * $callable has to return an instance of \OCP\Activity\IExtension
90
-	 *
91
-	 * @param \Closure $callable
92
-	 * @return void
93
-	 * @since 8.0.0
94
-	 */
95
-	public function registerExtension(\Closure $callable);
85
+    /**
86
+     * In order to improve lazy loading a closure can be registered which will be called in case
87
+     * activity consumers are actually requested
88
+     *
89
+     * $callable has to return an instance of \OCP\Activity\IExtension
90
+     *
91
+     * @param \Closure $callable
92
+     * @return void
93
+     * @since 8.0.0
94
+     */
95
+    public function registerExtension(\Closure $callable);
96 96
 
97
-	/**
98
-	 * @param string $filter Class must implement OCA\Activity\IFilter
99
-	 * @return void
100
-	 * @since 11.0.0
101
-	 */
102
-	public function registerFilter($filter);
97
+    /**
98
+     * @param string $filter Class must implement OCA\Activity\IFilter
99
+     * @return void
100
+     * @since 11.0.0
101
+     */
102
+    public function registerFilter($filter);
103 103
 
104
-	/**
105
-	 * @return IFilter[]
106
-	 * @since 11.0.0
107
-	 */
108
-	public function getFilters();
104
+    /**
105
+     * @return IFilter[]
106
+     * @since 11.0.0
107
+     */
108
+    public function getFilters();
109 109
 
110
-	/**
111
-	 * @param string $id
112
-	 * @return IFilter
113
-	 * @throws \InvalidArgumentException when the filter was not found
114
-	 * @since 11.0.0
115
-	 */
116
-	public function getFilterById($id);
110
+    /**
111
+     * @param string $id
112
+     * @return IFilter
113
+     * @throws \InvalidArgumentException when the filter was not found
114
+     * @since 11.0.0
115
+     */
116
+    public function getFilterById($id);
117 117
 
118
-	/**
119
-	 * @param string $setting Class must implement OCA\Activity\ISetting
120
-	 * @return void
121
-	 * @since 11.0.0
122
-	 */
123
-	public function registerSetting($setting);
118
+    /**
119
+     * @param string $setting Class must implement OCA\Activity\ISetting
120
+     * @return void
121
+     * @since 11.0.0
122
+     */
123
+    public function registerSetting($setting);
124 124
 
125
-	/**
126
-	 * @return ISetting[]
127
-	 * @since 11.0.0
128
-	 */
129
-	public function getSettings();
125
+    /**
126
+     * @return ISetting[]
127
+     * @since 11.0.0
128
+     */
129
+    public function getSettings();
130 130
 
131
-	/**
132
-	 * @param string $provider Class must implement OCA\Activity\IProvider
133
-	 * @return void
134
-	 * @since 11.0.0
135
-	 */
136
-	public function registerProvider($provider);
131
+    /**
132
+     * @param string $provider Class must implement OCA\Activity\IProvider
133
+     * @return void
134
+     * @since 11.0.0
135
+     */
136
+    public function registerProvider($provider);
137 137
 
138
-	/**
139
-	 * @return IProvider[]
140
-	 * @since 11.0.0
141
-	 */
142
-	public function getProviders();
138
+    /**
139
+     * @return IProvider[]
140
+     * @since 11.0.0
141
+     */
142
+    public function getProviders();
143 143
 
144
-	/**
145
-	 * @param string $id
146
-	 * @return ISetting
147
-	 * @throws \InvalidArgumentException when the setting was not found
148
-	 * @since 11.0.0
149
-	 */
150
-	public function getSettingById($id);
144
+    /**
145
+     * @param string $id
146
+     * @return ISetting
147
+     * @throws \InvalidArgumentException when the setting was not found
148
+     * @since 11.0.0
149
+     */
150
+    public function getSettingById($id);
151 151
 
152
-	/**
153
-	 * Will return additional notification types as specified by other apps
154
-	 *
155
-	 * @param string $languageCode
156
-	 * @return array Array "stringID of the type" => "translated string description for the setting"
157
-	 * 				or Array "stringID of the type" => [
158
-	 * 					'desc' => "translated string description for the setting"
159
-	 * 					'methods' => [\OCP\Activity\IExtension::METHOD_*],
160
-	 * 				]
161
-	 * @since 8.0.0 - 8.2.0: Added support to allow limiting notifications to certain methods
162
-	 * @deprecated 11.0.0 - Use getSettings() instead
163
-	 */
164
-	public function getNotificationTypes($languageCode);
152
+    /**
153
+     * Will return additional notification types as specified by other apps
154
+     *
155
+     * @param string $languageCode
156
+     * @return array Array "stringID of the type" => "translated string description for the setting"
157
+     * 				or Array "stringID of the type" => [
158
+     * 					'desc' => "translated string description for the setting"
159
+     * 					'methods' => [\OCP\Activity\IExtension::METHOD_*],
160
+     * 				]
161
+     * @since 8.0.0 - 8.2.0: Added support to allow limiting notifications to certain methods
162
+     * @deprecated 11.0.0 - Use getSettings() instead
163
+     */
164
+    public function getNotificationTypes($languageCode);
165 165
 
166
-	/**
167
-	 * @param string $method
168
-	 * @return array
169
-	 * @since 8.0.0
170
-	 * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead
171
-	 */
172
-	public function getDefaultTypes($method);
166
+    /**
167
+     * @param string $method
168
+     * @return array
169
+     * @since 8.0.0
170
+     * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead
171
+     */
172
+    public function getDefaultTypes($method);
173 173
 
174
-	/**
175
-	 * @param string $type
176
-	 * @return string
177
-	 * @since 8.0.0
178
-	 */
179
-	public function getTypeIcon($type);
174
+    /**
175
+     * @param string $type
176
+     * @return string
177
+     * @since 8.0.0
178
+     */
179
+    public function getTypeIcon($type);
180 180
 
181
-	/**
182
-	 * @param string $type
183
-	 * @param int $id
184
-	 * @since 8.2.0
185
-	 */
186
-	public function setFormattingObject($type, $id);
181
+    /**
182
+     * @param string $type
183
+     * @param int $id
184
+     * @since 8.2.0
185
+     */
186
+    public function setFormattingObject($type, $id);
187 187
 
188
-	/**
189
-	 * @return bool
190
-	 * @since 8.2.0
191
-	 */
192
-	public function isFormattingFilteredObject();
188
+    /**
189
+     * @return bool
190
+     * @since 8.2.0
191
+     */
192
+    public function isFormattingFilteredObject();
193 193
 
194
-	/**
195
-	 * @param bool $status Set to true, when parsing events should not use SVG icons
196
-	 * @since 12.0.1
197
-	 */
198
-	public function setRequirePNG($status);
194
+    /**
195
+     * @param bool $status Set to true, when parsing events should not use SVG icons
196
+     * @since 12.0.1
197
+     */
198
+    public function setRequirePNG($status);
199 199
 
200
-	/**
201
-	 * @return bool
202
-	 * @since 12.0.1
203
-	 */
204
-	public function getRequirePNG();
200
+    /**
201
+     * @return bool
202
+     * @since 12.0.1
203
+     */
204
+    public function getRequirePNG();
205 205
 
206
-	/**
207
-	 * @param string $app
208
-	 * @param string $text
209
-	 * @param array $params
210
-	 * @param boolean $stripPath
211
-	 * @param boolean $highlightParams
212
-	 * @param string $languageCode
213
-	 * @return string|false
214
-	 * @since 8.0.0
215
-	 */
216
-	public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
206
+    /**
207
+     * @param string $app
208
+     * @param string $text
209
+     * @param array $params
210
+     * @param boolean $stripPath
211
+     * @param boolean $highlightParams
212
+     * @param string $languageCode
213
+     * @return string|false
214
+     * @since 8.0.0
215
+     */
216
+    public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
217 217
 
218
-	/**
219
-	 * @param string $app
220
-	 * @param string $text
221
-	 * @return array|false
222
-	 * @since 8.0.0
223
-	 */
224
-	public function getSpecialParameterList($app, $text);
218
+    /**
219
+     * @param string $app
220
+     * @param string $text
221
+     * @return array|false
222
+     * @since 8.0.0
223
+     */
224
+    public function getSpecialParameterList($app, $text);
225 225
 
226
-	/**
227
-	 * @param array $activity
228
-	 * @return integer|false
229
-	 * @since 8.0.0
230
-	 */
231
-	public function getGroupParameter($activity);
226
+    /**
227
+     * @param array $activity
228
+     * @return integer|false
229
+     * @since 8.0.0
230
+     */
231
+    public function getGroupParameter($activity);
232 232
 
233 233
 
234
-	/**
235
-	 * Set the user we need to use
236
-	 *
237
-	 * @param string|null $currentUserId
238
-	 * @throws \UnexpectedValueException If the user is invalid
239
-	 * @since 9.0.1
240
-	 */
241
-	public function setCurrentUserId($currentUserId);
234
+    /**
235
+     * Set the user we need to use
236
+     *
237
+     * @param string|null $currentUserId
238
+     * @throws \UnexpectedValueException If the user is invalid
239
+     * @since 9.0.1
240
+     */
241
+    public function setCurrentUserId($currentUserId);
242 242
 
243
-	/**
244
-	 * Get the user we need to use
245
-	 *
246
-	 * Either the user is logged in, or we try to get it from the token
247
-	 *
248
-	 * @return string
249
-	 * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
250
-	 * @since 8.1.0
251
-	 */
252
-	public function getCurrentUserId();
243
+    /**
244
+     * Get the user we need to use
245
+     *
246
+     * Either the user is logged in, or we try to get it from the token
247
+     *
248
+     * @return string
249
+     * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
250
+     * @since 8.1.0
251
+     */
252
+    public function getCurrentUserId();
253 253
 
254
-	/**
255
-	 * @return array
256
-	 * @since 8.0.0
257
-	 * @deprecated 11.0.0 - Use getFilters() instead
258
-	 */
259
-	public function getNavigation();
254
+    /**
255
+     * @return array
256
+     * @since 8.0.0
257
+     * @deprecated 11.0.0 - Use getFilters() instead
258
+     */
259
+    public function getNavigation();
260 260
 
261
-	/**
262
-	 * @param string $filterValue
263
-	 * @return boolean
264
-	 * @since 8.0.0
265
-	 * @deprecated 11.0.0 - Use getFilterById() instead
266
-	 */
267
-	public function isFilterValid($filterValue);
261
+    /**
262
+     * @param string $filterValue
263
+     * @return boolean
264
+     * @since 8.0.0
265
+     * @deprecated 11.0.0 - Use getFilterById() instead
266
+     */
267
+    public function isFilterValid($filterValue);
268 268
 
269
-	/**
270
-	 * @param array $types
271
-	 * @param string $filter
272
-	 * @return array
273
-	 * @since 8.0.0
274
-	 * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead
275
-	 */
276
-	public function filterNotificationTypes($types, $filter);
269
+    /**
270
+     * @param array $types
271
+     * @param string $filter
272
+     * @return array
273
+     * @since 8.0.0
274
+     * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead
275
+     */
276
+    public function filterNotificationTypes($types, $filter);
277 277
 
278
-	/**
279
-	 * @param string $filter
280
-	 * @return array
281
-	 * @since 8.0.0
282
-	 * @deprecated 11.0.0 - Use getFilterById() instead
283
-	 */
284
-	public function getQueryForFilter($filter);
278
+    /**
279
+     * @param string $filter
280
+     * @return array
281
+     * @since 8.0.0
282
+     * @deprecated 11.0.0 - Use getFilterById() instead
283
+     */
284
+    public function getQueryForFilter($filter);
285 285
 }
Please login to merge, or discard this patch.