Passed
Push — master ( c449d5...4361d6 )
by Morris
24:35 queued 12:21
created
apps/dav/lib/Events/CalendarUnpublishedEvent.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -34,39 +34,39 @@
 block discarded – undo
34 34
  */
35 35
 class CalendarUnpublishedEvent extends Event {
36 36
 
37
-	/** @var int */
38
-	private $calendarId;
37
+    /** @var int */
38
+    private $calendarId;
39 39
 
40
-	/** @var array */
41
-	private $calendarData;
40
+    /** @var array */
41
+    private $calendarData;
42 42
 
43
-	/**
44
-	 * CalendarUnpublishedEvent constructor.
45
-	 *
46
-	 * @param int $calendarId
47
-	 * @param array $calendarData
48
-	 * @since 20.0.0
49
-	 */
50
-	public function __construct(int $calendarId,
51
-								array $calendarData) {
52
-		parent::__construct();
53
-		$this->calendarId = $calendarId;
54
-		$this->calendarData = $calendarData;
55
-	}
43
+    /**
44
+     * CalendarUnpublishedEvent constructor.
45
+     *
46
+     * @param int $calendarId
47
+     * @param array $calendarData
48
+     * @since 20.0.0
49
+     */
50
+    public function __construct(int $calendarId,
51
+                                array $calendarData) {
52
+        parent::__construct();
53
+        $this->calendarId = $calendarId;
54
+        $this->calendarData = $calendarData;
55
+    }
56 56
 
57
-	/**
58
-	 * @return int
59
-	 * @since 20.0.0
60
-	 */
61
-	public function getCalendarId(): int {
62
-		return $this->calendarId;
63
-	}
57
+    /**
58
+     * @return int
59
+     * @since 20.0.0
60
+     */
61
+    public function getCalendarId(): int {
62
+        return $this->calendarId;
63
+    }
64 64
 
65
-	/**
66
-	 * @return array
67
-	 * @since 20.0.0
68
-	 */
69
-	public function getCalendarData(): array {
70
-		return $this->calendarData;
71
-	}
65
+    /**
66
+     * @return array
67
+     * @since 20.0.0
68
+     */
69
+    public function getCalendarData(): array {
70
+        return $this->calendarData;
71
+    }
72 72
 }
Please login to merge, or discard this patch.
apps/dav/lib/Events/CalendarDeletedEvent.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -34,53 +34,53 @@
 block discarded – undo
34 34
  */
35 35
 class CalendarDeletedEvent extends Event {
36 36
 
37
-	/** @var int */
38
-	private $calendarId;
37
+    /** @var int */
38
+    private $calendarId;
39 39
 
40
-	/** @var array */
41
-	private $calendarData;
40
+    /** @var array */
41
+    private $calendarData;
42 42
 
43
-	/** @var array  */
44
-	private $shares;
43
+    /** @var array  */
44
+    private $shares;
45 45
 
46
-	/**
47
-	 * CalendarDeletedEvent constructor.
48
-	 *
49
-	 * @param int $calendarId
50
-	 * @param array $calendarData
51
-	 * @param array $shares
52
-	 * @since 20.0.0
53
-	 */
54
-	public function __construct(int $calendarId,
55
-								array $calendarData,
56
-								array $shares) {
57
-		parent::__construct();
58
-		$this->calendarId = $calendarId;
59
-		$this->calendarData = $calendarData;
60
-		$this->shares = $shares;
61
-	}
46
+    /**
47
+     * CalendarDeletedEvent constructor.
48
+     *
49
+     * @param int $calendarId
50
+     * @param array $calendarData
51
+     * @param array $shares
52
+     * @since 20.0.0
53
+     */
54
+    public function __construct(int $calendarId,
55
+                                array $calendarData,
56
+                                array $shares) {
57
+        parent::__construct();
58
+        $this->calendarId = $calendarId;
59
+        $this->calendarData = $calendarData;
60
+        $this->shares = $shares;
61
+    }
62 62
 
63
-	/**
64
-	 * @return int
65
-	 * @since 20.0.0
66
-	 */
67
-	public function getCalendarId(): int {
68
-		return $this->calendarId;
69
-	}
63
+    /**
64
+     * @return int
65
+     * @since 20.0.0
66
+     */
67
+    public function getCalendarId(): int {
68
+        return $this->calendarId;
69
+    }
70 70
 
71
-	/**
72
-	 * @return array
73
-	 * @since 20.0.0
74
-	 */
75
-	public function getCalendarData(): array {
76
-		return $this->calendarData;
77
-	}
71
+    /**
72
+     * @return array
73
+     * @since 20.0.0
74
+     */
75
+    public function getCalendarData(): array {
76
+        return $this->calendarData;
77
+    }
78 78
 
79
-	/**
80
-	 * @return array
81
-	 * @since 20.0.0
82
-	 */
83
-	public function getShares(): array {
84
-		return $this->shares;
85
-	}
79
+    /**
80
+     * @return array
81
+     * @since 20.0.0
82
+     */
83
+    public function getShares(): array {
84
+        return $this->shares;
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/CalDavBackend.php 2 patches
Indentation   +2712 added lines, -2712 removed lines patch added patch discarded remove patch
@@ -93,2716 +93,2716 @@
 block discarded – undo
93 93
  * @package OCA\DAV\CalDAV
94 94
  */
95 95
 class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport {
96
-	public const CALENDAR_TYPE_CALENDAR = 0;
97
-	public const CALENDAR_TYPE_SUBSCRIPTION = 1;
98
-
99
-	public const PERSONAL_CALENDAR_URI = 'personal';
100
-	public const PERSONAL_CALENDAR_NAME = 'Personal';
101
-
102
-	public const RESOURCE_BOOKING_CALENDAR_URI = 'calendar';
103
-	public const RESOURCE_BOOKING_CALENDAR_NAME = 'Calendar';
104
-
105
-	/**
106
-	 * We need to specify a max date, because we need to stop *somewhere*
107
-	 *
108
-	 * On 32 bit system the maximum for a signed integer is 2147483647, so
109
-	 * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results
110
-	 * in 2038-01-19 to avoid problems when the date is converted
111
-	 * to a unix timestamp.
112
-	 */
113
-	public const MAX_DATE = '2038-01-01';
114
-
115
-	public const ACCESS_PUBLIC = 4;
116
-	public const CLASSIFICATION_PUBLIC = 0;
117
-	public const CLASSIFICATION_PRIVATE = 1;
118
-	public const CLASSIFICATION_CONFIDENTIAL = 2;
119
-
120
-	/**
121
-	 * List of CalDAV properties, and how they map to database field names
122
-	 * Add your own properties by simply adding on to this array.
123
-	 *
124
-	 * Note that only string-based properties are supported here.
125
-	 *
126
-	 * @var array
127
-	 */
128
-	public $propertyMap = [
129
-		'{DAV:}displayname'                          => 'displayname',
130
-		'{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description',
131
-		'{urn:ietf:params:xml:ns:caldav}calendar-timezone'    => 'timezone',
132
-		'{http://apple.com/ns/ical/}calendar-order'  => 'calendarorder',
133
-		'{http://apple.com/ns/ical/}calendar-color'  => 'calendarcolor',
134
-	];
135
-
136
-	/**
137
-	 * List of subscription properties, and how they map to database field names.
138
-	 *
139
-	 * @var array
140
-	 */
141
-	public $subscriptionPropertyMap = [
142
-		'{DAV:}displayname'                                           => 'displayname',
143
-		'{http://apple.com/ns/ical/}refreshrate'                      => 'refreshrate',
144
-		'{http://apple.com/ns/ical/}calendar-order'                   => 'calendarorder',
145
-		'{http://apple.com/ns/ical/}calendar-color'                   => 'calendarcolor',
146
-		'{http://calendarserver.org/ns/}subscribed-strip-todos'       => 'striptodos',
147
-		'{http://calendarserver.org/ns/}subscribed-strip-alarms'      => 'stripalarms',
148
-		'{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments',
149
-	];
150
-
151
-	/** @var array properties to index */
152
-	public static $indexProperties = ['CATEGORIES', 'COMMENT', 'DESCRIPTION',
153
-		'LOCATION', 'RESOURCES', 'STATUS', 'SUMMARY', 'ATTENDEE', 'CONTACT',
154
-		'ORGANIZER'];
155
-
156
-	/** @var array parameters to index */
157
-	public static $indexParameters = [
158
-		'ATTENDEE' => ['CN'],
159
-		'ORGANIZER' => ['CN'],
160
-	];
161
-
162
-	/**
163
-	 * @var string[] Map of uid => display name
164
-	 */
165
-	protected $userDisplayNames;
166
-
167
-	/** @var IDBConnection */
168
-	private $db;
169
-
170
-	/** @var Backend */
171
-	private $calendarSharingBackend;
172
-
173
-	/** @var Principal */
174
-	private $principalBackend;
175
-
176
-	/** @var IUserManager */
177
-	private $userManager;
178
-
179
-	/** @var ISecureRandom */
180
-	private $random;
181
-
182
-	/** @var ILogger */
183
-	private $logger;
184
-
185
-	/** @var IEventDispatcher */
186
-	private $dispatcher;
187
-
188
-	/** @var EventDispatcherInterface */
189
-	private $legacyDispatcher;
190
-
191
-	/** @var bool */
192
-	private $legacyEndpoint;
193
-
194
-	/** @var string */
195
-	private $dbObjectPropertiesTable = 'calendarobjects_props';
196
-
197
-	/**
198
-	 * CalDavBackend constructor.
199
-	 *
200
-	 * @param IDBConnection $db
201
-	 * @param Principal $principalBackend
202
-	 * @param IUserManager $userManager
203
-	 * @param IGroupManager $groupManager
204
-	 * @param ISecureRandom $random
205
-	 * @param ILogger $logger
206
-	 * @param IEventDispatcher $dispatcher
207
-	 * @param EventDispatcherInterface $legacyDispatcher
208
-	 * @param bool $legacyEndpoint
209
-	 */
210
-	public function __construct(IDBConnection $db,
211
-								Principal $principalBackend,
212
-								IUserManager $userManager,
213
-								IGroupManager $groupManager,
214
-								ISecureRandom $random,
215
-								ILogger $logger,
216
-								IEventDispatcher $dispatcher,
217
-								EventDispatcherInterface $legacyDispatcher,
218
-								bool $legacyEndpoint = false) {
219
-		$this->db = $db;
220
-		$this->principalBackend = $principalBackend;
221
-		$this->userManager = $userManager;
222
-		$this->calendarSharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'calendar');
223
-		$this->random = $random;
224
-		$this->logger = $logger;
225
-		$this->dispatcher = $dispatcher;
226
-		$this->legacyDispatcher = $legacyDispatcher;
227
-		$this->legacyEndpoint = $legacyEndpoint;
228
-	}
229
-
230
-	/**
231
-	 * Return the number of calendars for a principal
232
-	 *
233
-	 * By default this excludes the automatically generated birthday calendar
234
-	 *
235
-	 * @param $principalUri
236
-	 * @param bool $excludeBirthday
237
-	 * @return int
238
-	 */
239
-	public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) {
240
-		$principalUri = $this->convertPrincipal($principalUri, true);
241
-		$query = $this->db->getQueryBuilder();
242
-		$query->select($query->func()->count('*'))
243
-			->from('calendars')
244
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
245
-
246
-		if ($excludeBirthday) {
247
-			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
248
-		}
249
-
250
-		return (int)$query->execute()->fetchColumn();
251
-	}
252
-
253
-	/**
254
-	 * Returns a list of calendars for a principal.
255
-	 *
256
-	 * Every project is an array with the following keys:
257
-	 *  * id, a unique id that will be used by other functions to modify the
258
-	 *    calendar. This can be the same as the uri or a database key.
259
-	 *  * uri, which the basename of the uri with which the calendar is
260
-	 *    accessed.
261
-	 *  * principaluri. The owner of the calendar. Almost always the same as
262
-	 *    principalUri passed to this method.
263
-	 *
264
-	 * Furthermore it can contain webdav properties in clark notation. A very
265
-	 * common one is '{DAV:}displayname'.
266
-	 *
267
-	 * Many clients also require:
268
-	 * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
269
-	 * For this property, you can just return an instance of
270
-	 * Sabre\CalDAV\Property\SupportedCalendarComponentSet.
271
-	 *
272
-	 * If you return {http://sabredav.org/ns}read-only and set the value to 1,
273
-	 * ACL will automatically be put in read-only mode.
274
-	 *
275
-	 * @param string $principalUri
276
-	 * @return array
277
-	 */
278
-	public function getCalendarsForUser($principalUri) {
279
-		$principalUriOriginal = $principalUri;
280
-		$principalUri = $this->convertPrincipal($principalUri, true);
281
-		$fields = array_values($this->propertyMap);
282
-		$fields[] = 'id';
283
-		$fields[] = 'uri';
284
-		$fields[] = 'synctoken';
285
-		$fields[] = 'components';
286
-		$fields[] = 'principaluri';
287
-		$fields[] = 'transparent';
288
-
289
-		// Making fields a comma-delimited list
290
-		$query = $this->db->getQueryBuilder();
291
-		$query->select($fields)->from('calendars')
292
-				->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
293
-				->orderBy('calendarorder', 'ASC');
294
-		$stmt = $query->execute();
295
-
296
-		$calendars = [];
297
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
298
-			$components = [];
299
-			if ($row['components']) {
300
-				$components = explode(',',$row['components']);
301
-			}
302
-
303
-			$calendar = [
304
-				'id' => $row['id'],
305
-				'uri' => $row['uri'],
306
-				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
307
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
308
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
309
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
310
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
311
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
312
-			];
313
-
314
-			foreach ($this->propertyMap as $xmlName=>$dbName) {
315
-				$calendar[$xmlName] = $row[$dbName];
316
-			}
317
-
318
-			$this->addOwnerPrincipal($calendar);
319
-
320
-			if (!isset($calendars[$calendar['id']])) {
321
-				$calendars[$calendar['id']] = $calendar;
322
-			}
323
-		}
324
-
325
-		$stmt->closeCursor();
326
-
327
-		// query for shared calendars
328
-		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
329
-		$principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
330
-
331
-		$principals = array_map(function ($principal) {
332
-			return urldecode($principal);
333
-		}, $principals);
334
-		$principals[]= $principalUri;
335
-
336
-		$fields = array_values($this->propertyMap);
337
-		$fields[] = 'a.id';
338
-		$fields[] = 'a.uri';
339
-		$fields[] = 'a.synctoken';
340
-		$fields[] = 'a.components';
341
-		$fields[] = 'a.principaluri';
342
-		$fields[] = 'a.transparent';
343
-		$fields[] = 's.access';
344
-		$query = $this->db->getQueryBuilder();
345
-		$result = $query->select($fields)
346
-			->from('dav_shares', 's')
347
-			->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
348
-			->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
349
-			->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
350
-			->setParameter('type', 'calendar')
351
-			->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
352
-			->execute();
353
-
354
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
355
-		while ($row = $result->fetch()) {
356
-			if ($row['principaluri'] === $principalUri) {
357
-				continue;
358
-			}
359
-
360
-			$readOnly = (int) $row['access'] === Backend::ACCESS_READ;
361
-			if (isset($calendars[$row['id']])) {
362
-				if ($readOnly) {
363
-					// New share can not have more permissions then the old one.
364
-					continue;
365
-				}
366
-				if (isset($calendars[$row['id']][$readOnlyPropertyName]) &&
367
-					$calendars[$row['id']][$readOnlyPropertyName] === 0) {
368
-					// Old share is already read-write, no more permissions can be gained
369
-					continue;
370
-				}
371
-			}
372
-
373
-			list(, $name) = Uri\split($row['principaluri']);
374
-			$uri = $row['uri'] . '_shared_by_' . $name;
375
-			$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
376
-			$components = [];
377
-			if ($row['components']) {
378
-				$components = explode(',',$row['components']);
379
-			}
380
-			$calendar = [
381
-				'id' => $row['id'],
382
-				'uri' => $uri,
383
-				'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
384
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
385
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
386
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
387
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'),
388
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
389
-				$readOnlyPropertyName => $readOnly,
390
-			];
391
-
392
-			foreach ($this->propertyMap as $xmlName=>$dbName) {
393
-				$calendar[$xmlName] = $row[$dbName];
394
-			}
395
-
396
-			$this->addOwnerPrincipal($calendar);
397
-
398
-			$calendars[$calendar['id']] = $calendar;
399
-		}
400
-		$result->closeCursor();
401
-
402
-		return array_values($calendars);
403
-	}
404
-
405
-	/**
406
-	 * @param $principalUri
407
-	 * @return array
408
-	 */
409
-	public function getUsersOwnCalendars($principalUri) {
410
-		$principalUri = $this->convertPrincipal($principalUri, true);
411
-		$fields = array_values($this->propertyMap);
412
-		$fields[] = 'id';
413
-		$fields[] = 'uri';
414
-		$fields[] = 'synctoken';
415
-		$fields[] = 'components';
416
-		$fields[] = 'principaluri';
417
-		$fields[] = 'transparent';
418
-		// Making fields a comma-delimited list
419
-		$query = $this->db->getQueryBuilder();
420
-		$query->select($fields)->from('calendars')
421
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
422
-			->orderBy('calendarorder', 'ASC');
423
-		$stmt = $query->execute();
424
-		$calendars = [];
425
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
426
-			$components = [];
427
-			if ($row['components']) {
428
-				$components = explode(',',$row['components']);
429
-			}
430
-			$calendar = [
431
-				'id' => $row['id'],
432
-				'uri' => $row['uri'],
433
-				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
434
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
435
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
436
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
437
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
438
-			];
439
-			foreach ($this->propertyMap as $xmlName=>$dbName) {
440
-				$calendar[$xmlName] = $row[$dbName];
441
-			}
442
-
443
-			$this->addOwnerPrincipal($calendar);
444
-
445
-			if (!isset($calendars[$calendar['id']])) {
446
-				$calendars[$calendar['id']] = $calendar;
447
-			}
448
-		}
449
-		$stmt->closeCursor();
450
-		return array_values($calendars);
451
-	}
452
-
453
-
454
-	/**
455
-	 * @param $uid
456
-	 * @return string
457
-	 */
458
-	private function getUserDisplayName($uid) {
459
-		if (!isset($this->userDisplayNames[$uid])) {
460
-			$user = $this->userManager->get($uid);
461
-
462
-			if ($user instanceof IUser) {
463
-				$this->userDisplayNames[$uid] = $user->getDisplayName();
464
-			} else {
465
-				$this->userDisplayNames[$uid] = $uid;
466
-			}
467
-		}
468
-
469
-		return $this->userDisplayNames[$uid];
470
-	}
471
-
472
-	/**
473
-	 * @return array
474
-	 */
475
-	public function getPublicCalendars() {
476
-		$fields = array_values($this->propertyMap);
477
-		$fields[] = 'a.id';
478
-		$fields[] = 'a.uri';
479
-		$fields[] = 'a.synctoken';
480
-		$fields[] = 'a.components';
481
-		$fields[] = 'a.principaluri';
482
-		$fields[] = 'a.transparent';
483
-		$fields[] = 's.access';
484
-		$fields[] = 's.publicuri';
485
-		$calendars = [];
486
-		$query = $this->db->getQueryBuilder();
487
-		$result = $query->select($fields)
488
-			->from('dav_shares', 's')
489
-			->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
490
-			->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
491
-			->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
492
-			->execute();
493
-
494
-		while ($row = $result->fetch()) {
495
-			list(, $name) = Uri\split($row['principaluri']);
496
-			$row['displayname'] = $row['displayname'] . "($name)";
497
-			$components = [];
498
-			if ($row['components']) {
499
-				$components = explode(',',$row['components']);
500
-			}
501
-			$calendar = [
502
-				'id' => $row['id'],
503
-				'uri' => $row['publicuri'],
504
-				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
505
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
506
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
507
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
508
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
509
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
510
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
511
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
512
-			];
513
-
514
-			foreach ($this->propertyMap as $xmlName=>$dbName) {
515
-				$calendar[$xmlName] = $row[$dbName];
516
-			}
517
-
518
-			$this->addOwnerPrincipal($calendar);
519
-
520
-			if (!isset($calendars[$calendar['id']])) {
521
-				$calendars[$calendar['id']] = $calendar;
522
-			}
523
-		}
524
-		$result->closeCursor();
525
-
526
-		return array_values($calendars);
527
-	}
528
-
529
-	/**
530
-	 * @param string $uri
531
-	 * @return array
532
-	 * @throws NotFound
533
-	 */
534
-	public function getPublicCalendar($uri) {
535
-		$fields = array_values($this->propertyMap);
536
-		$fields[] = 'a.id';
537
-		$fields[] = 'a.uri';
538
-		$fields[] = 'a.synctoken';
539
-		$fields[] = 'a.components';
540
-		$fields[] = 'a.principaluri';
541
-		$fields[] = 'a.transparent';
542
-		$fields[] = 's.access';
543
-		$fields[] = 's.publicuri';
544
-		$query = $this->db->getQueryBuilder();
545
-		$result = $query->select($fields)
546
-			->from('dav_shares', 's')
547
-			->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
548
-			->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
549
-			->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
550
-			->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri)))
551
-			->execute();
552
-
553
-		$row = $result->fetch(\PDO::FETCH_ASSOC);
554
-
555
-		$result->closeCursor();
556
-
557
-		if ($row === false) {
558
-			throw new NotFound('Node with name \'' . $uri . '\' could not be found');
559
-		}
560
-
561
-		list(, $name) = Uri\split($row['principaluri']);
562
-		$row['displayname'] = $row['displayname'] . ' ' . "($name)";
563
-		$components = [];
564
-		if ($row['components']) {
565
-			$components = explode(',',$row['components']);
566
-		}
567
-		$calendar = [
568
-			'id' => $row['id'],
569
-			'uri' => $row['publicuri'],
570
-			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
571
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
572
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
573
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
574
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
575
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
576
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
577
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
578
-		];
579
-
580
-		foreach ($this->propertyMap as $xmlName=>$dbName) {
581
-			$calendar[$xmlName] = $row[$dbName];
582
-		}
583
-
584
-		$this->addOwnerPrincipal($calendar);
585
-
586
-		return $calendar;
587
-	}
588
-
589
-	/**
590
-	 * @param string $principal
591
-	 * @param string $uri
592
-	 * @return array|null
593
-	 */
594
-	public function getCalendarByUri($principal, $uri) {
595
-		$fields = array_values($this->propertyMap);
596
-		$fields[] = 'id';
597
-		$fields[] = 'uri';
598
-		$fields[] = 'synctoken';
599
-		$fields[] = 'components';
600
-		$fields[] = 'principaluri';
601
-		$fields[] = 'transparent';
602
-
603
-		// Making fields a comma-delimited list
604
-		$query = $this->db->getQueryBuilder();
605
-		$query->select($fields)->from('calendars')
606
-			->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
607
-			->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($principal)))
608
-			->setMaxResults(1);
609
-		$stmt = $query->execute();
610
-
611
-		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
612
-		$stmt->closeCursor();
613
-		if ($row === false) {
614
-			return null;
615
-		}
616
-
617
-		$components = [];
618
-		if ($row['components']) {
619
-			$components = explode(',',$row['components']);
620
-		}
621
-
622
-		$calendar = [
623
-			'id' => $row['id'],
624
-			'uri' => $row['uri'],
625
-			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
626
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
627
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
628
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
629
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
630
-		];
631
-
632
-		foreach ($this->propertyMap as $xmlName=>$dbName) {
633
-			$calendar[$xmlName] = $row[$dbName];
634
-		}
635
-
636
-		$this->addOwnerPrincipal($calendar);
637
-
638
-		return $calendar;
639
-	}
640
-
641
-	/**
642
-	 * @param $calendarId
643
-	 * @return array|null
644
-	 */
645
-	public function getCalendarById($calendarId) {
646
-		$fields = array_values($this->propertyMap);
647
-		$fields[] = 'id';
648
-		$fields[] = 'uri';
649
-		$fields[] = 'synctoken';
650
-		$fields[] = 'components';
651
-		$fields[] = 'principaluri';
652
-		$fields[] = 'transparent';
653
-
654
-		// Making fields a comma-delimited list
655
-		$query = $this->db->getQueryBuilder();
656
-		$query->select($fields)->from('calendars')
657
-			->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)))
658
-			->setMaxResults(1);
659
-		$stmt = $query->execute();
660
-
661
-		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
662
-		$stmt->closeCursor();
663
-		if ($row === false) {
664
-			return null;
665
-		}
666
-
667
-		$components = [];
668
-		if ($row['components']) {
669
-			$components = explode(',',$row['components']);
670
-		}
671
-
672
-		$calendar = [
673
-			'id' => $row['id'],
674
-			'uri' => $row['uri'],
675
-			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
676
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
677
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
678
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
679
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
680
-		];
681
-
682
-		foreach ($this->propertyMap as $xmlName=>$dbName) {
683
-			$calendar[$xmlName] = $row[$dbName];
684
-		}
685
-
686
-		$this->addOwnerPrincipal($calendar);
687
-
688
-		return $calendar;
689
-	}
690
-
691
-	/**
692
-	 * @param $subscriptionId
693
-	 */
694
-	public function getSubscriptionById($subscriptionId) {
695
-		$fields = array_values($this->subscriptionPropertyMap);
696
-		$fields[] = 'id';
697
-		$fields[] = 'uri';
698
-		$fields[] = 'source';
699
-		$fields[] = 'synctoken';
700
-		$fields[] = 'principaluri';
701
-		$fields[] = 'lastmodified';
702
-
703
-		$query = $this->db->getQueryBuilder();
704
-		$query->select($fields)
705
-			->from('calendarsubscriptions')
706
-			->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
707
-			->orderBy('calendarorder', 'asc');
708
-		$stmt =$query->execute();
709
-
710
-		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
711
-		$stmt->closeCursor();
712
-		if ($row === false) {
713
-			return null;
714
-		}
715
-
716
-		$subscription = [
717
-			'id'           => $row['id'],
718
-			'uri'          => $row['uri'],
719
-			'principaluri' => $row['principaluri'],
720
-			'source'       => $row['source'],
721
-			'lastmodified' => $row['lastmodified'],
722
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
723
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
724
-		];
725
-
726
-		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
727
-			if (!is_null($row[$dbName])) {
728
-				$subscription[$xmlName] = $row[$dbName];
729
-			}
730
-		}
731
-
732
-		return $subscription;
733
-	}
734
-
735
-	/**
736
-	 * Creates a new calendar for a principal.
737
-	 *
738
-	 * If the creation was a success, an id must be returned that can be used to reference
739
-	 * this calendar in other methods, such as updateCalendar.
740
-	 *
741
-	 * @param string $principalUri
742
-	 * @param string $calendarUri
743
-	 * @param array $properties
744
-	 * @return int
745
-	 * @suppress SqlInjectionChecker
746
-	 */
747
-	public function createCalendar($principalUri, $calendarUri, array $properties) {
748
-		$values = [
749
-			'principaluri' => $this->convertPrincipal($principalUri, true),
750
-			'uri'          => $calendarUri,
751
-			'synctoken'    => 1,
752
-			'transparent'  => 0,
753
-			'components'   => 'VEVENT,VTODO',
754
-			'displayname'  => $calendarUri
755
-		];
756
-
757
-		// Default value
758
-		$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
759
-		if (isset($properties[$sccs])) {
760
-			if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
761
-				throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
762
-			}
763
-			$values['components'] = implode(',',$properties[$sccs]->getValue());
764
-		} elseif (isset($properties['components'])) {
765
-			// Allow to provide components internally without having
766
-			// to create a SupportedCalendarComponentSet object
767
-			$values['components'] = $properties['components'];
768
-		}
769
-
770
-		$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
771
-		if (isset($properties[$transp])) {
772
-			$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
773
-		}
774
-
775
-		foreach ($this->propertyMap as $xmlName=>$dbName) {
776
-			if (isset($properties[$xmlName])) {
777
-				$values[$dbName] = $properties[$xmlName];
778
-			}
779
-		}
780
-
781
-		$query = $this->db->getQueryBuilder();
782
-		$query->insert('calendars');
783
-		foreach ($values as $column => $value) {
784
-			$query->setValue($column, $query->createNamedParameter($value));
785
-		}
786
-		$query->execute();
787
-		$calendarId = $query->getLastInsertId();
788
-
789
-		$calendarData = $this->getCalendarById($calendarId);
790
-		$this->dispatcher->dispatchTyped(new CalendarCreatedEvent((int)$calendarId, $calendarData));
791
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent(
792
-			'\OCA\DAV\CalDAV\CalDavBackend::createCalendar',
793
-			[
794
-				'calendarId' => $calendarId,
795
-				'calendarData' => $calendarData,
796
-			]));
797
-
798
-		return $calendarId;
799
-	}
800
-
801
-	/**
802
-	 * Updates properties for a calendar.
803
-	 *
804
-	 * The list of mutations is stored in a Sabre\DAV\PropPatch object.
805
-	 * To do the actual updates, you must tell this object which properties
806
-	 * you're going to process with the handle() method.
807
-	 *
808
-	 * Calling the handle method is like telling the PropPatch object "I
809
-	 * promise I can handle updating this property".
810
-	 *
811
-	 * Read the PropPatch documentation for more info and examples.
812
-	 *
813
-	 * @param mixed $calendarId
814
-	 * @param PropPatch $propPatch
815
-	 * @return void
816
-	 */
817
-	public function updateCalendar($calendarId, PropPatch $propPatch) {
818
-		$supportedProperties = array_keys($this->propertyMap);
819
-		$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
820
-
821
-		/**
822
-		 * @suppress SqlInjectionChecker
823
-		 */
824
-		$propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
825
-			$newValues = [];
826
-			foreach ($mutations as $propertyName => $propertyValue) {
827
-				switch ($propertyName) {
828
-					case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
829
-						$fieldName = 'transparent';
830
-						$newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
831
-						break;
832
-					default:
833
-						$fieldName = $this->propertyMap[$propertyName];
834
-						$newValues[$fieldName] = $propertyValue;
835
-						break;
836
-				}
837
-			}
838
-			$query = $this->db->getQueryBuilder();
839
-			$query->update('calendars');
840
-			foreach ($newValues as $fieldName => $value) {
841
-				$query->set($fieldName, $query->createNamedParameter($value));
842
-			}
843
-			$query->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
844
-			$query->execute();
845
-
846
-			$this->addChange($calendarId, "", 2);
847
-
848
-			$calendarData = $this->getCalendarById($calendarId);
849
-			$shares = $this->getShares($calendarId);
850
-			$this->dispatcher->dispatchTyped(new CalendarUpdatedEvent((int)$calendarId, $calendarData, $shares, $mutations));
851
-			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent(
852
-				'\OCA\DAV\CalDAV\CalDavBackend::updateCalendar',
853
-				[
854
-					'calendarId' => $calendarId,
855
-					'calendarData' => $calendarData,
856
-					'shares' => $shares,
857
-					'propertyMutations' => $mutations,
858
-				]));
859
-
860
-			return true;
861
-		});
862
-	}
863
-
864
-	/**
865
-	 * Delete a calendar and all it's objects
866
-	 *
867
-	 * @param mixed $calendarId
868
-	 * @return void
869
-	 */
870
-	public function deleteCalendar($calendarId) {
871
-		$calendarData = $this->getCalendarById($calendarId);
872
-		$shares = $this->getShares($calendarId);
873
-
874
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', new GenericEvent(
875
-			'\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar',
876
-			[
877
-				'calendarId' => $calendarId,
878
-				'calendarData' => $calendarData,
879
-				'shares' => $shares,
880
-			]));
881
-
882
-		$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `calendartype` = ?');
883
-		$stmt->execute([$calendarId, self::CALENDAR_TYPE_CALENDAR]);
884
-
885
-		$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendars` WHERE `id` = ?');
886
-		$stmt->execute([$calendarId]);
887
-
888
-		$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarchanges` WHERE `calendarid` = ? AND `calendartype` = ?');
889
-		$stmt->execute([$calendarId, self::CALENDAR_TYPE_CALENDAR]);
890
-
891
-		$this->calendarSharingBackend->deleteAllShares($calendarId);
892
-
893
-		$query = $this->db->getQueryBuilder();
894
-		$query->delete($this->dbObjectPropertiesTable)
895
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
896
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)))
897
-			->execute();
898
-
899
-		if ($calendarData) {
900
-			$this->dispatcher->dispatchTyped(new CalendarDeletedEvent((int)$calendarId, $calendarData, $shares));
901
-		}
902
-	}
903
-
904
-	/**
905
-	 * Delete all of an user's shares
906
-	 *
907
-	 * @param string $principaluri
908
-	 * @return void
909
-	 */
910
-	public function deleteAllSharesByUser($principaluri) {
911
-		$this->calendarSharingBackend->deleteAllSharesByUser($principaluri);
912
-	}
913
-
914
-	/**
915
-	 * Returns all calendar objects within a calendar.
916
-	 *
917
-	 * Every item contains an array with the following keys:
918
-	 *   * calendardata - The iCalendar-compatible calendar data
919
-	 *   * uri - a unique key which will be used to construct the uri. This can
920
-	 *     be any arbitrary string, but making sure it ends with '.ics' is a
921
-	 *     good idea. This is only the basename, or filename, not the full
922
-	 *     path.
923
-	 *   * lastmodified - a timestamp of the last modification time
924
-	 *   * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
925
-	 *   '"abcdef"')
926
-	 *   * size - The size of the calendar objects, in bytes.
927
-	 *   * component - optional, a string containing the type of object, such
928
-	 *     as 'vevent' or 'vtodo'. If specified, this will be used to populate
929
-	 *     the Content-Type header.
930
-	 *
931
-	 * Note that the etag is optional, but it's highly encouraged to return for
932
-	 * speed reasons.
933
-	 *
934
-	 * The calendardata is also optional. If it's not returned
935
-	 * 'getCalendarObject' will be called later, which *is* expected to return
936
-	 * calendardata.
937
-	 *
938
-	 * If neither etag or size are specified, the calendardata will be
939
-	 * used/fetched to determine these numbers. If both are specified the
940
-	 * amount of times this is needed is reduced by a great degree.
941
-	 *
942
-	 * @param mixed $calendarId
943
-	 * @param int $calendarType
944
-	 * @return array
945
-	 */
946
-	public function getCalendarObjects($calendarId, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
947
-		$query = $this->db->getQueryBuilder();
948
-		$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype', 'classification'])
949
-			->from('calendarobjects')
950
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
951
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
952
-		$stmt = $query->execute();
953
-
954
-		$result = [];
955
-		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
956
-			$result[] = [
957
-				'id'           => $row['id'],
958
-				'uri'          => $row['uri'],
959
-				'lastmodified' => $row['lastmodified'],
960
-				'etag'         => '"' . $row['etag'] . '"',
961
-				'calendarid'   => $row['calendarid'],
962
-				'size'         => (int)$row['size'],
963
-				'component'    => strtolower($row['componenttype']),
964
-				'classification'=> (int)$row['classification']
965
-			];
966
-		}
967
-
968
-		return $result;
969
-	}
970
-
971
-	/**
972
-	 * Returns information from a single calendar object, based on it's object
973
-	 * uri.
974
-	 *
975
-	 * The object uri is only the basename, or filename and not a full path.
976
-	 *
977
-	 * The returned array must have the same keys as getCalendarObjects. The
978
-	 * 'calendardata' object is required here though, while it's not required
979
-	 * for getCalendarObjects.
980
-	 *
981
-	 * This method must return null if the object did not exist.
982
-	 *
983
-	 * @param mixed $calendarId
984
-	 * @param string $objectUri
985
-	 * @param int $calendarType
986
-	 * @return array|null
987
-	 */
988
-	public function getCalendarObject($calendarId, $objectUri, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
989
-		$query = $this->db->getQueryBuilder();
990
-		$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
991
-			->from('calendarobjects')
992
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
993
-			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
994
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
995
-		$stmt = $query->execute();
996
-		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
997
-
998
-		if (!$row) {
999
-			return null;
1000
-		}
1001
-
1002
-		return [
1003
-			'id'            => $row['id'],
1004
-			'uri'           => $row['uri'],
1005
-			'lastmodified'  => $row['lastmodified'],
1006
-			'etag'          => '"' . $row['etag'] . '"',
1007
-			'calendarid'    => $row['calendarid'],
1008
-			'size'          => (int)$row['size'],
1009
-			'calendardata'  => $this->readBlob($row['calendardata']),
1010
-			'component'     => strtolower($row['componenttype']),
1011
-			'classification'=> (int)$row['classification']
1012
-		];
1013
-	}
1014
-
1015
-	/**
1016
-	 * Returns a list of calendar objects.
1017
-	 *
1018
-	 * This method should work identical to getCalendarObject, but instead
1019
-	 * return all the calendar objects in the list as an array.
1020
-	 *
1021
-	 * If the backend supports this, it may allow for some speed-ups.
1022
-	 *
1023
-	 * @param mixed $calendarId
1024
-	 * @param string[] $uris
1025
-	 * @param int $calendarType
1026
-	 * @return array
1027
-	 */
1028
-	public function getMultipleCalendarObjects($calendarId, array $uris, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
1029
-		if (empty($uris)) {
1030
-			return [];
1031
-		}
1032
-
1033
-		$chunks = array_chunk($uris, 100);
1034
-		$objects = [];
1035
-
1036
-		$query = $this->db->getQueryBuilder();
1037
-		$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
1038
-			->from('calendarobjects')
1039
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
1040
-			->andWhere($query->expr()->in('uri', $query->createParameter('uri')))
1041
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
1042
-
1043
-		foreach ($chunks as $uris) {
1044
-			$query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
1045
-			$result = $query->execute();
1046
-
1047
-			while ($row = $result->fetch()) {
1048
-				$objects[] = [
1049
-					'id'           => $row['id'],
1050
-					'uri'          => $row['uri'],
1051
-					'lastmodified' => $row['lastmodified'],
1052
-					'etag'         => '"' . $row['etag'] . '"',
1053
-					'calendarid'   => $row['calendarid'],
1054
-					'size'         => (int)$row['size'],
1055
-					'calendardata' => $this->readBlob($row['calendardata']),
1056
-					'component'    => strtolower($row['componenttype']),
1057
-					'classification' => (int)$row['classification']
1058
-				];
1059
-			}
1060
-			$result->closeCursor();
1061
-		}
1062
-
1063
-		return $objects;
1064
-	}
1065
-
1066
-	/**
1067
-	 * Creates a new calendar object.
1068
-	 *
1069
-	 * The object uri is only the basename, or filename and not a full path.
1070
-	 *
1071
-	 * It is possible return an etag from this function, which will be used in
1072
-	 * the response to this PUT request. Note that the ETag must be surrounded
1073
-	 * by double-quotes.
1074
-	 *
1075
-	 * However, you should only really return this ETag if you don't mangle the
1076
-	 * calendar-data. If the result of a subsequent GET to this object is not
1077
-	 * the exact same as this request body, you should omit the ETag.
1078
-	 *
1079
-	 * @param mixed $calendarId
1080
-	 * @param string $objectUri
1081
-	 * @param string $calendarData
1082
-	 * @param int $calendarType
1083
-	 * @return string
1084
-	 */
1085
-	public function createCalendarObject($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1086
-		$extraData = $this->getDenormalizedData($calendarData);
1087
-
1088
-		$q = $this->db->getQueryBuilder();
1089
-		$q->select($q->func()->count('*'))
1090
-			->from('calendarobjects')
1091
-			->where($q->expr()->eq('calendarid', $q->createNamedParameter($calendarId)))
1092
-			->andWhere($q->expr()->eq('uid', $q->createNamedParameter($extraData['uid'])))
1093
-			->andWhere($q->expr()->eq('calendartype', $q->createNamedParameter($calendarType)));
1094
-
1095
-		$result = $q->execute();
1096
-		$count = (int) $result->fetchColumn();
1097
-		$result->closeCursor();
1098
-
1099
-		if ($count !== 0) {
1100
-			throw new \Sabre\DAV\Exception\BadRequest('Calendar object with uid already exists in this calendar collection.');
1101
-		}
1102
-
1103
-		$query = $this->db->getQueryBuilder();
1104
-		$query->insert('calendarobjects')
1105
-			->values([
1106
-				'calendarid' => $query->createNamedParameter($calendarId),
1107
-				'uri' => $query->createNamedParameter($objectUri),
1108
-				'calendardata' => $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB),
1109
-				'lastmodified' => $query->createNamedParameter(time()),
1110
-				'etag' => $query->createNamedParameter($extraData['etag']),
1111
-				'size' => $query->createNamedParameter($extraData['size']),
1112
-				'componenttype' => $query->createNamedParameter($extraData['componentType']),
1113
-				'firstoccurence' => $query->createNamedParameter($extraData['firstOccurence']),
1114
-				'lastoccurence' => $query->createNamedParameter($extraData['lastOccurence']),
1115
-				'classification' => $query->createNamedParameter($extraData['classification']),
1116
-				'uid' => $query->createNamedParameter($extraData['uid']),
1117
-				'calendartype' => $query->createNamedParameter($calendarType),
1118
-			])
1119
-			->execute();
1120
-
1121
-		$this->updateProperties($calendarId, $objectUri, $calendarData, $calendarType);
1122
-		$this->addChange($calendarId, $objectUri, 1, $calendarType);
1123
-
1124
-		$objectRow = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1125
-		if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1126
-			$calendarRow = $this->getCalendarById($calendarId);
1127
-			$shares = $this->getShares($calendarId);
1128
-
1129
-			$this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
1130
-			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent(
1131
-				'\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject',
1132
-				[
1133
-					'calendarId' => $calendarId,
1134
-					'calendarData' => $calendarRow,
1135
-					'shares' => $shares,
1136
-					'objectData' => $objectRow,
1137
-				]
1138
-			));
1139
-		} else {
1140
-			$subscriptionRow = $this->getSubscriptionById($calendarId);
1141
-
1142
-			$this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
1143
-			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject', new GenericEvent(
1144
-				'\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject',
1145
-				[
1146
-					'subscriptionId' => $calendarId,
1147
-					'calendarData' => $subscriptionRow,
1148
-					'shares' => [],
1149
-					'objectData' => $objectRow,
1150
-				]
1151
-			));
1152
-		}
1153
-
1154
-		return '"' . $extraData['etag'] . '"';
1155
-	}
1156
-
1157
-	/**
1158
-	 * Updates an existing calendarobject, based on it's uri.
1159
-	 *
1160
-	 * The object uri is only the basename, or filename and not a full path.
1161
-	 *
1162
-	 * It is possible return an etag from this function, which will be used in
1163
-	 * the response to this PUT request. Note that the ETag must be surrounded
1164
-	 * by double-quotes.
1165
-	 *
1166
-	 * However, you should only really return this ETag if you don't mangle the
1167
-	 * calendar-data. If the result of a subsequent GET to this object is not
1168
-	 * the exact same as this request body, you should omit the ETag.
1169
-	 *
1170
-	 * @param mixed $calendarId
1171
-	 * @param string $objectUri
1172
-	 * @param string $calendarData
1173
-	 * @param int $calendarType
1174
-	 * @return string
1175
-	 */
1176
-	public function updateCalendarObject($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1177
-		$extraData = $this->getDenormalizedData($calendarData);
1178
-		$query = $this->db->getQueryBuilder();
1179
-		$query->update('calendarobjects')
1180
-				->set('calendardata', $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB))
1181
-				->set('lastmodified', $query->createNamedParameter(time()))
1182
-				->set('etag', $query->createNamedParameter($extraData['etag']))
1183
-				->set('size', $query->createNamedParameter($extraData['size']))
1184
-				->set('componenttype', $query->createNamedParameter($extraData['componentType']))
1185
-				->set('firstoccurence', $query->createNamedParameter($extraData['firstOccurence']))
1186
-				->set('lastoccurence', $query->createNamedParameter($extraData['lastOccurence']))
1187
-				->set('classification', $query->createNamedParameter($extraData['classification']))
1188
-				->set('uid', $query->createNamedParameter($extraData['uid']))
1189
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
1190
-			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
1191
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)))
1192
-			->execute();
1193
-
1194
-		$this->updateProperties($calendarId, $objectUri, $calendarData, $calendarType);
1195
-		$this->addChange($calendarId, $objectUri, 2, $calendarType);
1196
-
1197
-		$objectRow = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1198
-		if (is_array($objectRow)) {
1199
-			if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1200
-				$calendarRow = $this->getCalendarById($calendarId);
1201
-				$shares = $this->getShares($calendarId);
1202
-
1203
-				$this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
1204
-				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent(
1205
-					'\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject',
1206
-					[
1207
-						'calendarId' => $calendarId,
1208
-						'calendarData' => $calendarRow,
1209
-						'shares' => $shares,
1210
-						'objectData' => $objectRow,
1211
-					]
1212
-				));
1213
-			} else {
1214
-				$subscriptionRow = $this->getSubscriptionById($calendarId);
1215
-
1216
-				$this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
1217
-				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject', new GenericEvent(
1218
-					'\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject',
1219
-					[
1220
-						'subscriptionId' => $calendarId,
1221
-						'calendarData' => $subscriptionRow,
1222
-						'shares' => [],
1223
-						'objectData' => $objectRow,
1224
-					]
1225
-				));
1226
-			}
1227
-		}
1228
-
1229
-		return '"' . $extraData['etag'] . '"';
1230
-	}
1231
-
1232
-	/**
1233
-	 * @param int $calendarObjectId
1234
-	 * @param int $classification
1235
-	 */
1236
-	public function setClassification($calendarObjectId, $classification) {
1237
-		if (!in_array($classification, [
1238
-			self::CLASSIFICATION_PUBLIC, self::CLASSIFICATION_PRIVATE, self::CLASSIFICATION_CONFIDENTIAL
1239
-		])) {
1240
-			throw new \InvalidArgumentException();
1241
-		}
1242
-		$query = $this->db->getQueryBuilder();
1243
-		$query->update('calendarobjects')
1244
-			->set('classification', $query->createNamedParameter($classification))
1245
-			->where($query->expr()->eq('id', $query->createNamedParameter($calendarObjectId)))
1246
-			->execute();
1247
-	}
1248
-
1249
-	/**
1250
-	 * Deletes an existing calendar object.
1251
-	 *
1252
-	 * The object uri is only the basename, or filename and not a full path.
1253
-	 *
1254
-	 * @param mixed $calendarId
1255
-	 * @param string $objectUri
1256
-	 * @param int $calendarType
1257
-	 * @return void
1258
-	 */
1259
-	public function deleteCalendarObject($calendarId, $objectUri, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1260
-		$data = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1261
-		if (is_array($data)) {
1262
-			if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1263
-				$calendarRow = $this->getCalendarById($calendarId);
1264
-				$shares = $this->getShares($calendarId);
1265
-
1266
-				$this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int)$calendarId, $calendarRow, $shares, $data));
1267
-				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent(
1268
-					'\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject',
1269
-					[
1270
-						'calendarId' => $calendarId,
1271
-						'calendarData' => $calendarRow,
1272
-						'shares' => $shares,
1273
-						'objectData' => $data,
1274
-					]
1275
-				));
1276
-			} else {
1277
-				$subscriptionRow = $this->getSubscriptionById($calendarId);
1278
-
1279
-				$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent((int)$calendarId, $subscriptionRow, [], $data));
1280
-				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject', new GenericEvent(
1281
-					'\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject',
1282
-					[
1283
-						'subscriptionId' => $calendarId,
1284
-						'calendarData' => $subscriptionRow,
1285
-						'shares' => [],
1286
-						'objectData' => $data,
1287
-					]
1288
-				));
1289
-			}
1290
-		}
1291
-
1292
-		$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `uri` = ? AND `calendartype` = ?');
1293
-		$stmt->execute([$calendarId, $objectUri, $calendarType]);
1294
-
1295
-		if (is_array($data)) {
1296
-			$this->purgeProperties($calendarId, $data['id'], $calendarType);
1297
-		}
1298
-
1299
-		$this->addChange($calendarId, $objectUri, 3, $calendarType);
1300
-	}
1301
-
1302
-	/**
1303
-	 * Performs a calendar-query on the contents of this calendar.
1304
-	 *
1305
-	 * The calendar-query is defined in RFC4791 : CalDAV. Using the
1306
-	 * calendar-query it is possible for a client to request a specific set of
1307
-	 * object, based on contents of iCalendar properties, date-ranges and
1308
-	 * iCalendar component types (VTODO, VEVENT).
1309
-	 *
1310
-	 * This method should just return a list of (relative) urls that match this
1311
-	 * query.
1312
-	 *
1313
-	 * The list of filters are specified as an array. The exact array is
1314
-	 * documented by Sabre\CalDAV\CalendarQueryParser.
1315
-	 *
1316
-	 * Note that it is extremely likely that getCalendarObject for every path
1317
-	 * returned from this method will be called almost immediately after. You
1318
-	 * may want to anticipate this to speed up these requests.
1319
-	 *
1320
-	 * This method provides a default implementation, which parses *all* the
1321
-	 * iCalendar objects in the specified calendar.
1322
-	 *
1323
-	 * This default may well be good enough for personal use, and calendars
1324
-	 * that aren't very large. But if you anticipate high usage, big calendars
1325
-	 * or high loads, you are strongly advised to optimize certain paths.
1326
-	 *
1327
-	 * The best way to do so is override this method and to optimize
1328
-	 * specifically for 'common filters'.
1329
-	 *
1330
-	 * Requests that are extremely common are:
1331
-	 *   * requests for just VEVENTS
1332
-	 *   * requests for just VTODO
1333
-	 *   * requests with a time-range-filter on either VEVENT or VTODO.
1334
-	 *
1335
-	 * ..and combinations of these requests. It may not be worth it to try to
1336
-	 * handle every possible situation and just rely on the (relatively
1337
-	 * easy to use) CalendarQueryValidator to handle the rest.
1338
-	 *
1339
-	 * Note that especially time-range-filters may be difficult to parse. A
1340
-	 * time-range filter specified on a VEVENT must for instance also handle
1341
-	 * recurrence rules correctly.
1342
-	 * A good example of how to interprete all these filters can also simply
1343
-	 * be found in Sabre\CalDAV\CalendarQueryFilter. This class is as correct
1344
-	 * as possible, so it gives you a good idea on what type of stuff you need
1345
-	 * to think of.
1346
-	 *
1347
-	 * @param mixed $calendarId
1348
-	 * @param array $filters
1349
-	 * @param int $calendarType
1350
-	 * @return array
1351
-	 */
1352
-	public function calendarQuery($calendarId, array $filters, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
1353
-		$componentType = null;
1354
-		$requirePostFilter = true;
1355
-		$timeRange = null;
1356
-
1357
-		// if no filters were specified, we don't need to filter after a query
1358
-		if (!$filters['prop-filters'] && !$filters['comp-filters']) {
1359
-			$requirePostFilter = false;
1360
-		}
1361
-
1362
-		// Figuring out if there's a component filter
1363
-		if (count($filters['comp-filters']) > 0 && !$filters['comp-filters'][0]['is-not-defined']) {
1364
-			$componentType = $filters['comp-filters'][0]['name'];
1365
-
1366
-			// Checking if we need post-filters
1367
-			if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['time-range'] && !$filters['comp-filters'][0]['prop-filters']) {
1368
-				$requirePostFilter = false;
1369
-			}
1370
-			// There was a time-range filter
1371
-			if ($componentType === 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) {
1372
-				$timeRange = $filters['comp-filters'][0]['time-range'];
1373
-
1374
-				// If start time OR the end time is not specified, we can do a
1375
-				// 100% accurate mysql query.
1376
-				if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['prop-filters'] && (!$timeRange['start'] || !$timeRange['end'])) {
1377
-					$requirePostFilter = false;
1378
-				}
1379
-			}
1380
-		}
1381
-		$columns = ['uri'];
1382
-		if ($requirePostFilter) {
1383
-			$columns = ['uri', 'calendardata'];
1384
-		}
1385
-		$query = $this->db->getQueryBuilder();
1386
-		$query->select($columns)
1387
-			->from('calendarobjects')
1388
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
1389
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
1390
-
1391
-		if ($componentType) {
1392
-			$query->andWhere($query->expr()->eq('componenttype', $query->createNamedParameter($componentType)));
1393
-		}
1394
-
1395
-		if ($timeRange && $timeRange['start']) {
1396
-			$query->andWhere($query->expr()->gt('lastoccurence', $query->createNamedParameter($timeRange['start']->getTimeStamp())));
1397
-		}
1398
-		if ($timeRange && $timeRange['end']) {
1399
-			$query->andWhere($query->expr()->lt('firstoccurence', $query->createNamedParameter($timeRange['end']->getTimeStamp())));
1400
-		}
1401
-
1402
-		$stmt = $query->execute();
1403
-
1404
-		$result = [];
1405
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1406
-			if ($requirePostFilter) {
1407
-				// validateFilterForObject will parse the calendar data
1408
-				// catch parsing errors
1409
-				try {
1410
-					$matches = $this->validateFilterForObject($row, $filters);
1411
-				} catch (ParseException $ex) {
1412
-					$this->logger->logException($ex, [
1413
-						'app' => 'dav',
1414
-						'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri']
1415
-					]);
1416
-					continue;
1417
-				} catch (InvalidDataException $ex) {
1418
-					$this->logger->logException($ex, [
1419
-						'app' => 'dav',
1420
-						'message' => 'Caught invalid data exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri']
1421
-					]);
1422
-					continue;
1423
-				}
1424
-
1425
-				if (!$matches) {
1426
-					continue;
1427
-				}
1428
-			}
1429
-			$result[] = $row['uri'];
1430
-		}
1431
-
1432
-		return $result;
1433
-	}
1434
-
1435
-	/**
1436
-	 * custom Nextcloud search extension for CalDAV
1437
-	 *
1438
-	 * TODO - this should optionally cover cached calendar objects as well
1439
-	 *
1440
-	 * @param string $principalUri
1441
-	 * @param array $filters
1442
-	 * @param integer|null $limit
1443
-	 * @param integer|null $offset
1444
-	 * @return array
1445
-	 */
1446
-	public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1447
-		$calendars = $this->getCalendarsForUser($principalUri);
1448
-		$ownCalendars = [];
1449
-		$sharedCalendars = [];
1450
-
1451
-		$uriMapper = [];
1452
-
1453
-		foreach ($calendars as $calendar) {
1454
-			if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
1455
-				$ownCalendars[] = $calendar['id'];
1456
-			} else {
1457
-				$sharedCalendars[] = $calendar['id'];
1458
-			}
1459
-			$uriMapper[$calendar['id']] = $calendar['uri'];
1460
-		}
1461
-		if (count($ownCalendars) === 0 && count($sharedCalendars) === 0) {
1462
-			return [];
1463
-		}
1464
-
1465
-		$query = $this->db->getQueryBuilder();
1466
-		// Calendar id expressions
1467
-		$calendarExpressions = [];
1468
-		foreach ($ownCalendars as $id) {
1469
-			$calendarExpressions[] = $query->expr()->andX(
1470
-				$query->expr()->eq('c.calendarid',
1471
-					$query->createNamedParameter($id)),
1472
-				$query->expr()->eq('c.calendartype',
1473
-						$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1474
-		}
1475
-		foreach ($sharedCalendars as $id) {
1476
-			$calendarExpressions[] = $query->expr()->andX(
1477
-				$query->expr()->eq('c.calendarid',
1478
-					$query->createNamedParameter($id)),
1479
-				$query->expr()->eq('c.classification',
1480
-					$query->createNamedParameter(self::CLASSIFICATION_PUBLIC)),
1481
-				$query->expr()->eq('c.calendartype',
1482
-					$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1483
-		}
1484
-
1485
-		if (count($calendarExpressions) === 1) {
1486
-			$calExpr = $calendarExpressions[0];
1487
-		} else {
1488
-			$calExpr = call_user_func_array([$query->expr(), 'orX'], $calendarExpressions);
1489
-		}
1490
-
1491
-		// Component expressions
1492
-		$compExpressions = [];
1493
-		foreach ($filters['comps'] as $comp) {
1494
-			$compExpressions[] = $query->expr()
1495
-				->eq('c.componenttype', $query->createNamedParameter($comp));
1496
-		}
1497
-
1498
-		if (count($compExpressions) === 1) {
1499
-			$compExpr = $compExpressions[0];
1500
-		} else {
1501
-			$compExpr = call_user_func_array([$query->expr(), 'orX'], $compExpressions);
1502
-		}
1503
-
1504
-		if (!isset($filters['props'])) {
1505
-			$filters['props'] = [];
1506
-		}
1507
-		if (!isset($filters['params'])) {
1508
-			$filters['params'] = [];
1509
-		}
1510
-
1511
-		$propParamExpressions = [];
1512
-		foreach ($filters['props'] as $prop) {
1513
-			$propParamExpressions[] = $query->expr()->andX(
1514
-				$query->expr()->eq('i.name', $query->createNamedParameter($prop)),
1515
-				$query->expr()->isNull('i.parameter')
1516
-			);
1517
-		}
1518
-		foreach ($filters['params'] as $param) {
1519
-			$propParamExpressions[] = $query->expr()->andX(
1520
-				$query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
1521
-				$query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
1522
-			);
1523
-		}
1524
-
1525
-		if (count($propParamExpressions) === 1) {
1526
-			$propParamExpr = $propParamExpressions[0];
1527
-		} else {
1528
-			$propParamExpr = call_user_func_array([$query->expr(), 'orX'], $propParamExpressions);
1529
-		}
1530
-
1531
-		$query->select(['c.calendarid', 'c.uri'])
1532
-			->from($this->dbObjectPropertiesTable, 'i')
1533
-			->join('i', 'calendarobjects', 'c', $query->expr()->eq('i.objectid', 'c.id'))
1534
-			->where($calExpr)
1535
-			->andWhere($compExpr)
1536
-			->andWhere($propParamExpr)
1537
-			->andWhere($query->expr()->iLike('i.value',
1538
-				$query->createNamedParameter('%'.$this->db->escapeLikeParameter($filters['search-term']).'%')));
1539
-
1540
-		if ($offset) {
1541
-			$query->setFirstResult($offset);
1542
-		}
1543
-		if ($limit) {
1544
-			$query->setMaxResults($limit);
1545
-		}
1546
-
1547
-		$stmt = $query->execute();
1548
-
1549
-		$result = [];
1550
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1551
-			$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1552
-			if (!in_array($path, $result)) {
1553
-				$result[] = $path;
1554
-			}
1555
-		}
1556
-
1557
-		return $result;
1558
-	}
1559
-
1560
-	/**
1561
-	 * used for Nextcloud's calendar API
1562
-	 *
1563
-	 * @param array $calendarInfo
1564
-	 * @param string $pattern
1565
-	 * @param array $searchProperties
1566
-	 * @param array $options
1567
-	 * @param integer|null $limit
1568
-	 * @param integer|null $offset
1569
-	 *
1570
-	 * @return array
1571
-	 */
1572
-	public function search(array $calendarInfo, $pattern, array $searchProperties,
1573
-						   array $options, $limit, $offset) {
1574
-		$outerQuery = $this->db->getQueryBuilder();
1575
-		$innerQuery = $this->db->getQueryBuilder();
1576
-
1577
-		$innerQuery->selectDistinct('op.objectid')
1578
-			->from($this->dbObjectPropertiesTable, 'op')
1579
-			->andWhere($innerQuery->expr()->eq('op.calendarid',
1580
-				$outerQuery->createNamedParameter($calendarInfo['id'])))
1581
-			->andWhere($innerQuery->expr()->eq('op.calendartype',
1582
-				$outerQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1583
-
1584
-		// only return public items for shared calendars for now
1585
-		if ($calendarInfo['principaluri'] !== $calendarInfo['{http://owncloud.org/ns}owner-principal']) {
1586
-			$innerQuery->andWhere($innerQuery->expr()->eq('c.classification',
1587
-				$outerQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
1588
-		}
1589
-
1590
-		$or = $innerQuery->expr()->orX();
1591
-		foreach ($searchProperties as $searchProperty) {
1592
-			$or->add($innerQuery->expr()->eq('op.name',
1593
-				$outerQuery->createNamedParameter($searchProperty)));
1594
-		}
1595
-		$innerQuery->andWhere($or);
1596
-
1597
-		if ($pattern !== '') {
1598
-			$innerQuery->andWhere($innerQuery->expr()->iLike('op.value',
1599
-				$outerQuery->createNamedParameter('%' .
1600
-					$this->db->escapeLikeParameter($pattern) . '%')));
1601
-		}
1602
-
1603
-		$outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri')
1604
-			->from('calendarobjects', 'c');
1605
-
1606
-		if (isset($options['timerange'])) {
1607
-			if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTime) {
1608
-				$outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence',
1609
-					$outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp())));
1610
-			}
1611
-			if (isset($options['timerange']['end']) && $options['timerange']['end'] instanceof DateTime) {
1612
-				$outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence',
1613
-					$outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp())));
1614
-			}
1615
-		}
1616
-
1617
-		if (isset($options['types'])) {
1618
-			$or = $outerQuery->expr()->orX();
1619
-			foreach ($options['types'] as $type) {
1620
-				$or->add($outerQuery->expr()->eq('componenttype',
1621
-					$outerQuery->createNamedParameter($type)));
1622
-			}
1623
-			$outerQuery->andWhere($or);
1624
-		}
1625
-
1626
-		$outerQuery->andWhere($outerQuery->expr()->in('c.id',
1627
-			$outerQuery->createFunction($innerQuery->getSQL())));
1628
-
1629
-		if ($offset) {
1630
-			$outerQuery->setFirstResult($offset);
1631
-		}
1632
-		if ($limit) {
1633
-			$outerQuery->setMaxResults($limit);
1634
-		}
1635
-
1636
-		$result = $outerQuery->execute();
1637
-		$calendarObjects = $result->fetchAll();
1638
-
1639
-		return array_map(function ($o) {
1640
-			$calendarData = Reader::read($o['calendardata']);
1641
-			$comps = $calendarData->getComponents();
1642
-			$objects = [];
1643
-			$timezones = [];
1644
-			foreach ($comps as $comp) {
1645
-				if ($comp instanceof VTimeZone) {
1646
-					$timezones[] = $comp;
1647
-				} else {
1648
-					$objects[] = $comp;
1649
-				}
1650
-			}
1651
-
1652
-			return [
1653
-				'id' => $o['id'],
1654
-				'type' => $o['componenttype'],
1655
-				'uid' => $o['uid'],
1656
-				'uri' => $o['uri'],
1657
-				'objects' => array_map(function ($c) {
1658
-					return $this->transformSearchData($c);
1659
-				}, $objects),
1660
-				'timezones' => array_map(function ($c) {
1661
-					return $this->transformSearchData($c);
1662
-				}, $timezones),
1663
-			];
1664
-		}, $calendarObjects);
1665
-	}
1666
-
1667
-	/**
1668
-	 * @param Component $comp
1669
-	 * @return array
1670
-	 */
1671
-	private function transformSearchData(Component $comp) {
1672
-		$data = [];
1673
-		/** @var Component[] $subComponents */
1674
-		$subComponents = $comp->getComponents();
1675
-		/** @var Property[] $properties */
1676
-		$properties = array_filter($comp->children(), function ($c) {
1677
-			return $c instanceof Property;
1678
-		});
1679
-		$validationRules = $comp->getValidationRules();
1680
-
1681
-		foreach ($subComponents as $subComponent) {
1682
-			$name = $subComponent->name;
1683
-			if (!isset($data[$name])) {
1684
-				$data[$name] = [];
1685
-			}
1686
-			$data[$name][] = $this->transformSearchData($subComponent);
1687
-		}
1688
-
1689
-		foreach ($properties as $property) {
1690
-			$name = $property->name;
1691
-			if (!isset($validationRules[$name])) {
1692
-				$validationRules[$name] = '*';
1693
-			}
1694
-
1695
-			$rule = $validationRules[$property->name];
1696
-			if ($rule === '+' || $rule === '*') { // multiple
1697
-				if (!isset($data[$name])) {
1698
-					$data[$name] = [];
1699
-				}
1700
-
1701
-				$data[$name][] = $this->transformSearchProperty($property);
1702
-			} else { // once
1703
-				$data[$name] = $this->transformSearchProperty($property);
1704
-			}
1705
-		}
1706
-
1707
-		return $data;
1708
-	}
1709
-
1710
-	/**
1711
-	 * @param Property $prop
1712
-	 * @return array
1713
-	 */
1714
-	private function transformSearchProperty(Property $prop) {
1715
-		// No need to check Date, as it extends DateTime
1716
-		if ($prop instanceof Property\ICalendar\DateTime) {
1717
-			$value = $prop->getDateTime();
1718
-		} else {
1719
-			$value = $prop->getValue();
1720
-		}
1721
-
1722
-		return [
1723
-			$value,
1724
-			$prop->parameters()
1725
-		];
1726
-	}
1727
-
1728
-	/**
1729
-	 * @param string $principalUri
1730
-	 * @param string $pattern
1731
-	 * @param array $componentTypes
1732
-	 * @param array $searchProperties
1733
-	 * @param array $searchParameters
1734
-	 * @param array $options
1735
-	 * @return array
1736
-	 */
1737
-	public function searchPrincipalUri(string $principalUri,
1738
-									   string $pattern,
1739
-									   array $componentTypes,
1740
-									   array $searchProperties,
1741
-									   array $searchParameters,
1742
-									   array $options = []): array {
1743
-		$escapePattern = !\array_key_exists('escape_like_param', $options) || $options['escape_like_param'] !== false;
1744
-
1745
-		$calendarObjectIdQuery = $this->db->getQueryBuilder();
1746
-		$calendarOr = $calendarObjectIdQuery->expr()->orX();
1747
-		$searchOr = $calendarObjectIdQuery->expr()->orX();
1748
-
1749
-		// Fetch calendars and subscription
1750
-		$calendars = $this->getCalendarsForUser($principalUri);
1751
-		$subscriptions = $this->getSubscriptionsForUser($principalUri);
1752
-		foreach ($calendars as $calendar) {
1753
-			$calendarAnd = $calendarObjectIdQuery->expr()->andX();
1754
-			$calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$calendar['id'])));
1755
-			$calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1756
-
1757
-			// If it's shared, limit search to public events
1758
-			if ($calendar['principaluri'] !== $calendar['{http://owncloud.org/ns}owner-principal']) {
1759
-				$calendarAnd->add($calendarObjectIdQuery->expr()->eq('co.classification', $calendarObjectIdQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
1760
-			}
1761
-
1762
-			$calendarOr->add($calendarAnd);
1763
-		}
1764
-		foreach ($subscriptions as $subscription) {
1765
-			$subscriptionAnd = $calendarObjectIdQuery->expr()->andX();
1766
-			$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$subscription['id'])));
1767
-			$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)));
1768
-
1769
-			// If it's shared, limit search to public events
1770
-			if ($subscription['principaluri'] !== $subscription['{http://owncloud.org/ns}owner-principal']) {
1771
-				$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('co.classification', $calendarObjectIdQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
1772
-			}
1773
-
1774
-			$calendarOr->add($subscriptionAnd);
1775
-		}
1776
-
1777
-		foreach ($searchProperties as $property) {
1778
-			$propertyAnd = $calendarObjectIdQuery->expr()->andX();
1779
-			$propertyAnd->add($calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)));
1780
-			$propertyAnd->add($calendarObjectIdQuery->expr()->isNull('cob.parameter'));
1781
-
1782
-			$searchOr->add($propertyAnd);
1783
-		}
1784
-		foreach ($searchParameters as $property => $parameter) {
1785
-			$parameterAnd = $calendarObjectIdQuery->expr()->andX();
1786
-			$parameterAnd->add($calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)));
1787
-			$parameterAnd->add($calendarObjectIdQuery->expr()->eq('cob.parameter', $calendarObjectIdQuery->createNamedParameter($parameter, IQueryBuilder::PARAM_STR)));
1788
-
1789
-			$searchOr->add($parameterAnd);
1790
-		}
1791
-
1792
-		if ($calendarOr->count() === 0) {
1793
-			return [];
1794
-		}
1795
-		if ($searchOr->count() === 0) {
1796
-			return [];
1797
-		}
1798
-
1799
-		$calendarObjectIdQuery->selectDistinct('cob.objectid')
1800
-			->from($this->dbObjectPropertiesTable, 'cob')
1801
-			->leftJoin('cob', 'calendarobjects', 'co', $calendarObjectIdQuery->expr()->eq('co.id', 'cob.objectid'))
1802
-			->andWhere($calendarObjectIdQuery->expr()->in('co.componenttype', $calendarObjectIdQuery->createNamedParameter($componentTypes, IQueryBuilder::PARAM_STR_ARRAY)))
1803
-			->andWhere($calendarOr)
1804
-			->andWhere($searchOr);
1805
-
1806
-		if ('' !== $pattern) {
1807
-			if (!$escapePattern) {
1808
-				$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter($pattern)));
1809
-			} else {
1810
-				$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1811
-			}
1812
-		}
1813
-
1814
-		if (isset($options['limit'])) {
1815
-			$calendarObjectIdQuery->setMaxResults($options['limit']);
1816
-		}
1817
-		if (isset($options['offset'])) {
1818
-			$calendarObjectIdQuery->setFirstResult($options['offset']);
1819
-		}
1820
-
1821
-		$result = $calendarObjectIdQuery->execute();
1822
-		$matches = $result->fetchAll();
1823
-		$result->closeCursor();
1824
-		$matches = array_map(static function (array $match):int {
1825
-			return (int) $match['objectid'];
1826
-		}, $matches);
1827
-
1828
-		$query = $this->db->getQueryBuilder();
1829
-		$query->select('calendardata', 'uri', 'calendarid', 'calendartype')
1830
-			->from('calendarobjects')
1831
-			->where($query->expr()->in('id', $query->createNamedParameter($matches, IQueryBuilder::PARAM_INT_ARRAY)));
1832
-
1833
-		$result = $query->execute();
1834
-		$calendarObjects = $result->fetchAll();
1835
-		$result->closeCursor();
1836
-
1837
-		return array_map(function (array $array): array {
1838
-			$array['calendarid'] = (int)$array['calendarid'];
1839
-			$array['calendartype'] = (int)$array['calendartype'];
1840
-			$array['calendardata'] = $this->readBlob($array['calendardata']);
1841
-
1842
-			return $array;
1843
-		}, $calendarObjects);
1844
-	}
1845
-
1846
-	/**
1847
-	 * Searches through all of a users calendars and calendar objects to find
1848
-	 * an object with a specific UID.
1849
-	 *
1850
-	 * This method should return the path to this object, relative to the
1851
-	 * calendar home, so this path usually only contains two parts:
1852
-	 *
1853
-	 * calendarpath/objectpath.ics
1854
-	 *
1855
-	 * If the uid is not found, return null.
1856
-	 *
1857
-	 * This method should only consider * objects that the principal owns, so
1858
-	 * any calendars owned by other principals that also appear in this
1859
-	 * collection should be ignored.
1860
-	 *
1861
-	 * @param string $principalUri
1862
-	 * @param string $uid
1863
-	 * @return string|null
1864
-	 */
1865
-	public function getCalendarObjectByUID($principalUri, $uid) {
1866
-		$query = $this->db->getQueryBuilder();
1867
-		$query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi')
1868
-			->from('calendarobjects', 'co')
1869
-			->leftJoin('co', 'calendars', 'c', $query->expr()->eq('co.calendarid', 'c.id'))
1870
-			->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri)))
1871
-			->andWhere($query->expr()->eq('co.uid', $query->createNamedParameter($uid)));
1872
-
1873
-		$stmt = $query->execute();
1874
-
1875
-		if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1876
-			return $row['calendaruri'] . '/' . $row['objecturi'];
1877
-		}
1878
-
1879
-		return null;
1880
-	}
1881
-
1882
-	/**
1883
-	 * The getChanges method returns all the changes that have happened, since
1884
-	 * the specified syncToken in the specified calendar.
1885
-	 *
1886
-	 * This function should return an array, such as the following:
1887
-	 *
1888
-	 * [
1889
-	 *   'syncToken' => 'The current synctoken',
1890
-	 *   'added'   => [
1891
-	 *      'new.txt',
1892
-	 *   ],
1893
-	 *   'modified'   => [
1894
-	 *      'modified.txt',
1895
-	 *   ],
1896
-	 *   'deleted' => [
1897
-	 *      'foo.php.bak',
1898
-	 *      'old.txt'
1899
-	 *   ]
1900
-	 * );
1901
-	 *
1902
-	 * The returned syncToken property should reflect the *current* syncToken
1903
-	 * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
1904
-	 * property This is * needed here too, to ensure the operation is atomic.
1905
-	 *
1906
-	 * If the $syncToken argument is specified as null, this is an initial
1907
-	 * sync, and all members should be reported.
1908
-	 *
1909
-	 * The modified property is an array of nodenames that have changed since
1910
-	 * the last token.
1911
-	 *
1912
-	 * The deleted property is an array with nodenames, that have been deleted
1913
-	 * from collection.
1914
-	 *
1915
-	 * The $syncLevel argument is basically the 'depth' of the report. If it's
1916
-	 * 1, you only have to report changes that happened only directly in
1917
-	 * immediate descendants. If it's 2, it should also include changes from
1918
-	 * the nodes below the child collections. (grandchildren)
1919
-	 *
1920
-	 * The $limit argument allows a client to specify how many results should
1921
-	 * be returned at most. If the limit is not specified, it should be treated
1922
-	 * as infinite.
1923
-	 *
1924
-	 * If the limit (infinite or not) is higher than you're willing to return,
1925
-	 * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
1926
-	 *
1927
-	 * If the syncToken is expired (due to data cleanup) or unknown, you must
1928
-	 * return null.
1929
-	 *
1930
-	 * The limit is 'suggestive'. You are free to ignore it.
1931
-	 *
1932
-	 * @param string $calendarId
1933
-	 * @param string $syncToken
1934
-	 * @param int $syncLevel
1935
-	 * @param int $limit
1936
-	 * @param int $calendarType
1937
-	 * @return array
1938
-	 */
1939
-	public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1940
-		// Current synctoken
1941
-		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1942
-		$stmt->execute([ $calendarId ]);
1943
-		$currentToken = $stmt->fetchColumn(0);
1944
-
1945
-		if (is_null($currentToken)) {
1946
-			return null;
1947
-		}
1948
-
1949
-		$result = [
1950
-			'syncToken' => $currentToken,
1951
-			'added'     => [],
1952
-			'modified'  => [],
1953
-			'deleted'   => [],
1954
-		];
1955
-
1956
-		if ($syncToken) {
1957
-			$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? AND `calendartype` = ? ORDER BY `synctoken`";
1958
-			if ($limit>0) {
1959
-				$query.= " LIMIT " . (int)$limit;
1960
-			}
1961
-
1962
-			// Fetching all changes
1963
-			$stmt = $this->db->prepare($query);
1964
-			$stmt->execute([$syncToken, $currentToken, $calendarId, $calendarType]);
1965
-
1966
-			$changes = [];
1967
-
1968
-			// This loop ensures that any duplicates are overwritten, only the
1969
-			// last change on a node is relevant.
1970
-			while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1971
-				$changes[$row['uri']] = $row['operation'];
1972
-			}
1973
-
1974
-			foreach ($changes as $uri => $operation) {
1975
-				switch ($operation) {
1976
-					case 1:
1977
-						$result['added'][] = $uri;
1978
-						break;
1979
-					case 2:
1980
-						$result['modified'][] = $uri;
1981
-						break;
1982
-					case 3:
1983
-						$result['deleted'][] = $uri;
1984
-						break;
1985
-				}
1986
-			}
1987
-		} else {
1988
-			// No synctoken supplied, this is the initial sync.
1989
-			$query = "SELECT `uri` FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `calendartype` = ?";
1990
-			$stmt = $this->db->prepare($query);
1991
-			$stmt->execute([$calendarId, $calendarType]);
1992
-
1993
-			$result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
1994
-		}
1995
-		return $result;
1996
-	}
1997
-
1998
-	/**
1999
-	 * Returns a list of subscriptions for a principal.
2000
-	 *
2001
-	 * Every subscription is an array with the following keys:
2002
-	 *  * id, a unique id that will be used by other functions to modify the
2003
-	 *    subscription. This can be the same as the uri or a database key.
2004
-	 *  * uri. This is just the 'base uri' or 'filename' of the subscription.
2005
-	 *  * principaluri. The owner of the subscription. Almost always the same as
2006
-	 *    principalUri passed to this method.
2007
-	 *
2008
-	 * Furthermore, all the subscription info must be returned too:
2009
-	 *
2010
-	 * 1. {DAV:}displayname
2011
-	 * 2. {http://apple.com/ns/ical/}refreshrate
2012
-	 * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos
2013
-	 *    should not be stripped).
2014
-	 * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms
2015
-	 *    should not be stripped).
2016
-	 * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if
2017
-	 *    attachments should not be stripped).
2018
-	 * 6. {http://calendarserver.org/ns/}source (Must be a
2019
-	 *     Sabre\DAV\Property\Href).
2020
-	 * 7. {http://apple.com/ns/ical/}calendar-color
2021
-	 * 8. {http://apple.com/ns/ical/}calendar-order
2022
-	 * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
2023
-	 *    (should just be an instance of
2024
-	 *    Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of
2025
-	 *    default components).
2026
-	 *
2027
-	 * @param string $principalUri
2028
-	 * @return array
2029
-	 */
2030
-	public function getSubscriptionsForUser($principalUri) {
2031
-		$fields = array_values($this->subscriptionPropertyMap);
2032
-		$fields[] = 'id';
2033
-		$fields[] = 'uri';
2034
-		$fields[] = 'source';
2035
-		$fields[] = 'principaluri';
2036
-		$fields[] = 'lastmodified';
2037
-		$fields[] = 'synctoken';
2038
-
2039
-		$query = $this->db->getQueryBuilder();
2040
-		$query->select($fields)
2041
-			->from('calendarsubscriptions')
2042
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2043
-			->orderBy('calendarorder', 'asc');
2044
-		$stmt =$query->execute();
2045
-
2046
-		$subscriptions = [];
2047
-		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
2048
-			$subscription = [
2049
-				'id'           => $row['id'],
2050
-				'uri'          => $row['uri'],
2051
-				'principaluri' => $row['principaluri'],
2052
-				'source'       => $row['source'],
2053
-				'lastmodified' => $row['lastmodified'],
2054
-
2055
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
2056
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
2057
-			];
2058
-
2059
-			foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
2060
-				if (!is_null($row[$dbName])) {
2061
-					$subscription[$xmlName] = $row[$dbName];
2062
-				}
2063
-			}
2064
-
2065
-			$subscriptions[] = $subscription;
2066
-		}
2067
-
2068
-		return $subscriptions;
2069
-	}
2070
-
2071
-	/**
2072
-	 * Creates a new subscription for a principal.
2073
-	 *
2074
-	 * If the creation was a success, an id must be returned that can be used to reference
2075
-	 * this subscription in other methods, such as updateSubscription.
2076
-	 *
2077
-	 * @param string $principalUri
2078
-	 * @param string $uri
2079
-	 * @param array $properties
2080
-	 * @return mixed
2081
-	 */
2082
-	public function createSubscription($principalUri, $uri, array $properties) {
2083
-		if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
2084
-			throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
2085
-		}
2086
-
2087
-		$values = [
2088
-			'principaluri' => $principalUri,
2089
-			'uri'          => $uri,
2090
-			'source'       => $properties['{http://calendarserver.org/ns/}source']->getHref(),
2091
-			'lastmodified' => time(),
2092
-		];
2093
-
2094
-		$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
2095
-
2096
-		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
2097
-			if (array_key_exists($xmlName, $properties)) {
2098
-				$values[$dbName] = $properties[$xmlName];
2099
-				if (in_array($dbName, $propertiesBoolean)) {
2100
-					$values[$dbName] = true;
2101
-				}
2102
-			}
2103
-		}
2104
-
2105
-		$valuesToInsert = [];
2106
-
2107
-		$query = $this->db->getQueryBuilder();
2108
-
2109
-		foreach (array_keys($values) as $name) {
2110
-			$valuesToInsert[$name] = $query->createNamedParameter($values[$name]);
2111
-		}
2112
-
2113
-		$query->insert('calendarsubscriptions')
2114
-			->values($valuesToInsert)
2115
-			->execute();
2116
-
2117
-		$subscriptionId = $this->db->lastInsertId('*PREFIX*calendarsubscriptions');
2118
-
2119
-		$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2120
-		$this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent((int)$subscriptionId, $subscriptionRow));
2121
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createSubscription', new GenericEvent(
2122
-			'\OCA\DAV\CalDAV\CalDavBackend::createSubscription',
2123
-			[
2124
-				'subscriptionId' => $subscriptionId,
2125
-				'subscriptionData' => $subscriptionRow,
2126
-			]));
2127
-
2128
-		return $subscriptionId;
2129
-	}
2130
-
2131
-	/**
2132
-	 * Updates a subscription
2133
-	 *
2134
-	 * The list of mutations is stored in a Sabre\DAV\PropPatch object.
2135
-	 * To do the actual updates, you must tell this object which properties
2136
-	 * you're going to process with the handle() method.
2137
-	 *
2138
-	 * Calling the handle method is like telling the PropPatch object "I
2139
-	 * promise I can handle updating this property".
2140
-	 *
2141
-	 * Read the PropPatch documentation for more info and examples.
2142
-	 *
2143
-	 * @param mixed $subscriptionId
2144
-	 * @param PropPatch $propPatch
2145
-	 * @return void
2146
-	 */
2147
-	public function updateSubscription($subscriptionId, PropPatch $propPatch) {
2148
-		$supportedProperties = array_keys($this->subscriptionPropertyMap);
2149
-		$supportedProperties[] = '{http://calendarserver.org/ns/}source';
2150
-
2151
-		/**
2152
-		 * @suppress SqlInjectionChecker
2153
-		 */
2154
-		$propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
2155
-			$newValues = [];
2156
-
2157
-			foreach ($mutations as $propertyName=>$propertyValue) {
2158
-				if ($propertyName === '{http://calendarserver.org/ns/}source') {
2159
-					$newValues['source'] = $propertyValue->getHref();
2160
-				} else {
2161
-					$fieldName = $this->subscriptionPropertyMap[$propertyName];
2162
-					$newValues[$fieldName] = $propertyValue;
2163
-				}
2164
-			}
2165
-
2166
-			$query = $this->db->getQueryBuilder();
2167
-			$query->update('calendarsubscriptions')
2168
-				->set('lastmodified', $query->createNamedParameter(time()));
2169
-			foreach ($newValues as $fieldName=>$value) {
2170
-				$query->set($fieldName, $query->createNamedParameter($value));
2171
-			}
2172
-			$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
2173
-				->execute();
2174
-
2175
-			$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2176
-			$this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
2177
-			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateSubscription', new GenericEvent(
2178
-				'\OCA\DAV\CalDAV\CalDavBackend::updateSubscription',
2179
-				[
2180
-					'subscriptionId' => $subscriptionId,
2181
-					'subscriptionData' => $subscriptionRow,
2182
-					'propertyMutations' => $mutations,
2183
-				]));
2184
-
2185
-			return true;
2186
-		});
2187
-	}
2188
-
2189
-	/**
2190
-	 * Deletes a subscription.
2191
-	 *
2192
-	 * @param mixed $subscriptionId
2193
-	 * @return void
2194
-	 */
2195
-	public function deleteSubscription($subscriptionId) {
2196
-		$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2197
-
2198
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription', new GenericEvent(
2199
-			'\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription',
2200
-			[
2201
-				'subscriptionId' => $subscriptionId,
2202
-				'subscriptionData' => $this->getSubscriptionById($subscriptionId),
2203
-			]));
2204
-
2205
-		$query = $this->db->getQueryBuilder();
2206
-		$query->delete('calendarsubscriptions')
2207
-			->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
2208
-			->execute();
2209
-
2210
-		$query = $this->db->getQueryBuilder();
2211
-		$query->delete('calendarobjects')
2212
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2213
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2214
-			->execute();
2215
-
2216
-		$query->delete('calendarchanges')
2217
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2218
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2219
-			->execute();
2220
-
2221
-		$query->delete($this->dbObjectPropertiesTable)
2222
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2223
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2224
-			->execute();
2225
-
2226
-		if ($subscriptionRow) {
2227
-			$this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent((int)$subscriptionId, $subscriptionRow, []));
2228
-		}
2229
-	}
2230
-
2231
-	/**
2232
-	 * Returns a single scheduling object for the inbox collection.
2233
-	 *
2234
-	 * The returned array should contain the following elements:
2235
-	 *   * uri - A unique basename for the object. This will be used to
2236
-	 *           construct a full uri.
2237
-	 *   * calendardata - The iCalendar object
2238
-	 *   * lastmodified - The last modification date. Can be an int for a unix
2239
-	 *                    timestamp, or a PHP DateTime object.
2240
-	 *   * etag - A unique token that must change if the object changed.
2241
-	 *   * size - The size of the object, in bytes.
2242
-	 *
2243
-	 * @param string $principalUri
2244
-	 * @param string $objectUri
2245
-	 * @return array
2246
-	 */
2247
-	public function getSchedulingObject($principalUri, $objectUri) {
2248
-		$query = $this->db->getQueryBuilder();
2249
-		$stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size'])
2250
-			->from('schedulingobjects')
2251
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2252
-			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
2253
-			->execute();
2254
-
2255
-		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
2256
-
2257
-		if (!$row) {
2258
-			return null;
2259
-		}
2260
-
2261
-		return [
2262
-			'uri'          => $row['uri'],
2263
-			'calendardata' => $row['calendardata'],
2264
-			'lastmodified' => $row['lastmodified'],
2265
-			'etag'         => '"' . $row['etag'] . '"',
2266
-			'size'         => (int)$row['size'],
2267
-		];
2268
-	}
2269
-
2270
-	/**
2271
-	 * Returns all scheduling objects for the inbox collection.
2272
-	 *
2273
-	 * These objects should be returned as an array. Every item in the array
2274
-	 * should follow the same structure as returned from getSchedulingObject.
2275
-	 *
2276
-	 * The main difference is that 'calendardata' is optional.
2277
-	 *
2278
-	 * @param string $principalUri
2279
-	 * @return array
2280
-	 */
2281
-	public function getSchedulingObjects($principalUri) {
2282
-		$query = $this->db->getQueryBuilder();
2283
-		$stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size'])
2284
-				->from('schedulingobjects')
2285
-				->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2286
-				->execute();
2287
-
2288
-		$result = [];
2289
-		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
2290
-			$result[] = [
2291
-				'calendardata' => $row['calendardata'],
2292
-				'uri'          => $row['uri'],
2293
-				'lastmodified' => $row['lastmodified'],
2294
-				'etag'         => '"' . $row['etag'] . '"',
2295
-				'size'         => (int)$row['size'],
2296
-			];
2297
-		}
2298
-
2299
-		return $result;
2300
-	}
2301
-
2302
-	/**
2303
-	 * Deletes a scheduling object from the inbox collection.
2304
-	 *
2305
-	 * @param string $principalUri
2306
-	 * @param string $objectUri
2307
-	 * @return void
2308
-	 */
2309
-	public function deleteSchedulingObject($principalUri, $objectUri) {
2310
-		$query = $this->db->getQueryBuilder();
2311
-		$query->delete('schedulingobjects')
2312
-				->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2313
-				->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
2314
-				->execute();
2315
-	}
2316
-
2317
-	/**
2318
-	 * Creates a new scheduling object. This should land in a users' inbox.
2319
-	 *
2320
-	 * @param string $principalUri
2321
-	 * @param string $objectUri
2322
-	 * @param string $objectData
2323
-	 * @return void
2324
-	 */
2325
-	public function createSchedulingObject($principalUri, $objectUri, $objectData) {
2326
-		$query = $this->db->getQueryBuilder();
2327
-		$query->insert('schedulingobjects')
2328
-			->values([
2329
-				'principaluri' => $query->createNamedParameter($principalUri),
2330
-				'calendardata' => $query->createNamedParameter($objectData, IQueryBuilder::PARAM_LOB),
2331
-				'uri' => $query->createNamedParameter($objectUri),
2332
-				'lastmodified' => $query->createNamedParameter(time()),
2333
-				'etag' => $query->createNamedParameter(md5($objectData)),
2334
-				'size' => $query->createNamedParameter(strlen($objectData))
2335
-			])
2336
-			->execute();
2337
-	}
2338
-
2339
-	/**
2340
-	 * Adds a change record to the calendarchanges table.
2341
-	 *
2342
-	 * @param mixed $calendarId
2343
-	 * @param string $objectUri
2344
-	 * @param int $operation 1 = add, 2 = modify, 3 = delete.
2345
-	 * @param int $calendarType
2346
-	 * @return void
2347
-	 */
2348
-	protected function addChange($calendarId, $objectUri, $operation, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2349
-		$table = $calendarType === self::CALENDAR_TYPE_CALENDAR ? 'calendars': 'calendarsubscriptions';
2350
-
2351
-		$query = $this->db->getQueryBuilder();
2352
-		$query->select('synctoken')
2353
-			->from($table)
2354
-			->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
2355
-		$syncToken = (int)$query->execute()->fetchColumn();
2356
-
2357
-		$query = $this->db->getQueryBuilder();
2358
-		$query->insert('calendarchanges')
2359
-			->values([
2360
-				'uri' => $query->createNamedParameter($objectUri),
2361
-				'synctoken' => $query->createNamedParameter($syncToken),
2362
-				'calendarid' => $query->createNamedParameter($calendarId),
2363
-				'operation' => $query->createNamedParameter($operation),
2364
-				'calendartype' => $query->createNamedParameter($calendarType),
2365
-			])
2366
-			->execute();
2367
-
2368
-		$stmt = $this->db->prepare("UPDATE `*PREFIX*$table` SET `synctoken` = `synctoken` + 1 WHERE `id` = ?");
2369
-		$stmt->execute([
2370
-			$calendarId
2371
-		]);
2372
-	}
2373
-
2374
-	/**
2375
-	 * Parses some information from calendar objects, used for optimized
2376
-	 * calendar-queries.
2377
-	 *
2378
-	 * Returns an array with the following keys:
2379
-	 *   * etag - An md5 checksum of the object without the quotes.
2380
-	 *   * size - Size of the object in bytes
2381
-	 *   * componentType - VEVENT, VTODO or VJOURNAL
2382
-	 *   * firstOccurence
2383
-	 *   * lastOccurence
2384
-	 *   * uid - value of the UID property
2385
-	 *
2386
-	 * @param string $calendarData
2387
-	 * @return array
2388
-	 */
2389
-	public function getDenormalizedData($calendarData) {
2390
-		$vObject = Reader::read($calendarData);
2391
-		$componentType = null;
2392
-		$component = null;
2393
-		$firstOccurrence = null;
2394
-		$lastOccurrence = null;
2395
-		$uid = null;
2396
-		$classification = self::CLASSIFICATION_PUBLIC;
2397
-		foreach ($vObject->getComponents() as $component) {
2398
-			if ($component->name!=='VTIMEZONE') {
2399
-				$componentType = $component->name;
2400
-				$uid = (string)$component->UID;
2401
-				break;
2402
-			}
2403
-		}
2404
-		if (!$componentType) {
2405
-			throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
2406
-		}
2407
-		if ($componentType === 'VEVENT' && $component->DTSTART) {
2408
-			$firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp();
2409
-			// Finding the last occurrence is a bit harder
2410
-			if (!isset($component->RRULE)) {
2411
-				if (isset($component->DTEND)) {
2412
-					$lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp();
2413
-				} elseif (isset($component->DURATION)) {
2414
-					$endDate = clone $component->DTSTART->getDateTime();
2415
-					$endDate->add(DateTimeParser::parse($component->DURATION->getValue()));
2416
-					$lastOccurrence = $endDate->getTimeStamp();
2417
-				} elseif (!$component->DTSTART->hasTime()) {
2418
-					$endDate = clone $component->DTSTART->getDateTime();
2419
-					$endDate->modify('+1 day');
2420
-					$lastOccurrence = $endDate->getTimeStamp();
2421
-				} else {
2422
-					$lastOccurrence = $firstOccurrence;
2423
-				}
2424
-			} else {
2425
-				$it = new EventIterator($vObject, (string)$component->UID);
2426
-				$maxDate = new DateTime(self::MAX_DATE);
2427
-				if ($it->isInfinite()) {
2428
-					$lastOccurrence = $maxDate->getTimestamp();
2429
-				} else {
2430
-					$end = $it->getDtEnd();
2431
-					while ($it->valid() && $end < $maxDate) {
2432
-						$end = $it->getDtEnd();
2433
-						$it->next();
2434
-					}
2435
-					$lastOccurrence = $end->getTimestamp();
2436
-				}
2437
-			}
2438
-		}
2439
-
2440
-		if ($component->CLASS) {
2441
-			$classification = CalDavBackend::CLASSIFICATION_PRIVATE;
2442
-			switch ($component->CLASS->getValue()) {
2443
-				case 'PUBLIC':
2444
-					$classification = CalDavBackend::CLASSIFICATION_PUBLIC;
2445
-					break;
2446
-				case 'CONFIDENTIAL':
2447
-					$classification = CalDavBackend::CLASSIFICATION_CONFIDENTIAL;
2448
-					break;
2449
-			}
2450
-		}
2451
-		return [
2452
-			'etag' => md5($calendarData),
2453
-			'size' => strlen($calendarData),
2454
-			'componentType' => $componentType,
2455
-			'firstOccurence' => is_null($firstOccurrence) ? null : max(0, $firstOccurrence),
2456
-			'lastOccurence'  => $lastOccurrence,
2457
-			'uid' => $uid,
2458
-			'classification' => $classification
2459
-		];
2460
-	}
2461
-
2462
-	/**
2463
-	 * @param $cardData
2464
-	 * @return bool|string
2465
-	 */
2466
-	private function readBlob($cardData) {
2467
-		if (is_resource($cardData)) {
2468
-			return stream_get_contents($cardData);
2469
-		}
2470
-
2471
-		return $cardData;
2472
-	}
2473
-
2474
-	/**
2475
-	 * @param IShareable $shareable
2476
-	 * @param array $add
2477
-	 * @param array $remove
2478
-	 */
2479
-	public function updateShares($shareable, $add, $remove) {
2480
-		$calendarId = $shareable->getResourceId();
2481
-		$calendarRow = $this->getCalendarById($calendarId);
2482
-		$oldShares = $this->getShares($calendarId);
2483
-
2484
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateShares', new GenericEvent(
2485
-			'\OCA\DAV\CalDAV\CalDavBackend::updateShares',
2486
-			[
2487
-				'calendarId' => $calendarId,
2488
-				'calendarData' => $calendarRow,
2489
-				'shares' => $oldShares,
2490
-				'add' => $add,
2491
-				'remove' => $remove,
2492
-			]));
2493
-		$this->calendarSharingBackend->updateShares($shareable, $add, $remove);
2494
-
2495
-		$this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent((int)$calendarId, $calendarRow, $oldShares, $add, $remove));
2496
-	}
2497
-
2498
-	/**
2499
-	 * @param int $resourceId
2500
-	 * @param int $calendarType
2501
-	 * @return array
2502
-	 */
2503
-	public function getShares($resourceId, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2504
-		return $this->calendarSharingBackend->getShares($resourceId);
2505
-	}
2506
-
2507
-	/**
2508
-	 * @param boolean $value
2509
-	 * @param \OCA\DAV\CalDAV\Calendar $calendar
2510
-	 * @return string|null
2511
-	 */
2512
-	public function setPublishStatus($value, $calendar) {
2513
-		$calendarId = $calendar->getResourceId();
2514
-		$calendarData = $this->getCalendarById($calendarId);
2515
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
2516
-			'\OCA\DAV\CalDAV\CalDavBackend::updateShares',
2517
-			[
2518
-				'calendarId' => $calendarId,
2519
-				'calendarData' => $calendarData,
2520
-				'public' => $value,
2521
-			]));
2522
-
2523
-		$query = $this->db->getQueryBuilder();
2524
-		if ($value) {
2525
-			$publicUri = $this->random->generate(16, ISecureRandom::CHAR_HUMAN_READABLE);
2526
-			$query->insert('dav_shares')
2527
-				->values([
2528
-					'principaluri' => $query->createNamedParameter($calendar->getPrincipalURI()),
2529
-					'type' => $query->createNamedParameter('calendar'),
2530
-					'access' => $query->createNamedParameter(self::ACCESS_PUBLIC),
2531
-					'resourceid' => $query->createNamedParameter($calendar->getResourceId()),
2532
-					'publicuri' => $query->createNamedParameter($publicUri)
2533
-				]);
2534
-			$query->execute();
2535
-
2536
-			$this->dispatcher->dispatchTyped(new CalendarPublishedEvent((int)$calendarId, $calendarData, $publicUri));
2537
-			return $publicUri;
2538
-		}
2539
-		$query->delete('dav_shares')
2540
-			->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
2541
-			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)));
2542
-		$query->execute();
2543
-
2544
-		$this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent((int)$calendarId, $calendarData));
2545
-		return null;
2546
-	}
2547
-
2548
-	/**
2549
-	 * @param \OCA\DAV\CalDAV\Calendar $calendar
2550
-	 * @return mixed
2551
-	 */
2552
-	public function getPublishStatus($calendar) {
2553
-		$query = $this->db->getQueryBuilder();
2554
-		$result = $query->select('publicuri')
2555
-			->from('dav_shares')
2556
-			->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
2557
-			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
2558
-			->execute();
2559
-
2560
-		$row = $result->fetch();
2561
-		$result->closeCursor();
2562
-		return $row ? reset($row) : false;
2563
-	}
2564
-
2565
-	/**
2566
-	 * @param int $resourceId
2567
-	 * @param array $acl
2568
-	 * @return array
2569
-	 */
2570
-	public function applyShareAcl($resourceId, $acl) {
2571
-		return $this->calendarSharingBackend->applyShareAcl($resourceId, $acl);
2572
-	}
2573
-
2574
-
2575
-
2576
-	/**
2577
-	 * update properties table
2578
-	 *
2579
-	 * @param int $calendarId
2580
-	 * @param string $objectUri
2581
-	 * @param string $calendarData
2582
-	 * @param int $calendarType
2583
-	 */
2584
-	public function updateProperties($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2585
-		$objectId = $this->getCalendarObjectId($calendarId, $objectUri, $calendarType);
2586
-
2587
-		try {
2588
-			$vCalendar = $this->readCalendarData($calendarData);
2589
-		} catch (\Exception $ex) {
2590
-			return;
2591
-		}
2592
-
2593
-		$this->purgeProperties($calendarId, $objectId);
2594
-
2595
-		$query = $this->db->getQueryBuilder();
2596
-		$query->insert($this->dbObjectPropertiesTable)
2597
-			->values(
2598
-				[
2599
-					'calendarid' => $query->createNamedParameter($calendarId),
2600
-					'calendartype' => $query->createNamedParameter($calendarType),
2601
-					'objectid' => $query->createNamedParameter($objectId),
2602
-					'name' => $query->createParameter('name'),
2603
-					'parameter' => $query->createParameter('parameter'),
2604
-					'value' => $query->createParameter('value'),
2605
-				]
2606
-			);
2607
-
2608
-		$indexComponents = ['VEVENT', 'VJOURNAL', 'VTODO'];
2609
-		foreach ($vCalendar->getComponents() as $component) {
2610
-			if (!in_array($component->name, $indexComponents)) {
2611
-				continue;
2612
-			}
2613
-
2614
-			foreach ($component->children() as $property) {
2615
-				if (in_array($property->name, self::$indexProperties)) {
2616
-					$value = $property->getValue();
2617
-					// is this a shitty db?
2618
-					if (!$this->db->supports4ByteText()) {
2619
-						$value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
2620
-					}
2621
-					$value = mb_substr($value, 0, 254);
2622
-
2623
-					$query->setParameter('name', $property->name);
2624
-					$query->setParameter('parameter', null);
2625
-					$query->setParameter('value', $value);
2626
-					$query->execute();
2627
-				}
2628
-
2629
-				if (array_key_exists($property->name, self::$indexParameters)) {
2630
-					$parameters = $property->parameters();
2631
-					$indexedParametersForProperty = self::$indexParameters[$property->name];
2632
-
2633
-					foreach ($parameters as $key => $value) {
2634
-						if (in_array($key, $indexedParametersForProperty)) {
2635
-							// is this a shitty db?
2636
-							if ($this->db->supports4ByteText()) {
2637
-								$value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
2638
-							}
2639
-
2640
-							$query->setParameter('name', $property->name);
2641
-							$query->setParameter('parameter', mb_substr($key, 0, 254));
2642
-							$query->setParameter('value', mb_substr($value, 0, 254));
2643
-							$query->execute();
2644
-						}
2645
-					}
2646
-				}
2647
-			}
2648
-		}
2649
-	}
2650
-
2651
-	/**
2652
-	 * deletes all birthday calendars
2653
-	 */
2654
-	public function deleteAllBirthdayCalendars() {
2655
-		$query = $this->db->getQueryBuilder();
2656
-		$result = $query->select(['id'])->from('calendars')
2657
-			->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
2658
-			->execute();
2659
-
2660
-		$ids = $result->fetchAll();
2661
-		foreach ($ids as $id) {
2662
-			$this->deleteCalendar($id['id']);
2663
-		}
2664
-	}
2665
-
2666
-	/**
2667
-	 * @param $subscriptionId
2668
-	 */
2669
-	public function purgeAllCachedEventsForSubscription($subscriptionId) {
2670
-		$query = $this->db->getQueryBuilder();
2671
-		$query->select('uri')
2672
-			->from('calendarobjects')
2673
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2674
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)));
2675
-		$stmt = $query->execute();
2676
-
2677
-		$uris = [];
2678
-		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
2679
-			$uris[] = $row['uri'];
2680
-		}
2681
-		$stmt->closeCursor();
2682
-
2683
-		$query = $this->db->getQueryBuilder();
2684
-		$query->delete('calendarobjects')
2685
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2686
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2687
-			->execute();
2688
-
2689
-		$query->delete('calendarchanges')
2690
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2691
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2692
-			->execute();
2693
-
2694
-		$query->delete($this->dbObjectPropertiesTable)
2695
-			->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2696
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2697
-			->execute();
2698
-
2699
-		foreach ($uris as $uri) {
2700
-			$this->addChange($subscriptionId, $uri, 3, self::CALENDAR_TYPE_SUBSCRIPTION);
2701
-		}
2702
-	}
2703
-
2704
-	/**
2705
-	 * Move a calendar from one user to another
2706
-	 *
2707
-	 * @param string $uriName
2708
-	 * @param string $uriOrigin
2709
-	 * @param string $uriDestination
2710
-	 */
2711
-	public function moveCalendar($uriName, $uriOrigin, $uriDestination) {
2712
-		$query = $this->db->getQueryBuilder();
2713
-		$query->update('calendars')
2714
-			->set('principaluri', $query->createNamedParameter($uriDestination))
2715
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($uriOrigin)))
2716
-			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($uriName)))
2717
-			->execute();
2718
-	}
2719
-
2720
-	/**
2721
-	 * read VCalendar data into a VCalendar object
2722
-	 *
2723
-	 * @param string $objectData
2724
-	 * @return VCalendar
2725
-	 */
2726
-	protected function readCalendarData($objectData) {
2727
-		return Reader::read($objectData);
2728
-	}
2729
-
2730
-	/**
2731
-	 * delete all properties from a given calendar object
2732
-	 *
2733
-	 * @param int $calendarId
2734
-	 * @param int $objectId
2735
-	 */
2736
-	protected function purgeProperties($calendarId, $objectId) {
2737
-		$query = $this->db->getQueryBuilder();
2738
-		$query->delete($this->dbObjectPropertiesTable)
2739
-			->where($query->expr()->eq('objectid', $query->createNamedParameter($objectId)))
2740
-			->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)));
2741
-		$query->execute();
2742
-	}
2743
-
2744
-	/**
2745
-	 * get ID from a given calendar object
2746
-	 *
2747
-	 * @param int $calendarId
2748
-	 * @param string $uri
2749
-	 * @param int $calendarType
2750
-	 * @return int
2751
-	 */
2752
-	protected function getCalendarObjectId($calendarId, $uri, $calendarType):int {
2753
-		$query = $this->db->getQueryBuilder();
2754
-		$query->select('id')
2755
-			->from('calendarobjects')
2756
-			->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
2757
-			->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
2758
-			->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
2759
-
2760
-		$result = $query->execute();
2761
-		$objectIds = $result->fetch();
2762
-		$result->closeCursor();
2763
-
2764
-		if (!isset($objectIds['id'])) {
2765
-			throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2766
-		}
2767
-
2768
-		return (int)$objectIds['id'];
2769
-	}
2770
-
2771
-	/**
2772
-	 * return legacy endpoint principal name to new principal name
2773
-	 *
2774
-	 * @param $principalUri
2775
-	 * @param $toV2
2776
-	 * @return string
2777
-	 */
2778
-	private function convertPrincipal($principalUri, $toV2) {
2779
-		if ($this->principalBackend->getPrincipalPrefix() === 'principals') {
2780
-			list(, $name) = Uri\split($principalUri);
2781
-			if ($toV2 === true) {
2782
-				return "principals/users/$name";
2783
-			}
2784
-			return "principals/$name";
2785
-		}
2786
-		return $principalUri;
2787
-	}
2788
-
2789
-	/**
2790
-	 * adds information about an owner to the calendar data
2791
-	 *
2792
-	 * @param $calendarInfo
2793
-	 */
2794
-	private function addOwnerPrincipal(&$calendarInfo) {
2795
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
2796
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
2797
-		if (isset($calendarInfo[$ownerPrincipalKey])) {
2798
-			$uri = $calendarInfo[$ownerPrincipalKey];
2799
-		} else {
2800
-			$uri = $calendarInfo['principaluri'];
2801
-		}
2802
-
2803
-		$principalInformation = $this->principalBackend->getPrincipalByPath($uri);
2804
-		if (isset($principalInformation['{DAV:}displayname'])) {
2805
-			$calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
2806
-		}
2807
-	}
96
+    public const CALENDAR_TYPE_CALENDAR = 0;
97
+    public const CALENDAR_TYPE_SUBSCRIPTION = 1;
98
+
99
+    public const PERSONAL_CALENDAR_URI = 'personal';
100
+    public const PERSONAL_CALENDAR_NAME = 'Personal';
101
+
102
+    public const RESOURCE_BOOKING_CALENDAR_URI = 'calendar';
103
+    public const RESOURCE_BOOKING_CALENDAR_NAME = 'Calendar';
104
+
105
+    /**
106
+     * We need to specify a max date, because we need to stop *somewhere*
107
+     *
108
+     * On 32 bit system the maximum for a signed integer is 2147483647, so
109
+     * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results
110
+     * in 2038-01-19 to avoid problems when the date is converted
111
+     * to a unix timestamp.
112
+     */
113
+    public const MAX_DATE = '2038-01-01';
114
+
115
+    public const ACCESS_PUBLIC = 4;
116
+    public const CLASSIFICATION_PUBLIC = 0;
117
+    public const CLASSIFICATION_PRIVATE = 1;
118
+    public const CLASSIFICATION_CONFIDENTIAL = 2;
119
+
120
+    /**
121
+     * List of CalDAV properties, and how they map to database field names
122
+     * Add your own properties by simply adding on to this array.
123
+     *
124
+     * Note that only string-based properties are supported here.
125
+     *
126
+     * @var array
127
+     */
128
+    public $propertyMap = [
129
+        '{DAV:}displayname'                          => 'displayname',
130
+        '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description',
131
+        '{urn:ietf:params:xml:ns:caldav}calendar-timezone'    => 'timezone',
132
+        '{http://apple.com/ns/ical/}calendar-order'  => 'calendarorder',
133
+        '{http://apple.com/ns/ical/}calendar-color'  => 'calendarcolor',
134
+    ];
135
+
136
+    /**
137
+     * List of subscription properties, and how they map to database field names.
138
+     *
139
+     * @var array
140
+     */
141
+    public $subscriptionPropertyMap = [
142
+        '{DAV:}displayname'                                           => 'displayname',
143
+        '{http://apple.com/ns/ical/}refreshrate'                      => 'refreshrate',
144
+        '{http://apple.com/ns/ical/}calendar-order'                   => 'calendarorder',
145
+        '{http://apple.com/ns/ical/}calendar-color'                   => 'calendarcolor',
146
+        '{http://calendarserver.org/ns/}subscribed-strip-todos'       => 'striptodos',
147
+        '{http://calendarserver.org/ns/}subscribed-strip-alarms'      => 'stripalarms',
148
+        '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments',
149
+    ];
150
+
151
+    /** @var array properties to index */
152
+    public static $indexProperties = ['CATEGORIES', 'COMMENT', 'DESCRIPTION',
153
+        'LOCATION', 'RESOURCES', 'STATUS', 'SUMMARY', 'ATTENDEE', 'CONTACT',
154
+        'ORGANIZER'];
155
+
156
+    /** @var array parameters to index */
157
+    public static $indexParameters = [
158
+        'ATTENDEE' => ['CN'],
159
+        'ORGANIZER' => ['CN'],
160
+    ];
161
+
162
+    /**
163
+     * @var string[] Map of uid => display name
164
+     */
165
+    protected $userDisplayNames;
166
+
167
+    /** @var IDBConnection */
168
+    private $db;
169
+
170
+    /** @var Backend */
171
+    private $calendarSharingBackend;
172
+
173
+    /** @var Principal */
174
+    private $principalBackend;
175
+
176
+    /** @var IUserManager */
177
+    private $userManager;
178
+
179
+    /** @var ISecureRandom */
180
+    private $random;
181
+
182
+    /** @var ILogger */
183
+    private $logger;
184
+
185
+    /** @var IEventDispatcher */
186
+    private $dispatcher;
187
+
188
+    /** @var EventDispatcherInterface */
189
+    private $legacyDispatcher;
190
+
191
+    /** @var bool */
192
+    private $legacyEndpoint;
193
+
194
+    /** @var string */
195
+    private $dbObjectPropertiesTable = 'calendarobjects_props';
196
+
197
+    /**
198
+     * CalDavBackend constructor.
199
+     *
200
+     * @param IDBConnection $db
201
+     * @param Principal $principalBackend
202
+     * @param IUserManager $userManager
203
+     * @param IGroupManager $groupManager
204
+     * @param ISecureRandom $random
205
+     * @param ILogger $logger
206
+     * @param IEventDispatcher $dispatcher
207
+     * @param EventDispatcherInterface $legacyDispatcher
208
+     * @param bool $legacyEndpoint
209
+     */
210
+    public function __construct(IDBConnection $db,
211
+                                Principal $principalBackend,
212
+                                IUserManager $userManager,
213
+                                IGroupManager $groupManager,
214
+                                ISecureRandom $random,
215
+                                ILogger $logger,
216
+                                IEventDispatcher $dispatcher,
217
+                                EventDispatcherInterface $legacyDispatcher,
218
+                                bool $legacyEndpoint = false) {
219
+        $this->db = $db;
220
+        $this->principalBackend = $principalBackend;
221
+        $this->userManager = $userManager;
222
+        $this->calendarSharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'calendar');
223
+        $this->random = $random;
224
+        $this->logger = $logger;
225
+        $this->dispatcher = $dispatcher;
226
+        $this->legacyDispatcher = $legacyDispatcher;
227
+        $this->legacyEndpoint = $legacyEndpoint;
228
+    }
229
+
230
+    /**
231
+     * Return the number of calendars for a principal
232
+     *
233
+     * By default this excludes the automatically generated birthday calendar
234
+     *
235
+     * @param $principalUri
236
+     * @param bool $excludeBirthday
237
+     * @return int
238
+     */
239
+    public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) {
240
+        $principalUri = $this->convertPrincipal($principalUri, true);
241
+        $query = $this->db->getQueryBuilder();
242
+        $query->select($query->func()->count('*'))
243
+            ->from('calendars')
244
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
245
+
246
+        if ($excludeBirthday) {
247
+            $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
248
+        }
249
+
250
+        return (int)$query->execute()->fetchColumn();
251
+    }
252
+
253
+    /**
254
+     * Returns a list of calendars for a principal.
255
+     *
256
+     * Every project is an array with the following keys:
257
+     *  * id, a unique id that will be used by other functions to modify the
258
+     *    calendar. This can be the same as the uri or a database key.
259
+     *  * uri, which the basename of the uri with which the calendar is
260
+     *    accessed.
261
+     *  * principaluri. The owner of the calendar. Almost always the same as
262
+     *    principalUri passed to this method.
263
+     *
264
+     * Furthermore it can contain webdav properties in clark notation. A very
265
+     * common one is '{DAV:}displayname'.
266
+     *
267
+     * Many clients also require:
268
+     * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
269
+     * For this property, you can just return an instance of
270
+     * Sabre\CalDAV\Property\SupportedCalendarComponentSet.
271
+     *
272
+     * If you return {http://sabredav.org/ns}read-only and set the value to 1,
273
+     * ACL will automatically be put in read-only mode.
274
+     *
275
+     * @param string $principalUri
276
+     * @return array
277
+     */
278
+    public function getCalendarsForUser($principalUri) {
279
+        $principalUriOriginal = $principalUri;
280
+        $principalUri = $this->convertPrincipal($principalUri, true);
281
+        $fields = array_values($this->propertyMap);
282
+        $fields[] = 'id';
283
+        $fields[] = 'uri';
284
+        $fields[] = 'synctoken';
285
+        $fields[] = 'components';
286
+        $fields[] = 'principaluri';
287
+        $fields[] = 'transparent';
288
+
289
+        // Making fields a comma-delimited list
290
+        $query = $this->db->getQueryBuilder();
291
+        $query->select($fields)->from('calendars')
292
+                ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
293
+                ->orderBy('calendarorder', 'ASC');
294
+        $stmt = $query->execute();
295
+
296
+        $calendars = [];
297
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
298
+            $components = [];
299
+            if ($row['components']) {
300
+                $components = explode(',',$row['components']);
301
+            }
302
+
303
+            $calendar = [
304
+                'id' => $row['id'],
305
+                'uri' => $row['uri'],
306
+                'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
307
+                '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
308
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
309
+                '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
310
+                '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
311
+                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
312
+            ];
313
+
314
+            foreach ($this->propertyMap as $xmlName=>$dbName) {
315
+                $calendar[$xmlName] = $row[$dbName];
316
+            }
317
+
318
+            $this->addOwnerPrincipal($calendar);
319
+
320
+            if (!isset($calendars[$calendar['id']])) {
321
+                $calendars[$calendar['id']] = $calendar;
322
+            }
323
+        }
324
+
325
+        $stmt->closeCursor();
326
+
327
+        // query for shared calendars
328
+        $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
329
+        $principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
330
+
331
+        $principals = array_map(function ($principal) {
332
+            return urldecode($principal);
333
+        }, $principals);
334
+        $principals[]= $principalUri;
335
+
336
+        $fields = array_values($this->propertyMap);
337
+        $fields[] = 'a.id';
338
+        $fields[] = 'a.uri';
339
+        $fields[] = 'a.synctoken';
340
+        $fields[] = 'a.components';
341
+        $fields[] = 'a.principaluri';
342
+        $fields[] = 'a.transparent';
343
+        $fields[] = 's.access';
344
+        $query = $this->db->getQueryBuilder();
345
+        $result = $query->select($fields)
346
+            ->from('dav_shares', 's')
347
+            ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
348
+            ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
349
+            ->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
350
+            ->setParameter('type', 'calendar')
351
+            ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
352
+            ->execute();
353
+
354
+        $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
355
+        while ($row = $result->fetch()) {
356
+            if ($row['principaluri'] === $principalUri) {
357
+                continue;
358
+            }
359
+
360
+            $readOnly = (int) $row['access'] === Backend::ACCESS_READ;
361
+            if (isset($calendars[$row['id']])) {
362
+                if ($readOnly) {
363
+                    // New share can not have more permissions then the old one.
364
+                    continue;
365
+                }
366
+                if (isset($calendars[$row['id']][$readOnlyPropertyName]) &&
367
+                    $calendars[$row['id']][$readOnlyPropertyName] === 0) {
368
+                    // Old share is already read-write, no more permissions can be gained
369
+                    continue;
370
+                }
371
+            }
372
+
373
+            list(, $name) = Uri\split($row['principaluri']);
374
+            $uri = $row['uri'] . '_shared_by_' . $name;
375
+            $row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
376
+            $components = [];
377
+            if ($row['components']) {
378
+                $components = explode(',',$row['components']);
379
+            }
380
+            $calendar = [
381
+                'id' => $row['id'],
382
+                'uri' => $uri,
383
+                'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
384
+                '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
385
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
386
+                '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
387
+                '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'),
388
+                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
389
+                $readOnlyPropertyName => $readOnly,
390
+            ];
391
+
392
+            foreach ($this->propertyMap as $xmlName=>$dbName) {
393
+                $calendar[$xmlName] = $row[$dbName];
394
+            }
395
+
396
+            $this->addOwnerPrincipal($calendar);
397
+
398
+            $calendars[$calendar['id']] = $calendar;
399
+        }
400
+        $result->closeCursor();
401
+
402
+        return array_values($calendars);
403
+    }
404
+
405
+    /**
406
+     * @param $principalUri
407
+     * @return array
408
+     */
409
+    public function getUsersOwnCalendars($principalUri) {
410
+        $principalUri = $this->convertPrincipal($principalUri, true);
411
+        $fields = array_values($this->propertyMap);
412
+        $fields[] = 'id';
413
+        $fields[] = 'uri';
414
+        $fields[] = 'synctoken';
415
+        $fields[] = 'components';
416
+        $fields[] = 'principaluri';
417
+        $fields[] = 'transparent';
418
+        // Making fields a comma-delimited list
419
+        $query = $this->db->getQueryBuilder();
420
+        $query->select($fields)->from('calendars')
421
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
422
+            ->orderBy('calendarorder', 'ASC');
423
+        $stmt = $query->execute();
424
+        $calendars = [];
425
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
426
+            $components = [];
427
+            if ($row['components']) {
428
+                $components = explode(',',$row['components']);
429
+            }
430
+            $calendar = [
431
+                'id' => $row['id'],
432
+                'uri' => $row['uri'],
433
+                'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
434
+                '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
435
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
436
+                '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
437
+                '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
438
+            ];
439
+            foreach ($this->propertyMap as $xmlName=>$dbName) {
440
+                $calendar[$xmlName] = $row[$dbName];
441
+            }
442
+
443
+            $this->addOwnerPrincipal($calendar);
444
+
445
+            if (!isset($calendars[$calendar['id']])) {
446
+                $calendars[$calendar['id']] = $calendar;
447
+            }
448
+        }
449
+        $stmt->closeCursor();
450
+        return array_values($calendars);
451
+    }
452
+
453
+
454
+    /**
455
+     * @param $uid
456
+     * @return string
457
+     */
458
+    private function getUserDisplayName($uid) {
459
+        if (!isset($this->userDisplayNames[$uid])) {
460
+            $user = $this->userManager->get($uid);
461
+
462
+            if ($user instanceof IUser) {
463
+                $this->userDisplayNames[$uid] = $user->getDisplayName();
464
+            } else {
465
+                $this->userDisplayNames[$uid] = $uid;
466
+            }
467
+        }
468
+
469
+        return $this->userDisplayNames[$uid];
470
+    }
471
+
472
+    /**
473
+     * @return array
474
+     */
475
+    public function getPublicCalendars() {
476
+        $fields = array_values($this->propertyMap);
477
+        $fields[] = 'a.id';
478
+        $fields[] = 'a.uri';
479
+        $fields[] = 'a.synctoken';
480
+        $fields[] = 'a.components';
481
+        $fields[] = 'a.principaluri';
482
+        $fields[] = 'a.transparent';
483
+        $fields[] = 's.access';
484
+        $fields[] = 's.publicuri';
485
+        $calendars = [];
486
+        $query = $this->db->getQueryBuilder();
487
+        $result = $query->select($fields)
488
+            ->from('dav_shares', 's')
489
+            ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
490
+            ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
491
+            ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
492
+            ->execute();
493
+
494
+        while ($row = $result->fetch()) {
495
+            list(, $name) = Uri\split($row['principaluri']);
496
+            $row['displayname'] = $row['displayname'] . "($name)";
497
+            $components = [];
498
+            if ($row['components']) {
499
+                $components = explode(',',$row['components']);
500
+            }
501
+            $calendar = [
502
+                'id' => $row['id'],
503
+                'uri' => $row['publicuri'],
504
+                'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
505
+                '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
506
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
507
+                '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
508
+                '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
509
+                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
510
+                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
511
+                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
512
+            ];
513
+
514
+            foreach ($this->propertyMap as $xmlName=>$dbName) {
515
+                $calendar[$xmlName] = $row[$dbName];
516
+            }
517
+
518
+            $this->addOwnerPrincipal($calendar);
519
+
520
+            if (!isset($calendars[$calendar['id']])) {
521
+                $calendars[$calendar['id']] = $calendar;
522
+            }
523
+        }
524
+        $result->closeCursor();
525
+
526
+        return array_values($calendars);
527
+    }
528
+
529
+    /**
530
+     * @param string $uri
531
+     * @return array
532
+     * @throws NotFound
533
+     */
534
+    public function getPublicCalendar($uri) {
535
+        $fields = array_values($this->propertyMap);
536
+        $fields[] = 'a.id';
537
+        $fields[] = 'a.uri';
538
+        $fields[] = 'a.synctoken';
539
+        $fields[] = 'a.components';
540
+        $fields[] = 'a.principaluri';
541
+        $fields[] = 'a.transparent';
542
+        $fields[] = 's.access';
543
+        $fields[] = 's.publicuri';
544
+        $query = $this->db->getQueryBuilder();
545
+        $result = $query->select($fields)
546
+            ->from('dav_shares', 's')
547
+            ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
548
+            ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
549
+            ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
550
+            ->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri)))
551
+            ->execute();
552
+
553
+        $row = $result->fetch(\PDO::FETCH_ASSOC);
554
+
555
+        $result->closeCursor();
556
+
557
+        if ($row === false) {
558
+            throw new NotFound('Node with name \'' . $uri . '\' could not be found');
559
+        }
560
+
561
+        list(, $name) = Uri\split($row['principaluri']);
562
+        $row['displayname'] = $row['displayname'] . ' ' . "($name)";
563
+        $components = [];
564
+        if ($row['components']) {
565
+            $components = explode(',',$row['components']);
566
+        }
567
+        $calendar = [
568
+            'id' => $row['id'],
569
+            'uri' => $row['publicuri'],
570
+            'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
571
+            '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
572
+            '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
573
+            '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
574
+            '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
575
+            '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
576
+            '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
577
+            '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
578
+        ];
579
+
580
+        foreach ($this->propertyMap as $xmlName=>$dbName) {
581
+            $calendar[$xmlName] = $row[$dbName];
582
+        }
583
+
584
+        $this->addOwnerPrincipal($calendar);
585
+
586
+        return $calendar;
587
+    }
588
+
589
+    /**
590
+     * @param string $principal
591
+     * @param string $uri
592
+     * @return array|null
593
+     */
594
+    public function getCalendarByUri($principal, $uri) {
595
+        $fields = array_values($this->propertyMap);
596
+        $fields[] = 'id';
597
+        $fields[] = 'uri';
598
+        $fields[] = 'synctoken';
599
+        $fields[] = 'components';
600
+        $fields[] = 'principaluri';
601
+        $fields[] = 'transparent';
602
+
603
+        // Making fields a comma-delimited list
604
+        $query = $this->db->getQueryBuilder();
605
+        $query->select($fields)->from('calendars')
606
+            ->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
607
+            ->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($principal)))
608
+            ->setMaxResults(1);
609
+        $stmt = $query->execute();
610
+
611
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
612
+        $stmt->closeCursor();
613
+        if ($row === false) {
614
+            return null;
615
+        }
616
+
617
+        $components = [];
618
+        if ($row['components']) {
619
+            $components = explode(',',$row['components']);
620
+        }
621
+
622
+        $calendar = [
623
+            'id' => $row['id'],
624
+            'uri' => $row['uri'],
625
+            'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
626
+            '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
627
+            '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
628
+            '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
629
+            '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
630
+        ];
631
+
632
+        foreach ($this->propertyMap as $xmlName=>$dbName) {
633
+            $calendar[$xmlName] = $row[$dbName];
634
+        }
635
+
636
+        $this->addOwnerPrincipal($calendar);
637
+
638
+        return $calendar;
639
+    }
640
+
641
+    /**
642
+     * @param $calendarId
643
+     * @return array|null
644
+     */
645
+    public function getCalendarById($calendarId) {
646
+        $fields = array_values($this->propertyMap);
647
+        $fields[] = 'id';
648
+        $fields[] = 'uri';
649
+        $fields[] = 'synctoken';
650
+        $fields[] = 'components';
651
+        $fields[] = 'principaluri';
652
+        $fields[] = 'transparent';
653
+
654
+        // Making fields a comma-delimited list
655
+        $query = $this->db->getQueryBuilder();
656
+        $query->select($fields)->from('calendars')
657
+            ->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)))
658
+            ->setMaxResults(1);
659
+        $stmt = $query->execute();
660
+
661
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
662
+        $stmt->closeCursor();
663
+        if ($row === false) {
664
+            return null;
665
+        }
666
+
667
+        $components = [];
668
+        if ($row['components']) {
669
+            $components = explode(',',$row['components']);
670
+        }
671
+
672
+        $calendar = [
673
+            'id' => $row['id'],
674
+            'uri' => $row['uri'],
675
+            'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
676
+            '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
677
+            '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
678
+            '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
679
+            '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
680
+        ];
681
+
682
+        foreach ($this->propertyMap as $xmlName=>$dbName) {
683
+            $calendar[$xmlName] = $row[$dbName];
684
+        }
685
+
686
+        $this->addOwnerPrincipal($calendar);
687
+
688
+        return $calendar;
689
+    }
690
+
691
+    /**
692
+     * @param $subscriptionId
693
+     */
694
+    public function getSubscriptionById($subscriptionId) {
695
+        $fields = array_values($this->subscriptionPropertyMap);
696
+        $fields[] = 'id';
697
+        $fields[] = 'uri';
698
+        $fields[] = 'source';
699
+        $fields[] = 'synctoken';
700
+        $fields[] = 'principaluri';
701
+        $fields[] = 'lastmodified';
702
+
703
+        $query = $this->db->getQueryBuilder();
704
+        $query->select($fields)
705
+            ->from('calendarsubscriptions')
706
+            ->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
707
+            ->orderBy('calendarorder', 'asc');
708
+        $stmt =$query->execute();
709
+
710
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
711
+        $stmt->closeCursor();
712
+        if ($row === false) {
713
+            return null;
714
+        }
715
+
716
+        $subscription = [
717
+            'id'           => $row['id'],
718
+            'uri'          => $row['uri'],
719
+            'principaluri' => $row['principaluri'],
720
+            'source'       => $row['source'],
721
+            'lastmodified' => $row['lastmodified'],
722
+            '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
723
+            '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
724
+        ];
725
+
726
+        foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
727
+            if (!is_null($row[$dbName])) {
728
+                $subscription[$xmlName] = $row[$dbName];
729
+            }
730
+        }
731
+
732
+        return $subscription;
733
+    }
734
+
735
+    /**
736
+     * Creates a new calendar for a principal.
737
+     *
738
+     * If the creation was a success, an id must be returned that can be used to reference
739
+     * this calendar in other methods, such as updateCalendar.
740
+     *
741
+     * @param string $principalUri
742
+     * @param string $calendarUri
743
+     * @param array $properties
744
+     * @return int
745
+     * @suppress SqlInjectionChecker
746
+     */
747
+    public function createCalendar($principalUri, $calendarUri, array $properties) {
748
+        $values = [
749
+            'principaluri' => $this->convertPrincipal($principalUri, true),
750
+            'uri'          => $calendarUri,
751
+            'synctoken'    => 1,
752
+            'transparent'  => 0,
753
+            'components'   => 'VEVENT,VTODO',
754
+            'displayname'  => $calendarUri
755
+        ];
756
+
757
+        // Default value
758
+        $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
759
+        if (isset($properties[$sccs])) {
760
+            if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
761
+                throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
762
+            }
763
+            $values['components'] = implode(',',$properties[$sccs]->getValue());
764
+        } elseif (isset($properties['components'])) {
765
+            // Allow to provide components internally without having
766
+            // to create a SupportedCalendarComponentSet object
767
+            $values['components'] = $properties['components'];
768
+        }
769
+
770
+        $transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
771
+        if (isset($properties[$transp])) {
772
+            $values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
773
+        }
774
+
775
+        foreach ($this->propertyMap as $xmlName=>$dbName) {
776
+            if (isset($properties[$xmlName])) {
777
+                $values[$dbName] = $properties[$xmlName];
778
+            }
779
+        }
780
+
781
+        $query = $this->db->getQueryBuilder();
782
+        $query->insert('calendars');
783
+        foreach ($values as $column => $value) {
784
+            $query->setValue($column, $query->createNamedParameter($value));
785
+        }
786
+        $query->execute();
787
+        $calendarId = $query->getLastInsertId();
788
+
789
+        $calendarData = $this->getCalendarById($calendarId);
790
+        $this->dispatcher->dispatchTyped(new CalendarCreatedEvent((int)$calendarId, $calendarData));
791
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent(
792
+            '\OCA\DAV\CalDAV\CalDavBackend::createCalendar',
793
+            [
794
+                'calendarId' => $calendarId,
795
+                'calendarData' => $calendarData,
796
+            ]));
797
+
798
+        return $calendarId;
799
+    }
800
+
801
+    /**
802
+     * Updates properties for a calendar.
803
+     *
804
+     * The list of mutations is stored in a Sabre\DAV\PropPatch object.
805
+     * To do the actual updates, you must tell this object which properties
806
+     * you're going to process with the handle() method.
807
+     *
808
+     * Calling the handle method is like telling the PropPatch object "I
809
+     * promise I can handle updating this property".
810
+     *
811
+     * Read the PropPatch documentation for more info and examples.
812
+     *
813
+     * @param mixed $calendarId
814
+     * @param PropPatch $propPatch
815
+     * @return void
816
+     */
817
+    public function updateCalendar($calendarId, PropPatch $propPatch) {
818
+        $supportedProperties = array_keys($this->propertyMap);
819
+        $supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
820
+
821
+        /**
822
+         * @suppress SqlInjectionChecker
823
+         */
824
+        $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
825
+            $newValues = [];
826
+            foreach ($mutations as $propertyName => $propertyValue) {
827
+                switch ($propertyName) {
828
+                    case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
829
+                        $fieldName = 'transparent';
830
+                        $newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
831
+                        break;
832
+                    default:
833
+                        $fieldName = $this->propertyMap[$propertyName];
834
+                        $newValues[$fieldName] = $propertyValue;
835
+                        break;
836
+                }
837
+            }
838
+            $query = $this->db->getQueryBuilder();
839
+            $query->update('calendars');
840
+            foreach ($newValues as $fieldName => $value) {
841
+                $query->set($fieldName, $query->createNamedParameter($value));
842
+            }
843
+            $query->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
844
+            $query->execute();
845
+
846
+            $this->addChange($calendarId, "", 2);
847
+
848
+            $calendarData = $this->getCalendarById($calendarId);
849
+            $shares = $this->getShares($calendarId);
850
+            $this->dispatcher->dispatchTyped(new CalendarUpdatedEvent((int)$calendarId, $calendarData, $shares, $mutations));
851
+            $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent(
852
+                '\OCA\DAV\CalDAV\CalDavBackend::updateCalendar',
853
+                [
854
+                    'calendarId' => $calendarId,
855
+                    'calendarData' => $calendarData,
856
+                    'shares' => $shares,
857
+                    'propertyMutations' => $mutations,
858
+                ]));
859
+
860
+            return true;
861
+        });
862
+    }
863
+
864
+    /**
865
+     * Delete a calendar and all it's objects
866
+     *
867
+     * @param mixed $calendarId
868
+     * @return void
869
+     */
870
+    public function deleteCalendar($calendarId) {
871
+        $calendarData = $this->getCalendarById($calendarId);
872
+        $shares = $this->getShares($calendarId);
873
+
874
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', new GenericEvent(
875
+            '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar',
876
+            [
877
+                'calendarId' => $calendarId,
878
+                'calendarData' => $calendarData,
879
+                'shares' => $shares,
880
+            ]));
881
+
882
+        $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `calendartype` = ?');
883
+        $stmt->execute([$calendarId, self::CALENDAR_TYPE_CALENDAR]);
884
+
885
+        $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendars` WHERE `id` = ?');
886
+        $stmt->execute([$calendarId]);
887
+
888
+        $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarchanges` WHERE `calendarid` = ? AND `calendartype` = ?');
889
+        $stmt->execute([$calendarId, self::CALENDAR_TYPE_CALENDAR]);
890
+
891
+        $this->calendarSharingBackend->deleteAllShares($calendarId);
892
+
893
+        $query = $this->db->getQueryBuilder();
894
+        $query->delete($this->dbObjectPropertiesTable)
895
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
896
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)))
897
+            ->execute();
898
+
899
+        if ($calendarData) {
900
+            $this->dispatcher->dispatchTyped(new CalendarDeletedEvent((int)$calendarId, $calendarData, $shares));
901
+        }
902
+    }
903
+
904
+    /**
905
+     * Delete all of an user's shares
906
+     *
907
+     * @param string $principaluri
908
+     * @return void
909
+     */
910
+    public function deleteAllSharesByUser($principaluri) {
911
+        $this->calendarSharingBackend->deleteAllSharesByUser($principaluri);
912
+    }
913
+
914
+    /**
915
+     * Returns all calendar objects within a calendar.
916
+     *
917
+     * Every item contains an array with the following keys:
918
+     *   * calendardata - The iCalendar-compatible calendar data
919
+     *   * uri - a unique key which will be used to construct the uri. This can
920
+     *     be any arbitrary string, but making sure it ends with '.ics' is a
921
+     *     good idea. This is only the basename, or filename, not the full
922
+     *     path.
923
+     *   * lastmodified - a timestamp of the last modification time
924
+     *   * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
925
+     *   '"abcdef"')
926
+     *   * size - The size of the calendar objects, in bytes.
927
+     *   * component - optional, a string containing the type of object, such
928
+     *     as 'vevent' or 'vtodo'. If specified, this will be used to populate
929
+     *     the Content-Type header.
930
+     *
931
+     * Note that the etag is optional, but it's highly encouraged to return for
932
+     * speed reasons.
933
+     *
934
+     * The calendardata is also optional. If it's not returned
935
+     * 'getCalendarObject' will be called later, which *is* expected to return
936
+     * calendardata.
937
+     *
938
+     * If neither etag or size are specified, the calendardata will be
939
+     * used/fetched to determine these numbers. If both are specified the
940
+     * amount of times this is needed is reduced by a great degree.
941
+     *
942
+     * @param mixed $calendarId
943
+     * @param int $calendarType
944
+     * @return array
945
+     */
946
+    public function getCalendarObjects($calendarId, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
947
+        $query = $this->db->getQueryBuilder();
948
+        $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype', 'classification'])
949
+            ->from('calendarobjects')
950
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
951
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
952
+        $stmt = $query->execute();
953
+
954
+        $result = [];
955
+        foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
956
+            $result[] = [
957
+                'id'           => $row['id'],
958
+                'uri'          => $row['uri'],
959
+                'lastmodified' => $row['lastmodified'],
960
+                'etag'         => '"' . $row['etag'] . '"',
961
+                'calendarid'   => $row['calendarid'],
962
+                'size'         => (int)$row['size'],
963
+                'component'    => strtolower($row['componenttype']),
964
+                'classification'=> (int)$row['classification']
965
+            ];
966
+        }
967
+
968
+        return $result;
969
+    }
970
+
971
+    /**
972
+     * Returns information from a single calendar object, based on it's object
973
+     * uri.
974
+     *
975
+     * The object uri is only the basename, or filename and not a full path.
976
+     *
977
+     * The returned array must have the same keys as getCalendarObjects. The
978
+     * 'calendardata' object is required here though, while it's not required
979
+     * for getCalendarObjects.
980
+     *
981
+     * This method must return null if the object did not exist.
982
+     *
983
+     * @param mixed $calendarId
984
+     * @param string $objectUri
985
+     * @param int $calendarType
986
+     * @return array|null
987
+     */
988
+    public function getCalendarObject($calendarId, $objectUri, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
989
+        $query = $this->db->getQueryBuilder();
990
+        $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
991
+            ->from('calendarobjects')
992
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
993
+            ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
994
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
995
+        $stmt = $query->execute();
996
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
997
+
998
+        if (!$row) {
999
+            return null;
1000
+        }
1001
+
1002
+        return [
1003
+            'id'            => $row['id'],
1004
+            'uri'           => $row['uri'],
1005
+            'lastmodified'  => $row['lastmodified'],
1006
+            'etag'          => '"' . $row['etag'] . '"',
1007
+            'calendarid'    => $row['calendarid'],
1008
+            'size'          => (int)$row['size'],
1009
+            'calendardata'  => $this->readBlob($row['calendardata']),
1010
+            'component'     => strtolower($row['componenttype']),
1011
+            'classification'=> (int)$row['classification']
1012
+        ];
1013
+    }
1014
+
1015
+    /**
1016
+     * Returns a list of calendar objects.
1017
+     *
1018
+     * This method should work identical to getCalendarObject, but instead
1019
+     * return all the calendar objects in the list as an array.
1020
+     *
1021
+     * If the backend supports this, it may allow for some speed-ups.
1022
+     *
1023
+     * @param mixed $calendarId
1024
+     * @param string[] $uris
1025
+     * @param int $calendarType
1026
+     * @return array
1027
+     */
1028
+    public function getMultipleCalendarObjects($calendarId, array $uris, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
1029
+        if (empty($uris)) {
1030
+            return [];
1031
+        }
1032
+
1033
+        $chunks = array_chunk($uris, 100);
1034
+        $objects = [];
1035
+
1036
+        $query = $this->db->getQueryBuilder();
1037
+        $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
1038
+            ->from('calendarobjects')
1039
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
1040
+            ->andWhere($query->expr()->in('uri', $query->createParameter('uri')))
1041
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
1042
+
1043
+        foreach ($chunks as $uris) {
1044
+            $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
1045
+            $result = $query->execute();
1046
+
1047
+            while ($row = $result->fetch()) {
1048
+                $objects[] = [
1049
+                    'id'           => $row['id'],
1050
+                    'uri'          => $row['uri'],
1051
+                    'lastmodified' => $row['lastmodified'],
1052
+                    'etag'         => '"' . $row['etag'] . '"',
1053
+                    'calendarid'   => $row['calendarid'],
1054
+                    'size'         => (int)$row['size'],
1055
+                    'calendardata' => $this->readBlob($row['calendardata']),
1056
+                    'component'    => strtolower($row['componenttype']),
1057
+                    'classification' => (int)$row['classification']
1058
+                ];
1059
+            }
1060
+            $result->closeCursor();
1061
+        }
1062
+
1063
+        return $objects;
1064
+    }
1065
+
1066
+    /**
1067
+     * Creates a new calendar object.
1068
+     *
1069
+     * The object uri is only the basename, or filename and not a full path.
1070
+     *
1071
+     * It is possible return an etag from this function, which will be used in
1072
+     * the response to this PUT request. Note that the ETag must be surrounded
1073
+     * by double-quotes.
1074
+     *
1075
+     * However, you should only really return this ETag if you don't mangle the
1076
+     * calendar-data. If the result of a subsequent GET to this object is not
1077
+     * the exact same as this request body, you should omit the ETag.
1078
+     *
1079
+     * @param mixed $calendarId
1080
+     * @param string $objectUri
1081
+     * @param string $calendarData
1082
+     * @param int $calendarType
1083
+     * @return string
1084
+     */
1085
+    public function createCalendarObject($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1086
+        $extraData = $this->getDenormalizedData($calendarData);
1087
+
1088
+        $q = $this->db->getQueryBuilder();
1089
+        $q->select($q->func()->count('*'))
1090
+            ->from('calendarobjects')
1091
+            ->where($q->expr()->eq('calendarid', $q->createNamedParameter($calendarId)))
1092
+            ->andWhere($q->expr()->eq('uid', $q->createNamedParameter($extraData['uid'])))
1093
+            ->andWhere($q->expr()->eq('calendartype', $q->createNamedParameter($calendarType)));
1094
+
1095
+        $result = $q->execute();
1096
+        $count = (int) $result->fetchColumn();
1097
+        $result->closeCursor();
1098
+
1099
+        if ($count !== 0) {
1100
+            throw new \Sabre\DAV\Exception\BadRequest('Calendar object with uid already exists in this calendar collection.');
1101
+        }
1102
+
1103
+        $query = $this->db->getQueryBuilder();
1104
+        $query->insert('calendarobjects')
1105
+            ->values([
1106
+                'calendarid' => $query->createNamedParameter($calendarId),
1107
+                'uri' => $query->createNamedParameter($objectUri),
1108
+                'calendardata' => $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB),
1109
+                'lastmodified' => $query->createNamedParameter(time()),
1110
+                'etag' => $query->createNamedParameter($extraData['etag']),
1111
+                'size' => $query->createNamedParameter($extraData['size']),
1112
+                'componenttype' => $query->createNamedParameter($extraData['componentType']),
1113
+                'firstoccurence' => $query->createNamedParameter($extraData['firstOccurence']),
1114
+                'lastoccurence' => $query->createNamedParameter($extraData['lastOccurence']),
1115
+                'classification' => $query->createNamedParameter($extraData['classification']),
1116
+                'uid' => $query->createNamedParameter($extraData['uid']),
1117
+                'calendartype' => $query->createNamedParameter($calendarType),
1118
+            ])
1119
+            ->execute();
1120
+
1121
+        $this->updateProperties($calendarId, $objectUri, $calendarData, $calendarType);
1122
+        $this->addChange($calendarId, $objectUri, 1, $calendarType);
1123
+
1124
+        $objectRow = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1125
+        if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1126
+            $calendarRow = $this->getCalendarById($calendarId);
1127
+            $shares = $this->getShares($calendarId);
1128
+
1129
+            $this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
1130
+            $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent(
1131
+                '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject',
1132
+                [
1133
+                    'calendarId' => $calendarId,
1134
+                    'calendarData' => $calendarRow,
1135
+                    'shares' => $shares,
1136
+                    'objectData' => $objectRow,
1137
+                ]
1138
+            ));
1139
+        } else {
1140
+            $subscriptionRow = $this->getSubscriptionById($calendarId);
1141
+
1142
+            $this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
1143
+            $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject', new GenericEvent(
1144
+                '\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject',
1145
+                [
1146
+                    'subscriptionId' => $calendarId,
1147
+                    'calendarData' => $subscriptionRow,
1148
+                    'shares' => [],
1149
+                    'objectData' => $objectRow,
1150
+                ]
1151
+            ));
1152
+        }
1153
+
1154
+        return '"' . $extraData['etag'] . '"';
1155
+    }
1156
+
1157
+    /**
1158
+     * Updates an existing calendarobject, based on it's uri.
1159
+     *
1160
+     * The object uri is only the basename, or filename and not a full path.
1161
+     *
1162
+     * It is possible return an etag from this function, which will be used in
1163
+     * the response to this PUT request. Note that the ETag must be surrounded
1164
+     * by double-quotes.
1165
+     *
1166
+     * However, you should only really return this ETag if you don't mangle the
1167
+     * calendar-data. If the result of a subsequent GET to this object is not
1168
+     * the exact same as this request body, you should omit the ETag.
1169
+     *
1170
+     * @param mixed $calendarId
1171
+     * @param string $objectUri
1172
+     * @param string $calendarData
1173
+     * @param int $calendarType
1174
+     * @return string
1175
+     */
1176
+    public function updateCalendarObject($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1177
+        $extraData = $this->getDenormalizedData($calendarData);
1178
+        $query = $this->db->getQueryBuilder();
1179
+        $query->update('calendarobjects')
1180
+                ->set('calendardata', $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB))
1181
+                ->set('lastmodified', $query->createNamedParameter(time()))
1182
+                ->set('etag', $query->createNamedParameter($extraData['etag']))
1183
+                ->set('size', $query->createNamedParameter($extraData['size']))
1184
+                ->set('componenttype', $query->createNamedParameter($extraData['componentType']))
1185
+                ->set('firstoccurence', $query->createNamedParameter($extraData['firstOccurence']))
1186
+                ->set('lastoccurence', $query->createNamedParameter($extraData['lastOccurence']))
1187
+                ->set('classification', $query->createNamedParameter($extraData['classification']))
1188
+                ->set('uid', $query->createNamedParameter($extraData['uid']))
1189
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
1190
+            ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
1191
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)))
1192
+            ->execute();
1193
+
1194
+        $this->updateProperties($calendarId, $objectUri, $calendarData, $calendarType);
1195
+        $this->addChange($calendarId, $objectUri, 2, $calendarType);
1196
+
1197
+        $objectRow = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1198
+        if (is_array($objectRow)) {
1199
+            if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1200
+                $calendarRow = $this->getCalendarById($calendarId);
1201
+                $shares = $this->getShares($calendarId);
1202
+
1203
+                $this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
1204
+                $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent(
1205
+                    '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject',
1206
+                    [
1207
+                        'calendarId' => $calendarId,
1208
+                        'calendarData' => $calendarRow,
1209
+                        'shares' => $shares,
1210
+                        'objectData' => $objectRow,
1211
+                    ]
1212
+                ));
1213
+            } else {
1214
+                $subscriptionRow = $this->getSubscriptionById($calendarId);
1215
+
1216
+                $this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
1217
+                $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject', new GenericEvent(
1218
+                    '\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject',
1219
+                    [
1220
+                        'subscriptionId' => $calendarId,
1221
+                        'calendarData' => $subscriptionRow,
1222
+                        'shares' => [],
1223
+                        'objectData' => $objectRow,
1224
+                    ]
1225
+                ));
1226
+            }
1227
+        }
1228
+
1229
+        return '"' . $extraData['etag'] . '"';
1230
+    }
1231
+
1232
+    /**
1233
+     * @param int $calendarObjectId
1234
+     * @param int $classification
1235
+     */
1236
+    public function setClassification($calendarObjectId, $classification) {
1237
+        if (!in_array($classification, [
1238
+            self::CLASSIFICATION_PUBLIC, self::CLASSIFICATION_PRIVATE, self::CLASSIFICATION_CONFIDENTIAL
1239
+        ])) {
1240
+            throw new \InvalidArgumentException();
1241
+        }
1242
+        $query = $this->db->getQueryBuilder();
1243
+        $query->update('calendarobjects')
1244
+            ->set('classification', $query->createNamedParameter($classification))
1245
+            ->where($query->expr()->eq('id', $query->createNamedParameter($calendarObjectId)))
1246
+            ->execute();
1247
+    }
1248
+
1249
+    /**
1250
+     * Deletes an existing calendar object.
1251
+     *
1252
+     * The object uri is only the basename, or filename and not a full path.
1253
+     *
1254
+     * @param mixed $calendarId
1255
+     * @param string $objectUri
1256
+     * @param int $calendarType
1257
+     * @return void
1258
+     */
1259
+    public function deleteCalendarObject($calendarId, $objectUri, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1260
+        $data = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1261
+        if (is_array($data)) {
1262
+            if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1263
+                $calendarRow = $this->getCalendarById($calendarId);
1264
+                $shares = $this->getShares($calendarId);
1265
+
1266
+                $this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int)$calendarId, $calendarRow, $shares, $data));
1267
+                $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent(
1268
+                    '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject',
1269
+                    [
1270
+                        'calendarId' => $calendarId,
1271
+                        'calendarData' => $calendarRow,
1272
+                        'shares' => $shares,
1273
+                        'objectData' => $data,
1274
+                    ]
1275
+                ));
1276
+            } else {
1277
+                $subscriptionRow = $this->getSubscriptionById($calendarId);
1278
+
1279
+                $this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent((int)$calendarId, $subscriptionRow, [], $data));
1280
+                $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject', new GenericEvent(
1281
+                    '\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject',
1282
+                    [
1283
+                        'subscriptionId' => $calendarId,
1284
+                        'calendarData' => $subscriptionRow,
1285
+                        'shares' => [],
1286
+                        'objectData' => $data,
1287
+                    ]
1288
+                ));
1289
+            }
1290
+        }
1291
+
1292
+        $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `uri` = ? AND `calendartype` = ?');
1293
+        $stmt->execute([$calendarId, $objectUri, $calendarType]);
1294
+
1295
+        if (is_array($data)) {
1296
+            $this->purgeProperties($calendarId, $data['id'], $calendarType);
1297
+        }
1298
+
1299
+        $this->addChange($calendarId, $objectUri, 3, $calendarType);
1300
+    }
1301
+
1302
+    /**
1303
+     * Performs a calendar-query on the contents of this calendar.
1304
+     *
1305
+     * The calendar-query is defined in RFC4791 : CalDAV. Using the
1306
+     * calendar-query it is possible for a client to request a specific set of
1307
+     * object, based on contents of iCalendar properties, date-ranges and
1308
+     * iCalendar component types (VTODO, VEVENT).
1309
+     *
1310
+     * This method should just return a list of (relative) urls that match this
1311
+     * query.
1312
+     *
1313
+     * The list of filters are specified as an array. The exact array is
1314
+     * documented by Sabre\CalDAV\CalendarQueryParser.
1315
+     *
1316
+     * Note that it is extremely likely that getCalendarObject for every path
1317
+     * returned from this method will be called almost immediately after. You
1318
+     * may want to anticipate this to speed up these requests.
1319
+     *
1320
+     * This method provides a default implementation, which parses *all* the
1321
+     * iCalendar objects in the specified calendar.
1322
+     *
1323
+     * This default may well be good enough for personal use, and calendars
1324
+     * that aren't very large. But if you anticipate high usage, big calendars
1325
+     * or high loads, you are strongly advised to optimize certain paths.
1326
+     *
1327
+     * The best way to do so is override this method and to optimize
1328
+     * specifically for 'common filters'.
1329
+     *
1330
+     * Requests that are extremely common are:
1331
+     *   * requests for just VEVENTS
1332
+     *   * requests for just VTODO
1333
+     *   * requests with a time-range-filter on either VEVENT or VTODO.
1334
+     *
1335
+     * ..and combinations of these requests. It may not be worth it to try to
1336
+     * handle every possible situation and just rely on the (relatively
1337
+     * easy to use) CalendarQueryValidator to handle the rest.
1338
+     *
1339
+     * Note that especially time-range-filters may be difficult to parse. A
1340
+     * time-range filter specified on a VEVENT must for instance also handle
1341
+     * recurrence rules correctly.
1342
+     * A good example of how to interprete all these filters can also simply
1343
+     * be found in Sabre\CalDAV\CalendarQueryFilter. This class is as correct
1344
+     * as possible, so it gives you a good idea on what type of stuff you need
1345
+     * to think of.
1346
+     *
1347
+     * @param mixed $calendarId
1348
+     * @param array $filters
1349
+     * @param int $calendarType
1350
+     * @return array
1351
+     */
1352
+    public function calendarQuery($calendarId, array $filters, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
1353
+        $componentType = null;
1354
+        $requirePostFilter = true;
1355
+        $timeRange = null;
1356
+
1357
+        // if no filters were specified, we don't need to filter after a query
1358
+        if (!$filters['prop-filters'] && !$filters['comp-filters']) {
1359
+            $requirePostFilter = false;
1360
+        }
1361
+
1362
+        // Figuring out if there's a component filter
1363
+        if (count($filters['comp-filters']) > 0 && !$filters['comp-filters'][0]['is-not-defined']) {
1364
+            $componentType = $filters['comp-filters'][0]['name'];
1365
+
1366
+            // Checking if we need post-filters
1367
+            if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['time-range'] && !$filters['comp-filters'][0]['prop-filters']) {
1368
+                $requirePostFilter = false;
1369
+            }
1370
+            // There was a time-range filter
1371
+            if ($componentType === 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) {
1372
+                $timeRange = $filters['comp-filters'][0]['time-range'];
1373
+
1374
+                // If start time OR the end time is not specified, we can do a
1375
+                // 100% accurate mysql query.
1376
+                if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['prop-filters'] && (!$timeRange['start'] || !$timeRange['end'])) {
1377
+                    $requirePostFilter = false;
1378
+                }
1379
+            }
1380
+        }
1381
+        $columns = ['uri'];
1382
+        if ($requirePostFilter) {
1383
+            $columns = ['uri', 'calendardata'];
1384
+        }
1385
+        $query = $this->db->getQueryBuilder();
1386
+        $query->select($columns)
1387
+            ->from('calendarobjects')
1388
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
1389
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
1390
+
1391
+        if ($componentType) {
1392
+            $query->andWhere($query->expr()->eq('componenttype', $query->createNamedParameter($componentType)));
1393
+        }
1394
+
1395
+        if ($timeRange && $timeRange['start']) {
1396
+            $query->andWhere($query->expr()->gt('lastoccurence', $query->createNamedParameter($timeRange['start']->getTimeStamp())));
1397
+        }
1398
+        if ($timeRange && $timeRange['end']) {
1399
+            $query->andWhere($query->expr()->lt('firstoccurence', $query->createNamedParameter($timeRange['end']->getTimeStamp())));
1400
+        }
1401
+
1402
+        $stmt = $query->execute();
1403
+
1404
+        $result = [];
1405
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1406
+            if ($requirePostFilter) {
1407
+                // validateFilterForObject will parse the calendar data
1408
+                // catch parsing errors
1409
+                try {
1410
+                    $matches = $this->validateFilterForObject($row, $filters);
1411
+                } catch (ParseException $ex) {
1412
+                    $this->logger->logException($ex, [
1413
+                        'app' => 'dav',
1414
+                        'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri']
1415
+                    ]);
1416
+                    continue;
1417
+                } catch (InvalidDataException $ex) {
1418
+                    $this->logger->logException($ex, [
1419
+                        'app' => 'dav',
1420
+                        'message' => 'Caught invalid data exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri']
1421
+                    ]);
1422
+                    continue;
1423
+                }
1424
+
1425
+                if (!$matches) {
1426
+                    continue;
1427
+                }
1428
+            }
1429
+            $result[] = $row['uri'];
1430
+        }
1431
+
1432
+        return $result;
1433
+    }
1434
+
1435
+    /**
1436
+     * custom Nextcloud search extension for CalDAV
1437
+     *
1438
+     * TODO - this should optionally cover cached calendar objects as well
1439
+     *
1440
+     * @param string $principalUri
1441
+     * @param array $filters
1442
+     * @param integer|null $limit
1443
+     * @param integer|null $offset
1444
+     * @return array
1445
+     */
1446
+    public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1447
+        $calendars = $this->getCalendarsForUser($principalUri);
1448
+        $ownCalendars = [];
1449
+        $sharedCalendars = [];
1450
+
1451
+        $uriMapper = [];
1452
+
1453
+        foreach ($calendars as $calendar) {
1454
+            if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
1455
+                $ownCalendars[] = $calendar['id'];
1456
+            } else {
1457
+                $sharedCalendars[] = $calendar['id'];
1458
+            }
1459
+            $uriMapper[$calendar['id']] = $calendar['uri'];
1460
+        }
1461
+        if (count($ownCalendars) === 0 && count($sharedCalendars) === 0) {
1462
+            return [];
1463
+        }
1464
+
1465
+        $query = $this->db->getQueryBuilder();
1466
+        // Calendar id expressions
1467
+        $calendarExpressions = [];
1468
+        foreach ($ownCalendars as $id) {
1469
+            $calendarExpressions[] = $query->expr()->andX(
1470
+                $query->expr()->eq('c.calendarid',
1471
+                    $query->createNamedParameter($id)),
1472
+                $query->expr()->eq('c.calendartype',
1473
+                        $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1474
+        }
1475
+        foreach ($sharedCalendars as $id) {
1476
+            $calendarExpressions[] = $query->expr()->andX(
1477
+                $query->expr()->eq('c.calendarid',
1478
+                    $query->createNamedParameter($id)),
1479
+                $query->expr()->eq('c.classification',
1480
+                    $query->createNamedParameter(self::CLASSIFICATION_PUBLIC)),
1481
+                $query->expr()->eq('c.calendartype',
1482
+                    $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1483
+        }
1484
+
1485
+        if (count($calendarExpressions) === 1) {
1486
+            $calExpr = $calendarExpressions[0];
1487
+        } else {
1488
+            $calExpr = call_user_func_array([$query->expr(), 'orX'], $calendarExpressions);
1489
+        }
1490
+
1491
+        // Component expressions
1492
+        $compExpressions = [];
1493
+        foreach ($filters['comps'] as $comp) {
1494
+            $compExpressions[] = $query->expr()
1495
+                ->eq('c.componenttype', $query->createNamedParameter($comp));
1496
+        }
1497
+
1498
+        if (count($compExpressions) === 1) {
1499
+            $compExpr = $compExpressions[0];
1500
+        } else {
1501
+            $compExpr = call_user_func_array([$query->expr(), 'orX'], $compExpressions);
1502
+        }
1503
+
1504
+        if (!isset($filters['props'])) {
1505
+            $filters['props'] = [];
1506
+        }
1507
+        if (!isset($filters['params'])) {
1508
+            $filters['params'] = [];
1509
+        }
1510
+
1511
+        $propParamExpressions = [];
1512
+        foreach ($filters['props'] as $prop) {
1513
+            $propParamExpressions[] = $query->expr()->andX(
1514
+                $query->expr()->eq('i.name', $query->createNamedParameter($prop)),
1515
+                $query->expr()->isNull('i.parameter')
1516
+            );
1517
+        }
1518
+        foreach ($filters['params'] as $param) {
1519
+            $propParamExpressions[] = $query->expr()->andX(
1520
+                $query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
1521
+                $query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
1522
+            );
1523
+        }
1524
+
1525
+        if (count($propParamExpressions) === 1) {
1526
+            $propParamExpr = $propParamExpressions[0];
1527
+        } else {
1528
+            $propParamExpr = call_user_func_array([$query->expr(), 'orX'], $propParamExpressions);
1529
+        }
1530
+
1531
+        $query->select(['c.calendarid', 'c.uri'])
1532
+            ->from($this->dbObjectPropertiesTable, 'i')
1533
+            ->join('i', 'calendarobjects', 'c', $query->expr()->eq('i.objectid', 'c.id'))
1534
+            ->where($calExpr)
1535
+            ->andWhere($compExpr)
1536
+            ->andWhere($propParamExpr)
1537
+            ->andWhere($query->expr()->iLike('i.value',
1538
+                $query->createNamedParameter('%'.$this->db->escapeLikeParameter($filters['search-term']).'%')));
1539
+
1540
+        if ($offset) {
1541
+            $query->setFirstResult($offset);
1542
+        }
1543
+        if ($limit) {
1544
+            $query->setMaxResults($limit);
1545
+        }
1546
+
1547
+        $stmt = $query->execute();
1548
+
1549
+        $result = [];
1550
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1551
+            $path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1552
+            if (!in_array($path, $result)) {
1553
+                $result[] = $path;
1554
+            }
1555
+        }
1556
+
1557
+        return $result;
1558
+    }
1559
+
1560
+    /**
1561
+     * used for Nextcloud's calendar API
1562
+     *
1563
+     * @param array $calendarInfo
1564
+     * @param string $pattern
1565
+     * @param array $searchProperties
1566
+     * @param array $options
1567
+     * @param integer|null $limit
1568
+     * @param integer|null $offset
1569
+     *
1570
+     * @return array
1571
+     */
1572
+    public function search(array $calendarInfo, $pattern, array $searchProperties,
1573
+                            array $options, $limit, $offset) {
1574
+        $outerQuery = $this->db->getQueryBuilder();
1575
+        $innerQuery = $this->db->getQueryBuilder();
1576
+
1577
+        $innerQuery->selectDistinct('op.objectid')
1578
+            ->from($this->dbObjectPropertiesTable, 'op')
1579
+            ->andWhere($innerQuery->expr()->eq('op.calendarid',
1580
+                $outerQuery->createNamedParameter($calendarInfo['id'])))
1581
+            ->andWhere($innerQuery->expr()->eq('op.calendartype',
1582
+                $outerQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1583
+
1584
+        // only return public items for shared calendars for now
1585
+        if ($calendarInfo['principaluri'] !== $calendarInfo['{http://owncloud.org/ns}owner-principal']) {
1586
+            $innerQuery->andWhere($innerQuery->expr()->eq('c.classification',
1587
+                $outerQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
1588
+        }
1589
+
1590
+        $or = $innerQuery->expr()->orX();
1591
+        foreach ($searchProperties as $searchProperty) {
1592
+            $or->add($innerQuery->expr()->eq('op.name',
1593
+                $outerQuery->createNamedParameter($searchProperty)));
1594
+        }
1595
+        $innerQuery->andWhere($or);
1596
+
1597
+        if ($pattern !== '') {
1598
+            $innerQuery->andWhere($innerQuery->expr()->iLike('op.value',
1599
+                $outerQuery->createNamedParameter('%' .
1600
+                    $this->db->escapeLikeParameter($pattern) . '%')));
1601
+        }
1602
+
1603
+        $outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri')
1604
+            ->from('calendarobjects', 'c');
1605
+
1606
+        if (isset($options['timerange'])) {
1607
+            if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTime) {
1608
+                $outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence',
1609
+                    $outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp())));
1610
+            }
1611
+            if (isset($options['timerange']['end']) && $options['timerange']['end'] instanceof DateTime) {
1612
+                $outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence',
1613
+                    $outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp())));
1614
+            }
1615
+        }
1616
+
1617
+        if (isset($options['types'])) {
1618
+            $or = $outerQuery->expr()->orX();
1619
+            foreach ($options['types'] as $type) {
1620
+                $or->add($outerQuery->expr()->eq('componenttype',
1621
+                    $outerQuery->createNamedParameter($type)));
1622
+            }
1623
+            $outerQuery->andWhere($or);
1624
+        }
1625
+
1626
+        $outerQuery->andWhere($outerQuery->expr()->in('c.id',
1627
+            $outerQuery->createFunction($innerQuery->getSQL())));
1628
+
1629
+        if ($offset) {
1630
+            $outerQuery->setFirstResult($offset);
1631
+        }
1632
+        if ($limit) {
1633
+            $outerQuery->setMaxResults($limit);
1634
+        }
1635
+
1636
+        $result = $outerQuery->execute();
1637
+        $calendarObjects = $result->fetchAll();
1638
+
1639
+        return array_map(function ($o) {
1640
+            $calendarData = Reader::read($o['calendardata']);
1641
+            $comps = $calendarData->getComponents();
1642
+            $objects = [];
1643
+            $timezones = [];
1644
+            foreach ($comps as $comp) {
1645
+                if ($comp instanceof VTimeZone) {
1646
+                    $timezones[] = $comp;
1647
+                } else {
1648
+                    $objects[] = $comp;
1649
+                }
1650
+            }
1651
+
1652
+            return [
1653
+                'id' => $o['id'],
1654
+                'type' => $o['componenttype'],
1655
+                'uid' => $o['uid'],
1656
+                'uri' => $o['uri'],
1657
+                'objects' => array_map(function ($c) {
1658
+                    return $this->transformSearchData($c);
1659
+                }, $objects),
1660
+                'timezones' => array_map(function ($c) {
1661
+                    return $this->transformSearchData($c);
1662
+                }, $timezones),
1663
+            ];
1664
+        }, $calendarObjects);
1665
+    }
1666
+
1667
+    /**
1668
+     * @param Component $comp
1669
+     * @return array
1670
+     */
1671
+    private function transformSearchData(Component $comp) {
1672
+        $data = [];
1673
+        /** @var Component[] $subComponents */
1674
+        $subComponents = $comp->getComponents();
1675
+        /** @var Property[] $properties */
1676
+        $properties = array_filter($comp->children(), function ($c) {
1677
+            return $c instanceof Property;
1678
+        });
1679
+        $validationRules = $comp->getValidationRules();
1680
+
1681
+        foreach ($subComponents as $subComponent) {
1682
+            $name = $subComponent->name;
1683
+            if (!isset($data[$name])) {
1684
+                $data[$name] = [];
1685
+            }
1686
+            $data[$name][] = $this->transformSearchData($subComponent);
1687
+        }
1688
+
1689
+        foreach ($properties as $property) {
1690
+            $name = $property->name;
1691
+            if (!isset($validationRules[$name])) {
1692
+                $validationRules[$name] = '*';
1693
+            }
1694
+
1695
+            $rule = $validationRules[$property->name];
1696
+            if ($rule === '+' || $rule === '*') { // multiple
1697
+                if (!isset($data[$name])) {
1698
+                    $data[$name] = [];
1699
+                }
1700
+
1701
+                $data[$name][] = $this->transformSearchProperty($property);
1702
+            } else { // once
1703
+                $data[$name] = $this->transformSearchProperty($property);
1704
+            }
1705
+        }
1706
+
1707
+        return $data;
1708
+    }
1709
+
1710
+    /**
1711
+     * @param Property $prop
1712
+     * @return array
1713
+     */
1714
+    private function transformSearchProperty(Property $prop) {
1715
+        // No need to check Date, as it extends DateTime
1716
+        if ($prop instanceof Property\ICalendar\DateTime) {
1717
+            $value = $prop->getDateTime();
1718
+        } else {
1719
+            $value = $prop->getValue();
1720
+        }
1721
+
1722
+        return [
1723
+            $value,
1724
+            $prop->parameters()
1725
+        ];
1726
+    }
1727
+
1728
+    /**
1729
+     * @param string $principalUri
1730
+     * @param string $pattern
1731
+     * @param array $componentTypes
1732
+     * @param array $searchProperties
1733
+     * @param array $searchParameters
1734
+     * @param array $options
1735
+     * @return array
1736
+     */
1737
+    public function searchPrincipalUri(string $principalUri,
1738
+                                        string $pattern,
1739
+                                        array $componentTypes,
1740
+                                        array $searchProperties,
1741
+                                        array $searchParameters,
1742
+                                        array $options = []): array {
1743
+        $escapePattern = !\array_key_exists('escape_like_param', $options) || $options['escape_like_param'] !== false;
1744
+
1745
+        $calendarObjectIdQuery = $this->db->getQueryBuilder();
1746
+        $calendarOr = $calendarObjectIdQuery->expr()->orX();
1747
+        $searchOr = $calendarObjectIdQuery->expr()->orX();
1748
+
1749
+        // Fetch calendars and subscription
1750
+        $calendars = $this->getCalendarsForUser($principalUri);
1751
+        $subscriptions = $this->getSubscriptionsForUser($principalUri);
1752
+        foreach ($calendars as $calendar) {
1753
+            $calendarAnd = $calendarObjectIdQuery->expr()->andX();
1754
+            $calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$calendar['id'])));
1755
+            $calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1756
+
1757
+            // If it's shared, limit search to public events
1758
+            if ($calendar['principaluri'] !== $calendar['{http://owncloud.org/ns}owner-principal']) {
1759
+                $calendarAnd->add($calendarObjectIdQuery->expr()->eq('co.classification', $calendarObjectIdQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
1760
+            }
1761
+
1762
+            $calendarOr->add($calendarAnd);
1763
+        }
1764
+        foreach ($subscriptions as $subscription) {
1765
+            $subscriptionAnd = $calendarObjectIdQuery->expr()->andX();
1766
+            $subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$subscription['id'])));
1767
+            $subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)));
1768
+
1769
+            // If it's shared, limit search to public events
1770
+            if ($subscription['principaluri'] !== $subscription['{http://owncloud.org/ns}owner-principal']) {
1771
+                $subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('co.classification', $calendarObjectIdQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
1772
+            }
1773
+
1774
+            $calendarOr->add($subscriptionAnd);
1775
+        }
1776
+
1777
+        foreach ($searchProperties as $property) {
1778
+            $propertyAnd = $calendarObjectIdQuery->expr()->andX();
1779
+            $propertyAnd->add($calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)));
1780
+            $propertyAnd->add($calendarObjectIdQuery->expr()->isNull('cob.parameter'));
1781
+
1782
+            $searchOr->add($propertyAnd);
1783
+        }
1784
+        foreach ($searchParameters as $property => $parameter) {
1785
+            $parameterAnd = $calendarObjectIdQuery->expr()->andX();
1786
+            $parameterAnd->add($calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)));
1787
+            $parameterAnd->add($calendarObjectIdQuery->expr()->eq('cob.parameter', $calendarObjectIdQuery->createNamedParameter($parameter, IQueryBuilder::PARAM_STR)));
1788
+
1789
+            $searchOr->add($parameterAnd);
1790
+        }
1791
+
1792
+        if ($calendarOr->count() === 0) {
1793
+            return [];
1794
+        }
1795
+        if ($searchOr->count() === 0) {
1796
+            return [];
1797
+        }
1798
+
1799
+        $calendarObjectIdQuery->selectDistinct('cob.objectid')
1800
+            ->from($this->dbObjectPropertiesTable, 'cob')
1801
+            ->leftJoin('cob', 'calendarobjects', 'co', $calendarObjectIdQuery->expr()->eq('co.id', 'cob.objectid'))
1802
+            ->andWhere($calendarObjectIdQuery->expr()->in('co.componenttype', $calendarObjectIdQuery->createNamedParameter($componentTypes, IQueryBuilder::PARAM_STR_ARRAY)))
1803
+            ->andWhere($calendarOr)
1804
+            ->andWhere($searchOr);
1805
+
1806
+        if ('' !== $pattern) {
1807
+            if (!$escapePattern) {
1808
+                $calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter($pattern)));
1809
+            } else {
1810
+                $calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1811
+            }
1812
+        }
1813
+
1814
+        if (isset($options['limit'])) {
1815
+            $calendarObjectIdQuery->setMaxResults($options['limit']);
1816
+        }
1817
+        if (isset($options['offset'])) {
1818
+            $calendarObjectIdQuery->setFirstResult($options['offset']);
1819
+        }
1820
+
1821
+        $result = $calendarObjectIdQuery->execute();
1822
+        $matches = $result->fetchAll();
1823
+        $result->closeCursor();
1824
+        $matches = array_map(static function (array $match):int {
1825
+            return (int) $match['objectid'];
1826
+        }, $matches);
1827
+
1828
+        $query = $this->db->getQueryBuilder();
1829
+        $query->select('calendardata', 'uri', 'calendarid', 'calendartype')
1830
+            ->from('calendarobjects')
1831
+            ->where($query->expr()->in('id', $query->createNamedParameter($matches, IQueryBuilder::PARAM_INT_ARRAY)));
1832
+
1833
+        $result = $query->execute();
1834
+        $calendarObjects = $result->fetchAll();
1835
+        $result->closeCursor();
1836
+
1837
+        return array_map(function (array $array): array {
1838
+            $array['calendarid'] = (int)$array['calendarid'];
1839
+            $array['calendartype'] = (int)$array['calendartype'];
1840
+            $array['calendardata'] = $this->readBlob($array['calendardata']);
1841
+
1842
+            return $array;
1843
+        }, $calendarObjects);
1844
+    }
1845
+
1846
+    /**
1847
+     * Searches through all of a users calendars and calendar objects to find
1848
+     * an object with a specific UID.
1849
+     *
1850
+     * This method should return the path to this object, relative to the
1851
+     * calendar home, so this path usually only contains two parts:
1852
+     *
1853
+     * calendarpath/objectpath.ics
1854
+     *
1855
+     * If the uid is not found, return null.
1856
+     *
1857
+     * This method should only consider * objects that the principal owns, so
1858
+     * any calendars owned by other principals that also appear in this
1859
+     * collection should be ignored.
1860
+     *
1861
+     * @param string $principalUri
1862
+     * @param string $uid
1863
+     * @return string|null
1864
+     */
1865
+    public function getCalendarObjectByUID($principalUri, $uid) {
1866
+        $query = $this->db->getQueryBuilder();
1867
+        $query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi')
1868
+            ->from('calendarobjects', 'co')
1869
+            ->leftJoin('co', 'calendars', 'c', $query->expr()->eq('co.calendarid', 'c.id'))
1870
+            ->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri)))
1871
+            ->andWhere($query->expr()->eq('co.uid', $query->createNamedParameter($uid)));
1872
+
1873
+        $stmt = $query->execute();
1874
+
1875
+        if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1876
+            return $row['calendaruri'] . '/' . $row['objecturi'];
1877
+        }
1878
+
1879
+        return null;
1880
+    }
1881
+
1882
+    /**
1883
+     * The getChanges method returns all the changes that have happened, since
1884
+     * the specified syncToken in the specified calendar.
1885
+     *
1886
+     * This function should return an array, such as the following:
1887
+     *
1888
+     * [
1889
+     *   'syncToken' => 'The current synctoken',
1890
+     *   'added'   => [
1891
+     *      'new.txt',
1892
+     *   ],
1893
+     *   'modified'   => [
1894
+     *      'modified.txt',
1895
+     *   ],
1896
+     *   'deleted' => [
1897
+     *      'foo.php.bak',
1898
+     *      'old.txt'
1899
+     *   ]
1900
+     * );
1901
+     *
1902
+     * The returned syncToken property should reflect the *current* syncToken
1903
+     * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
1904
+     * property This is * needed here too, to ensure the operation is atomic.
1905
+     *
1906
+     * If the $syncToken argument is specified as null, this is an initial
1907
+     * sync, and all members should be reported.
1908
+     *
1909
+     * The modified property is an array of nodenames that have changed since
1910
+     * the last token.
1911
+     *
1912
+     * The deleted property is an array with nodenames, that have been deleted
1913
+     * from collection.
1914
+     *
1915
+     * The $syncLevel argument is basically the 'depth' of the report. If it's
1916
+     * 1, you only have to report changes that happened only directly in
1917
+     * immediate descendants. If it's 2, it should also include changes from
1918
+     * the nodes below the child collections. (grandchildren)
1919
+     *
1920
+     * The $limit argument allows a client to specify how many results should
1921
+     * be returned at most. If the limit is not specified, it should be treated
1922
+     * as infinite.
1923
+     *
1924
+     * If the limit (infinite or not) is higher than you're willing to return,
1925
+     * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
1926
+     *
1927
+     * If the syncToken is expired (due to data cleanup) or unknown, you must
1928
+     * return null.
1929
+     *
1930
+     * The limit is 'suggestive'. You are free to ignore it.
1931
+     *
1932
+     * @param string $calendarId
1933
+     * @param string $syncToken
1934
+     * @param int $syncLevel
1935
+     * @param int $limit
1936
+     * @param int $calendarType
1937
+     * @return array
1938
+     */
1939
+    public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1940
+        // Current synctoken
1941
+        $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1942
+        $stmt->execute([ $calendarId ]);
1943
+        $currentToken = $stmt->fetchColumn(0);
1944
+
1945
+        if (is_null($currentToken)) {
1946
+            return null;
1947
+        }
1948
+
1949
+        $result = [
1950
+            'syncToken' => $currentToken,
1951
+            'added'     => [],
1952
+            'modified'  => [],
1953
+            'deleted'   => [],
1954
+        ];
1955
+
1956
+        if ($syncToken) {
1957
+            $query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? AND `calendartype` = ? ORDER BY `synctoken`";
1958
+            if ($limit>0) {
1959
+                $query.= " LIMIT " . (int)$limit;
1960
+            }
1961
+
1962
+            // Fetching all changes
1963
+            $stmt = $this->db->prepare($query);
1964
+            $stmt->execute([$syncToken, $currentToken, $calendarId, $calendarType]);
1965
+
1966
+            $changes = [];
1967
+
1968
+            // This loop ensures that any duplicates are overwritten, only the
1969
+            // last change on a node is relevant.
1970
+            while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1971
+                $changes[$row['uri']] = $row['operation'];
1972
+            }
1973
+
1974
+            foreach ($changes as $uri => $operation) {
1975
+                switch ($operation) {
1976
+                    case 1:
1977
+                        $result['added'][] = $uri;
1978
+                        break;
1979
+                    case 2:
1980
+                        $result['modified'][] = $uri;
1981
+                        break;
1982
+                    case 3:
1983
+                        $result['deleted'][] = $uri;
1984
+                        break;
1985
+                }
1986
+            }
1987
+        } else {
1988
+            // No synctoken supplied, this is the initial sync.
1989
+            $query = "SELECT `uri` FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `calendartype` = ?";
1990
+            $stmt = $this->db->prepare($query);
1991
+            $stmt->execute([$calendarId, $calendarType]);
1992
+
1993
+            $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
1994
+        }
1995
+        return $result;
1996
+    }
1997
+
1998
+    /**
1999
+     * Returns a list of subscriptions for a principal.
2000
+     *
2001
+     * Every subscription is an array with the following keys:
2002
+     *  * id, a unique id that will be used by other functions to modify the
2003
+     *    subscription. This can be the same as the uri or a database key.
2004
+     *  * uri. This is just the 'base uri' or 'filename' of the subscription.
2005
+     *  * principaluri. The owner of the subscription. Almost always the same as
2006
+     *    principalUri passed to this method.
2007
+     *
2008
+     * Furthermore, all the subscription info must be returned too:
2009
+     *
2010
+     * 1. {DAV:}displayname
2011
+     * 2. {http://apple.com/ns/ical/}refreshrate
2012
+     * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos
2013
+     *    should not be stripped).
2014
+     * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms
2015
+     *    should not be stripped).
2016
+     * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if
2017
+     *    attachments should not be stripped).
2018
+     * 6. {http://calendarserver.org/ns/}source (Must be a
2019
+     *     Sabre\DAV\Property\Href).
2020
+     * 7. {http://apple.com/ns/ical/}calendar-color
2021
+     * 8. {http://apple.com/ns/ical/}calendar-order
2022
+     * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
2023
+     *    (should just be an instance of
2024
+     *    Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of
2025
+     *    default components).
2026
+     *
2027
+     * @param string $principalUri
2028
+     * @return array
2029
+     */
2030
+    public function getSubscriptionsForUser($principalUri) {
2031
+        $fields = array_values($this->subscriptionPropertyMap);
2032
+        $fields[] = 'id';
2033
+        $fields[] = 'uri';
2034
+        $fields[] = 'source';
2035
+        $fields[] = 'principaluri';
2036
+        $fields[] = 'lastmodified';
2037
+        $fields[] = 'synctoken';
2038
+
2039
+        $query = $this->db->getQueryBuilder();
2040
+        $query->select($fields)
2041
+            ->from('calendarsubscriptions')
2042
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2043
+            ->orderBy('calendarorder', 'asc');
2044
+        $stmt =$query->execute();
2045
+
2046
+        $subscriptions = [];
2047
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
2048
+            $subscription = [
2049
+                'id'           => $row['id'],
2050
+                'uri'          => $row['uri'],
2051
+                'principaluri' => $row['principaluri'],
2052
+                'source'       => $row['source'],
2053
+                'lastmodified' => $row['lastmodified'],
2054
+
2055
+                '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
2056
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
2057
+            ];
2058
+
2059
+            foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
2060
+                if (!is_null($row[$dbName])) {
2061
+                    $subscription[$xmlName] = $row[$dbName];
2062
+                }
2063
+            }
2064
+
2065
+            $subscriptions[] = $subscription;
2066
+        }
2067
+
2068
+        return $subscriptions;
2069
+    }
2070
+
2071
+    /**
2072
+     * Creates a new subscription for a principal.
2073
+     *
2074
+     * If the creation was a success, an id must be returned that can be used to reference
2075
+     * this subscription in other methods, such as updateSubscription.
2076
+     *
2077
+     * @param string $principalUri
2078
+     * @param string $uri
2079
+     * @param array $properties
2080
+     * @return mixed
2081
+     */
2082
+    public function createSubscription($principalUri, $uri, array $properties) {
2083
+        if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
2084
+            throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
2085
+        }
2086
+
2087
+        $values = [
2088
+            'principaluri' => $principalUri,
2089
+            'uri'          => $uri,
2090
+            'source'       => $properties['{http://calendarserver.org/ns/}source']->getHref(),
2091
+            'lastmodified' => time(),
2092
+        ];
2093
+
2094
+        $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
2095
+
2096
+        foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
2097
+            if (array_key_exists($xmlName, $properties)) {
2098
+                $values[$dbName] = $properties[$xmlName];
2099
+                if (in_array($dbName, $propertiesBoolean)) {
2100
+                    $values[$dbName] = true;
2101
+                }
2102
+            }
2103
+        }
2104
+
2105
+        $valuesToInsert = [];
2106
+
2107
+        $query = $this->db->getQueryBuilder();
2108
+
2109
+        foreach (array_keys($values) as $name) {
2110
+            $valuesToInsert[$name] = $query->createNamedParameter($values[$name]);
2111
+        }
2112
+
2113
+        $query->insert('calendarsubscriptions')
2114
+            ->values($valuesToInsert)
2115
+            ->execute();
2116
+
2117
+        $subscriptionId = $this->db->lastInsertId('*PREFIX*calendarsubscriptions');
2118
+
2119
+        $subscriptionRow = $this->getSubscriptionById($subscriptionId);
2120
+        $this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent((int)$subscriptionId, $subscriptionRow));
2121
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createSubscription', new GenericEvent(
2122
+            '\OCA\DAV\CalDAV\CalDavBackend::createSubscription',
2123
+            [
2124
+                'subscriptionId' => $subscriptionId,
2125
+                'subscriptionData' => $subscriptionRow,
2126
+            ]));
2127
+
2128
+        return $subscriptionId;
2129
+    }
2130
+
2131
+    /**
2132
+     * Updates a subscription
2133
+     *
2134
+     * The list of mutations is stored in a Sabre\DAV\PropPatch object.
2135
+     * To do the actual updates, you must tell this object which properties
2136
+     * you're going to process with the handle() method.
2137
+     *
2138
+     * Calling the handle method is like telling the PropPatch object "I
2139
+     * promise I can handle updating this property".
2140
+     *
2141
+     * Read the PropPatch documentation for more info and examples.
2142
+     *
2143
+     * @param mixed $subscriptionId
2144
+     * @param PropPatch $propPatch
2145
+     * @return void
2146
+     */
2147
+    public function updateSubscription($subscriptionId, PropPatch $propPatch) {
2148
+        $supportedProperties = array_keys($this->subscriptionPropertyMap);
2149
+        $supportedProperties[] = '{http://calendarserver.org/ns/}source';
2150
+
2151
+        /**
2152
+         * @suppress SqlInjectionChecker
2153
+         */
2154
+        $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
2155
+            $newValues = [];
2156
+
2157
+            foreach ($mutations as $propertyName=>$propertyValue) {
2158
+                if ($propertyName === '{http://calendarserver.org/ns/}source') {
2159
+                    $newValues['source'] = $propertyValue->getHref();
2160
+                } else {
2161
+                    $fieldName = $this->subscriptionPropertyMap[$propertyName];
2162
+                    $newValues[$fieldName] = $propertyValue;
2163
+                }
2164
+            }
2165
+
2166
+            $query = $this->db->getQueryBuilder();
2167
+            $query->update('calendarsubscriptions')
2168
+                ->set('lastmodified', $query->createNamedParameter(time()));
2169
+            foreach ($newValues as $fieldName=>$value) {
2170
+                $query->set($fieldName, $query->createNamedParameter($value));
2171
+            }
2172
+            $query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
2173
+                ->execute();
2174
+
2175
+            $subscriptionRow = $this->getSubscriptionById($subscriptionId);
2176
+            $this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
2177
+            $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateSubscription', new GenericEvent(
2178
+                '\OCA\DAV\CalDAV\CalDavBackend::updateSubscription',
2179
+                [
2180
+                    'subscriptionId' => $subscriptionId,
2181
+                    'subscriptionData' => $subscriptionRow,
2182
+                    'propertyMutations' => $mutations,
2183
+                ]));
2184
+
2185
+            return true;
2186
+        });
2187
+    }
2188
+
2189
+    /**
2190
+     * Deletes a subscription.
2191
+     *
2192
+     * @param mixed $subscriptionId
2193
+     * @return void
2194
+     */
2195
+    public function deleteSubscription($subscriptionId) {
2196
+        $subscriptionRow = $this->getSubscriptionById($subscriptionId);
2197
+
2198
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription', new GenericEvent(
2199
+            '\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription',
2200
+            [
2201
+                'subscriptionId' => $subscriptionId,
2202
+                'subscriptionData' => $this->getSubscriptionById($subscriptionId),
2203
+            ]));
2204
+
2205
+        $query = $this->db->getQueryBuilder();
2206
+        $query->delete('calendarsubscriptions')
2207
+            ->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
2208
+            ->execute();
2209
+
2210
+        $query = $this->db->getQueryBuilder();
2211
+        $query->delete('calendarobjects')
2212
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2213
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2214
+            ->execute();
2215
+
2216
+        $query->delete('calendarchanges')
2217
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2218
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2219
+            ->execute();
2220
+
2221
+        $query->delete($this->dbObjectPropertiesTable)
2222
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2223
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2224
+            ->execute();
2225
+
2226
+        if ($subscriptionRow) {
2227
+            $this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent((int)$subscriptionId, $subscriptionRow, []));
2228
+        }
2229
+    }
2230
+
2231
+    /**
2232
+     * Returns a single scheduling object for the inbox collection.
2233
+     *
2234
+     * The returned array should contain the following elements:
2235
+     *   * uri - A unique basename for the object. This will be used to
2236
+     *           construct a full uri.
2237
+     *   * calendardata - The iCalendar object
2238
+     *   * lastmodified - The last modification date. Can be an int for a unix
2239
+     *                    timestamp, or a PHP DateTime object.
2240
+     *   * etag - A unique token that must change if the object changed.
2241
+     *   * size - The size of the object, in bytes.
2242
+     *
2243
+     * @param string $principalUri
2244
+     * @param string $objectUri
2245
+     * @return array
2246
+     */
2247
+    public function getSchedulingObject($principalUri, $objectUri) {
2248
+        $query = $this->db->getQueryBuilder();
2249
+        $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size'])
2250
+            ->from('schedulingobjects')
2251
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2252
+            ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
2253
+            ->execute();
2254
+
2255
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
2256
+
2257
+        if (!$row) {
2258
+            return null;
2259
+        }
2260
+
2261
+        return [
2262
+            'uri'          => $row['uri'],
2263
+            'calendardata' => $row['calendardata'],
2264
+            'lastmodified' => $row['lastmodified'],
2265
+            'etag'         => '"' . $row['etag'] . '"',
2266
+            'size'         => (int)$row['size'],
2267
+        ];
2268
+    }
2269
+
2270
+    /**
2271
+     * Returns all scheduling objects for the inbox collection.
2272
+     *
2273
+     * These objects should be returned as an array. Every item in the array
2274
+     * should follow the same structure as returned from getSchedulingObject.
2275
+     *
2276
+     * The main difference is that 'calendardata' is optional.
2277
+     *
2278
+     * @param string $principalUri
2279
+     * @return array
2280
+     */
2281
+    public function getSchedulingObjects($principalUri) {
2282
+        $query = $this->db->getQueryBuilder();
2283
+        $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size'])
2284
+                ->from('schedulingobjects')
2285
+                ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2286
+                ->execute();
2287
+
2288
+        $result = [];
2289
+        foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
2290
+            $result[] = [
2291
+                'calendardata' => $row['calendardata'],
2292
+                'uri'          => $row['uri'],
2293
+                'lastmodified' => $row['lastmodified'],
2294
+                'etag'         => '"' . $row['etag'] . '"',
2295
+                'size'         => (int)$row['size'],
2296
+            ];
2297
+        }
2298
+
2299
+        return $result;
2300
+    }
2301
+
2302
+    /**
2303
+     * Deletes a scheduling object from the inbox collection.
2304
+     *
2305
+     * @param string $principalUri
2306
+     * @param string $objectUri
2307
+     * @return void
2308
+     */
2309
+    public function deleteSchedulingObject($principalUri, $objectUri) {
2310
+        $query = $this->db->getQueryBuilder();
2311
+        $query->delete('schedulingobjects')
2312
+                ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2313
+                ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri)))
2314
+                ->execute();
2315
+    }
2316
+
2317
+    /**
2318
+     * Creates a new scheduling object. This should land in a users' inbox.
2319
+     *
2320
+     * @param string $principalUri
2321
+     * @param string $objectUri
2322
+     * @param string $objectData
2323
+     * @return void
2324
+     */
2325
+    public function createSchedulingObject($principalUri, $objectUri, $objectData) {
2326
+        $query = $this->db->getQueryBuilder();
2327
+        $query->insert('schedulingobjects')
2328
+            ->values([
2329
+                'principaluri' => $query->createNamedParameter($principalUri),
2330
+                'calendardata' => $query->createNamedParameter($objectData, IQueryBuilder::PARAM_LOB),
2331
+                'uri' => $query->createNamedParameter($objectUri),
2332
+                'lastmodified' => $query->createNamedParameter(time()),
2333
+                'etag' => $query->createNamedParameter(md5($objectData)),
2334
+                'size' => $query->createNamedParameter(strlen($objectData))
2335
+            ])
2336
+            ->execute();
2337
+    }
2338
+
2339
+    /**
2340
+     * Adds a change record to the calendarchanges table.
2341
+     *
2342
+     * @param mixed $calendarId
2343
+     * @param string $objectUri
2344
+     * @param int $operation 1 = add, 2 = modify, 3 = delete.
2345
+     * @param int $calendarType
2346
+     * @return void
2347
+     */
2348
+    protected function addChange($calendarId, $objectUri, $operation, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2349
+        $table = $calendarType === self::CALENDAR_TYPE_CALENDAR ? 'calendars': 'calendarsubscriptions';
2350
+
2351
+        $query = $this->db->getQueryBuilder();
2352
+        $query->select('synctoken')
2353
+            ->from($table)
2354
+            ->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
2355
+        $syncToken = (int)$query->execute()->fetchColumn();
2356
+
2357
+        $query = $this->db->getQueryBuilder();
2358
+        $query->insert('calendarchanges')
2359
+            ->values([
2360
+                'uri' => $query->createNamedParameter($objectUri),
2361
+                'synctoken' => $query->createNamedParameter($syncToken),
2362
+                'calendarid' => $query->createNamedParameter($calendarId),
2363
+                'operation' => $query->createNamedParameter($operation),
2364
+                'calendartype' => $query->createNamedParameter($calendarType),
2365
+            ])
2366
+            ->execute();
2367
+
2368
+        $stmt = $this->db->prepare("UPDATE `*PREFIX*$table` SET `synctoken` = `synctoken` + 1 WHERE `id` = ?");
2369
+        $stmt->execute([
2370
+            $calendarId
2371
+        ]);
2372
+    }
2373
+
2374
+    /**
2375
+     * Parses some information from calendar objects, used for optimized
2376
+     * calendar-queries.
2377
+     *
2378
+     * Returns an array with the following keys:
2379
+     *   * etag - An md5 checksum of the object without the quotes.
2380
+     *   * size - Size of the object in bytes
2381
+     *   * componentType - VEVENT, VTODO or VJOURNAL
2382
+     *   * firstOccurence
2383
+     *   * lastOccurence
2384
+     *   * uid - value of the UID property
2385
+     *
2386
+     * @param string $calendarData
2387
+     * @return array
2388
+     */
2389
+    public function getDenormalizedData($calendarData) {
2390
+        $vObject = Reader::read($calendarData);
2391
+        $componentType = null;
2392
+        $component = null;
2393
+        $firstOccurrence = null;
2394
+        $lastOccurrence = null;
2395
+        $uid = null;
2396
+        $classification = self::CLASSIFICATION_PUBLIC;
2397
+        foreach ($vObject->getComponents() as $component) {
2398
+            if ($component->name!=='VTIMEZONE') {
2399
+                $componentType = $component->name;
2400
+                $uid = (string)$component->UID;
2401
+                break;
2402
+            }
2403
+        }
2404
+        if (!$componentType) {
2405
+            throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
2406
+        }
2407
+        if ($componentType === 'VEVENT' && $component->DTSTART) {
2408
+            $firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp();
2409
+            // Finding the last occurrence is a bit harder
2410
+            if (!isset($component->RRULE)) {
2411
+                if (isset($component->DTEND)) {
2412
+                    $lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp();
2413
+                } elseif (isset($component->DURATION)) {
2414
+                    $endDate = clone $component->DTSTART->getDateTime();
2415
+                    $endDate->add(DateTimeParser::parse($component->DURATION->getValue()));
2416
+                    $lastOccurrence = $endDate->getTimeStamp();
2417
+                } elseif (!$component->DTSTART->hasTime()) {
2418
+                    $endDate = clone $component->DTSTART->getDateTime();
2419
+                    $endDate->modify('+1 day');
2420
+                    $lastOccurrence = $endDate->getTimeStamp();
2421
+                } else {
2422
+                    $lastOccurrence = $firstOccurrence;
2423
+                }
2424
+            } else {
2425
+                $it = new EventIterator($vObject, (string)$component->UID);
2426
+                $maxDate = new DateTime(self::MAX_DATE);
2427
+                if ($it->isInfinite()) {
2428
+                    $lastOccurrence = $maxDate->getTimestamp();
2429
+                } else {
2430
+                    $end = $it->getDtEnd();
2431
+                    while ($it->valid() && $end < $maxDate) {
2432
+                        $end = $it->getDtEnd();
2433
+                        $it->next();
2434
+                    }
2435
+                    $lastOccurrence = $end->getTimestamp();
2436
+                }
2437
+            }
2438
+        }
2439
+
2440
+        if ($component->CLASS) {
2441
+            $classification = CalDavBackend::CLASSIFICATION_PRIVATE;
2442
+            switch ($component->CLASS->getValue()) {
2443
+                case 'PUBLIC':
2444
+                    $classification = CalDavBackend::CLASSIFICATION_PUBLIC;
2445
+                    break;
2446
+                case 'CONFIDENTIAL':
2447
+                    $classification = CalDavBackend::CLASSIFICATION_CONFIDENTIAL;
2448
+                    break;
2449
+            }
2450
+        }
2451
+        return [
2452
+            'etag' => md5($calendarData),
2453
+            'size' => strlen($calendarData),
2454
+            'componentType' => $componentType,
2455
+            'firstOccurence' => is_null($firstOccurrence) ? null : max(0, $firstOccurrence),
2456
+            'lastOccurence'  => $lastOccurrence,
2457
+            'uid' => $uid,
2458
+            'classification' => $classification
2459
+        ];
2460
+    }
2461
+
2462
+    /**
2463
+     * @param $cardData
2464
+     * @return bool|string
2465
+     */
2466
+    private function readBlob($cardData) {
2467
+        if (is_resource($cardData)) {
2468
+            return stream_get_contents($cardData);
2469
+        }
2470
+
2471
+        return $cardData;
2472
+    }
2473
+
2474
+    /**
2475
+     * @param IShareable $shareable
2476
+     * @param array $add
2477
+     * @param array $remove
2478
+     */
2479
+    public function updateShares($shareable, $add, $remove) {
2480
+        $calendarId = $shareable->getResourceId();
2481
+        $calendarRow = $this->getCalendarById($calendarId);
2482
+        $oldShares = $this->getShares($calendarId);
2483
+
2484
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateShares', new GenericEvent(
2485
+            '\OCA\DAV\CalDAV\CalDavBackend::updateShares',
2486
+            [
2487
+                'calendarId' => $calendarId,
2488
+                'calendarData' => $calendarRow,
2489
+                'shares' => $oldShares,
2490
+                'add' => $add,
2491
+                'remove' => $remove,
2492
+            ]));
2493
+        $this->calendarSharingBackend->updateShares($shareable, $add, $remove);
2494
+
2495
+        $this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent((int)$calendarId, $calendarRow, $oldShares, $add, $remove));
2496
+    }
2497
+
2498
+    /**
2499
+     * @param int $resourceId
2500
+     * @param int $calendarType
2501
+     * @return array
2502
+     */
2503
+    public function getShares($resourceId, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2504
+        return $this->calendarSharingBackend->getShares($resourceId);
2505
+    }
2506
+
2507
+    /**
2508
+     * @param boolean $value
2509
+     * @param \OCA\DAV\CalDAV\Calendar $calendar
2510
+     * @return string|null
2511
+     */
2512
+    public function setPublishStatus($value, $calendar) {
2513
+        $calendarId = $calendar->getResourceId();
2514
+        $calendarData = $this->getCalendarById($calendarId);
2515
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
2516
+            '\OCA\DAV\CalDAV\CalDavBackend::updateShares',
2517
+            [
2518
+                'calendarId' => $calendarId,
2519
+                'calendarData' => $calendarData,
2520
+                'public' => $value,
2521
+            ]));
2522
+
2523
+        $query = $this->db->getQueryBuilder();
2524
+        if ($value) {
2525
+            $publicUri = $this->random->generate(16, ISecureRandom::CHAR_HUMAN_READABLE);
2526
+            $query->insert('dav_shares')
2527
+                ->values([
2528
+                    'principaluri' => $query->createNamedParameter($calendar->getPrincipalURI()),
2529
+                    'type' => $query->createNamedParameter('calendar'),
2530
+                    'access' => $query->createNamedParameter(self::ACCESS_PUBLIC),
2531
+                    'resourceid' => $query->createNamedParameter($calendar->getResourceId()),
2532
+                    'publicuri' => $query->createNamedParameter($publicUri)
2533
+                ]);
2534
+            $query->execute();
2535
+
2536
+            $this->dispatcher->dispatchTyped(new CalendarPublishedEvent((int)$calendarId, $calendarData, $publicUri));
2537
+            return $publicUri;
2538
+        }
2539
+        $query->delete('dav_shares')
2540
+            ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
2541
+            ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)));
2542
+        $query->execute();
2543
+
2544
+        $this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent((int)$calendarId, $calendarData));
2545
+        return null;
2546
+    }
2547
+
2548
+    /**
2549
+     * @param \OCA\DAV\CalDAV\Calendar $calendar
2550
+     * @return mixed
2551
+     */
2552
+    public function getPublishStatus($calendar) {
2553
+        $query = $this->db->getQueryBuilder();
2554
+        $result = $query->select('publicuri')
2555
+            ->from('dav_shares')
2556
+            ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
2557
+            ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
2558
+            ->execute();
2559
+
2560
+        $row = $result->fetch();
2561
+        $result->closeCursor();
2562
+        return $row ? reset($row) : false;
2563
+    }
2564
+
2565
+    /**
2566
+     * @param int $resourceId
2567
+     * @param array $acl
2568
+     * @return array
2569
+     */
2570
+    public function applyShareAcl($resourceId, $acl) {
2571
+        return $this->calendarSharingBackend->applyShareAcl($resourceId, $acl);
2572
+    }
2573
+
2574
+
2575
+
2576
+    /**
2577
+     * update properties table
2578
+     *
2579
+     * @param int $calendarId
2580
+     * @param string $objectUri
2581
+     * @param string $calendarData
2582
+     * @param int $calendarType
2583
+     */
2584
+    public function updateProperties($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2585
+        $objectId = $this->getCalendarObjectId($calendarId, $objectUri, $calendarType);
2586
+
2587
+        try {
2588
+            $vCalendar = $this->readCalendarData($calendarData);
2589
+        } catch (\Exception $ex) {
2590
+            return;
2591
+        }
2592
+
2593
+        $this->purgeProperties($calendarId, $objectId);
2594
+
2595
+        $query = $this->db->getQueryBuilder();
2596
+        $query->insert($this->dbObjectPropertiesTable)
2597
+            ->values(
2598
+                [
2599
+                    'calendarid' => $query->createNamedParameter($calendarId),
2600
+                    'calendartype' => $query->createNamedParameter($calendarType),
2601
+                    'objectid' => $query->createNamedParameter($objectId),
2602
+                    'name' => $query->createParameter('name'),
2603
+                    'parameter' => $query->createParameter('parameter'),
2604
+                    'value' => $query->createParameter('value'),
2605
+                ]
2606
+            );
2607
+
2608
+        $indexComponents = ['VEVENT', 'VJOURNAL', 'VTODO'];
2609
+        foreach ($vCalendar->getComponents() as $component) {
2610
+            if (!in_array($component->name, $indexComponents)) {
2611
+                continue;
2612
+            }
2613
+
2614
+            foreach ($component->children() as $property) {
2615
+                if (in_array($property->name, self::$indexProperties)) {
2616
+                    $value = $property->getValue();
2617
+                    // is this a shitty db?
2618
+                    if (!$this->db->supports4ByteText()) {
2619
+                        $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
2620
+                    }
2621
+                    $value = mb_substr($value, 0, 254);
2622
+
2623
+                    $query->setParameter('name', $property->name);
2624
+                    $query->setParameter('parameter', null);
2625
+                    $query->setParameter('value', $value);
2626
+                    $query->execute();
2627
+                }
2628
+
2629
+                if (array_key_exists($property->name, self::$indexParameters)) {
2630
+                    $parameters = $property->parameters();
2631
+                    $indexedParametersForProperty = self::$indexParameters[$property->name];
2632
+
2633
+                    foreach ($parameters as $key => $value) {
2634
+                        if (in_array($key, $indexedParametersForProperty)) {
2635
+                            // is this a shitty db?
2636
+                            if ($this->db->supports4ByteText()) {
2637
+                                $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
2638
+                            }
2639
+
2640
+                            $query->setParameter('name', $property->name);
2641
+                            $query->setParameter('parameter', mb_substr($key, 0, 254));
2642
+                            $query->setParameter('value', mb_substr($value, 0, 254));
2643
+                            $query->execute();
2644
+                        }
2645
+                    }
2646
+                }
2647
+            }
2648
+        }
2649
+    }
2650
+
2651
+    /**
2652
+     * deletes all birthday calendars
2653
+     */
2654
+    public function deleteAllBirthdayCalendars() {
2655
+        $query = $this->db->getQueryBuilder();
2656
+        $result = $query->select(['id'])->from('calendars')
2657
+            ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
2658
+            ->execute();
2659
+
2660
+        $ids = $result->fetchAll();
2661
+        foreach ($ids as $id) {
2662
+            $this->deleteCalendar($id['id']);
2663
+        }
2664
+    }
2665
+
2666
+    /**
2667
+     * @param $subscriptionId
2668
+     */
2669
+    public function purgeAllCachedEventsForSubscription($subscriptionId) {
2670
+        $query = $this->db->getQueryBuilder();
2671
+        $query->select('uri')
2672
+            ->from('calendarobjects')
2673
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2674
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)));
2675
+        $stmt = $query->execute();
2676
+
2677
+        $uris = [];
2678
+        foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
2679
+            $uris[] = $row['uri'];
2680
+        }
2681
+        $stmt->closeCursor();
2682
+
2683
+        $query = $this->db->getQueryBuilder();
2684
+        $query->delete('calendarobjects')
2685
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2686
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2687
+            ->execute();
2688
+
2689
+        $query->delete('calendarchanges')
2690
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2691
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2692
+            ->execute();
2693
+
2694
+        $query->delete($this->dbObjectPropertiesTable)
2695
+            ->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
2696
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
2697
+            ->execute();
2698
+
2699
+        foreach ($uris as $uri) {
2700
+            $this->addChange($subscriptionId, $uri, 3, self::CALENDAR_TYPE_SUBSCRIPTION);
2701
+        }
2702
+    }
2703
+
2704
+    /**
2705
+     * Move a calendar from one user to another
2706
+     *
2707
+     * @param string $uriName
2708
+     * @param string $uriOrigin
2709
+     * @param string $uriDestination
2710
+     */
2711
+    public function moveCalendar($uriName, $uriOrigin, $uriDestination) {
2712
+        $query = $this->db->getQueryBuilder();
2713
+        $query->update('calendars')
2714
+            ->set('principaluri', $query->createNamedParameter($uriDestination))
2715
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($uriOrigin)))
2716
+            ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($uriName)))
2717
+            ->execute();
2718
+    }
2719
+
2720
+    /**
2721
+     * read VCalendar data into a VCalendar object
2722
+     *
2723
+     * @param string $objectData
2724
+     * @return VCalendar
2725
+     */
2726
+    protected function readCalendarData($objectData) {
2727
+        return Reader::read($objectData);
2728
+    }
2729
+
2730
+    /**
2731
+     * delete all properties from a given calendar object
2732
+     *
2733
+     * @param int $calendarId
2734
+     * @param int $objectId
2735
+     */
2736
+    protected function purgeProperties($calendarId, $objectId) {
2737
+        $query = $this->db->getQueryBuilder();
2738
+        $query->delete($this->dbObjectPropertiesTable)
2739
+            ->where($query->expr()->eq('objectid', $query->createNamedParameter($objectId)))
2740
+            ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)));
2741
+        $query->execute();
2742
+    }
2743
+
2744
+    /**
2745
+     * get ID from a given calendar object
2746
+     *
2747
+     * @param int $calendarId
2748
+     * @param string $uri
2749
+     * @param int $calendarType
2750
+     * @return int
2751
+     */
2752
+    protected function getCalendarObjectId($calendarId, $uri, $calendarType):int {
2753
+        $query = $this->db->getQueryBuilder();
2754
+        $query->select('id')
2755
+            ->from('calendarobjects')
2756
+            ->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
2757
+            ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
2758
+            ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
2759
+
2760
+        $result = $query->execute();
2761
+        $objectIds = $result->fetch();
2762
+        $result->closeCursor();
2763
+
2764
+        if (!isset($objectIds['id'])) {
2765
+            throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2766
+        }
2767
+
2768
+        return (int)$objectIds['id'];
2769
+    }
2770
+
2771
+    /**
2772
+     * return legacy endpoint principal name to new principal name
2773
+     *
2774
+     * @param $principalUri
2775
+     * @param $toV2
2776
+     * @return string
2777
+     */
2778
+    private function convertPrincipal($principalUri, $toV2) {
2779
+        if ($this->principalBackend->getPrincipalPrefix() === 'principals') {
2780
+            list(, $name) = Uri\split($principalUri);
2781
+            if ($toV2 === true) {
2782
+                return "principals/users/$name";
2783
+            }
2784
+            return "principals/$name";
2785
+        }
2786
+        return $principalUri;
2787
+    }
2788
+
2789
+    /**
2790
+     * adds information about an owner to the calendar data
2791
+     *
2792
+     * @param $calendarInfo
2793
+     */
2794
+    private function addOwnerPrincipal(&$calendarInfo) {
2795
+        $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
2796
+        $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
2797
+        if (isset($calendarInfo[$ownerPrincipalKey])) {
2798
+            $uri = $calendarInfo[$ownerPrincipalKey];
2799
+        } else {
2800
+            $uri = $calendarInfo['principaluri'];
2801
+        }
2802
+
2803
+        $principalInformation = $this->principalBackend->getPrincipalByPath($uri);
2804
+        if (isset($principalInformation['{DAV:}displayname'])) {
2805
+            $calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
2806
+        }
2807
+    }
2808 2808
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
248 248
 		}
249 249
 
250
-		return (int)$query->execute()->fetchColumn();
250
+		return (int) $query->execute()->fetchColumn();
251 251
 	}
252 252
 
253 253
 	/**
@@ -297,18 +297,18 @@  discard block
 block discarded – undo
297 297
 		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
298 298
 			$components = [];
299 299
 			if ($row['components']) {
300
-				$components = explode(',',$row['components']);
300
+				$components = explode(',', $row['components']);
301 301
 			}
302 302
 
303 303
 			$calendar = [
304 304
 				'id' => $row['id'],
305 305
 				'uri' => $row['uri'],
306 306
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
307
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
308
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
309
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
310
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
311
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
307
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
308
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
309
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
310
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
311
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
312 312
 			];
313 313
 
314 314
 			foreach ($this->propertyMap as $xmlName=>$dbName) {
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
329 329
 		$principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
330 330
 
331
-		$principals = array_map(function ($principal) {
331
+		$principals = array_map(function($principal) {
332 332
 			return urldecode($principal);
333 333
 		}, $principals);
334
-		$principals[]= $principalUri;
334
+		$principals[] = $principalUri;
335 335
 
336 336
 		$fields = array_values($this->propertyMap);
337 337
 		$fields[] = 'a.id';
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 			->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
352 352
 			->execute();
353 353
 
354
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
354
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
355 355
 		while ($row = $result->fetch()) {
356 356
 			if ($row['principaluri'] === $principalUri) {
357 357
 				continue;
@@ -371,21 +371,21 @@  discard block
 block discarded – undo
371 371
 			}
372 372
 
373 373
 			list(, $name) = Uri\split($row['principaluri']);
374
-			$uri = $row['uri'] . '_shared_by_' . $name;
375
-			$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
374
+			$uri = $row['uri'].'_shared_by_'.$name;
375
+			$row['displayname'] = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
376 376
 			$components = [];
377 377
 			if ($row['components']) {
378
-				$components = explode(',',$row['components']);
378
+				$components = explode(',', $row['components']);
379 379
 			}
380 380
 			$calendar = [
381 381
 				'id' => $row['id'],
382 382
 				'uri' => $uri,
383 383
 				'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
384
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
385
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
386
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
387
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'),
388
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
384
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
385
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
386
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
387
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'),
388
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
389 389
 				$readOnlyPropertyName => $readOnly,
390 390
 			];
391 391
 
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
426 426
 			$components = [];
427 427
 			if ($row['components']) {
428
-				$components = explode(',',$row['components']);
428
+				$components = explode(',', $row['components']);
429 429
 			}
430 430
 			$calendar = [
431 431
 				'id' => $row['id'],
432 432
 				'uri' => $row['uri'],
433 433
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
434
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
435
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
436
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
437
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
434
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
435
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
436
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
437
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
438 438
 			];
439 439
 			foreach ($this->propertyMap as $xmlName=>$dbName) {
440 440
 				$calendar[$xmlName] = $row[$dbName];
@@ -493,22 +493,22 @@  discard block
 block discarded – undo
493 493
 
494 494
 		while ($row = $result->fetch()) {
495 495
 			list(, $name) = Uri\split($row['principaluri']);
496
-			$row['displayname'] = $row['displayname'] . "($name)";
496
+			$row['displayname'] = $row['displayname']."($name)";
497 497
 			$components = [];
498 498
 			if ($row['components']) {
499
-				$components = explode(',',$row['components']);
499
+				$components = explode(',', $row['components']);
500 500
 			}
501 501
 			$calendar = [
502 502
 				'id' => $row['id'],
503 503
 				'uri' => $row['publicuri'],
504 504
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
505
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
506
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
507
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
508
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
509
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
510
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
511
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
505
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
506
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
507
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
508
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
509
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
510
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
511
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
512 512
 			];
513 513
 
514 514
 			foreach ($this->propertyMap as $xmlName=>$dbName) {
@@ -555,26 +555,26 @@  discard block
 block discarded – undo
555 555
 		$result->closeCursor();
556 556
 
557 557
 		if ($row === false) {
558
-			throw new NotFound('Node with name \'' . $uri . '\' could not be found');
558
+			throw new NotFound('Node with name \''.$uri.'\' could not be found');
559 559
 		}
560 560
 
561 561
 		list(, $name) = Uri\split($row['principaluri']);
562
-		$row['displayname'] = $row['displayname'] . ' ' . "($name)";
562
+		$row['displayname'] = $row['displayname'].' '."($name)";
563 563
 		$components = [];
564 564
 		if ($row['components']) {
565
-			$components = explode(',',$row['components']);
565
+			$components = explode(',', $row['components']);
566 566
 		}
567 567
 		$calendar = [
568 568
 			'id' => $row['id'],
569 569
 			'uri' => $row['publicuri'],
570 570
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
571
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
572
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
573
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
574
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
575
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
576
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
577
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
571
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
572
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
573
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
574
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
575
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
576
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
577
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
578 578
 		];
579 579
 
580 580
 		foreach ($this->propertyMap as $xmlName=>$dbName) {
@@ -616,17 +616,17 @@  discard block
 block discarded – undo
616 616
 
617 617
 		$components = [];
618 618
 		if ($row['components']) {
619
-			$components = explode(',',$row['components']);
619
+			$components = explode(',', $row['components']);
620 620
 		}
621 621
 
622 622
 		$calendar = [
623 623
 			'id' => $row['id'],
624 624
 			'uri' => $row['uri'],
625 625
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
626
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
627
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
628
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
629
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
626
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
627
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
628
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
629
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
630 630
 		];
631 631
 
632 632
 		foreach ($this->propertyMap as $xmlName=>$dbName) {
@@ -666,17 +666,17 @@  discard block
 block discarded – undo
666 666
 
667 667
 		$components = [];
668 668
 		if ($row['components']) {
669
-			$components = explode(',',$row['components']);
669
+			$components = explode(',', $row['components']);
670 670
 		}
671 671
 
672 672
 		$calendar = [
673 673
 			'id' => $row['id'],
674 674
 			'uri' => $row['uri'],
675 675
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
676
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
677
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
678
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
679
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
676
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
677
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
678
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
679
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
680 680
 		];
681 681
 
682 682
 		foreach ($this->propertyMap as $xmlName=>$dbName) {
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			->from('calendarsubscriptions')
706 706
 			->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
707 707
 			->orderBy('calendarorder', 'asc');
708
-		$stmt =$query->execute();
708
+		$stmt = $query->execute();
709 709
 
710 710
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
711 711
 		$stmt->closeCursor();
@@ -719,8 +719,8 @@  discard block
 block discarded – undo
719 719
 			'principaluri' => $row['principaluri'],
720 720
 			'source'       => $row['source'],
721 721
 			'lastmodified' => $row['lastmodified'],
722
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
723
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
722
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
723
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
724 724
 		];
725 725
 
726 726
 		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
@@ -758,16 +758,16 @@  discard block
 block discarded – undo
758 758
 		$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
759 759
 		if (isset($properties[$sccs])) {
760 760
 			if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
761
-				throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
761
+				throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
762 762
 			}
763
-			$values['components'] = implode(',',$properties[$sccs]->getValue());
763
+			$values['components'] = implode(',', $properties[$sccs]->getValue());
764 764
 		} elseif (isset($properties['components'])) {
765 765
 			// Allow to provide components internally without having
766 766
 			// to create a SupportedCalendarComponentSet object
767 767
 			$values['components'] = $properties['components'];
768 768
 		}
769 769
 
770
-		$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
770
+		$transp = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
771 771
 		if (isset($properties[$transp])) {
772 772
 			$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
773 773
 		}
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		$calendarId = $query->getLastInsertId();
788 788
 
789 789
 		$calendarData = $this->getCalendarById($calendarId);
790
-		$this->dispatcher->dispatchTyped(new CalendarCreatedEvent((int)$calendarId, $calendarData));
790
+		$this->dispatcher->dispatchTyped(new CalendarCreatedEvent((int) $calendarId, $calendarData));
791 791
 		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent(
792 792
 			'\OCA\DAV\CalDAV\CalDavBackend::createCalendar',
793 793
 			[
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
 	 */
817 817
 	public function updateCalendar($calendarId, PropPatch $propPatch) {
818 818
 		$supportedProperties = array_keys($this->propertyMap);
819
-		$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
819
+		$supportedProperties[] = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
820 820
 
821 821
 		/**
822 822
 		 * @suppress SqlInjectionChecker
823 823
 		 */
824
-		$propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
824
+		$propPatch->handle($supportedProperties, function($mutations) use ($calendarId) {
825 825
 			$newValues = [];
826 826
 			foreach ($mutations as $propertyName => $propertyValue) {
827 827
 				switch ($propertyName) {
828
-					case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
828
+					case '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp':
829 829
 						$fieldName = 'transparent';
830 830
 						$newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
831 831
 						break;
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 
848 848
 			$calendarData = $this->getCalendarById($calendarId);
849 849
 			$shares = $this->getShares($calendarId);
850
-			$this->dispatcher->dispatchTyped(new CalendarUpdatedEvent((int)$calendarId, $calendarData, $shares, $mutations));
850
+			$this->dispatcher->dispatchTyped(new CalendarUpdatedEvent((int) $calendarId, $calendarData, $shares, $mutations));
851 851
 			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent(
852 852
 				'\OCA\DAV\CalDAV\CalDavBackend::updateCalendar',
853 853
 				[
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 			->execute();
898 898
 
899 899
 		if ($calendarData) {
900
-			$this->dispatcher->dispatchTyped(new CalendarDeletedEvent((int)$calendarId, $calendarData, $shares));
900
+			$this->dispatcher->dispatchTyped(new CalendarDeletedEvent((int) $calendarId, $calendarData, $shares));
901 901
 		}
902 902
 	}
903 903
 
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 	 * @param int $calendarType
944 944
 	 * @return array
945 945
 	 */
946
-	public function getCalendarObjects($calendarId, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
946
+	public function getCalendarObjects($calendarId, $calendarType = self::CALENDAR_TYPE_CALENDAR):array {
947 947
 		$query = $this->db->getQueryBuilder();
948 948
 		$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype', 'classification'])
949 949
 			->from('calendarobjects')
@@ -957,11 +957,11 @@  discard block
 block discarded – undo
957 957
 				'id'           => $row['id'],
958 958
 				'uri'          => $row['uri'],
959 959
 				'lastmodified' => $row['lastmodified'],
960
-				'etag'         => '"' . $row['etag'] . '"',
960
+				'etag'         => '"'.$row['etag'].'"',
961 961
 				'calendarid'   => $row['calendarid'],
962
-				'size'         => (int)$row['size'],
962
+				'size'         => (int) $row['size'],
963 963
 				'component'    => strtolower($row['componenttype']),
964
-				'classification'=> (int)$row['classification']
964
+				'classification'=> (int) $row['classification']
965 965
 			];
966 966
 		}
967 967
 
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 	 * @param int $calendarType
986 986
 	 * @return array|null
987 987
 	 */
988
-	public function getCalendarObject($calendarId, $objectUri, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
988
+	public function getCalendarObject($calendarId, $objectUri, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
989 989
 		$query = $this->db->getQueryBuilder();
990 990
 		$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
991 991
 			->from('calendarobjects')
@@ -1003,12 +1003,12 @@  discard block
 block discarded – undo
1003 1003
 			'id'            => $row['id'],
1004 1004
 			'uri'           => $row['uri'],
1005 1005
 			'lastmodified'  => $row['lastmodified'],
1006
-			'etag'          => '"' . $row['etag'] . '"',
1006
+			'etag'          => '"'.$row['etag'].'"',
1007 1007
 			'calendarid'    => $row['calendarid'],
1008
-			'size'          => (int)$row['size'],
1008
+			'size'          => (int) $row['size'],
1009 1009
 			'calendardata'  => $this->readBlob($row['calendardata']),
1010 1010
 			'component'     => strtolower($row['componenttype']),
1011
-			'classification'=> (int)$row['classification']
1011
+			'classification'=> (int) $row['classification']
1012 1012
 		];
1013 1013
 	}
1014 1014
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 * @param int $calendarType
1026 1026
 	 * @return array
1027 1027
 	 */
1028
-	public function getMultipleCalendarObjects($calendarId, array $uris, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
1028
+	public function getMultipleCalendarObjects($calendarId, array $uris, $calendarType = self::CALENDAR_TYPE_CALENDAR):array {
1029 1029
 		if (empty($uris)) {
1030 1030
 			return [];
1031 1031
 		}
@@ -1049,12 +1049,12 @@  discard block
 block discarded – undo
1049 1049
 					'id'           => $row['id'],
1050 1050
 					'uri'          => $row['uri'],
1051 1051
 					'lastmodified' => $row['lastmodified'],
1052
-					'etag'         => '"' . $row['etag'] . '"',
1052
+					'etag'         => '"'.$row['etag'].'"',
1053 1053
 					'calendarid'   => $row['calendarid'],
1054
-					'size'         => (int)$row['size'],
1054
+					'size'         => (int) $row['size'],
1055 1055
 					'calendardata' => $this->readBlob($row['calendardata']),
1056 1056
 					'component'    => strtolower($row['componenttype']),
1057
-					'classification' => (int)$row['classification']
1057
+					'classification' => (int) $row['classification']
1058 1058
 				];
1059 1059
 			}
1060 1060
 			$result->closeCursor();
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	 * @param int $calendarType
1083 1083
 	 * @return string
1084 1084
 	 */
1085
-	public function createCalendarObject($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1085
+	public function createCalendarObject($calendarId, $objectUri, $calendarData, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
1086 1086
 		$extraData = $this->getDenormalizedData($calendarData);
1087 1087
 
1088 1088
 		$q = $this->db->getQueryBuilder();
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 			$calendarRow = $this->getCalendarById($calendarId);
1127 1127
 			$shares = $this->getShares($calendarId);
1128 1128
 
1129
-			$this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
1129
+			$this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int) $calendarId, $calendarRow, $shares, $objectRow));
1130 1130
 			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent(
1131 1131
 				'\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject',
1132 1132
 				[
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 		} else {
1140 1140
 			$subscriptionRow = $this->getSubscriptionById($calendarId);
1141 1141
 
1142
-			$this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
1142
+			$this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent((int) $calendarId, $subscriptionRow, [], $objectRow));
1143 1143
 			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject', new GenericEvent(
1144 1144
 				'\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject',
1145 1145
 				[
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 			));
1152 1152
 		}
1153 1153
 
1154
-		return '"' . $extraData['etag'] . '"';
1154
+		return '"'.$extraData['etag'].'"';
1155 1155
 	}
1156 1156
 
1157 1157
 	/**
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
 	 * @param int $calendarType
1174 1174
 	 * @return string
1175 1175
 	 */
1176
-	public function updateCalendarObject($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1176
+	public function updateCalendarObject($calendarId, $objectUri, $calendarData, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
1177 1177
 		$extraData = $this->getDenormalizedData($calendarData);
1178 1178
 		$query = $this->db->getQueryBuilder();
1179 1179
 		$query->update('calendarobjects')
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 				$calendarRow = $this->getCalendarById($calendarId);
1201 1201
 				$shares = $this->getShares($calendarId);
1202 1202
 
1203
-				$this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
1203
+				$this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int) $calendarId, $calendarRow, $shares, $objectRow));
1204 1204
 				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent(
1205 1205
 					'\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject',
1206 1206
 					[
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 			} else {
1214 1214
 				$subscriptionRow = $this->getSubscriptionById($calendarId);
1215 1215
 
1216
-				$this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
1216
+				$this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent((int) $calendarId, $subscriptionRow, [], $objectRow));
1217 1217
 				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject', new GenericEvent(
1218 1218
 					'\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject',
1219 1219
 					[
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 			}
1227 1227
 		}
1228 1228
 
1229
-		return '"' . $extraData['etag'] . '"';
1229
+		return '"'.$extraData['etag'].'"';
1230 1230
 	}
1231 1231
 
1232 1232
 	/**
@@ -1256,14 +1256,14 @@  discard block
 block discarded – undo
1256 1256
 	 * @param int $calendarType
1257 1257
 	 * @return void
1258 1258
 	 */
1259
-	public function deleteCalendarObject($calendarId, $objectUri, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1259
+	public function deleteCalendarObject($calendarId, $objectUri, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
1260 1260
 		$data = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
1261 1261
 		if (is_array($data)) {
1262 1262
 			if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
1263 1263
 				$calendarRow = $this->getCalendarById($calendarId);
1264 1264
 				$shares = $this->getShares($calendarId);
1265 1265
 
1266
-				$this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int)$calendarId, $calendarRow, $shares, $data));
1266
+				$this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int) $calendarId, $calendarRow, $shares, $data));
1267 1267
 				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent(
1268 1268
 					'\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject',
1269 1269
 					[
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 			} else {
1277 1277
 				$subscriptionRow = $this->getSubscriptionById($calendarId);
1278 1278
 
1279
-				$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent((int)$calendarId, $subscriptionRow, [], $data));
1279
+				$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent((int) $calendarId, $subscriptionRow, [], $data));
1280 1280
 				$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject', new GenericEvent(
1281 1281
 					'\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject',
1282 1282
 					[
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
 	 * @param int $calendarType
1350 1350
 	 * @return array
1351 1351
 	 */
1352
-	public function calendarQuery($calendarId, array $filters, $calendarType=self::CALENDAR_TYPE_CALENDAR):array {
1352
+	public function calendarQuery($calendarId, array $filters, $calendarType = self::CALENDAR_TYPE_CALENDAR):array {
1353 1353
 		$componentType = null;
1354 1354
 		$requirePostFilter = true;
1355 1355
 		$timeRange = null;
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 	 * @param integer|null $offset
1444 1444
 	 * @return array
1445 1445
 	 */
1446
-	public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1446
+	public function calendarSearch($principalUri, array $filters, $limit = null, $offset = null) {
1447 1447
 		$calendars = $this->getCalendarsForUser($principalUri);
1448 1448
 		$ownCalendars = [];
1449 1449
 		$sharedCalendars = [];
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 
1549 1549
 		$result = [];
1550 1550
 		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1551
-			$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1551
+			$path = $uriMapper[$row['calendarid']].'/'.$row['uri'];
1552 1552
 			if (!in_array($path, $result)) {
1553 1553
 				$result[] = $path;
1554 1554
 			}
@@ -1596,8 +1596,8 @@  discard block
 block discarded – undo
1596 1596
 
1597 1597
 		if ($pattern !== '') {
1598 1598
 			$innerQuery->andWhere($innerQuery->expr()->iLike('op.value',
1599
-				$outerQuery->createNamedParameter('%' .
1600
-					$this->db->escapeLikeParameter($pattern) . '%')));
1599
+				$outerQuery->createNamedParameter('%'.
1600
+					$this->db->escapeLikeParameter($pattern).'%')));
1601 1601
 		}
1602 1602
 
1603 1603
 		$outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri')
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 		$result = $outerQuery->execute();
1637 1637
 		$calendarObjects = $result->fetchAll();
1638 1638
 
1639
-		return array_map(function ($o) {
1639
+		return array_map(function($o) {
1640 1640
 			$calendarData = Reader::read($o['calendardata']);
1641 1641
 			$comps = $calendarData->getComponents();
1642 1642
 			$objects = [];
@@ -1654,10 +1654,10 @@  discard block
 block discarded – undo
1654 1654
 				'type' => $o['componenttype'],
1655 1655
 				'uid' => $o['uid'],
1656 1656
 				'uri' => $o['uri'],
1657
-				'objects' => array_map(function ($c) {
1657
+				'objects' => array_map(function($c) {
1658 1658
 					return $this->transformSearchData($c);
1659 1659
 				}, $objects),
1660
-				'timezones' => array_map(function ($c) {
1660
+				'timezones' => array_map(function($c) {
1661 1661
 					return $this->transformSearchData($c);
1662 1662
 				}, $timezones),
1663 1663
 			];
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 		/** @var Component[] $subComponents */
1674 1674
 		$subComponents = $comp->getComponents();
1675 1675
 		/** @var Property[] $properties */
1676
-		$properties = array_filter($comp->children(), function ($c) {
1676
+		$properties = array_filter($comp->children(), function($c) {
1677 1677
 			return $c instanceof Property;
1678 1678
 		});
1679 1679
 		$validationRules = $comp->getValidationRules();
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
 		$subscriptions = $this->getSubscriptionsForUser($principalUri);
1752 1752
 		foreach ($calendars as $calendar) {
1753 1753
 			$calendarAnd = $calendarObjectIdQuery->expr()->andX();
1754
-			$calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$calendar['id'])));
1754
+			$calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int) $calendar['id'])));
1755 1755
 			$calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1756 1756
 
1757 1757
 			// If it's shared, limit search to public events
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
 		}
1764 1764
 		foreach ($subscriptions as $subscription) {
1765 1765
 			$subscriptionAnd = $calendarObjectIdQuery->expr()->andX();
1766
-			$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$subscription['id'])));
1766
+			$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int) $subscription['id'])));
1767 1767
 			$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)));
1768 1768
 
1769 1769
 			// If it's shared, limit search to public events
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 			if (!$escapePattern) {
1808 1808
 				$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter($pattern)));
1809 1809
 			} else {
1810
-				$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1810
+				$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%')));
1811 1811
 			}
1812 1812
 		}
1813 1813
 
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
 		$result = $calendarObjectIdQuery->execute();
1822 1822
 		$matches = $result->fetchAll();
1823 1823
 		$result->closeCursor();
1824
-		$matches = array_map(static function (array $match):int {
1824
+		$matches = array_map(static function(array $match):int {
1825 1825
 			return (int) $match['objectid'];
1826 1826
 		}, $matches);
1827 1827
 
@@ -1834,9 +1834,9 @@  discard block
 block discarded – undo
1834 1834
 		$calendarObjects = $result->fetchAll();
1835 1835
 		$result->closeCursor();
1836 1836
 
1837
-		return array_map(function (array $array): array {
1838
-			$array['calendarid'] = (int)$array['calendarid'];
1839
-			$array['calendartype'] = (int)$array['calendartype'];
1837
+		return array_map(function(array $array): array {
1838
+			$array['calendarid'] = (int) $array['calendarid'];
1839
+			$array['calendartype'] = (int) $array['calendartype'];
1840 1840
 			$array['calendardata'] = $this->readBlob($array['calendardata']);
1841 1841
 
1842 1842
 			return $array;
@@ -1873,7 +1873,7 @@  discard block
 block discarded – undo
1873 1873
 		$stmt = $query->execute();
1874 1874
 
1875 1875
 		if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1876
-			return $row['calendaruri'] . '/' . $row['objecturi'];
1876
+			return $row['calendaruri'].'/'.$row['objecturi'];
1877 1877
 		}
1878 1878
 
1879 1879
 		return null;
@@ -1936,10 +1936,10 @@  discard block
 block discarded – undo
1936 1936
 	 * @param int $calendarType
1937 1937
 	 * @return array
1938 1938
 	 */
1939
-	public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
1939
+	public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
1940 1940
 		// Current synctoken
1941 1941
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1942
-		$stmt->execute([ $calendarId ]);
1942
+		$stmt->execute([$calendarId]);
1943 1943
 		$currentToken = $stmt->fetchColumn(0);
1944 1944
 
1945 1945
 		if (is_null($currentToken)) {
@@ -1955,8 +1955,8 @@  discard block
 block discarded – undo
1955 1955
 
1956 1956
 		if ($syncToken) {
1957 1957
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? AND `calendartype` = ? ORDER BY `synctoken`";
1958
-			if ($limit>0) {
1959
-				$query.= " LIMIT " . (int)$limit;
1958
+			if ($limit > 0) {
1959
+				$query .= " LIMIT ".(int) $limit;
1960 1960
 			}
1961 1961
 
1962 1962
 			// Fetching all changes
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
 			->from('calendarsubscriptions')
2042 2042
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
2043 2043
 			->orderBy('calendarorder', 'asc');
2044
-		$stmt =$query->execute();
2044
+		$stmt = $query->execute();
2045 2045
 
2046 2046
 		$subscriptions = [];
2047 2047
 		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
@@ -2052,8 +2052,8 @@  discard block
 block discarded – undo
2052 2052
 				'source'       => $row['source'],
2053 2053
 				'lastmodified' => $row['lastmodified'],
2054 2054
 
2055
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
2056
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
2055
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
2056
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
2057 2057
 			];
2058 2058
 
2059 2059
 			foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
@@ -2117,7 +2117,7 @@  discard block
 block discarded – undo
2117 2117
 		$subscriptionId = $this->db->lastInsertId('*PREFIX*calendarsubscriptions');
2118 2118
 
2119 2119
 		$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2120
-		$this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent((int)$subscriptionId, $subscriptionRow));
2120
+		$this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent((int) $subscriptionId, $subscriptionRow));
2121 2121
 		$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createSubscription', new GenericEvent(
2122 2122
 			'\OCA\DAV\CalDAV\CalDavBackend::createSubscription',
2123 2123
 			[
@@ -2151,7 +2151,7 @@  discard block
 block discarded – undo
2151 2151
 		/**
2152 2152
 		 * @suppress SqlInjectionChecker
2153 2153
 		 */
2154
-		$propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
2154
+		$propPatch->handle($supportedProperties, function($mutations) use ($subscriptionId) {
2155 2155
 			$newValues = [];
2156 2156
 
2157 2157
 			foreach ($mutations as $propertyName=>$propertyValue) {
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
 				->execute();
2174 2174
 
2175 2175
 			$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2176
-			$this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
2176
+			$this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int) $subscriptionId, $subscriptionRow, [], $mutations));
2177 2177
 			$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateSubscription', new GenericEvent(
2178 2178
 				'\OCA\DAV\CalDAV\CalDavBackend::updateSubscription',
2179 2179
 				[
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
 			->execute();
2225 2225
 
2226 2226
 		if ($subscriptionRow) {
2227
-			$this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent((int)$subscriptionId, $subscriptionRow, []));
2227
+			$this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent((int) $subscriptionId, $subscriptionRow, []));
2228 2228
 		}
2229 2229
 	}
2230 2230
 
@@ -2262,8 +2262,8 @@  discard block
 block discarded – undo
2262 2262
 			'uri'          => $row['uri'],
2263 2263
 			'calendardata' => $row['calendardata'],
2264 2264
 			'lastmodified' => $row['lastmodified'],
2265
-			'etag'         => '"' . $row['etag'] . '"',
2266
-			'size'         => (int)$row['size'],
2265
+			'etag'         => '"'.$row['etag'].'"',
2266
+			'size'         => (int) $row['size'],
2267 2267
 		];
2268 2268
 	}
2269 2269
 
@@ -2291,8 +2291,8 @@  discard block
 block discarded – undo
2291 2291
 				'calendardata' => $row['calendardata'],
2292 2292
 				'uri'          => $row['uri'],
2293 2293
 				'lastmodified' => $row['lastmodified'],
2294
-				'etag'         => '"' . $row['etag'] . '"',
2295
-				'size'         => (int)$row['size'],
2294
+				'etag'         => '"'.$row['etag'].'"',
2295
+				'size'         => (int) $row['size'],
2296 2296
 			];
2297 2297
 		}
2298 2298
 
@@ -2345,14 +2345,14 @@  discard block
 block discarded – undo
2345 2345
 	 * @param int $calendarType
2346 2346
 	 * @return void
2347 2347
 	 */
2348
-	protected function addChange($calendarId, $objectUri, $operation, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2349
-		$table = $calendarType === self::CALENDAR_TYPE_CALENDAR ? 'calendars': 'calendarsubscriptions';
2348
+	protected function addChange($calendarId, $objectUri, $operation, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
2349
+		$table = $calendarType === self::CALENDAR_TYPE_CALENDAR ? 'calendars' : 'calendarsubscriptions';
2350 2350
 
2351 2351
 		$query = $this->db->getQueryBuilder();
2352 2352
 		$query->select('synctoken')
2353 2353
 			->from($table)
2354 2354
 			->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
2355
-		$syncToken = (int)$query->execute()->fetchColumn();
2355
+		$syncToken = (int) $query->execute()->fetchColumn();
2356 2356
 
2357 2357
 		$query = $this->db->getQueryBuilder();
2358 2358
 		$query->insert('calendarchanges')
@@ -2395,9 +2395,9 @@  discard block
 block discarded – undo
2395 2395
 		$uid = null;
2396 2396
 		$classification = self::CLASSIFICATION_PUBLIC;
2397 2397
 		foreach ($vObject->getComponents() as $component) {
2398
-			if ($component->name!=='VTIMEZONE') {
2398
+			if ($component->name !== 'VTIMEZONE') {
2399 2399
 				$componentType = $component->name;
2400
-				$uid = (string)$component->UID;
2400
+				$uid = (string) $component->UID;
2401 2401
 				break;
2402 2402
 			}
2403 2403
 		}
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
 					$lastOccurrence = $firstOccurrence;
2423 2423
 				}
2424 2424
 			} else {
2425
-				$it = new EventIterator($vObject, (string)$component->UID);
2425
+				$it = new EventIterator($vObject, (string) $component->UID);
2426 2426
 				$maxDate = new DateTime(self::MAX_DATE);
2427 2427
 				if ($it->isInfinite()) {
2428 2428
 					$lastOccurrence = $maxDate->getTimestamp();
@@ -2492,7 +2492,7 @@  discard block
 block discarded – undo
2492 2492
 			]));
2493 2493
 		$this->calendarSharingBackend->updateShares($shareable, $add, $remove);
2494 2494
 
2495
-		$this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent((int)$calendarId, $calendarRow, $oldShares, $add, $remove));
2495
+		$this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent((int) $calendarId, $calendarRow, $oldShares, $add, $remove));
2496 2496
 	}
2497 2497
 
2498 2498
 	/**
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
 	 * @param int $calendarType
2501 2501
 	 * @return array
2502 2502
 	 */
2503
-	public function getShares($resourceId, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2503
+	public function getShares($resourceId, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
2504 2504
 		return $this->calendarSharingBackend->getShares($resourceId);
2505 2505
 	}
2506 2506
 
@@ -2533,7 +2533,7 @@  discard block
 block discarded – undo
2533 2533
 				]);
2534 2534
 			$query->execute();
2535 2535
 
2536
-			$this->dispatcher->dispatchTyped(new CalendarPublishedEvent((int)$calendarId, $calendarData, $publicUri));
2536
+			$this->dispatcher->dispatchTyped(new CalendarPublishedEvent((int) $calendarId, $calendarData, $publicUri));
2537 2537
 			return $publicUri;
2538 2538
 		}
2539 2539
 		$query->delete('dav_shares')
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
 			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)));
2542 2542
 		$query->execute();
2543 2543
 
2544
-		$this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent((int)$calendarId, $calendarData));
2544
+		$this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent((int) $calendarId, $calendarData));
2545 2545
 		return null;
2546 2546
 	}
2547 2547
 
@@ -2581,7 +2581,7 @@  discard block
 block discarded – undo
2581 2581
 	 * @param string $calendarData
2582 2582
 	 * @param int $calendarType
2583 2583
 	 */
2584
-	public function updateProperties($calendarId, $objectUri, $calendarData, $calendarType=self::CALENDAR_TYPE_CALENDAR) {
2584
+	public function updateProperties($calendarId, $objectUri, $calendarData, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
2585 2585
 		$objectId = $this->getCalendarObjectId($calendarId, $objectUri, $calendarType);
2586 2586
 
2587 2587
 		try {
@@ -2762,10 +2762,10 @@  discard block
 block discarded – undo
2762 2762
 		$result->closeCursor();
2763 2763
 
2764 2764
 		if (!isset($objectIds['id'])) {
2765
-			throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2765
+			throw new \InvalidArgumentException('Calendarobject does not exists: '.$uri);
2766 2766
 		}
2767 2767
 
2768
-		return (int)$objectIds['id'];
2768
+		return (int) $objectIds['id'];
2769 2769
 	}
2770 2770
 
2771 2771
 	/**
@@ -2792,8 +2792,8 @@  discard block
 block discarded – undo
2792 2792
 	 * @param $calendarInfo
2793 2793
 	 */
2794 2794
 	private function addOwnerPrincipal(&$calendarInfo) {
2795
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
2796
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
2795
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
2796
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
2797 2797
 		if (isset($calendarInfo[$ownerPrincipalKey])) {
2798 2798
 			$uri = $calendarInfo[$ownerPrincipalKey];
2799 2799
 		} else {
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/CardDavBackend.php 2 patches
Indentation   +1302 added lines, -1302 removed lines patch added patch discarded remove patch
@@ -64,1306 +64,1306 @@
 block discarded – undo
64 64
 use Symfony\Component\EventDispatcher\GenericEvent;
65 65
 
66 66
 class CardDavBackend implements BackendInterface, SyncSupport {
67
-	public const PERSONAL_ADDRESSBOOK_URI = 'contacts';
68
-	public const PERSONAL_ADDRESSBOOK_NAME = 'Contacts';
69
-
70
-	/** @var Principal */
71
-	private $principalBackend;
72
-
73
-	/** @var string */
74
-	private $dbCardsTable = 'cards';
75
-
76
-	/** @var string */
77
-	private $dbCardsPropertiesTable = 'cards_properties';
78
-
79
-	/** @var IDBConnection */
80
-	private $db;
81
-
82
-	/** @var Backend */
83
-	private $sharingBackend;
84
-
85
-	/** @var array properties to index */
86
-	public static $indexProperties = [
87
-		'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME',
88
-		'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO', 'CLOUD'];
89
-
90
-	/**
91
-	 * @var string[] Map of uid => display name
92
-	 */
93
-	protected $userDisplayNames;
94
-
95
-	/** @var IUserManager */
96
-	private $userManager;
97
-
98
-	/** @var IEventDispatcher */
99
-	private $dispatcher;
100
-
101
-	/** @var EventDispatcherInterface */
102
-	private $legacyDispatcher;
103
-
104
-	private $etagCache = [];
105
-
106
-	/**
107
-	 * CardDavBackend constructor.
108
-	 *
109
-	 * @param IDBConnection $db
110
-	 * @param Principal $principalBackend
111
-	 * @param IUserManager $userManager
112
-	 * @param IGroupManager $groupManager
113
-	 * @param IEventDispatcher $dispatcher
114
-	 * @param EventDispatcherInterface $legacyDispatcher
115
-	 */
116
-	public function __construct(IDBConnection $db,
117
-								Principal $principalBackend,
118
-								IUserManager $userManager,
119
-								IGroupManager $groupManager,
120
-								IEventDispatcher $dispatcher,
121
-								EventDispatcherInterface $legacyDispatcher) {
122
-		$this->db = $db;
123
-		$this->principalBackend = $principalBackend;
124
-		$this->userManager = $userManager;
125
-		$this->dispatcher = $dispatcher;
126
-		$this->legacyDispatcher = $legacyDispatcher;
127
-		$this->sharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'addressbook');
128
-	}
129
-
130
-	/**
131
-	 * Return the number of address books for a principal
132
-	 *
133
-	 * @param $principalUri
134
-	 * @return int
135
-	 */
136
-	public function getAddressBooksForUserCount($principalUri) {
137
-		$principalUri = $this->convertPrincipal($principalUri, true);
138
-		$query = $this->db->getQueryBuilder();
139
-		$query->select($query->func()->count('*'))
140
-			->from('addressbooks')
141
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
142
-
143
-		return (int)$query->execute()->fetchColumn();
144
-	}
145
-
146
-	/**
147
-	 * Returns the list of address books for a specific user.
148
-	 *
149
-	 * Every addressbook should have the following properties:
150
-	 *   id - an arbitrary unique id
151
-	 *   uri - the 'basename' part of the url
152
-	 *   principaluri - Same as the passed parameter
153
-	 *
154
-	 * Any additional clark-notation property may be passed besides this. Some
155
-	 * common ones are :
156
-	 *   {DAV:}displayname
157
-	 *   {urn:ietf:params:xml:ns:carddav}addressbook-description
158
-	 *   {http://calendarserver.org/ns/}getctag
159
-	 *
160
-	 * @param string $principalUri
161
-	 * @return array
162
-	 */
163
-	public function getAddressBooksForUser($principalUri) {
164
-		$principalUriOriginal = $principalUri;
165
-		$principalUri = $this->convertPrincipal($principalUri, true);
166
-		$query = $this->db->getQueryBuilder();
167
-		$query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
168
-			->from('addressbooks')
169
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
170
-
171
-		$addressBooks = [];
172
-
173
-		$result = $query->execute();
174
-		while ($row = $result->fetch()) {
175
-			$addressBooks[$row['id']] = [
176
-				'id' => $row['id'],
177
-				'uri' => $row['uri'],
178
-				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
179
-				'{DAV:}displayname' => $row['displayname'],
180
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
181
-				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
182
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
183
-			];
184
-
185
-			$this->addOwnerPrincipal($addressBooks[$row['id']]);
186
-		}
187
-		$result->closeCursor();
188
-
189
-		// query for shared addressbooks
190
-		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
191
-		$principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
192
-
193
-		$principals = array_map(function ($principal) {
194
-			return urldecode($principal);
195
-		}, $principals);
196
-		$principals[] = $principalUri;
197
-
198
-		$query = $this->db->getQueryBuilder();
199
-		$result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])
200
-			->from('dav_shares', 's')
201
-			->join('s', 'addressbooks', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
202
-			->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
203
-			->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
204
-			->setParameter('type', 'addressbook')
205
-			->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
206
-			->execute();
207
-
208
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
209
-		while ($row = $result->fetch()) {
210
-			if ($row['principaluri'] === $principalUri) {
211
-				continue;
212
-			}
213
-
214
-			$readOnly = (int)$row['access'] === Backend::ACCESS_READ;
215
-			if (isset($addressBooks[$row['id']])) {
216
-				if ($readOnly) {
217
-					// New share can not have more permissions then the old one.
218
-					continue;
219
-				}
220
-				if (isset($addressBooks[$row['id']][$readOnlyPropertyName]) &&
221
-					$addressBooks[$row['id']][$readOnlyPropertyName] === 0) {
222
-					// Old share is already read-write, no more permissions can be gained
223
-					continue;
224
-				}
225
-			}
226
-
227
-			list(, $name) = \Sabre\Uri\split($row['principaluri']);
228
-			$uri = $row['uri'] . '_shared_by_' . $name;
229
-			$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
230
-
231
-			$addressBooks[$row['id']] = [
232
-				'id' => $row['id'],
233
-				'uri' => $uri,
234
-				'principaluri' => $principalUriOriginal,
235
-				'{DAV:}displayname' => $displayName,
236
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
237
-				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
238
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
239
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
240
-				$readOnlyPropertyName => $readOnly,
241
-			];
242
-
243
-			$this->addOwnerPrincipal($addressBooks[$row['id']]);
244
-		}
245
-		$result->closeCursor();
246
-
247
-		return array_values($addressBooks);
248
-	}
249
-
250
-	public function getUsersOwnAddressBooks($principalUri) {
251
-		$principalUri = $this->convertPrincipal($principalUri, true);
252
-		$query = $this->db->getQueryBuilder();
253
-		$query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
254
-			->from('addressbooks')
255
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
256
-
257
-		$addressBooks = [];
258
-
259
-		$result = $query->execute();
260
-		while ($row = $result->fetch()) {
261
-			$addressBooks[$row['id']] = [
262
-				'id' => $row['id'],
263
-				'uri' => $row['uri'],
264
-				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
265
-				'{DAV:}displayname' => $row['displayname'],
266
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
267
-				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
268
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
269
-			];
270
-
271
-			$this->addOwnerPrincipal($addressBooks[$row['id']]);
272
-		}
273
-		$result->closeCursor();
274
-
275
-		return array_values($addressBooks);
276
-	}
277
-
278
-	private function getUserDisplayName($uid) {
279
-		if (!isset($this->userDisplayNames[$uid])) {
280
-			$user = $this->userManager->get($uid);
281
-
282
-			if ($user instanceof IUser) {
283
-				$this->userDisplayNames[$uid] = $user->getDisplayName();
284
-			} else {
285
-				$this->userDisplayNames[$uid] = $uid;
286
-			}
287
-		}
288
-
289
-		return $this->userDisplayNames[$uid];
290
-	}
291
-
292
-	/**
293
-	 * @param int $addressBookId
294
-	 */
295
-	public function getAddressBookById($addressBookId) {
296
-		$query = $this->db->getQueryBuilder();
297
-		$result = $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
298
-			->from('addressbooks')
299
-			->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
300
-			->execute();
301
-
302
-		$row = $result->fetch();
303
-		$result->closeCursor();
304
-		if ($row === false) {
305
-			return null;
306
-		}
307
-
308
-		$addressBook = [
309
-			'id' => $row['id'],
310
-			'uri' => $row['uri'],
311
-			'principaluri' => $row['principaluri'],
312
-			'{DAV:}displayname' => $row['displayname'],
313
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
314
-			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
315
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
316
-		];
317
-
318
-		$this->addOwnerPrincipal($addressBook);
319
-
320
-		return $addressBook;
321
-	}
322
-
323
-	/**
324
-	 * @param $addressBookUri
325
-	 * @return array|null
326
-	 */
327
-	public function getAddressBooksByUri($principal, $addressBookUri) {
328
-		$query = $this->db->getQueryBuilder();
329
-		$result = $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
330
-			->from('addressbooks')
331
-			->where($query->expr()->eq('uri', $query->createNamedParameter($addressBookUri)))
332
-			->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($principal)))
333
-			->setMaxResults(1)
334
-			->execute();
335
-
336
-		$row = $result->fetch();
337
-		$result->closeCursor();
338
-		if ($row === false) {
339
-			return null;
340
-		}
341
-
342
-		$addressBook = [
343
-			'id' => $row['id'],
344
-			'uri' => $row['uri'],
345
-			'principaluri' => $row['principaluri'],
346
-			'{DAV:}displayname' => $row['displayname'],
347
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
348
-			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
349
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
350
-		];
351
-
352
-		$this->addOwnerPrincipal($addressBook);
353
-
354
-		return $addressBook;
355
-	}
356
-
357
-	/**
358
-	 * Updates properties for an address book.
359
-	 *
360
-	 * The list of mutations is stored in a Sabre\DAV\PropPatch object.
361
-	 * To do the actual updates, you must tell this object which properties
362
-	 * you're going to process with the handle() method.
363
-	 *
364
-	 * Calling the handle method is like telling the PropPatch object "I
365
-	 * promise I can handle updating this property".
366
-	 *
367
-	 * Read the PropPatch documentation for more info and examples.
368
-	 *
369
-	 * @param string $addressBookId
370
-	 * @param \Sabre\DAV\PropPatch $propPatch
371
-	 * @return void
372
-	 */
373
-	public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
374
-		$supportedProperties = [
375
-			'{DAV:}displayname',
376
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description',
377
-		];
378
-
379
-		/**
380
-		 * @suppress SqlInjectionChecker
381
-		 */
382
-		$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
383
-			$updates = [];
384
-			foreach ($mutations as $property => $newValue) {
385
-				switch ($property) {
386
-					case '{DAV:}displayname':
387
-						$updates['displayname'] = $newValue;
388
-						break;
389
-					case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
390
-						$updates['description'] = $newValue;
391
-						break;
392
-				}
393
-			}
394
-			$query = $this->db->getQueryBuilder();
395
-			$query->update('addressbooks');
396
-
397
-			foreach ($updates as $key => $value) {
398
-				$query->set($key, $query->createNamedParameter($value));
399
-			}
400
-			$query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
401
-				->execute();
402
-
403
-			$this->addChange($addressBookId, "", 2);
404
-
405
-			$addressBookRow = $this->getAddressBookById((int)$addressBookId);
406
-			$shares = $this->getShares($addressBookId);
407
-			$this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
408
-
409
-			return true;
410
-		});
411
-	}
412
-
413
-	/**
414
-	 * Creates a new address book
415
-	 *
416
-	 * @param string $principalUri
417
-	 * @param string $url Just the 'basename' of the url.
418
-	 * @param array $properties
419
-	 * @return int
420
-	 * @throws BadRequest
421
-	 */
422
-	public function createAddressBook($principalUri, $url, array $properties) {
423
-		$values = [
424
-			'displayname' => null,
425
-			'description' => null,
426
-			'principaluri' => $principalUri,
427
-			'uri' => $url,
428
-			'synctoken' => 1
429
-		];
430
-
431
-		foreach ($properties as $property => $newValue) {
432
-			switch ($property) {
433
-				case '{DAV:}displayname':
434
-					$values['displayname'] = $newValue;
435
-					break;
436
-				case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
437
-					$values['description'] = $newValue;
438
-					break;
439
-				default:
440
-					throw new BadRequest('Unknown property: ' . $property);
441
-			}
442
-		}
443
-
444
-		// Fallback to make sure the displayname is set. Some clients may refuse
445
-		// to work with addressbooks not having a displayname.
446
-		if (is_null($values['displayname'])) {
447
-			$values['displayname'] = $url;
448
-		}
449
-
450
-		$query = $this->db->getQueryBuilder();
451
-		$query->insert('addressbooks')
452
-			->values([
453
-				'uri' => $query->createParameter('uri'),
454
-				'displayname' => $query->createParameter('displayname'),
455
-				'description' => $query->createParameter('description'),
456
-				'principaluri' => $query->createParameter('principaluri'),
457
-				'synctoken' => $query->createParameter('synctoken'),
458
-			])
459
-			->setParameters($values)
460
-			->execute();
461
-
462
-		$addressBookId = $query->getLastInsertId();
463
-		$addressBookRow = $this->getAddressBookById($addressBookId);
464
-		$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow));
465
-
466
-		return $addressBookId;
467
-	}
468
-
469
-	/**
470
-	 * Deletes an entire addressbook and all its contents
471
-	 *
472
-	 * @param mixed $addressBookId
473
-	 * @return void
474
-	 */
475
-	public function deleteAddressBook($addressBookId) {
476
-		$addressBookData = $this->getAddressBookById($addressBookId);
477
-		$shares = $this->getShares($addressBookId);
478
-
479
-		$query = $this->db->getQueryBuilder();
480
-		$query->delete($this->dbCardsTable)
481
-			->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
482
-			->setParameter('addressbookid', $addressBookId)
483
-			->execute();
484
-
485
-		$query->delete('addressbookchanges')
486
-			->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
487
-			->setParameter('addressbookid', $addressBookId)
488
-			->execute();
489
-
490
-		$query->delete('addressbooks')
491
-			->where($query->expr()->eq('id', $query->createParameter('id')))
492
-			->setParameter('id', $addressBookId)
493
-			->execute();
494
-
495
-		$this->sharingBackend->deleteAllShares($addressBookId);
496
-
497
-		$query->delete($this->dbCardsPropertiesTable)
498
-			->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
499
-			->execute();
500
-
501
-		if ($addressBookData) {
502
-			$this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares));
503
-		}
504
-	}
505
-
506
-	/**
507
-	 * Returns all cards for a specific addressbook id.
508
-	 *
509
-	 * This method should return the following properties for each card:
510
-	 *   * carddata - raw vcard data
511
-	 *   * uri - Some unique url
512
-	 *   * lastmodified - A unix timestamp
513
-	 *
514
-	 * It's recommended to also return the following properties:
515
-	 *   * etag - A unique etag. This must change every time the card changes.
516
-	 *   * size - The size of the card in bytes.
517
-	 *
518
-	 * If these last two properties are provided, less time will be spent
519
-	 * calculating them. If they are specified, you can also ommit carddata.
520
-	 * This may speed up certain requests, especially with large cards.
521
-	 *
522
-	 * @param mixed $addressBookId
523
-	 * @return array
524
-	 */
525
-	public function getCards($addressBookId) {
526
-		$query = $this->db->getQueryBuilder();
527
-		$query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
528
-			->from($this->dbCardsTable)
529
-			->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
530
-
531
-		$cards = [];
532
-
533
-		$result = $query->execute();
534
-		while ($row = $result->fetch()) {
535
-			$row['etag'] = '"' . $row['etag'] . '"';
536
-
537
-			$modified = false;
538
-			$row['carddata'] = $this->readBlob($row['carddata'], $modified);
539
-			if ($modified) {
540
-				$row['size'] = strlen($row['carddata']);
541
-			}
542
-
543
-			$cards[] = $row;
544
-		}
545
-		$result->closeCursor();
546
-
547
-		return $cards;
548
-	}
549
-
550
-	/**
551
-	 * Returns a specific card.
552
-	 *
553
-	 * The same set of properties must be returned as with getCards. The only
554
-	 * exception is that 'carddata' is absolutely required.
555
-	 *
556
-	 * If the card does not exist, you must return false.
557
-	 *
558
-	 * @param mixed $addressBookId
559
-	 * @param string $cardUri
560
-	 * @return array
561
-	 */
562
-	public function getCard($addressBookId, $cardUri) {
563
-		$query = $this->db->getQueryBuilder();
564
-		$query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
565
-			->from($this->dbCardsTable)
566
-			->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
567
-			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
568
-			->setMaxResults(1);
569
-
570
-		$result = $query->execute();
571
-		$row = $result->fetch();
572
-		if (!$row) {
573
-			return false;
574
-		}
575
-		$row['etag'] = '"' . $row['etag'] . '"';
576
-
577
-		$modified = false;
578
-		$row['carddata'] = $this->readBlob($row['carddata'], $modified);
579
-		if ($modified) {
580
-			$row['size'] = strlen($row['carddata']);
581
-		}
582
-
583
-		return $row;
584
-	}
585
-
586
-	/**
587
-	 * Returns a list of cards.
588
-	 *
589
-	 * This method should work identical to getCard, but instead return all the
590
-	 * cards in the list as an array.
591
-	 *
592
-	 * If the backend supports this, it may allow for some speed-ups.
593
-	 *
594
-	 * @param mixed $addressBookId
595
-	 * @param string[] $uris
596
-	 * @return array
597
-	 */
598
-	public function getMultipleCards($addressBookId, array $uris) {
599
-		if (empty($uris)) {
600
-			return [];
601
-		}
602
-
603
-		$chunks = array_chunk($uris, 100);
604
-		$cards = [];
605
-
606
-		$query = $this->db->getQueryBuilder();
607
-		$query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
608
-			->from($this->dbCardsTable)
609
-			->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
610
-			->andWhere($query->expr()->in('uri', $query->createParameter('uri')));
611
-
612
-		foreach ($chunks as $uris) {
613
-			$query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
614
-			$result = $query->execute();
615
-
616
-			while ($row = $result->fetch()) {
617
-				$row['etag'] = '"' . $row['etag'] . '"';
618
-
619
-				$modified = false;
620
-				$row['carddata'] = $this->readBlob($row['carddata'], $modified);
621
-				if ($modified) {
622
-					$row['size'] = strlen($row['carddata']);
623
-				}
624
-
625
-				$cards[] = $row;
626
-			}
627
-			$result->closeCursor();
628
-		}
629
-		return $cards;
630
-	}
631
-
632
-	/**
633
-	 * Creates a new card.
634
-	 *
635
-	 * The addressbook id will be passed as the first argument. This is the
636
-	 * same id as it is returned from the getAddressBooksForUser method.
637
-	 *
638
-	 * The cardUri is a base uri, and doesn't include the full path. The
639
-	 * cardData argument is the vcard body, and is passed as a string.
640
-	 *
641
-	 * It is possible to return an ETag from this method. This ETag is for the
642
-	 * newly created resource, and must be enclosed with double quotes (that
643
-	 * is, the string itself must contain the double quotes).
644
-	 *
645
-	 * You should only return the ETag if you store the carddata as-is. If a
646
-	 * subsequent GET request on the same card does not have the same body,
647
-	 * byte-by-byte and you did return an ETag here, clients tend to get
648
-	 * confused.
649
-	 *
650
-	 * If you don't return an ETag, you can just return null.
651
-	 *
652
-	 * @param mixed $addressBookId
653
-	 * @param string $cardUri
654
-	 * @param string $cardData
655
-	 * @return string
656
-	 */
657
-	public function createCard($addressBookId, $cardUri, $cardData) {
658
-		$etag = md5($cardData);
659
-		$uid = $this->getUID($cardData);
660
-
661
-		$q = $this->db->getQueryBuilder();
662
-		$q->select('uid')
663
-			->from($this->dbCardsTable)
664
-			->where($q->expr()->eq('addressbookid', $q->createNamedParameter($addressBookId)))
665
-			->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid)))
666
-			->setMaxResults(1);
667
-		$result = $q->execute();
668
-		$count = (bool)$result->fetchColumn();
669
-		$result->closeCursor();
670
-		if ($count) {
671
-			throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.');
672
-		}
673
-
674
-		$query = $this->db->getQueryBuilder();
675
-		$query->insert('cards')
676
-			->values([
677
-				'carddata' => $query->createNamedParameter($cardData, IQueryBuilder::PARAM_LOB),
678
-				'uri' => $query->createNamedParameter($cardUri),
679
-				'lastmodified' => $query->createNamedParameter(time()),
680
-				'addressbookid' => $query->createNamedParameter($addressBookId),
681
-				'size' => $query->createNamedParameter(strlen($cardData)),
682
-				'etag' => $query->createNamedParameter($etag),
683
-				'uid' => $query->createNamedParameter($uid),
684
-			])
685
-			->execute();
686
-
687
-		$etagCacheKey = "$addressBookId#$cardUri";
688
-		$this->etagCache[$etagCacheKey] = $etag;
689
-
690
-		$this->addChange($addressBookId, $cardUri, 1);
691
-		$this->updateProperties($addressBookId, $cardUri, $cardData);
692
-
693
-		$addressBookData = $this->getAddressBookById($addressBookId);
694
-		$shares = $this->getShares($addressBookId);
695
-		$objectRow = $this->getCard($addressBookId, $cardUri);
696
-		$this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
697
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
698
-			new GenericEvent(null, [
699
-				'addressBookId' => $addressBookId,
700
-				'cardUri' => $cardUri,
701
-				'cardData' => $cardData]));
702
-
703
-		return '"' . $etag . '"';
704
-	}
705
-
706
-	/**
707
-	 * Updates a card.
708
-	 *
709
-	 * The addressbook id will be passed as the first argument. This is the
710
-	 * same id as it is returned from the getAddressBooksForUser method.
711
-	 *
712
-	 * The cardUri is a base uri, and doesn't include the full path. The
713
-	 * cardData argument is the vcard body, and is passed as a string.
714
-	 *
715
-	 * It is possible to return an ETag from this method. This ETag should
716
-	 * match that of the updated resource, and must be enclosed with double
717
-	 * quotes (that is: the string itself must contain the actual quotes).
718
-	 *
719
-	 * You should only return the ETag if you store the carddata as-is. If a
720
-	 * subsequent GET request on the same card does not have the same body,
721
-	 * byte-by-byte and you did return an ETag here, clients tend to get
722
-	 * confused.
723
-	 *
724
-	 * If you don't return an ETag, you can just return null.
725
-	 *
726
-	 * @param mixed $addressBookId
727
-	 * @param string $cardUri
728
-	 * @param string $cardData
729
-	 * @return string
730
-	 */
731
-	public function updateCard($addressBookId, $cardUri, $cardData) {
732
-		$uid = $this->getUID($cardData);
733
-		$etag = md5($cardData);
734
-		$query = $this->db->getQueryBuilder();
735
-
736
-		// check for recently stored etag and stop if it is the same
737
-		$etagCacheKey = "$addressBookId#$cardUri";
738
-		if (isset($this->etagCache[$etagCacheKey]) && $this->etagCache[$etagCacheKey] === $etag) {
739
-			return '"' . $etag . '"';
740
-		}
741
-
742
-		$query->update($this->dbCardsTable)
743
-			->set('carddata', $query->createNamedParameter($cardData, IQueryBuilder::PARAM_LOB))
744
-			->set('lastmodified', $query->createNamedParameter(time()))
745
-			->set('size', $query->createNamedParameter(strlen($cardData)))
746
-			->set('etag', $query->createNamedParameter($etag))
747
-			->set('uid', $query->createNamedParameter($uid))
748
-			->where($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
749
-			->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
750
-			->execute();
751
-
752
-		$this->etagCache[$etagCacheKey] = $etag;
753
-
754
-		$this->addChange($addressBookId, $cardUri, 2);
755
-		$this->updateProperties($addressBookId, $cardUri, $cardData);
756
-
757
-		$addressBookData = $this->getAddressBookById($addressBookId);
758
-		$shares = $this->getShares($addressBookId);
759
-		$objectRow = $this->getCard($addressBookId, $cardUri);
760
-		$this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
761
-		$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
762
-			new GenericEvent(null, [
763
-				'addressBookId' => $addressBookId,
764
-				'cardUri' => $cardUri,
765
-				'cardData' => $cardData]));
766
-
767
-		return '"' . $etag . '"';
768
-	}
769
-
770
-	/**
771
-	 * Deletes a card
772
-	 *
773
-	 * @param mixed $addressBookId
774
-	 * @param string $cardUri
775
-	 * @return bool
776
-	 */
777
-	public function deleteCard($addressBookId, $cardUri) {
778
-		$addressBookData = $this->getAddressBookById($addressBookId);
779
-		$shares = $this->getShares($addressBookId);
780
-		$objectRow = $this->getCard($addressBookId, $cardUri);
781
-
782
-		try {
783
-			$cardId = $this->getCardId($addressBookId, $cardUri);
784
-		} catch (\InvalidArgumentException $e) {
785
-			$cardId = null;
786
-		}
787
-		$query = $this->db->getQueryBuilder();
788
-		$ret = $query->delete($this->dbCardsTable)
789
-			->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
790
-			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
791
-			->execute();
792
-
793
-		$this->addChange($addressBookId, $cardUri, 3);
794
-
795
-		if ($ret === 1) {
796
-			if ($cardId !== null) {
797
-				$this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
798
-				$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
799
-					new GenericEvent(null, [
800
-						'addressBookId' => $addressBookId,
801
-						'cardUri' => $cardUri]));
802
-
803
-				$this->purgeProperties($addressBookId, $cardId);
804
-			}
805
-			return true;
806
-		}
807
-
808
-		return false;
809
-	}
810
-
811
-	/**
812
-	 * The getChanges method returns all the changes that have happened, since
813
-	 * the specified syncToken in the specified address book.
814
-	 *
815
-	 * This function should return an array, such as the following:
816
-	 *
817
-	 * [
818
-	 *   'syncToken' => 'The current synctoken',
819
-	 *   'added'   => [
820
-	 *      'new.txt',
821
-	 *   ],
822
-	 *   'modified'   => [
823
-	 *      'modified.txt',
824
-	 *   ],
825
-	 *   'deleted' => [
826
-	 *      'foo.php.bak',
827
-	 *      'old.txt'
828
-	 *   ]
829
-	 * ];
830
-	 *
831
-	 * The returned syncToken property should reflect the *current* syncToken
832
-	 * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
833
-	 * property. This is needed here too, to ensure the operation is atomic.
834
-	 *
835
-	 * If the $syncToken argument is specified as null, this is an initial
836
-	 * sync, and all members should be reported.
837
-	 *
838
-	 * The modified property is an array of nodenames that have changed since
839
-	 * the last token.
840
-	 *
841
-	 * The deleted property is an array with nodenames, that have been deleted
842
-	 * from collection.
843
-	 *
844
-	 * The $syncLevel argument is basically the 'depth' of the report. If it's
845
-	 * 1, you only have to report changes that happened only directly in
846
-	 * immediate descendants. If it's 2, it should also include changes from
847
-	 * the nodes below the child collections. (grandchildren)
848
-	 *
849
-	 * The $limit argument allows a client to specify how many results should
850
-	 * be returned at most. If the limit is not specified, it should be treated
851
-	 * as infinite.
852
-	 *
853
-	 * If the limit (infinite or not) is higher than you're willing to return,
854
-	 * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
855
-	 *
856
-	 * If the syncToken is expired (due to data cleanup) or unknown, you must
857
-	 * return null.
858
-	 *
859
-	 * The limit is 'suggestive'. You are free to ignore it.
860
-	 *
861
-	 * @param string $addressBookId
862
-	 * @param string $syncToken
863
-	 * @param int $syncLevel
864
-	 * @param int $limit
865
-	 * @return array
866
-	 */
867
-	public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) {
868
-		// Current synctoken
869
-		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?');
870
-		$stmt->execute([$addressBookId]);
871
-		$currentToken = $stmt->fetchColumn(0);
872
-
873
-		if (is_null($currentToken)) {
874
-			return null;
875
-		}
876
-
877
-		$result = [
878
-			'syncToken' => $currentToken,
879
-			'added' => [],
880
-			'modified' => [],
881
-			'deleted' => [],
882
-		];
883
-
884
-		if ($syncToken) {
885
-			$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
886
-			if ($limit > 0) {
887
-				$query .= " LIMIT " . (int)$limit;
888
-			}
889
-
890
-			// Fetching all changes
891
-			$stmt = $this->db->prepare($query);
892
-			$stmt->execute([$syncToken, $currentToken, $addressBookId]);
893
-
894
-			$changes = [];
895
-
896
-			// This loop ensures that any duplicates are overwritten, only the
897
-			// last change on a node is relevant.
898
-			while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
899
-				$changes[$row['uri']] = $row['operation'];
900
-			}
901
-
902
-			foreach ($changes as $uri => $operation) {
903
-				switch ($operation) {
904
-					case 1:
905
-						$result['added'][] = $uri;
906
-						break;
907
-					case 2:
908
-						$result['modified'][] = $uri;
909
-						break;
910
-					case 3:
911
-						$result['deleted'][] = $uri;
912
-						break;
913
-				}
914
-			}
915
-		} else {
916
-			// No synctoken supplied, this is the initial sync.
917
-			$query = "SELECT `uri` FROM `*PREFIX*cards` WHERE `addressbookid` = ?";
918
-			$stmt = $this->db->prepare($query);
919
-			$stmt->execute([$addressBookId]);
920
-
921
-			$result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
922
-		}
923
-		return $result;
924
-	}
925
-
926
-	/**
927
-	 * Adds a change record to the addressbookchanges table.
928
-	 *
929
-	 * @param mixed $addressBookId
930
-	 * @param string $objectUri
931
-	 * @param int $operation 1 = add, 2 = modify, 3 = delete
932
-	 * @return void
933
-	 */
934
-	protected function addChange($addressBookId, $objectUri, $operation) {
935
-		$sql = 'INSERT INTO `*PREFIX*addressbookchanges`(`uri`, `synctoken`, `addressbookid`, `operation`) SELECT ?, `synctoken`, ?, ? FROM `*PREFIX*addressbooks` WHERE `id` = ?';
936
-		$stmt = $this->db->prepare($sql);
937
-		$stmt->execute([
938
-			$objectUri,
939
-			$addressBookId,
940
-			$operation,
941
-			$addressBookId
942
-		]);
943
-		$stmt = $this->db->prepare('UPDATE `*PREFIX*addressbooks` SET `synctoken` = `synctoken` + 1 WHERE `id` = ?');
944
-		$stmt->execute([
945
-			$addressBookId
946
-		]);
947
-	}
948
-
949
-	/**
950
-	 * @param resource|string $cardData
951
-	 * @param bool $modified
952
-	 * @return string
953
-	 */
954
-	private function readBlob($cardData, &$modified = false) {
955
-		if (is_resource($cardData)) {
956
-			$cardData = stream_get_contents($cardData);
957
-		}
958
-
959
-		$cardDataArray = explode("\r\n", $cardData);
960
-
961
-		$cardDataFiltered = [];
962
-		$removingPhoto = false;
963
-		foreach ($cardDataArray as $line) {
964
-			if (strpos($line, 'PHOTO:data:') === 0
965
-				&& strpos($line, 'PHOTO:data:image/') !== 0) {
966
-				// Filter out PHOTO data of non-images
967
-				$removingPhoto = true;
968
-				$modified = true;
969
-				continue;
970
-			}
971
-
972
-			if ($removingPhoto) {
973
-				if (strpos($line, ' ') === 0) {
974
-					continue;
975
-				}
976
-				// No leading space means this is a new property
977
-				$removingPhoto = false;
978
-			}
979
-
980
-			$cardDataFiltered[] = $line;
981
-		}
982
-
983
-		return implode("\r\n", $cardDataFiltered);
984
-	}
985
-
986
-	/**
987
-	 * @param IShareable $shareable
988
-	 * @param string[] $add
989
-	 * @param string[] $remove
990
-	 */
991
-	public function updateShares(IShareable $shareable, $add, $remove) {
992
-		$addressBookId = $shareable->getResourceId();
993
-		$addressBookData = $this->getAddressBookById($addressBookId);
994
-		$oldShares = $this->getShares($addressBookId);
995
-
996
-		$this->sharingBackend->updateShares($shareable, $add, $remove);
997
-
998
-		$this->dispatcher->dispatchTyped(new AddressBookShareUpdatedEvent($addressBookId, $addressBookData, $oldShares, $add, $remove));
999
-	}
1000
-
1001
-	/**
1002
-	 * Search contacts in a specific address-book
1003
-	 *
1004
-	 * @param int $addressBookId
1005
-	 * @param string $pattern which should match within the $searchProperties
1006
-	 * @param array $searchProperties defines the properties within the query pattern should match
1007
-	 * @param array $options = array() to define the search behavior
1008
-	 *    - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are
1009
-	 *    - 'limit' - Set a numeric limit for the search results
1010
-	 *    - 'offset' - Set the offset for the limited search results
1011
-	 * @return array an array of contacts which are arrays of key-value-pairs
1012
-	 */
1013
-	public function search($addressBookId, $pattern, $searchProperties, $options = []): array {
1014
-		return $this->searchByAddressBookIds([$addressBookId], $pattern, $searchProperties, $options);
1015
-	}
1016
-
1017
-	/**
1018
-	 * Search contacts in all address-books accessible by a user
1019
-	 *
1020
-	 * @param string $principalUri
1021
-	 * @param string $pattern
1022
-	 * @param array $searchProperties
1023
-	 * @param array $options
1024
-	 * @return array
1025
-	 */
1026
-	public function searchPrincipalUri(string $principalUri,
1027
-									   string $pattern,
1028
-									   array $searchProperties,
1029
-									   array $options = []): array {
1030
-		$addressBookIds = array_map(static function ($row):int {
1031
-			return (int) $row['id'];
1032
-		}, $this->getAddressBooksForUser($principalUri));
1033
-
1034
-		return $this->searchByAddressBookIds($addressBookIds, $pattern, $searchProperties, $options);
1035
-	}
1036
-
1037
-	/**
1038
-	 * @param array $addressBookIds
1039
-	 * @param string $pattern
1040
-	 * @param array $searchProperties
1041
-	 * @param array $options
1042
-	 * @return array
1043
-	 */
1044
-	private function searchByAddressBookIds(array $addressBookIds,
1045
-											string $pattern,
1046
-											array $searchProperties,
1047
-											array $options = []): array {
1048
-		$escapePattern = !\array_key_exists('escape_like_param', $options) || $options['escape_like_param'] !== false;
1049
-
1050
-		$query2 = $this->db->getQueryBuilder();
1051
-
1052
-		$addressBookOr =  $query2->expr()->orX();
1053
-		foreach ($addressBookIds as $addressBookId) {
1054
-			$addressBookOr->add($query2->expr()->eq('cp.addressbookid', $query2->createNamedParameter($addressBookId)));
1055
-		}
1056
-
1057
-		if ($addressBookOr->count() === 0) {
1058
-			return [];
1059
-		}
1060
-
1061
-		$propertyOr = $query2->expr()->orX();
1062
-		foreach ($searchProperties as $property) {
1063
-			if ($escapePattern) {
1064
-				if ($property === 'EMAIL' && strpos($pattern, ' ') !== false) {
1065
-					// There can be no spaces in emails
1066
-					continue;
1067
-				}
1068
-
1069
-				if ($property === 'CLOUD' && preg_match('/[^a-zA-Z0-9 :_.@\/\-\']/', $pattern) === 1) {
1070
-					// There can be no chars in cloud ids which are not valid for user ids plus :/
1071
-					// worst case: CA61590A-BBBC-423E-84AF-E6DF01455A53@https://my.nxt/srv/
1072
-					continue;
1073
-				}
1074
-			}
1075
-
1076
-			$propertyOr->add($query2->expr()->eq('cp.name', $query2->createNamedParameter($property)));
1077
-		}
1078
-
1079
-		if ($propertyOr->count() === 0) {
1080
-			return [];
1081
-		}
1082
-
1083
-		$query2->selectDistinct('cp.cardid')
1084
-			->from($this->dbCardsPropertiesTable, 'cp')
1085
-			->andWhere($addressBookOr)
1086
-			->andWhere($propertyOr);
1087
-
1088
-		// No need for like when the pattern is empty
1089
-		if ('' !== $pattern) {
1090
-			if (!$escapePattern) {
1091
-				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern)));
1092
-			} else {
1093
-				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1094
-			}
1095
-		}
1096
-
1097
-		if (isset($options['limit'])) {
1098
-			$query2->setMaxResults($options['limit']);
1099
-		}
1100
-		if (isset($options['offset'])) {
1101
-			$query2->setFirstResult($options['offset']);
1102
-		}
1103
-
1104
-		$result = $query2->execute();
1105
-		$matches = $result->fetchAll();
1106
-		$result->closeCursor();
1107
-		$matches = array_map(function ($match) {
1108
-			return (int)$match['cardid'];
1109
-		}, $matches);
1110
-
1111
-		$query = $this->db->getQueryBuilder();
1112
-		$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1113
-			->from($this->dbCardsTable, 'c')
1114
-			->where($query->expr()->in('c.id', $query->createNamedParameter($matches, IQueryBuilder::PARAM_INT_ARRAY)));
1115
-
1116
-		$result = $query->execute();
1117
-		$cards = $result->fetchAll();
1118
-
1119
-		$result->closeCursor();
1120
-
1121
-		return array_map(function ($array) {
1122
-			$array['addressbookid'] = (int) $array['addressbookid'];
1123
-			$modified = false;
1124
-			$array['carddata'] = $this->readBlob($array['carddata'], $modified);
1125
-			if ($modified) {
1126
-				$array['size'] = strlen($array['carddata']);
1127
-			}
1128
-			return $array;
1129
-		}, $cards);
1130
-	}
1131
-
1132
-	/**
1133
-	 * @param int $bookId
1134
-	 * @param string $name
1135
-	 * @return array
1136
-	 */
1137
-	public function collectCardProperties($bookId, $name) {
1138
-		$query = $this->db->getQueryBuilder();
1139
-		$result = $query->selectDistinct('value')
1140
-			->from($this->dbCardsPropertiesTable)
1141
-			->where($query->expr()->eq('name', $query->createNamedParameter($name)))
1142
-			->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($bookId)))
1143
-			->execute();
1144
-
1145
-		$all = $result->fetchAll(PDO::FETCH_COLUMN);
1146
-		$result->closeCursor();
1147
-
1148
-		return $all;
1149
-	}
1150
-
1151
-	/**
1152
-	 * get URI from a given contact
1153
-	 *
1154
-	 * @param int $id
1155
-	 * @return string
1156
-	 */
1157
-	public function getCardUri($id) {
1158
-		$query = $this->db->getQueryBuilder();
1159
-		$query->select('uri')->from($this->dbCardsTable)
1160
-			->where($query->expr()->eq('id', $query->createParameter('id')))
1161
-			->setParameter('id', $id);
1162
-
1163
-		$result = $query->execute();
1164
-		$uri = $result->fetch();
1165
-		$result->closeCursor();
1166
-
1167
-		if (!isset($uri['uri'])) {
1168
-			throw new \InvalidArgumentException('Card does not exists: ' . $id);
1169
-		}
1170
-
1171
-		return $uri['uri'];
1172
-	}
1173
-
1174
-	/**
1175
-	 * return contact with the given URI
1176
-	 *
1177
-	 * @param int $addressBookId
1178
-	 * @param string $uri
1179
-	 * @returns array
1180
-	 */
1181
-	public function getContact($addressBookId, $uri) {
1182
-		$result = [];
1183
-		$query = $this->db->getQueryBuilder();
1184
-		$query->select('*')->from($this->dbCardsTable)
1185
-			->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
1186
-			->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1187
-		$queryResult = $query->execute();
1188
-		$contact = $queryResult->fetch();
1189
-		$queryResult->closeCursor();
1190
-
1191
-		if (is_array($contact)) {
1192
-			$modified = false;
1193
-			$contact['etag'] = '"' . $contact['etag'] . '"';
1194
-			$contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
1195
-			if ($modified) {
1196
-				$contact['size'] = strlen($contact['carddata']);
1197
-			}
1198
-
1199
-			$result = $contact;
1200
-		}
1201
-
1202
-		return $result;
1203
-	}
1204
-
1205
-	/**
1206
-	 * Returns the list of people whom this address book is shared with.
1207
-	 *
1208
-	 * Every element in this array should have the following properties:
1209
-	 *   * href - Often a mailto: address
1210
-	 *   * commonName - Optional, for example a first + last name
1211
-	 *   * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
1212
-	 *   * readOnly - boolean
1213
-	 *   * summary - Optional, a description for the share
1214
-	 *
1215
-	 * @return array
1216
-	 */
1217
-	public function getShares($addressBookId) {
1218
-		return $this->sharingBackend->getShares($addressBookId);
1219
-	}
1220
-
1221
-	/**
1222
-	 * update properties table
1223
-	 *
1224
-	 * @param int $addressBookId
1225
-	 * @param string $cardUri
1226
-	 * @param string $vCardSerialized
1227
-	 */
1228
-	protected function updateProperties($addressBookId, $cardUri, $vCardSerialized) {
1229
-		$cardId = $this->getCardId($addressBookId, $cardUri);
1230
-		$vCard = $this->readCard($vCardSerialized);
1231
-
1232
-		$this->purgeProperties($addressBookId, $cardId);
1233
-
1234
-		$query = $this->db->getQueryBuilder();
1235
-		$query->insert($this->dbCardsPropertiesTable)
1236
-			->values(
1237
-				[
1238
-					'addressbookid' => $query->createNamedParameter($addressBookId),
1239
-					'cardid' => $query->createNamedParameter($cardId),
1240
-					'name' => $query->createParameter('name'),
1241
-					'value' => $query->createParameter('value'),
1242
-					'preferred' => $query->createParameter('preferred')
1243
-				]
1244
-			);
1245
-
1246
-		foreach ($vCard->children() as $property) {
1247
-			if (!in_array($property->name, self::$indexProperties)) {
1248
-				continue;
1249
-			}
1250
-			$preferred = 0;
1251
-			foreach ($property->parameters as $parameter) {
1252
-				if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') {
1253
-					$preferred = 1;
1254
-					break;
1255
-				}
1256
-			}
1257
-			$query->setParameter('name', $property->name);
1258
-			$query->setParameter('value', mb_substr($property->getValue(), 0, 254));
1259
-			$query->setParameter('preferred', $preferred);
1260
-			$query->execute();
1261
-		}
1262
-	}
1263
-
1264
-	/**
1265
-	 * read vCard data into a vCard object
1266
-	 *
1267
-	 * @param string $cardData
1268
-	 * @return VCard
1269
-	 */
1270
-	protected function readCard($cardData) {
1271
-		return Reader::read($cardData);
1272
-	}
1273
-
1274
-	/**
1275
-	 * delete all properties from a given card
1276
-	 *
1277
-	 * @param int $addressBookId
1278
-	 * @param int $cardId
1279
-	 */
1280
-	protected function purgeProperties($addressBookId, $cardId) {
1281
-		$query = $this->db->getQueryBuilder();
1282
-		$query->delete($this->dbCardsPropertiesTable)
1283
-			->where($query->expr()->eq('cardid', $query->createNamedParameter($cardId)))
1284
-			->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1285
-		$query->execute();
1286
-	}
1287
-
1288
-	/**
1289
-	 * get ID from a given contact
1290
-	 *
1291
-	 * @param int $addressBookId
1292
-	 * @param string $uri
1293
-	 * @return int
1294
-	 */
1295
-	protected function getCardId($addressBookId, $uri) {
1296
-		$query = $this->db->getQueryBuilder();
1297
-		$query->select('id')->from($this->dbCardsTable)
1298
-			->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
1299
-			->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1300
-
1301
-		$result = $query->execute();
1302
-		$cardIds = $result->fetch();
1303
-		$result->closeCursor();
1304
-
1305
-		if (!isset($cardIds['id'])) {
1306
-			throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1307
-		}
1308
-
1309
-		return (int)$cardIds['id'];
1310
-	}
1311
-
1312
-	/**
1313
-	 * For shared address books the sharee is set in the ACL of the address book
1314
-	 *
1315
-	 * @param $addressBookId
1316
-	 * @param $acl
1317
-	 * @return array
1318
-	 */
1319
-	public function applyShareAcl($addressBookId, $acl) {
1320
-		return $this->sharingBackend->applyShareAcl($addressBookId, $acl);
1321
-	}
1322
-
1323
-	private function convertPrincipal($principalUri, $toV2) {
1324
-		if ($this->principalBackend->getPrincipalPrefix() === 'principals') {
1325
-			list(, $name) = \Sabre\Uri\split($principalUri);
1326
-			if ($toV2 === true) {
1327
-				return "principals/users/$name";
1328
-			}
1329
-			return "principals/$name";
1330
-		}
1331
-		return $principalUri;
1332
-	}
1333
-
1334
-	private function addOwnerPrincipal(&$addressbookInfo) {
1335
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
1336
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
1337
-		if (isset($addressbookInfo[$ownerPrincipalKey])) {
1338
-			$uri = $addressbookInfo[$ownerPrincipalKey];
1339
-		} else {
1340
-			$uri = $addressbookInfo['principaluri'];
1341
-		}
1342
-
1343
-		$principalInformation = $this->principalBackend->getPrincipalByPath($uri);
1344
-		if (isset($principalInformation['{DAV:}displayname'])) {
1345
-			$addressbookInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
1346
-		}
1347
-	}
1348
-
1349
-	/**
1350
-	 * Extract UID from vcard
1351
-	 *
1352
-	 * @param string $cardData the vcard raw data
1353
-	 * @return string the uid
1354
-	 * @throws BadRequest if no UID is available
1355
-	 */
1356
-	private function getUID($cardData) {
1357
-		if ($cardData != '') {
1358
-			$vCard = Reader::read($cardData);
1359
-			if ($vCard->UID) {
1360
-				$uid = $vCard->UID->getValue();
1361
-				return $uid;
1362
-			}
1363
-			// should already be handled, but just in case
1364
-			throw new BadRequest('vCards on CardDAV servers MUST have a UID property');
1365
-		}
1366
-		// should already be handled, but just in case
1367
-		throw new BadRequest('vCard can not be empty');
1368
-	}
67
+    public const PERSONAL_ADDRESSBOOK_URI = 'contacts';
68
+    public const PERSONAL_ADDRESSBOOK_NAME = 'Contacts';
69
+
70
+    /** @var Principal */
71
+    private $principalBackend;
72
+
73
+    /** @var string */
74
+    private $dbCardsTable = 'cards';
75
+
76
+    /** @var string */
77
+    private $dbCardsPropertiesTable = 'cards_properties';
78
+
79
+    /** @var IDBConnection */
80
+    private $db;
81
+
82
+    /** @var Backend */
83
+    private $sharingBackend;
84
+
85
+    /** @var array properties to index */
86
+    public static $indexProperties = [
87
+        'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME',
88
+        'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO', 'CLOUD'];
89
+
90
+    /**
91
+     * @var string[] Map of uid => display name
92
+     */
93
+    protected $userDisplayNames;
94
+
95
+    /** @var IUserManager */
96
+    private $userManager;
97
+
98
+    /** @var IEventDispatcher */
99
+    private $dispatcher;
100
+
101
+    /** @var EventDispatcherInterface */
102
+    private $legacyDispatcher;
103
+
104
+    private $etagCache = [];
105
+
106
+    /**
107
+     * CardDavBackend constructor.
108
+     *
109
+     * @param IDBConnection $db
110
+     * @param Principal $principalBackend
111
+     * @param IUserManager $userManager
112
+     * @param IGroupManager $groupManager
113
+     * @param IEventDispatcher $dispatcher
114
+     * @param EventDispatcherInterface $legacyDispatcher
115
+     */
116
+    public function __construct(IDBConnection $db,
117
+                                Principal $principalBackend,
118
+                                IUserManager $userManager,
119
+                                IGroupManager $groupManager,
120
+                                IEventDispatcher $dispatcher,
121
+                                EventDispatcherInterface $legacyDispatcher) {
122
+        $this->db = $db;
123
+        $this->principalBackend = $principalBackend;
124
+        $this->userManager = $userManager;
125
+        $this->dispatcher = $dispatcher;
126
+        $this->legacyDispatcher = $legacyDispatcher;
127
+        $this->sharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'addressbook');
128
+    }
129
+
130
+    /**
131
+     * Return the number of address books for a principal
132
+     *
133
+     * @param $principalUri
134
+     * @return int
135
+     */
136
+    public function getAddressBooksForUserCount($principalUri) {
137
+        $principalUri = $this->convertPrincipal($principalUri, true);
138
+        $query = $this->db->getQueryBuilder();
139
+        $query->select($query->func()->count('*'))
140
+            ->from('addressbooks')
141
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
142
+
143
+        return (int)$query->execute()->fetchColumn();
144
+    }
145
+
146
+    /**
147
+     * Returns the list of address books for a specific user.
148
+     *
149
+     * Every addressbook should have the following properties:
150
+     *   id - an arbitrary unique id
151
+     *   uri - the 'basename' part of the url
152
+     *   principaluri - Same as the passed parameter
153
+     *
154
+     * Any additional clark-notation property may be passed besides this. Some
155
+     * common ones are :
156
+     *   {DAV:}displayname
157
+     *   {urn:ietf:params:xml:ns:carddav}addressbook-description
158
+     *   {http://calendarserver.org/ns/}getctag
159
+     *
160
+     * @param string $principalUri
161
+     * @return array
162
+     */
163
+    public function getAddressBooksForUser($principalUri) {
164
+        $principalUriOriginal = $principalUri;
165
+        $principalUri = $this->convertPrincipal($principalUri, true);
166
+        $query = $this->db->getQueryBuilder();
167
+        $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
168
+            ->from('addressbooks')
169
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
170
+
171
+        $addressBooks = [];
172
+
173
+        $result = $query->execute();
174
+        while ($row = $result->fetch()) {
175
+            $addressBooks[$row['id']] = [
176
+                'id' => $row['id'],
177
+                'uri' => $row['uri'],
178
+                'principaluri' => $this->convertPrincipal($row['principaluri'], false),
179
+                '{DAV:}displayname' => $row['displayname'],
180
+                '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
181
+                '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
182
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
183
+            ];
184
+
185
+            $this->addOwnerPrincipal($addressBooks[$row['id']]);
186
+        }
187
+        $result->closeCursor();
188
+
189
+        // query for shared addressbooks
190
+        $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
191
+        $principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
192
+
193
+        $principals = array_map(function ($principal) {
194
+            return urldecode($principal);
195
+        }, $principals);
196
+        $principals[] = $principalUri;
197
+
198
+        $query = $this->db->getQueryBuilder();
199
+        $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])
200
+            ->from('dav_shares', 's')
201
+            ->join('s', 'addressbooks', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
202
+            ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
203
+            ->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
204
+            ->setParameter('type', 'addressbook')
205
+            ->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
206
+            ->execute();
207
+
208
+        $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
209
+        while ($row = $result->fetch()) {
210
+            if ($row['principaluri'] === $principalUri) {
211
+                continue;
212
+            }
213
+
214
+            $readOnly = (int)$row['access'] === Backend::ACCESS_READ;
215
+            if (isset($addressBooks[$row['id']])) {
216
+                if ($readOnly) {
217
+                    // New share can not have more permissions then the old one.
218
+                    continue;
219
+                }
220
+                if (isset($addressBooks[$row['id']][$readOnlyPropertyName]) &&
221
+                    $addressBooks[$row['id']][$readOnlyPropertyName] === 0) {
222
+                    // Old share is already read-write, no more permissions can be gained
223
+                    continue;
224
+                }
225
+            }
226
+
227
+            list(, $name) = \Sabre\Uri\split($row['principaluri']);
228
+            $uri = $row['uri'] . '_shared_by_' . $name;
229
+            $displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
230
+
231
+            $addressBooks[$row['id']] = [
232
+                'id' => $row['id'],
233
+                'uri' => $uri,
234
+                'principaluri' => $principalUriOriginal,
235
+                '{DAV:}displayname' => $displayName,
236
+                '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
237
+                '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
238
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
239
+                '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
240
+                $readOnlyPropertyName => $readOnly,
241
+            ];
242
+
243
+            $this->addOwnerPrincipal($addressBooks[$row['id']]);
244
+        }
245
+        $result->closeCursor();
246
+
247
+        return array_values($addressBooks);
248
+    }
249
+
250
+    public function getUsersOwnAddressBooks($principalUri) {
251
+        $principalUri = $this->convertPrincipal($principalUri, true);
252
+        $query = $this->db->getQueryBuilder();
253
+        $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
254
+            ->from('addressbooks')
255
+            ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
256
+
257
+        $addressBooks = [];
258
+
259
+        $result = $query->execute();
260
+        while ($row = $result->fetch()) {
261
+            $addressBooks[$row['id']] = [
262
+                'id' => $row['id'],
263
+                'uri' => $row['uri'],
264
+                'principaluri' => $this->convertPrincipal($row['principaluri'], false),
265
+                '{DAV:}displayname' => $row['displayname'],
266
+                '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
267
+                '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
268
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
269
+            ];
270
+
271
+            $this->addOwnerPrincipal($addressBooks[$row['id']]);
272
+        }
273
+        $result->closeCursor();
274
+
275
+        return array_values($addressBooks);
276
+    }
277
+
278
+    private function getUserDisplayName($uid) {
279
+        if (!isset($this->userDisplayNames[$uid])) {
280
+            $user = $this->userManager->get($uid);
281
+
282
+            if ($user instanceof IUser) {
283
+                $this->userDisplayNames[$uid] = $user->getDisplayName();
284
+            } else {
285
+                $this->userDisplayNames[$uid] = $uid;
286
+            }
287
+        }
288
+
289
+        return $this->userDisplayNames[$uid];
290
+    }
291
+
292
+    /**
293
+     * @param int $addressBookId
294
+     */
295
+    public function getAddressBookById($addressBookId) {
296
+        $query = $this->db->getQueryBuilder();
297
+        $result = $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
298
+            ->from('addressbooks')
299
+            ->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
300
+            ->execute();
301
+
302
+        $row = $result->fetch();
303
+        $result->closeCursor();
304
+        if ($row === false) {
305
+            return null;
306
+        }
307
+
308
+        $addressBook = [
309
+            'id' => $row['id'],
310
+            'uri' => $row['uri'],
311
+            'principaluri' => $row['principaluri'],
312
+            '{DAV:}displayname' => $row['displayname'],
313
+            '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
314
+            '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
315
+            '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
316
+        ];
317
+
318
+        $this->addOwnerPrincipal($addressBook);
319
+
320
+        return $addressBook;
321
+    }
322
+
323
+    /**
324
+     * @param $addressBookUri
325
+     * @return array|null
326
+     */
327
+    public function getAddressBooksByUri($principal, $addressBookUri) {
328
+        $query = $this->db->getQueryBuilder();
329
+        $result = $query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
330
+            ->from('addressbooks')
331
+            ->where($query->expr()->eq('uri', $query->createNamedParameter($addressBookUri)))
332
+            ->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($principal)))
333
+            ->setMaxResults(1)
334
+            ->execute();
335
+
336
+        $row = $result->fetch();
337
+        $result->closeCursor();
338
+        if ($row === false) {
339
+            return null;
340
+        }
341
+
342
+        $addressBook = [
343
+            'id' => $row['id'],
344
+            'uri' => $row['uri'],
345
+            'principaluri' => $row['principaluri'],
346
+            '{DAV:}displayname' => $row['displayname'],
347
+            '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
348
+            '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
349
+            '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
350
+        ];
351
+
352
+        $this->addOwnerPrincipal($addressBook);
353
+
354
+        return $addressBook;
355
+    }
356
+
357
+    /**
358
+     * Updates properties for an address book.
359
+     *
360
+     * The list of mutations is stored in a Sabre\DAV\PropPatch object.
361
+     * To do the actual updates, you must tell this object which properties
362
+     * you're going to process with the handle() method.
363
+     *
364
+     * Calling the handle method is like telling the PropPatch object "I
365
+     * promise I can handle updating this property".
366
+     *
367
+     * Read the PropPatch documentation for more info and examples.
368
+     *
369
+     * @param string $addressBookId
370
+     * @param \Sabre\DAV\PropPatch $propPatch
371
+     * @return void
372
+     */
373
+    public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
374
+        $supportedProperties = [
375
+            '{DAV:}displayname',
376
+            '{' . Plugin::NS_CARDDAV . '}addressbook-description',
377
+        ];
378
+
379
+        /**
380
+         * @suppress SqlInjectionChecker
381
+         */
382
+        $propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
383
+            $updates = [];
384
+            foreach ($mutations as $property => $newValue) {
385
+                switch ($property) {
386
+                    case '{DAV:}displayname':
387
+                        $updates['displayname'] = $newValue;
388
+                        break;
389
+                    case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
390
+                        $updates['description'] = $newValue;
391
+                        break;
392
+                }
393
+            }
394
+            $query = $this->db->getQueryBuilder();
395
+            $query->update('addressbooks');
396
+
397
+            foreach ($updates as $key => $value) {
398
+                $query->set($key, $query->createNamedParameter($value));
399
+            }
400
+            $query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
401
+                ->execute();
402
+
403
+            $this->addChange($addressBookId, "", 2);
404
+
405
+            $addressBookRow = $this->getAddressBookById((int)$addressBookId);
406
+            $shares = $this->getShares($addressBookId);
407
+            $this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
408
+
409
+            return true;
410
+        });
411
+    }
412
+
413
+    /**
414
+     * Creates a new address book
415
+     *
416
+     * @param string $principalUri
417
+     * @param string $url Just the 'basename' of the url.
418
+     * @param array $properties
419
+     * @return int
420
+     * @throws BadRequest
421
+     */
422
+    public function createAddressBook($principalUri, $url, array $properties) {
423
+        $values = [
424
+            'displayname' => null,
425
+            'description' => null,
426
+            'principaluri' => $principalUri,
427
+            'uri' => $url,
428
+            'synctoken' => 1
429
+        ];
430
+
431
+        foreach ($properties as $property => $newValue) {
432
+            switch ($property) {
433
+                case '{DAV:}displayname':
434
+                    $values['displayname'] = $newValue;
435
+                    break;
436
+                case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
437
+                    $values['description'] = $newValue;
438
+                    break;
439
+                default:
440
+                    throw new BadRequest('Unknown property: ' . $property);
441
+            }
442
+        }
443
+
444
+        // Fallback to make sure the displayname is set. Some clients may refuse
445
+        // to work with addressbooks not having a displayname.
446
+        if (is_null($values['displayname'])) {
447
+            $values['displayname'] = $url;
448
+        }
449
+
450
+        $query = $this->db->getQueryBuilder();
451
+        $query->insert('addressbooks')
452
+            ->values([
453
+                'uri' => $query->createParameter('uri'),
454
+                'displayname' => $query->createParameter('displayname'),
455
+                'description' => $query->createParameter('description'),
456
+                'principaluri' => $query->createParameter('principaluri'),
457
+                'synctoken' => $query->createParameter('synctoken'),
458
+            ])
459
+            ->setParameters($values)
460
+            ->execute();
461
+
462
+        $addressBookId = $query->getLastInsertId();
463
+        $addressBookRow = $this->getAddressBookById($addressBookId);
464
+        $this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow));
465
+
466
+        return $addressBookId;
467
+    }
468
+
469
+    /**
470
+     * Deletes an entire addressbook and all its contents
471
+     *
472
+     * @param mixed $addressBookId
473
+     * @return void
474
+     */
475
+    public function deleteAddressBook($addressBookId) {
476
+        $addressBookData = $this->getAddressBookById($addressBookId);
477
+        $shares = $this->getShares($addressBookId);
478
+
479
+        $query = $this->db->getQueryBuilder();
480
+        $query->delete($this->dbCardsTable)
481
+            ->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
482
+            ->setParameter('addressbookid', $addressBookId)
483
+            ->execute();
484
+
485
+        $query->delete('addressbookchanges')
486
+            ->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
487
+            ->setParameter('addressbookid', $addressBookId)
488
+            ->execute();
489
+
490
+        $query->delete('addressbooks')
491
+            ->where($query->expr()->eq('id', $query->createParameter('id')))
492
+            ->setParameter('id', $addressBookId)
493
+            ->execute();
494
+
495
+        $this->sharingBackend->deleteAllShares($addressBookId);
496
+
497
+        $query->delete($this->dbCardsPropertiesTable)
498
+            ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
499
+            ->execute();
500
+
501
+        if ($addressBookData) {
502
+            $this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares));
503
+        }
504
+    }
505
+
506
+    /**
507
+     * Returns all cards for a specific addressbook id.
508
+     *
509
+     * This method should return the following properties for each card:
510
+     *   * carddata - raw vcard data
511
+     *   * uri - Some unique url
512
+     *   * lastmodified - A unix timestamp
513
+     *
514
+     * It's recommended to also return the following properties:
515
+     *   * etag - A unique etag. This must change every time the card changes.
516
+     *   * size - The size of the card in bytes.
517
+     *
518
+     * If these last two properties are provided, less time will be spent
519
+     * calculating them. If they are specified, you can also ommit carddata.
520
+     * This may speed up certain requests, especially with large cards.
521
+     *
522
+     * @param mixed $addressBookId
523
+     * @return array
524
+     */
525
+    public function getCards($addressBookId) {
526
+        $query = $this->db->getQueryBuilder();
527
+        $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
528
+            ->from($this->dbCardsTable)
529
+            ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
530
+
531
+        $cards = [];
532
+
533
+        $result = $query->execute();
534
+        while ($row = $result->fetch()) {
535
+            $row['etag'] = '"' . $row['etag'] . '"';
536
+
537
+            $modified = false;
538
+            $row['carddata'] = $this->readBlob($row['carddata'], $modified);
539
+            if ($modified) {
540
+                $row['size'] = strlen($row['carddata']);
541
+            }
542
+
543
+            $cards[] = $row;
544
+        }
545
+        $result->closeCursor();
546
+
547
+        return $cards;
548
+    }
549
+
550
+    /**
551
+     * Returns a specific card.
552
+     *
553
+     * The same set of properties must be returned as with getCards. The only
554
+     * exception is that 'carddata' is absolutely required.
555
+     *
556
+     * If the card does not exist, you must return false.
557
+     *
558
+     * @param mixed $addressBookId
559
+     * @param string $cardUri
560
+     * @return array
561
+     */
562
+    public function getCard($addressBookId, $cardUri) {
563
+        $query = $this->db->getQueryBuilder();
564
+        $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
565
+            ->from($this->dbCardsTable)
566
+            ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
567
+            ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
568
+            ->setMaxResults(1);
569
+
570
+        $result = $query->execute();
571
+        $row = $result->fetch();
572
+        if (!$row) {
573
+            return false;
574
+        }
575
+        $row['etag'] = '"' . $row['etag'] . '"';
576
+
577
+        $modified = false;
578
+        $row['carddata'] = $this->readBlob($row['carddata'], $modified);
579
+        if ($modified) {
580
+            $row['size'] = strlen($row['carddata']);
581
+        }
582
+
583
+        return $row;
584
+    }
585
+
586
+    /**
587
+     * Returns a list of cards.
588
+     *
589
+     * This method should work identical to getCard, but instead return all the
590
+     * cards in the list as an array.
591
+     *
592
+     * If the backend supports this, it may allow for some speed-ups.
593
+     *
594
+     * @param mixed $addressBookId
595
+     * @param string[] $uris
596
+     * @return array
597
+     */
598
+    public function getMultipleCards($addressBookId, array $uris) {
599
+        if (empty($uris)) {
600
+            return [];
601
+        }
602
+
603
+        $chunks = array_chunk($uris, 100);
604
+        $cards = [];
605
+
606
+        $query = $this->db->getQueryBuilder();
607
+        $query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata', 'uid'])
608
+            ->from($this->dbCardsTable)
609
+            ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
610
+            ->andWhere($query->expr()->in('uri', $query->createParameter('uri')));
611
+
612
+        foreach ($chunks as $uris) {
613
+            $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
614
+            $result = $query->execute();
615
+
616
+            while ($row = $result->fetch()) {
617
+                $row['etag'] = '"' . $row['etag'] . '"';
618
+
619
+                $modified = false;
620
+                $row['carddata'] = $this->readBlob($row['carddata'], $modified);
621
+                if ($modified) {
622
+                    $row['size'] = strlen($row['carddata']);
623
+                }
624
+
625
+                $cards[] = $row;
626
+            }
627
+            $result->closeCursor();
628
+        }
629
+        return $cards;
630
+    }
631
+
632
+    /**
633
+     * Creates a new card.
634
+     *
635
+     * The addressbook id will be passed as the first argument. This is the
636
+     * same id as it is returned from the getAddressBooksForUser method.
637
+     *
638
+     * The cardUri is a base uri, and doesn't include the full path. The
639
+     * cardData argument is the vcard body, and is passed as a string.
640
+     *
641
+     * It is possible to return an ETag from this method. This ETag is for the
642
+     * newly created resource, and must be enclosed with double quotes (that
643
+     * is, the string itself must contain the double quotes).
644
+     *
645
+     * You should only return the ETag if you store the carddata as-is. If a
646
+     * subsequent GET request on the same card does not have the same body,
647
+     * byte-by-byte and you did return an ETag here, clients tend to get
648
+     * confused.
649
+     *
650
+     * If you don't return an ETag, you can just return null.
651
+     *
652
+     * @param mixed $addressBookId
653
+     * @param string $cardUri
654
+     * @param string $cardData
655
+     * @return string
656
+     */
657
+    public function createCard($addressBookId, $cardUri, $cardData) {
658
+        $etag = md5($cardData);
659
+        $uid = $this->getUID($cardData);
660
+
661
+        $q = $this->db->getQueryBuilder();
662
+        $q->select('uid')
663
+            ->from($this->dbCardsTable)
664
+            ->where($q->expr()->eq('addressbookid', $q->createNamedParameter($addressBookId)))
665
+            ->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid)))
666
+            ->setMaxResults(1);
667
+        $result = $q->execute();
668
+        $count = (bool)$result->fetchColumn();
669
+        $result->closeCursor();
670
+        if ($count) {
671
+            throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.');
672
+        }
673
+
674
+        $query = $this->db->getQueryBuilder();
675
+        $query->insert('cards')
676
+            ->values([
677
+                'carddata' => $query->createNamedParameter($cardData, IQueryBuilder::PARAM_LOB),
678
+                'uri' => $query->createNamedParameter($cardUri),
679
+                'lastmodified' => $query->createNamedParameter(time()),
680
+                'addressbookid' => $query->createNamedParameter($addressBookId),
681
+                'size' => $query->createNamedParameter(strlen($cardData)),
682
+                'etag' => $query->createNamedParameter($etag),
683
+                'uid' => $query->createNamedParameter($uid),
684
+            ])
685
+            ->execute();
686
+
687
+        $etagCacheKey = "$addressBookId#$cardUri";
688
+        $this->etagCache[$etagCacheKey] = $etag;
689
+
690
+        $this->addChange($addressBookId, $cardUri, 1);
691
+        $this->updateProperties($addressBookId, $cardUri, $cardData);
692
+
693
+        $addressBookData = $this->getAddressBookById($addressBookId);
694
+        $shares = $this->getShares($addressBookId);
695
+        $objectRow = $this->getCard($addressBookId, $cardUri);
696
+        $this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
697
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
698
+            new GenericEvent(null, [
699
+                'addressBookId' => $addressBookId,
700
+                'cardUri' => $cardUri,
701
+                'cardData' => $cardData]));
702
+
703
+        return '"' . $etag . '"';
704
+    }
705
+
706
+    /**
707
+     * Updates a card.
708
+     *
709
+     * The addressbook id will be passed as the first argument. This is the
710
+     * same id as it is returned from the getAddressBooksForUser method.
711
+     *
712
+     * The cardUri is a base uri, and doesn't include the full path. The
713
+     * cardData argument is the vcard body, and is passed as a string.
714
+     *
715
+     * It is possible to return an ETag from this method. This ETag should
716
+     * match that of the updated resource, and must be enclosed with double
717
+     * quotes (that is: the string itself must contain the actual quotes).
718
+     *
719
+     * You should only return the ETag if you store the carddata as-is. If a
720
+     * subsequent GET request on the same card does not have the same body,
721
+     * byte-by-byte and you did return an ETag here, clients tend to get
722
+     * confused.
723
+     *
724
+     * If you don't return an ETag, you can just return null.
725
+     *
726
+     * @param mixed $addressBookId
727
+     * @param string $cardUri
728
+     * @param string $cardData
729
+     * @return string
730
+     */
731
+    public function updateCard($addressBookId, $cardUri, $cardData) {
732
+        $uid = $this->getUID($cardData);
733
+        $etag = md5($cardData);
734
+        $query = $this->db->getQueryBuilder();
735
+
736
+        // check for recently stored etag and stop if it is the same
737
+        $etagCacheKey = "$addressBookId#$cardUri";
738
+        if (isset($this->etagCache[$etagCacheKey]) && $this->etagCache[$etagCacheKey] === $etag) {
739
+            return '"' . $etag . '"';
740
+        }
741
+
742
+        $query->update($this->dbCardsTable)
743
+            ->set('carddata', $query->createNamedParameter($cardData, IQueryBuilder::PARAM_LOB))
744
+            ->set('lastmodified', $query->createNamedParameter(time()))
745
+            ->set('size', $query->createNamedParameter(strlen($cardData)))
746
+            ->set('etag', $query->createNamedParameter($etag))
747
+            ->set('uid', $query->createNamedParameter($uid))
748
+            ->where($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
749
+            ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
750
+            ->execute();
751
+
752
+        $this->etagCache[$etagCacheKey] = $etag;
753
+
754
+        $this->addChange($addressBookId, $cardUri, 2);
755
+        $this->updateProperties($addressBookId, $cardUri, $cardData);
756
+
757
+        $addressBookData = $this->getAddressBookById($addressBookId);
758
+        $shares = $this->getShares($addressBookId);
759
+        $objectRow = $this->getCard($addressBookId, $cardUri);
760
+        $this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
761
+        $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
762
+            new GenericEvent(null, [
763
+                'addressBookId' => $addressBookId,
764
+                'cardUri' => $cardUri,
765
+                'cardData' => $cardData]));
766
+
767
+        return '"' . $etag . '"';
768
+    }
769
+
770
+    /**
771
+     * Deletes a card
772
+     *
773
+     * @param mixed $addressBookId
774
+     * @param string $cardUri
775
+     * @return bool
776
+     */
777
+    public function deleteCard($addressBookId, $cardUri) {
778
+        $addressBookData = $this->getAddressBookById($addressBookId);
779
+        $shares = $this->getShares($addressBookId);
780
+        $objectRow = $this->getCard($addressBookId, $cardUri);
781
+
782
+        try {
783
+            $cardId = $this->getCardId($addressBookId, $cardUri);
784
+        } catch (\InvalidArgumentException $e) {
785
+            $cardId = null;
786
+        }
787
+        $query = $this->db->getQueryBuilder();
788
+        $ret = $query->delete($this->dbCardsTable)
789
+            ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
790
+            ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($cardUri)))
791
+            ->execute();
792
+
793
+        $this->addChange($addressBookId, $cardUri, 3);
794
+
795
+        if ($ret === 1) {
796
+            if ($cardId !== null) {
797
+                $this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
798
+                $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
799
+                    new GenericEvent(null, [
800
+                        'addressBookId' => $addressBookId,
801
+                        'cardUri' => $cardUri]));
802
+
803
+                $this->purgeProperties($addressBookId, $cardId);
804
+            }
805
+            return true;
806
+        }
807
+
808
+        return false;
809
+    }
810
+
811
+    /**
812
+     * The getChanges method returns all the changes that have happened, since
813
+     * the specified syncToken in the specified address book.
814
+     *
815
+     * This function should return an array, such as the following:
816
+     *
817
+     * [
818
+     *   'syncToken' => 'The current synctoken',
819
+     *   'added'   => [
820
+     *      'new.txt',
821
+     *   ],
822
+     *   'modified'   => [
823
+     *      'modified.txt',
824
+     *   ],
825
+     *   'deleted' => [
826
+     *      'foo.php.bak',
827
+     *      'old.txt'
828
+     *   ]
829
+     * ];
830
+     *
831
+     * The returned syncToken property should reflect the *current* syncToken
832
+     * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
833
+     * property. This is needed here too, to ensure the operation is atomic.
834
+     *
835
+     * If the $syncToken argument is specified as null, this is an initial
836
+     * sync, and all members should be reported.
837
+     *
838
+     * The modified property is an array of nodenames that have changed since
839
+     * the last token.
840
+     *
841
+     * The deleted property is an array with nodenames, that have been deleted
842
+     * from collection.
843
+     *
844
+     * The $syncLevel argument is basically the 'depth' of the report. If it's
845
+     * 1, you only have to report changes that happened only directly in
846
+     * immediate descendants. If it's 2, it should also include changes from
847
+     * the nodes below the child collections. (grandchildren)
848
+     *
849
+     * The $limit argument allows a client to specify how many results should
850
+     * be returned at most. If the limit is not specified, it should be treated
851
+     * as infinite.
852
+     *
853
+     * If the limit (infinite or not) is higher than you're willing to return,
854
+     * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
855
+     *
856
+     * If the syncToken is expired (due to data cleanup) or unknown, you must
857
+     * return null.
858
+     *
859
+     * The limit is 'suggestive'. You are free to ignore it.
860
+     *
861
+     * @param string $addressBookId
862
+     * @param string $syncToken
863
+     * @param int $syncLevel
864
+     * @param int $limit
865
+     * @return array
866
+     */
867
+    public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) {
868
+        // Current synctoken
869
+        $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?');
870
+        $stmt->execute([$addressBookId]);
871
+        $currentToken = $stmt->fetchColumn(0);
872
+
873
+        if (is_null($currentToken)) {
874
+            return null;
875
+        }
876
+
877
+        $result = [
878
+            'syncToken' => $currentToken,
879
+            'added' => [],
880
+            'modified' => [],
881
+            'deleted' => [],
882
+        ];
883
+
884
+        if ($syncToken) {
885
+            $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
886
+            if ($limit > 0) {
887
+                $query .= " LIMIT " . (int)$limit;
888
+            }
889
+
890
+            // Fetching all changes
891
+            $stmt = $this->db->prepare($query);
892
+            $stmt->execute([$syncToken, $currentToken, $addressBookId]);
893
+
894
+            $changes = [];
895
+
896
+            // This loop ensures that any duplicates are overwritten, only the
897
+            // last change on a node is relevant.
898
+            while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
899
+                $changes[$row['uri']] = $row['operation'];
900
+            }
901
+
902
+            foreach ($changes as $uri => $operation) {
903
+                switch ($operation) {
904
+                    case 1:
905
+                        $result['added'][] = $uri;
906
+                        break;
907
+                    case 2:
908
+                        $result['modified'][] = $uri;
909
+                        break;
910
+                    case 3:
911
+                        $result['deleted'][] = $uri;
912
+                        break;
913
+                }
914
+            }
915
+        } else {
916
+            // No synctoken supplied, this is the initial sync.
917
+            $query = "SELECT `uri` FROM `*PREFIX*cards` WHERE `addressbookid` = ?";
918
+            $stmt = $this->db->prepare($query);
919
+            $stmt->execute([$addressBookId]);
920
+
921
+            $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
922
+        }
923
+        return $result;
924
+    }
925
+
926
+    /**
927
+     * Adds a change record to the addressbookchanges table.
928
+     *
929
+     * @param mixed $addressBookId
930
+     * @param string $objectUri
931
+     * @param int $operation 1 = add, 2 = modify, 3 = delete
932
+     * @return void
933
+     */
934
+    protected function addChange($addressBookId, $objectUri, $operation) {
935
+        $sql = 'INSERT INTO `*PREFIX*addressbookchanges`(`uri`, `synctoken`, `addressbookid`, `operation`) SELECT ?, `synctoken`, ?, ? FROM `*PREFIX*addressbooks` WHERE `id` = ?';
936
+        $stmt = $this->db->prepare($sql);
937
+        $stmt->execute([
938
+            $objectUri,
939
+            $addressBookId,
940
+            $operation,
941
+            $addressBookId
942
+        ]);
943
+        $stmt = $this->db->prepare('UPDATE `*PREFIX*addressbooks` SET `synctoken` = `synctoken` + 1 WHERE `id` = ?');
944
+        $stmt->execute([
945
+            $addressBookId
946
+        ]);
947
+    }
948
+
949
+    /**
950
+     * @param resource|string $cardData
951
+     * @param bool $modified
952
+     * @return string
953
+     */
954
+    private function readBlob($cardData, &$modified = false) {
955
+        if (is_resource($cardData)) {
956
+            $cardData = stream_get_contents($cardData);
957
+        }
958
+
959
+        $cardDataArray = explode("\r\n", $cardData);
960
+
961
+        $cardDataFiltered = [];
962
+        $removingPhoto = false;
963
+        foreach ($cardDataArray as $line) {
964
+            if (strpos($line, 'PHOTO:data:') === 0
965
+                && strpos($line, 'PHOTO:data:image/') !== 0) {
966
+                // Filter out PHOTO data of non-images
967
+                $removingPhoto = true;
968
+                $modified = true;
969
+                continue;
970
+            }
971
+
972
+            if ($removingPhoto) {
973
+                if (strpos($line, ' ') === 0) {
974
+                    continue;
975
+                }
976
+                // No leading space means this is a new property
977
+                $removingPhoto = false;
978
+            }
979
+
980
+            $cardDataFiltered[] = $line;
981
+        }
982
+
983
+        return implode("\r\n", $cardDataFiltered);
984
+    }
985
+
986
+    /**
987
+     * @param IShareable $shareable
988
+     * @param string[] $add
989
+     * @param string[] $remove
990
+     */
991
+    public function updateShares(IShareable $shareable, $add, $remove) {
992
+        $addressBookId = $shareable->getResourceId();
993
+        $addressBookData = $this->getAddressBookById($addressBookId);
994
+        $oldShares = $this->getShares($addressBookId);
995
+
996
+        $this->sharingBackend->updateShares($shareable, $add, $remove);
997
+
998
+        $this->dispatcher->dispatchTyped(new AddressBookShareUpdatedEvent($addressBookId, $addressBookData, $oldShares, $add, $remove));
999
+    }
1000
+
1001
+    /**
1002
+     * Search contacts in a specific address-book
1003
+     *
1004
+     * @param int $addressBookId
1005
+     * @param string $pattern which should match within the $searchProperties
1006
+     * @param array $searchProperties defines the properties within the query pattern should match
1007
+     * @param array $options = array() to define the search behavior
1008
+     *    - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are
1009
+     *    - 'limit' - Set a numeric limit for the search results
1010
+     *    - 'offset' - Set the offset for the limited search results
1011
+     * @return array an array of contacts which are arrays of key-value-pairs
1012
+     */
1013
+    public function search($addressBookId, $pattern, $searchProperties, $options = []): array {
1014
+        return $this->searchByAddressBookIds([$addressBookId], $pattern, $searchProperties, $options);
1015
+    }
1016
+
1017
+    /**
1018
+     * Search contacts in all address-books accessible by a user
1019
+     *
1020
+     * @param string $principalUri
1021
+     * @param string $pattern
1022
+     * @param array $searchProperties
1023
+     * @param array $options
1024
+     * @return array
1025
+     */
1026
+    public function searchPrincipalUri(string $principalUri,
1027
+                                        string $pattern,
1028
+                                        array $searchProperties,
1029
+                                        array $options = []): array {
1030
+        $addressBookIds = array_map(static function ($row):int {
1031
+            return (int) $row['id'];
1032
+        }, $this->getAddressBooksForUser($principalUri));
1033
+
1034
+        return $this->searchByAddressBookIds($addressBookIds, $pattern, $searchProperties, $options);
1035
+    }
1036
+
1037
+    /**
1038
+     * @param array $addressBookIds
1039
+     * @param string $pattern
1040
+     * @param array $searchProperties
1041
+     * @param array $options
1042
+     * @return array
1043
+     */
1044
+    private function searchByAddressBookIds(array $addressBookIds,
1045
+                                            string $pattern,
1046
+                                            array $searchProperties,
1047
+                                            array $options = []): array {
1048
+        $escapePattern = !\array_key_exists('escape_like_param', $options) || $options['escape_like_param'] !== false;
1049
+
1050
+        $query2 = $this->db->getQueryBuilder();
1051
+
1052
+        $addressBookOr =  $query2->expr()->orX();
1053
+        foreach ($addressBookIds as $addressBookId) {
1054
+            $addressBookOr->add($query2->expr()->eq('cp.addressbookid', $query2->createNamedParameter($addressBookId)));
1055
+        }
1056
+
1057
+        if ($addressBookOr->count() === 0) {
1058
+            return [];
1059
+        }
1060
+
1061
+        $propertyOr = $query2->expr()->orX();
1062
+        foreach ($searchProperties as $property) {
1063
+            if ($escapePattern) {
1064
+                if ($property === 'EMAIL' && strpos($pattern, ' ') !== false) {
1065
+                    // There can be no spaces in emails
1066
+                    continue;
1067
+                }
1068
+
1069
+                if ($property === 'CLOUD' && preg_match('/[^a-zA-Z0-9 :_.@\/\-\']/', $pattern) === 1) {
1070
+                    // There can be no chars in cloud ids which are not valid for user ids plus :/
1071
+                    // worst case: CA61590A-BBBC-423E-84AF-E6DF01455A53@https://my.nxt/srv/
1072
+                    continue;
1073
+                }
1074
+            }
1075
+
1076
+            $propertyOr->add($query2->expr()->eq('cp.name', $query2->createNamedParameter($property)));
1077
+        }
1078
+
1079
+        if ($propertyOr->count() === 0) {
1080
+            return [];
1081
+        }
1082
+
1083
+        $query2->selectDistinct('cp.cardid')
1084
+            ->from($this->dbCardsPropertiesTable, 'cp')
1085
+            ->andWhere($addressBookOr)
1086
+            ->andWhere($propertyOr);
1087
+
1088
+        // No need for like when the pattern is empty
1089
+        if ('' !== $pattern) {
1090
+            if (!$escapePattern) {
1091
+                $query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern)));
1092
+            } else {
1093
+                $query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1094
+            }
1095
+        }
1096
+
1097
+        if (isset($options['limit'])) {
1098
+            $query2->setMaxResults($options['limit']);
1099
+        }
1100
+        if (isset($options['offset'])) {
1101
+            $query2->setFirstResult($options['offset']);
1102
+        }
1103
+
1104
+        $result = $query2->execute();
1105
+        $matches = $result->fetchAll();
1106
+        $result->closeCursor();
1107
+        $matches = array_map(function ($match) {
1108
+            return (int)$match['cardid'];
1109
+        }, $matches);
1110
+
1111
+        $query = $this->db->getQueryBuilder();
1112
+        $query->select('c.addressbookid', 'c.carddata', 'c.uri')
1113
+            ->from($this->dbCardsTable, 'c')
1114
+            ->where($query->expr()->in('c.id', $query->createNamedParameter($matches, IQueryBuilder::PARAM_INT_ARRAY)));
1115
+
1116
+        $result = $query->execute();
1117
+        $cards = $result->fetchAll();
1118
+
1119
+        $result->closeCursor();
1120
+
1121
+        return array_map(function ($array) {
1122
+            $array['addressbookid'] = (int) $array['addressbookid'];
1123
+            $modified = false;
1124
+            $array['carddata'] = $this->readBlob($array['carddata'], $modified);
1125
+            if ($modified) {
1126
+                $array['size'] = strlen($array['carddata']);
1127
+            }
1128
+            return $array;
1129
+        }, $cards);
1130
+    }
1131
+
1132
+    /**
1133
+     * @param int $bookId
1134
+     * @param string $name
1135
+     * @return array
1136
+     */
1137
+    public function collectCardProperties($bookId, $name) {
1138
+        $query = $this->db->getQueryBuilder();
1139
+        $result = $query->selectDistinct('value')
1140
+            ->from($this->dbCardsPropertiesTable)
1141
+            ->where($query->expr()->eq('name', $query->createNamedParameter($name)))
1142
+            ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($bookId)))
1143
+            ->execute();
1144
+
1145
+        $all = $result->fetchAll(PDO::FETCH_COLUMN);
1146
+        $result->closeCursor();
1147
+
1148
+        return $all;
1149
+    }
1150
+
1151
+    /**
1152
+     * get URI from a given contact
1153
+     *
1154
+     * @param int $id
1155
+     * @return string
1156
+     */
1157
+    public function getCardUri($id) {
1158
+        $query = $this->db->getQueryBuilder();
1159
+        $query->select('uri')->from($this->dbCardsTable)
1160
+            ->where($query->expr()->eq('id', $query->createParameter('id')))
1161
+            ->setParameter('id', $id);
1162
+
1163
+        $result = $query->execute();
1164
+        $uri = $result->fetch();
1165
+        $result->closeCursor();
1166
+
1167
+        if (!isset($uri['uri'])) {
1168
+            throw new \InvalidArgumentException('Card does not exists: ' . $id);
1169
+        }
1170
+
1171
+        return $uri['uri'];
1172
+    }
1173
+
1174
+    /**
1175
+     * return contact with the given URI
1176
+     *
1177
+     * @param int $addressBookId
1178
+     * @param string $uri
1179
+     * @returns array
1180
+     */
1181
+    public function getContact($addressBookId, $uri) {
1182
+        $result = [];
1183
+        $query = $this->db->getQueryBuilder();
1184
+        $query->select('*')->from($this->dbCardsTable)
1185
+            ->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
1186
+            ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1187
+        $queryResult = $query->execute();
1188
+        $contact = $queryResult->fetch();
1189
+        $queryResult->closeCursor();
1190
+
1191
+        if (is_array($contact)) {
1192
+            $modified = false;
1193
+            $contact['etag'] = '"' . $contact['etag'] . '"';
1194
+            $contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
1195
+            if ($modified) {
1196
+                $contact['size'] = strlen($contact['carddata']);
1197
+            }
1198
+
1199
+            $result = $contact;
1200
+        }
1201
+
1202
+        return $result;
1203
+    }
1204
+
1205
+    /**
1206
+     * Returns the list of people whom this address book is shared with.
1207
+     *
1208
+     * Every element in this array should have the following properties:
1209
+     *   * href - Often a mailto: address
1210
+     *   * commonName - Optional, for example a first + last name
1211
+     *   * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
1212
+     *   * readOnly - boolean
1213
+     *   * summary - Optional, a description for the share
1214
+     *
1215
+     * @return array
1216
+     */
1217
+    public function getShares($addressBookId) {
1218
+        return $this->sharingBackend->getShares($addressBookId);
1219
+    }
1220
+
1221
+    /**
1222
+     * update properties table
1223
+     *
1224
+     * @param int $addressBookId
1225
+     * @param string $cardUri
1226
+     * @param string $vCardSerialized
1227
+     */
1228
+    protected function updateProperties($addressBookId, $cardUri, $vCardSerialized) {
1229
+        $cardId = $this->getCardId($addressBookId, $cardUri);
1230
+        $vCard = $this->readCard($vCardSerialized);
1231
+
1232
+        $this->purgeProperties($addressBookId, $cardId);
1233
+
1234
+        $query = $this->db->getQueryBuilder();
1235
+        $query->insert($this->dbCardsPropertiesTable)
1236
+            ->values(
1237
+                [
1238
+                    'addressbookid' => $query->createNamedParameter($addressBookId),
1239
+                    'cardid' => $query->createNamedParameter($cardId),
1240
+                    'name' => $query->createParameter('name'),
1241
+                    'value' => $query->createParameter('value'),
1242
+                    'preferred' => $query->createParameter('preferred')
1243
+                ]
1244
+            );
1245
+
1246
+        foreach ($vCard->children() as $property) {
1247
+            if (!in_array($property->name, self::$indexProperties)) {
1248
+                continue;
1249
+            }
1250
+            $preferred = 0;
1251
+            foreach ($property->parameters as $parameter) {
1252
+                if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') {
1253
+                    $preferred = 1;
1254
+                    break;
1255
+                }
1256
+            }
1257
+            $query->setParameter('name', $property->name);
1258
+            $query->setParameter('value', mb_substr($property->getValue(), 0, 254));
1259
+            $query->setParameter('preferred', $preferred);
1260
+            $query->execute();
1261
+        }
1262
+    }
1263
+
1264
+    /**
1265
+     * read vCard data into a vCard object
1266
+     *
1267
+     * @param string $cardData
1268
+     * @return VCard
1269
+     */
1270
+    protected function readCard($cardData) {
1271
+        return Reader::read($cardData);
1272
+    }
1273
+
1274
+    /**
1275
+     * delete all properties from a given card
1276
+     *
1277
+     * @param int $addressBookId
1278
+     * @param int $cardId
1279
+     */
1280
+    protected function purgeProperties($addressBookId, $cardId) {
1281
+        $query = $this->db->getQueryBuilder();
1282
+        $query->delete($this->dbCardsPropertiesTable)
1283
+            ->where($query->expr()->eq('cardid', $query->createNamedParameter($cardId)))
1284
+            ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1285
+        $query->execute();
1286
+    }
1287
+
1288
+    /**
1289
+     * get ID from a given contact
1290
+     *
1291
+     * @param int $addressBookId
1292
+     * @param string $uri
1293
+     * @return int
1294
+     */
1295
+    protected function getCardId($addressBookId, $uri) {
1296
+        $query = $this->db->getQueryBuilder();
1297
+        $query->select('id')->from($this->dbCardsTable)
1298
+            ->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
1299
+            ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1300
+
1301
+        $result = $query->execute();
1302
+        $cardIds = $result->fetch();
1303
+        $result->closeCursor();
1304
+
1305
+        if (!isset($cardIds['id'])) {
1306
+            throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1307
+        }
1308
+
1309
+        return (int)$cardIds['id'];
1310
+    }
1311
+
1312
+    /**
1313
+     * For shared address books the sharee is set in the ACL of the address book
1314
+     *
1315
+     * @param $addressBookId
1316
+     * @param $acl
1317
+     * @return array
1318
+     */
1319
+    public function applyShareAcl($addressBookId, $acl) {
1320
+        return $this->sharingBackend->applyShareAcl($addressBookId, $acl);
1321
+    }
1322
+
1323
+    private function convertPrincipal($principalUri, $toV2) {
1324
+        if ($this->principalBackend->getPrincipalPrefix() === 'principals') {
1325
+            list(, $name) = \Sabre\Uri\split($principalUri);
1326
+            if ($toV2 === true) {
1327
+                return "principals/users/$name";
1328
+            }
1329
+            return "principals/$name";
1330
+        }
1331
+        return $principalUri;
1332
+    }
1333
+
1334
+    private function addOwnerPrincipal(&$addressbookInfo) {
1335
+        $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
1336
+        $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
1337
+        if (isset($addressbookInfo[$ownerPrincipalKey])) {
1338
+            $uri = $addressbookInfo[$ownerPrincipalKey];
1339
+        } else {
1340
+            $uri = $addressbookInfo['principaluri'];
1341
+        }
1342
+
1343
+        $principalInformation = $this->principalBackend->getPrincipalByPath($uri);
1344
+        if (isset($principalInformation['{DAV:}displayname'])) {
1345
+            $addressbookInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
1346
+        }
1347
+    }
1348
+
1349
+    /**
1350
+     * Extract UID from vcard
1351
+     *
1352
+     * @param string $cardData the vcard raw data
1353
+     * @return string the uid
1354
+     * @throws BadRequest if no UID is available
1355
+     */
1356
+    private function getUID($cardData) {
1357
+        if ($cardData != '') {
1358
+            $vCard = Reader::read($cardData);
1359
+            if ($vCard->UID) {
1360
+                $uid = $vCard->UID->getValue();
1361
+                return $uid;
1362
+            }
1363
+            // should already be handled, but just in case
1364
+            throw new BadRequest('vCards on CardDAV servers MUST have a UID property');
1365
+        }
1366
+        // should already be handled, but just in case
1367
+        throw new BadRequest('vCard can not be empty');
1368
+    }
1369 1369
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			->from('addressbooks')
141 141
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
142 142
 
143
-		return (int)$query->execute()->fetchColumn();
143
+		return (int) $query->execute()->fetchColumn();
144 144
 	}
145 145
 
146 146
 	/**
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 				'uri' => $row['uri'],
178 178
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
179 179
 				'{DAV:}displayname' => $row['displayname'],
180
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
180
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
181 181
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
182 182
 				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
183 183
 			];
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
191 191
 		$principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
192 192
 
193
-		$principals = array_map(function ($principal) {
193
+		$principals = array_map(function($principal) {
194 194
 			return urldecode($principal);
195 195
 		}, $principals);
196 196
 		$principals[] = $principalUri;
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 			->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
206 206
 			->execute();
207 207
 
208
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
208
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
209 209
 		while ($row = $result->fetch()) {
210 210
 			if ($row['principaluri'] === $principalUri) {
211 211
 				continue;
212 212
 			}
213 213
 
214
-			$readOnly = (int)$row['access'] === Backend::ACCESS_READ;
214
+			$readOnly = (int) $row['access'] === Backend::ACCESS_READ;
215 215
 			if (isset($addressBooks[$row['id']])) {
216 216
 				if ($readOnly) {
217 217
 					// New share can not have more permissions then the old one.
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
 			}
226 226
 
227 227
 			list(, $name) = \Sabre\Uri\split($row['principaluri']);
228
-			$uri = $row['uri'] . '_shared_by_' . $name;
229
-			$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
228
+			$uri = $row['uri'].'_shared_by_'.$name;
229
+			$displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
230 230
 
231 231
 			$addressBooks[$row['id']] = [
232 232
 				'id' => $row['id'],
233 233
 				'uri' => $uri,
234 234
 				'principaluri' => $principalUriOriginal,
235 235
 				'{DAV:}displayname' => $displayName,
236
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
236
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
237 237
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
238 238
 				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
239
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
239
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'],
240 240
 				$readOnlyPropertyName => $readOnly,
241 241
 			];
242 242
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 				'uri' => $row['uri'],
264 264
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
265 265
 				'{DAV:}displayname' => $row['displayname'],
266
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
266
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
267 267
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
268 268
 				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
269 269
 			];
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'uri' => $row['uri'],
311 311
 			'principaluri' => $row['principaluri'],
312 312
 			'{DAV:}displayname' => $row['displayname'],
313
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
313
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
314 314
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
315 315
 			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
316 316
 		];
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			'uri' => $row['uri'],
345 345
 			'principaluri' => $row['principaluri'],
346 346
 			'{DAV:}displayname' => $row['displayname'],
347
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
347
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
348 348
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
349 349
 			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
350 350
 		];
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 	public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
374 374
 		$supportedProperties = [
375 375
 			'{DAV:}displayname',
376
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description',
376
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description',
377 377
 		];
378 378
 
379 379
 		/**
380 380
 		 * @suppress SqlInjectionChecker
381 381
 		 */
382
-		$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
382
+		$propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) {
383 383
 			$updates = [];
384 384
 			foreach ($mutations as $property => $newValue) {
385 385
 				switch ($property) {
386 386
 					case '{DAV:}displayname':
387 387
 						$updates['displayname'] = $newValue;
388 388
 						break;
389
-					case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
389
+					case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
390 390
 						$updates['description'] = $newValue;
391 391
 						break;
392 392
 				}
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 
403 403
 			$this->addChange($addressBookId, "", 2);
404 404
 
405
-			$addressBookRow = $this->getAddressBookById((int)$addressBookId);
405
+			$addressBookRow = $this->getAddressBookById((int) $addressBookId);
406 406
 			$shares = $this->getShares($addressBookId);
407
-			$this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
407
+			$this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int) $addressBookId, $addressBookRow, $shares, $mutations));
408 408
 
409 409
 			return true;
410 410
 		});
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 				case '{DAV:}displayname':
434 434
 					$values['displayname'] = $newValue;
435 435
 					break;
436
-				case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
436
+				case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
437 437
 					$values['description'] = $newValue;
438 438
 					break;
439 439
 				default:
440
-					throw new BadRequest('Unknown property: ' . $property);
440
+					throw new BadRequest('Unknown property: '.$property);
441 441
 			}
442 442
 		}
443 443
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
 		$addressBookId = $query->getLastInsertId();
463 463
 		$addressBookRow = $this->getAddressBookById($addressBookId);
464
-		$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow));
464
+		$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int) $addressBookId, $addressBookRow));
465 465
 
466 466
 		return $addressBookId;
467 467
 	}
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 
533 533
 		$result = $query->execute();
534 534
 		while ($row = $result->fetch()) {
535
-			$row['etag'] = '"' . $row['etag'] . '"';
535
+			$row['etag'] = '"'.$row['etag'].'"';
536 536
 
537 537
 			$modified = false;
538 538
 			$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 		if (!$row) {
573 573
 			return false;
574 574
 		}
575
-		$row['etag'] = '"' . $row['etag'] . '"';
575
+		$row['etag'] = '"'.$row['etag'].'"';
576 576
 
577 577
 		$modified = false;
578 578
 		$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 			$result = $query->execute();
615 615
 
616 616
 			while ($row = $result->fetch()) {
617
-				$row['etag'] = '"' . $row['etag'] . '"';
617
+				$row['etag'] = '"'.$row['etag'].'"';
618 618
 
619 619
 				$modified = false;
620 620
 				$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 			->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid)))
666 666
 			->setMaxResults(1);
667 667
 		$result = $q->execute();
668
-		$count = (bool)$result->fetchColumn();
668
+		$count = (bool) $result->fetchColumn();
669 669
 		$result->closeCursor();
670 670
 		if ($count) {
671 671
 			throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.');
@@ -693,14 +693,14 @@  discard block
 block discarded – undo
693 693
 		$addressBookData = $this->getAddressBookById($addressBookId);
694 694
 		$shares = $this->getShares($addressBookId);
695 695
 		$objectRow = $this->getCard($addressBookId, $cardUri);
696
-		$this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
696
+		$this->dispatcher->dispatchTyped(new CardCreatedEvent((int) $addressBookId, $addressBookData, $shares, $objectRow));
697 697
 		$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
698 698
 			new GenericEvent(null, [
699 699
 				'addressBookId' => $addressBookId,
700 700
 				'cardUri' => $cardUri,
701 701
 				'cardData' => $cardData]));
702 702
 
703
-		return '"' . $etag . '"';
703
+		return '"'.$etag.'"';
704 704
 	}
705 705
 
706 706
 	/**
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		// check for recently stored etag and stop if it is the same
737 737
 		$etagCacheKey = "$addressBookId#$cardUri";
738 738
 		if (isset($this->etagCache[$etagCacheKey]) && $this->etagCache[$etagCacheKey] === $etag) {
739
-			return '"' . $etag . '"';
739
+			return '"'.$etag.'"';
740 740
 		}
741 741
 
742 742
 		$query->update($this->dbCardsTable)
@@ -757,14 +757,14 @@  discard block
 block discarded – undo
757 757
 		$addressBookData = $this->getAddressBookById($addressBookId);
758 758
 		$shares = $this->getShares($addressBookId);
759 759
 		$objectRow = $this->getCard($addressBookId, $cardUri);
760
-		$this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
760
+		$this->dispatcher->dispatchTyped(new CardUpdatedEvent((int) $addressBookId, $addressBookData, $shares, $objectRow));
761 761
 		$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
762 762
 			new GenericEvent(null, [
763 763
 				'addressBookId' => $addressBookId,
764 764
 				'cardUri' => $cardUri,
765 765
 				'cardData' => $cardData]));
766 766
 
767
-		return '"' . $etag . '"';
767
+		return '"'.$etag.'"';
768 768
 	}
769 769
 
770 770
 	/**
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 
795 795
 		if ($ret === 1) {
796 796
 			if ($cardId !== null) {
797
-				$this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
797
+				$this->dispatcher->dispatchTyped(new CardDeletedEvent((int) $addressBookId, $addressBookData, $shares, $objectRow));
798 798
 				$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
799 799
 					new GenericEvent(null, [
800 800
 						'addressBookId' => $addressBookId,
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 		if ($syncToken) {
885 885
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
886 886
 			if ($limit > 0) {
887
-				$query .= " LIMIT " . (int)$limit;
887
+				$query .= " LIMIT ".(int) $limit;
888 888
 			}
889 889
 
890 890
 			// Fetching all changes
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 									   string $pattern,
1028 1028
 									   array $searchProperties,
1029 1029
 									   array $options = []): array {
1030
-		$addressBookIds = array_map(static function ($row):int {
1030
+		$addressBookIds = array_map(static function($row):int {
1031 1031
 			return (int) $row['id'];
1032 1032
 		}, $this->getAddressBooksForUser($principalUri));
1033 1033
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
 		$query2 = $this->db->getQueryBuilder();
1051 1051
 
1052
-		$addressBookOr =  $query2->expr()->orX();
1052
+		$addressBookOr = $query2->expr()->orX();
1053 1053
 		foreach ($addressBookIds as $addressBookId) {
1054 1054
 			$addressBookOr->add($query2->expr()->eq('cp.addressbookid', $query2->createNamedParameter($addressBookId)));
1055 1055
 		}
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			if (!$escapePattern) {
1091 1091
 				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern)));
1092 1092
 			} else {
1093
-				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1093
+				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%')));
1094 1094
 			}
1095 1095
 		}
1096 1096
 
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
 		$result = $query2->execute();
1105 1105
 		$matches = $result->fetchAll();
1106 1106
 		$result->closeCursor();
1107
-		$matches = array_map(function ($match) {
1108
-			return (int)$match['cardid'];
1107
+		$matches = array_map(function($match) {
1108
+			return (int) $match['cardid'];
1109 1109
 		}, $matches);
1110 1110
 
1111 1111
 		$query = $this->db->getQueryBuilder();
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
 		$result->closeCursor();
1120 1120
 
1121
-		return array_map(function ($array) {
1121
+		return array_map(function($array) {
1122 1122
 			$array['addressbookid'] = (int) $array['addressbookid'];
1123 1123
 			$modified = false;
1124 1124
 			$array['carddata'] = $this->readBlob($array['carddata'], $modified);
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 		$result->closeCursor();
1166 1166
 
1167 1167
 		if (!isset($uri['uri'])) {
1168
-			throw new \InvalidArgumentException('Card does not exists: ' . $id);
1168
+			throw new \InvalidArgumentException('Card does not exists: '.$id);
1169 1169
 		}
1170 1170
 
1171 1171
 		return $uri['uri'];
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 		if (is_array($contact)) {
1192 1192
 			$modified = false;
1193
-			$contact['etag'] = '"' . $contact['etag'] . '"';
1193
+			$contact['etag'] = '"'.$contact['etag'].'"';
1194 1194
 			$contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
1195 1195
 			if ($modified) {
1196 1196
 				$contact['size'] = strlen($contact['carddata']);
@@ -1303,10 +1303,10 @@  discard block
 block discarded – undo
1303 1303
 		$result->closeCursor();
1304 1304
 
1305 1305
 		if (!isset($cardIds['id'])) {
1306
-			throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1306
+			throw new \InvalidArgumentException('Card does not exists: '.$uri);
1307 1307
 		}
1308 1308
 
1309
-		return (int)$cardIds['id'];
1309
+		return (int) $cardIds['id'];
1310 1310
 	}
1311 1311
 
1312 1312
 	/**
@@ -1332,8 +1332,8 @@  discard block
 block discarded – undo
1332 1332
 	}
1333 1333
 
1334 1334
 	private function addOwnerPrincipal(&$addressbookInfo) {
1335
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
1336
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
1335
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
1336
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
1337 1337
 		if (isset($addressbookInfo[$ownerPrincipalKey])) {
1338 1338
 			$uri = $addressbookInfo[$ownerPrincipalKey];
1339 1339
 		} else {
Please login to merge, or discard this patch.
apps/dav/lib/Command/CreateCalendar.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -41,61 +41,61 @@
 block discarded – undo
41 41
 
42 42
 class CreateCalendar extends Command {
43 43
 
44
-	/** @var IUserManager */
45
-	protected $userManager;
44
+    /** @var IUserManager */
45
+    protected $userManager;
46 46
 
47
-	/** @var IGroupManager $groupManager */
48
-	private $groupManager;
47
+    /** @var IGroupManager $groupManager */
48
+    private $groupManager;
49 49
 
50
-	/** @var \OCP\IDBConnection */
51
-	protected $dbConnection;
50
+    /** @var \OCP\IDBConnection */
51
+    protected $dbConnection;
52 52
 
53
-	/**
54
-	 * @param IUserManager $userManager
55
-	 * @param IGroupManager $groupManager
56
-	 * @param IDBConnection $dbConnection
57
-	 */
58
-	public function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
59
-		parent::__construct();
60
-		$this->userManager = $userManager;
61
-		$this->groupManager = $groupManager;
62
-		$this->dbConnection = $dbConnection;
63
-	}
53
+    /**
54
+     * @param IUserManager $userManager
55
+     * @param IGroupManager $groupManager
56
+     * @param IDBConnection $dbConnection
57
+     */
58
+    public function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
59
+        parent::__construct();
60
+        $this->userManager = $userManager;
61
+        $this->groupManager = $groupManager;
62
+        $this->dbConnection = $dbConnection;
63
+    }
64 64
 
65
-	protected function configure() {
66
-		$this
67
-			->setName('dav:create-calendar')
68
-			->setDescription('Create a dav calendar')
69
-			->addArgument('user',
70
-				InputArgument::REQUIRED,
71
-				'User for whom the calendar will be created')
72
-			->addArgument('name',
73
-				InputArgument::REQUIRED,
74
-				'Name of the calendar');
75
-	}
65
+    protected function configure() {
66
+        $this
67
+            ->setName('dav:create-calendar')
68
+            ->setDescription('Create a dav calendar')
69
+            ->addArgument('user',
70
+                InputArgument::REQUIRED,
71
+                'User for whom the calendar will be created')
72
+            ->addArgument('name',
73
+                InputArgument::REQUIRED,
74
+                'Name of the calendar');
75
+    }
76 76
 
77
-	protected function execute(InputInterface $input, OutputInterface $output): int {
78
-		$user = $input->getArgument('user');
79
-		if (!$this->userManager->userExists($user)) {
80
-			throw new \InvalidArgumentException("User <$user> in unknown.");
81
-		}
82
-		$principalBackend = new Principal(
83
-			$this->userManager,
84
-			$this->groupManager,
85
-			\OC::$server->getShareManager(),
86
-			\OC::$server->getUserSession(),
87
-			\OC::$server->getAppManager(),
88
-			\OC::$server->query(ProxyMapper::class),
89
-			\OC::$server->getConfig()
90
-		);
91
-		$random = \OC::$server->getSecureRandom();
92
-		$logger = \OC::$server->getLogger();
93
-		$dispatcher = \OC::$server->get(IEventDispatcher::class);
94
-		$legacyDispatcher = \OC::$server->getEventDispatcher();
77
+    protected function execute(InputInterface $input, OutputInterface $output): int {
78
+        $user = $input->getArgument('user');
79
+        if (!$this->userManager->userExists($user)) {
80
+            throw new \InvalidArgumentException("User <$user> in unknown.");
81
+        }
82
+        $principalBackend = new Principal(
83
+            $this->userManager,
84
+            $this->groupManager,
85
+            \OC::$server->getShareManager(),
86
+            \OC::$server->getUserSession(),
87
+            \OC::$server->getAppManager(),
88
+            \OC::$server->query(ProxyMapper::class),
89
+            \OC::$server->getConfig()
90
+        );
91
+        $random = \OC::$server->getSecureRandom();
92
+        $logger = \OC::$server->getLogger();
93
+        $dispatcher = \OC::$server->get(IEventDispatcher::class);
94
+        $legacyDispatcher = \OC::$server->getEventDispatcher();
95 95
 
96
-		$name = $input->getArgument('name');
97
-		$caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
98
-		$caldav->createCalendar("principals/users/$user", $name, []);
99
-		return 0;
100
-	}
96
+        $name = $input->getArgument('name');
97
+        $caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
98
+        $caldav->createCalendar("principals/users/$user", $name, []);
99
+        return 0;
100
+    }
101 101
 }
Please login to merge, or discard this patch.
apps/dav/lib/RootCollection.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -49,132 +49,132 @@
 block discarded – undo
49 49
 use Sabre\DAV\SimpleCollection;
50 50
 
51 51
 class RootCollection extends SimpleCollection {
52
-	public function __construct() {
53
-		$config = \OC::$server->getConfig();
54
-		$l10n = \OC::$server->getL10N('dav');
55
-		$random = \OC::$server->getSecureRandom();
56
-		$logger = \OC::$server->getLogger();
57
-		$userManager = \OC::$server->getUserManager();
58
-		$userSession = \OC::$server->getUserSession();
59
-		$groupManager = \OC::$server->getGroupManager();
60
-		$shareManager = \OC::$server->getShareManager();
61
-		$db = \OC::$server->getDatabaseConnection();
62
-		$dispatcher = \OC::$server->get(IEventDispatcher::class);
63
-		$legacyDispatcher = \OC::$server->getEventDispatcher();
64
-		$proxyMapper = \OC::$server->query(ProxyMapper::class);
65
-
66
-		$userPrincipalBackend = new Principal(
67
-			$userManager,
68
-			$groupManager,
69
-			$shareManager,
70
-			\OC::$server->getUserSession(),
71
-			\OC::$server->getAppManager(),
72
-			$proxyMapper,
73
-			\OC::$server->getConfig()
74
-		);
75
-		$groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager);
76
-		$calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
77
-		$calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
78
-		// as soon as debug mode is enabled we allow listing of principals
79
-		$disableListing = !$config->getSystemValue('debug', false);
80
-
81
-		// setup the first level of the dav tree
82
-		$userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
83
-		$userPrincipals->disableListing = $disableListing;
84
-		$groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
85
-		$groupPrincipals->disableListing = $disableListing;
86
-		$systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
87
-		$systemPrincipals->disableListing = $disableListing;
88
-		$calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources');
89
-		$calendarResourcePrincipals->disableListing = $disableListing;
90
-		$calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms');
91
-		$calendarRoomPrincipals->disableListing = $disableListing;
92
-
93
-
94
-		$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
95
-		$filesCollection->disableListing = $disableListing;
96
-		$caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
97
-		$userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
98
-		$userCalendarRoot->disableListing = $disableListing;
99
-
100
-		$resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
101
-		$resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources');
102
-		$resourceCalendarRoot->disableListing = $disableListing;
103
-		$roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
104
-		$roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms');
105
-		$roomCalendarRoot->disableListing = $disableListing;
106
-
107
-		$publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config);
108
-		$publicCalendarRoot->disableListing = $disableListing;
109
-
110
-		$systemTagCollection = new SystemTag\SystemTagsByIdCollection(
111
-			\OC::$server->getSystemTagManager(),
112
-			\OC::$server->getUserSession(),
113
-			$groupManager
114
-		);
115
-		$systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
116
-			\OC::$server->getSystemTagManager(),
117
-			\OC::$server->getSystemTagObjectMapper(),
118
-			\OC::$server->getUserSession(),
119
-			$groupManager,
120
-			\OC::$server->getEventDispatcher()
121
-		);
122
-		$commentsCollection = new Comments\RootCollection(
123
-			\OC::$server->getCommentsManager(),
124
-			$userManager,
125
-			\OC::$server->getUserSession(),
126
-			\OC::$server->getEventDispatcher(),
127
-			\OC::$server->getLogger()
128
-		);
129
-
130
-		$pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
131
-		$usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher, $legacyDispatcher);
132
-		$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, $pluginManager, 'principals/users');
133
-		$usersAddressBookRoot->disableListing = $disableListing;
134
-
135
-		$systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher, $legacyDispatcher);
136
-		$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, $pluginManager, 'principals/system');
137
-		$systemAddressBookRoot->disableListing = $disableListing;
138
-
139
-		$uploadCollection = new Upload\RootCollection(
140
-			$userPrincipalBackend,
141
-			'principals/users',
142
-			\OC::$server->query(CleanupService::class));
143
-		$uploadCollection->disableListing = $disableListing;
144
-
145
-		$avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users');
146
-		$avatarCollection->disableListing = $disableListing;
147
-
148
-		$appleProvisioning = new AppleProvisioningNode(
149
-			\OC::$server->query(ITimeFactory::class));
150
-
151
-		$children = [
152
-			new SimpleCollection('principals', [
153
-				$userPrincipals,
154
-				$groupPrincipals,
155
-				$systemPrincipals,
156
-				$calendarResourcePrincipals,
157
-				$calendarRoomPrincipals]),
158
-			$filesCollection,
159
-			$userCalendarRoot,
160
-			new SimpleCollection('system-calendars', [
161
-				$resourceCalendarRoot,
162
-				$roomCalendarRoot,
163
-			]),
164
-			$publicCalendarRoot,
165
-			new SimpleCollection('addressbooks', [
166
-				$usersAddressBookRoot,
167
-				$systemAddressBookRoot]),
168
-			$systemTagCollection,
169
-			$systemTagRelationsCollection,
170
-			$commentsCollection,
171
-			$uploadCollection,
172
-			$avatarCollection,
173
-			new SimpleCollection('provisioning', [
174
-				$appleProvisioning
175
-			])
176
-		];
177
-
178
-		parent::__construct('root', $children);
179
-	}
52
+    public function __construct() {
53
+        $config = \OC::$server->getConfig();
54
+        $l10n = \OC::$server->getL10N('dav');
55
+        $random = \OC::$server->getSecureRandom();
56
+        $logger = \OC::$server->getLogger();
57
+        $userManager = \OC::$server->getUserManager();
58
+        $userSession = \OC::$server->getUserSession();
59
+        $groupManager = \OC::$server->getGroupManager();
60
+        $shareManager = \OC::$server->getShareManager();
61
+        $db = \OC::$server->getDatabaseConnection();
62
+        $dispatcher = \OC::$server->get(IEventDispatcher::class);
63
+        $legacyDispatcher = \OC::$server->getEventDispatcher();
64
+        $proxyMapper = \OC::$server->query(ProxyMapper::class);
65
+
66
+        $userPrincipalBackend = new Principal(
67
+            $userManager,
68
+            $groupManager,
69
+            $shareManager,
70
+            \OC::$server->getUserSession(),
71
+            \OC::$server->getAppManager(),
72
+            $proxyMapper,
73
+            \OC::$server->getConfig()
74
+        );
75
+        $groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager);
76
+        $calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
77
+        $calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
78
+        // as soon as debug mode is enabled we allow listing of principals
79
+        $disableListing = !$config->getSystemValue('debug', false);
80
+
81
+        // setup the first level of the dav tree
82
+        $userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
83
+        $userPrincipals->disableListing = $disableListing;
84
+        $groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
85
+        $groupPrincipals->disableListing = $disableListing;
86
+        $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
87
+        $systemPrincipals->disableListing = $disableListing;
88
+        $calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources');
89
+        $calendarResourcePrincipals->disableListing = $disableListing;
90
+        $calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms');
91
+        $calendarRoomPrincipals->disableListing = $disableListing;
92
+
93
+
94
+        $filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
95
+        $filesCollection->disableListing = $disableListing;
96
+        $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
97
+        $userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
98
+        $userCalendarRoot->disableListing = $disableListing;
99
+
100
+        $resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
101
+        $resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources');
102
+        $resourceCalendarRoot->disableListing = $disableListing;
103
+        $roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
104
+        $roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms');
105
+        $roomCalendarRoot->disableListing = $disableListing;
106
+
107
+        $publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config);
108
+        $publicCalendarRoot->disableListing = $disableListing;
109
+
110
+        $systemTagCollection = new SystemTag\SystemTagsByIdCollection(
111
+            \OC::$server->getSystemTagManager(),
112
+            \OC::$server->getUserSession(),
113
+            $groupManager
114
+        );
115
+        $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
116
+            \OC::$server->getSystemTagManager(),
117
+            \OC::$server->getSystemTagObjectMapper(),
118
+            \OC::$server->getUserSession(),
119
+            $groupManager,
120
+            \OC::$server->getEventDispatcher()
121
+        );
122
+        $commentsCollection = new Comments\RootCollection(
123
+            \OC::$server->getCommentsManager(),
124
+            $userManager,
125
+            \OC::$server->getUserSession(),
126
+            \OC::$server->getEventDispatcher(),
127
+            \OC::$server->getLogger()
128
+        );
129
+
130
+        $pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
131
+        $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher, $legacyDispatcher);
132
+        $usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, $pluginManager, 'principals/users');
133
+        $usersAddressBookRoot->disableListing = $disableListing;
134
+
135
+        $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher, $legacyDispatcher);
136
+        $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, $pluginManager, 'principals/system');
137
+        $systemAddressBookRoot->disableListing = $disableListing;
138
+
139
+        $uploadCollection = new Upload\RootCollection(
140
+            $userPrincipalBackend,
141
+            'principals/users',
142
+            \OC::$server->query(CleanupService::class));
143
+        $uploadCollection->disableListing = $disableListing;
144
+
145
+        $avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users');
146
+        $avatarCollection->disableListing = $disableListing;
147
+
148
+        $appleProvisioning = new AppleProvisioningNode(
149
+            \OC::$server->query(ITimeFactory::class));
150
+
151
+        $children = [
152
+            new SimpleCollection('principals', [
153
+                $userPrincipals,
154
+                $groupPrincipals,
155
+                $systemPrincipals,
156
+                $calendarResourcePrincipals,
157
+                $calendarRoomPrincipals]),
158
+            $filesCollection,
159
+            $userCalendarRoot,
160
+            new SimpleCollection('system-calendars', [
161
+                $resourceCalendarRoot,
162
+                $roomCalendarRoot,
163
+            ]),
164
+            $publicCalendarRoot,
165
+            new SimpleCollection('addressbooks', [
166
+                $usersAddressBookRoot,
167
+                $systemAddressBookRoot]),
168
+            $systemTagCollection,
169
+            $systemTagRelationsCollection,
170
+            $commentsCollection,
171
+            $uploadCollection,
172
+            $avatarCollection,
173
+            new SimpleCollection('provisioning', [
174
+                $appleProvisioning
175
+            ])
176
+        ];
177
+
178
+        parent::__construct('root', $children);
179
+    }
180 180
 }
Please login to merge, or discard this patch.
apps/dav/composer/composer/autoload_static.php 1 patch
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -6,275 +6,275 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitDAV
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\DAV\\' => 8,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\DAV\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\DAV\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
25
-        'OCA\\DAV\\AppInfo\\PluginManager' => __DIR__ . '/..' . '/../lib/AppInfo/PluginManager.php',
26
-        'OCA\\DAV\\Avatars\\AvatarHome' => __DIR__ . '/..' . '/../lib/Avatars/AvatarHome.php',
27
-        'OCA\\DAV\\Avatars\\AvatarNode' => __DIR__ . '/..' . '/../lib/Avatars/AvatarNode.php',
28
-        'OCA\\DAV\\Avatars\\RootCollection' => __DIR__ . '/..' . '/../lib/Avatars/RootCollection.php',
29
-        'OCA\\DAV\\BackgroundJob\\BuildReminderIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/BuildReminderIndexBackgroundJob.php',
30
-        'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupDirectLinksJob.php',
31
-        'OCA\\DAV\\BackgroundJob\\CleanupInvitationTokenJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupInvitationTokenJob.php',
32
-        'OCA\\DAV\\BackgroundJob\\EventReminderJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/EventReminderJob.php',
33
-        'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php',
34
-        'OCA\\DAV\\BackgroundJob\\RefreshWebcalJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RefreshWebcalJob.php',
35
-        'OCA\\DAV\\BackgroundJob\\RegisterRegenerateBirthdayCalendars' => __DIR__ . '/..' . '/../lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php',
36
-        'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php',
37
-        'OCA\\DAV\\BackgroundJob\\UploadCleanup' => __DIR__ . '/..' . '/../lib/BackgroundJob/UploadCleanup.php',
38
-        'OCA\\DAV\\CalDAV\\Activity\\Backend' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Backend.php',
39
-        'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Filter/Calendar.php',
40
-        'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Filter/Todo.php',
41
-        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Base.php',
42
-        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Calendar.php',
43
-        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Event.php',
44
-        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Todo.php',
45
-        'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Setting/Calendar.php',
46
-        'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Setting/Event.php',
47
-        'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Setting/Todo.php',
48
-        'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => __DIR__ . '/..' . '/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php',
49
-        'OCA\\DAV\\CalDAV\\BirthdayService' => __DIR__ . '/..' . '/../lib/CalDAV/BirthdayService.php',
50
-        'OCA\\DAV\\CalDAV\\CachedSubscription' => __DIR__ . '/..' . '/../lib/CalDAV/CachedSubscription.php',
51
-        'OCA\\DAV\\CalDAV\\CachedSubscriptionObject' => __DIR__ . '/..' . '/../lib/CalDAV/CachedSubscriptionObject.php',
52
-        'OCA\\DAV\\CalDAV\\CalDavBackend' => __DIR__ . '/..' . '/../lib/CalDAV/CalDavBackend.php',
53
-        'OCA\\DAV\\CalDAV\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Calendar.php',
54
-        'OCA\\DAV\\CalDAV\\CalendarHome' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarHome.php',
55
-        'OCA\\DAV\\CalDAV\\CalendarImpl' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarImpl.php',
56
-        'OCA\\DAV\\CalDAV\\CalendarManager' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarManager.php',
57
-        'OCA\\DAV\\CalDAV\\CalendarObject' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarObject.php',
58
-        'OCA\\DAV\\CalDAV\\CalendarRoot' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarRoot.php',
59
-        'OCA\\DAV\\CalDAV\\ICSExportPlugin\\ICSExportPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php',
60
-        'OCA\\DAV\\CalDAV\\Integration\\ExternalCalendar' => __DIR__ . '/..' . '/../lib/CalDAV/Integration/ExternalCalendar.php',
61
-        'OCA\\DAV\\CalDAV\\Integration\\ICalendarProvider' => __DIR__ . '/..' . '/../lib/CalDAV/Integration/ICalendarProvider.php',
62
-        'OCA\\DAV\\CalDAV\\InvitationResponse\\InvitationResponseServer' => __DIR__ . '/..' . '/../lib/CalDAV/InvitationResponse/InvitationResponseServer.php',
63
-        'OCA\\DAV\\CalDAV\\Outbox' => __DIR__ . '/..' . '/../lib/CalDAV/Outbox.php',
64
-        'OCA\\DAV\\CalDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/Plugin.php',
65
-        'OCA\\DAV\\CalDAV\\Principal\\Collection' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/Collection.php',
66
-        'OCA\\DAV\\CalDAV\\Principal\\User' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/User.php',
67
-        'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => __DIR__ . '/..' . '/../lib/CalDAV/Proxy/Proxy.php',
68
-        'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => __DIR__ . '/..' . '/../lib/CalDAV/Proxy/ProxyMapper.php',
69
-        'OCA\\DAV\\CalDAV\\PublicCalendar' => __DIR__ . '/..' . '/../lib/CalDAV/PublicCalendar.php',
70
-        'OCA\\DAV\\CalDAV\\PublicCalendarObject' => __DIR__ . '/..' . '/../lib/CalDAV/PublicCalendarObject.php',
71
-        'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => __DIR__ . '/..' . '/../lib/CalDAV/PublicCalendarRoot.php',
72
-        'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/Publishing/PublishPlugin.php',
73
-        'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => __DIR__ . '/..' . '/../lib/CalDAV/Publishing/Xml/Publisher.php',
74
-        'OCA\\DAV\\CalDAV\\Reminder\\Backend' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/Backend.php',
75
-        'OCA\\DAV\\CalDAV\\Reminder\\INotificationProvider' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/INotificationProvider.php',
76
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProviderManager' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationProviderManager.php',
77
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AbstractProvider' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php',
78
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AudioProvider' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php',
79
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\EmailProvider' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php',
80
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\ProviderNotAvailableException' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php',
81
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\PushProvider' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationProvider/PushProvider.php',
82
-        'OCA\\DAV\\CalDAV\\Reminder\\NotificationTypeDoesNotExistException' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php',
83
-        'OCA\\DAV\\CalDAV\\Reminder\\Notifier' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/Notifier.php',
84
-        'OCA\\DAV\\CalDAV\\Reminder\\ReminderService' => __DIR__ . '/..' . '/../lib/CalDAV/Reminder/ReminderService.php',
85
-        'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => __DIR__ . '/..' . '/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php',
86
-        'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => __DIR__ . '/..' . '/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php',
87
-        'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => __DIR__ . '/..' . '/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php',
88
-        'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/Schedule/IMipPlugin.php',
89
-        'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/Schedule/Plugin.php',
90
-        'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/Search/SearchPlugin.php',
91
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/CompFilter.php',
92
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php',
93
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php',
94
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php',
95
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/PropFilter.php',
96
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php',
97
-        'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php',
98
-        'OCA\\DAV\\CalDAV\\WebcalCaching\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/WebcalCaching/Plugin.php',
99
-        'OCA\\DAV\\CalDAV\\WebcalCaching\\RefreshWebcalService' => __DIR__ . '/..' . '/../lib/CalDAV/WebcalCaching/RefreshWebcalService.php',
100
-        'OCA\\DAV\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
101
-        'OCA\\DAV\\CardDAV\\AddressBook' => __DIR__ . '/..' . '/../lib/CardDAV/AddressBook.php',
102
-        'OCA\\DAV\\CardDAV\\AddressBookImpl' => __DIR__ . '/..' . '/../lib/CardDAV/AddressBookImpl.php',
103
-        'OCA\\DAV\\CardDAV\\AddressBookRoot' => __DIR__ . '/..' . '/../lib/CardDAV/AddressBookRoot.php',
104
-        'OCA\\DAV\\CardDAV\\CardDavBackend' => __DIR__ . '/..' . '/../lib/CardDAV/CardDavBackend.php',
105
-        'OCA\\DAV\\CardDAV\\ContactsManager' => __DIR__ . '/..' . '/../lib/CardDAV/ContactsManager.php',
106
-        'OCA\\DAV\\CardDAV\\Converter' => __DIR__ . '/..' . '/../lib/CardDAV/Converter.php',
107
-        'OCA\\DAV\\CardDAV\\HasPhotoPlugin' => __DIR__ . '/..' . '/../lib/CardDAV/HasPhotoPlugin.php',
108
-        'OCA\\DAV\\CardDAV\\ImageExportPlugin' => __DIR__ . '/..' . '/../lib/CardDAV/ImageExportPlugin.php',
109
-        'OCA\\DAV\\CardDAV\\Integration\\ExternalAddressBook' => __DIR__ . '/..' . '/../lib/CardDAV/Integration/ExternalAddressBook.php',
110
-        'OCA\\DAV\\CardDAV\\Integration\\IAddressBookProvider' => __DIR__ . '/..' . '/../lib/CardDAV/Integration/IAddressBookProvider.php',
111
-        'OCA\\DAV\\CardDAV\\MultiGetExportPlugin' => __DIR__ . '/..' . '/../lib/CardDAV/MultiGetExportPlugin.php',
112
-        'OCA\\DAV\\CardDAV\\PhotoCache' => __DIR__ . '/..' . '/../lib/CardDAV/PhotoCache.php',
113
-        'OCA\\DAV\\CardDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CardDAV/Plugin.php',
114
-        'OCA\\DAV\\CardDAV\\SyncService' => __DIR__ . '/..' . '/../lib/CardDAV/SyncService.php',
115
-        'OCA\\DAV\\CardDAV\\SystemAddressbook' => __DIR__ . '/..' . '/../lib/CardDAV/SystemAddressbook.php',
116
-        'OCA\\DAV\\CardDAV\\UserAddressBooks' => __DIR__ . '/..' . '/../lib/CardDAV/UserAddressBooks.php',
117
-        'OCA\\DAV\\CardDAV\\Xml\\Groups' => __DIR__ . '/..' . '/../lib/CardDAV/Xml/Groups.php',
118
-        'OCA\\DAV\\Command\\CreateAddressBook' => __DIR__ . '/..' . '/../lib/Command/CreateAddressBook.php',
119
-        'OCA\\DAV\\Command\\CreateCalendar' => __DIR__ . '/..' . '/../lib/Command/CreateCalendar.php',
120
-        'OCA\\DAV\\Command\\ListCalendars' => __DIR__ . '/..' . '/../lib/Command/ListCalendars.php',
121
-        'OCA\\DAV\\Command\\MoveCalendar' => __DIR__ . '/..' . '/../lib/Command/MoveCalendar.php',
122
-        'OCA\\DAV\\Command\\RemoveInvalidShares' => __DIR__ . '/..' . '/../lib/Command/RemoveInvalidShares.php',
123
-        'OCA\\DAV\\Command\\SendEventReminders' => __DIR__ . '/..' . '/../lib/Command/SendEventReminders.php',
124
-        'OCA\\DAV\\Command\\SyncBirthdayCalendar' => __DIR__ . '/..' . '/../lib/Command/SyncBirthdayCalendar.php',
125
-        'OCA\\DAV\\Command\\SyncSystemAddressBook' => __DIR__ . '/..' . '/../lib/Command/SyncSystemAddressBook.php',
126
-        'OCA\\DAV\\Comments\\CommentNode' => __DIR__ . '/..' . '/../lib/Comments/CommentNode.php',
127
-        'OCA\\DAV\\Comments\\CommentsPlugin' => __DIR__ . '/..' . '/../lib/Comments/CommentsPlugin.php',
128
-        'OCA\\DAV\\Comments\\EntityCollection' => __DIR__ . '/..' . '/../lib/Comments/EntityCollection.php',
129
-        'OCA\\DAV\\Comments\\EntityTypeCollection' => __DIR__ . '/..' . '/../lib/Comments/EntityTypeCollection.php',
130
-        'OCA\\DAV\\Comments\\RootCollection' => __DIR__ . '/..' . '/../lib/Comments/RootCollection.php',
131
-        'OCA\\DAV\\Connector\\LegacyDAVACL' => __DIR__ . '/..' . '/../lib/Connector/LegacyDAVACL.php',
132
-        'OCA\\DAV\\Connector\\PublicAuth' => __DIR__ . '/..' . '/../lib/Connector/PublicAuth.php',
133
-        'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/AnonymousOptionsPlugin.php',
134
-        'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/AppEnabledPlugin.php',
135
-        'OCA\\DAV\\Connector\\Sabre\\Auth' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Auth.php',
136
-        'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => __DIR__ . '/..' . '/../lib/Connector/Sabre/BearerAuth.php',
137
-        'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/BlockLegacyClientPlugin.php',
138
-        'OCA\\DAV\\Connector\\Sabre\\CachingTree' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CachingTree.php',
139
-        'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ChecksumList.php',
140
-        'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CommentPropertiesPlugin.php',
141
-        'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php',
142
-        'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/DavAclPlugin.php',
143
-        'OCA\\DAV\\Connector\\Sabre\\Directory' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Directory.php',
144
-        'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/DummyGetResponsePlugin.php',
145
-        'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ExceptionLoggerPlugin.php',
146
-        'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/EntityTooLarge.php',
147
-        'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/FileLocked.php',
148
-        'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/Forbidden.php',
149
-        'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/InvalidPath.php',
150
-        'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php',
151
-        'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php',
152
-        'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/FakeLockerPlugin.php',
153
-        'OCA\\DAV\\Connector\\Sabre\\File' => __DIR__ . '/..' . '/../lib/Connector/Sabre/File.php',
154
-        'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/FilesPlugin.php',
155
-        'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/FilesReportPlugin.php',
156
-        'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/LockPlugin.php',
157
-        'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/MaintenancePlugin.php',
158
-        'OCA\\DAV\\Connector\\Sabre\\Node' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Node.php',
159
-        'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ObjectTree.php',
160
-        'OCA\\DAV\\Connector\\Sabre\\Principal' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Principal.php',
161
-        'OCA\\DAV\\Connector\\Sabre\\PropfindCompressionPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/PropfindCompressionPlugin.php',
162
-        'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/QuotaPlugin.php',
163
-        'OCA\\DAV\\Connector\\Sabre\\Server' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Server.php',
164
-        'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ServerFactory.php',
165
-        'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ShareTypeList.php',
166
-        'OCA\\DAV\\Connector\\Sabre\\ShareeList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ShareeList.php',
167
-        'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/SharesPlugin.php',
168
-        'OCA\\DAV\\Connector\\Sabre\\TagList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/TagList.php',
169
-        'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/TagsPlugin.php',
170
-        'OCA\\DAV\\Controller\\BirthdayCalendarController' => __DIR__ . '/..' . '/../lib/Controller/BirthdayCalendarController.php',
171
-        'OCA\\DAV\\Controller\\DirectController' => __DIR__ . '/..' . '/../lib/Controller/DirectController.php',
172
-        'OCA\\DAV\\Controller\\InvitationResponseController' => __DIR__ . '/..' . '/../lib/Controller/InvitationResponseController.php',
173
-        'OCA\\DAV\\DAV\\CustomPropertiesBackend' => __DIR__ . '/..' . '/../lib/DAV/CustomPropertiesBackend.php',
174
-        'OCA\\DAV\\DAV\\GroupPrincipalBackend' => __DIR__ . '/..' . '/../lib/DAV/GroupPrincipalBackend.php',
175
-        'OCA\\DAV\\DAV\\PublicAuth' => __DIR__ . '/..' . '/../lib/DAV/PublicAuth.php',
176
-        'OCA\\DAV\\DAV\\Sharing\\Backend' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Backend.php',
177
-        'OCA\\DAV\\DAV\\Sharing\\IShareable' => __DIR__ . '/..' . '/../lib/DAV/Sharing/IShareable.php',
178
-        'OCA\\DAV\\DAV\\Sharing\\Plugin' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Plugin.php',
179
-        'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Xml/Invite.php',
180
-        'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Xml/ShareRequest.php',
181
-        'OCA\\DAV\\DAV\\SystemPrincipalBackend' => __DIR__ . '/..' . '/../lib/DAV/SystemPrincipalBackend.php',
182
-        'OCA\\DAV\\Db\\Direct' => __DIR__ . '/..' . '/../lib/Db/Direct.php',
183
-        'OCA\\DAV\\Db\\DirectMapper' => __DIR__ . '/..' . '/../lib/Db/DirectMapper.php',
184
-        'OCA\\DAV\\Direct\\DirectFile' => __DIR__ . '/..' . '/../lib/Direct/DirectFile.php',
185
-        'OCA\\DAV\\Direct\\DirectHome' => __DIR__ . '/..' . '/../lib/Direct/DirectHome.php',
186
-        'OCA\\DAV\\Direct\\Server' => __DIR__ . '/..' . '/../lib/Direct/Server.php',
187
-        'OCA\\DAV\\Direct\\ServerFactory' => __DIR__ . '/..' . '/../lib/Direct/ServerFactory.php',
188
-        'OCA\\DAV\\Events\\AddressBookCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookCreatedEvent.php',
189
-        'OCA\\DAV\\Events\\AddressBookDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookDeletedEvent.php',
190
-        'OCA\\DAV\\Events\\AddressBookShareUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookShareUpdatedEvent.php',
191
-        'OCA\\DAV\\Events\\AddressBookUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookUpdatedEvent.php',
192
-        'OCA\\DAV\\Events\\CachedCalendarObjectCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CachedCalendarObjectCreatedEvent.php',
193
-        'OCA\\DAV\\Events\\CachedCalendarObjectDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CachedCalendarObjectDeletedEvent.php',
194
-        'OCA\\DAV\\Events\\CachedCalendarObjectUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CachedCalendarObjectUpdatedEvent.php',
195
-        'OCA\\DAV\\Events\\CalendarCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarCreatedEvent.php',
196
-        'OCA\\DAV\\Events\\CalendarDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarDeletedEvent.php',
197
-        'OCA\\DAV\\Events\\CalendarObjectCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarObjectCreatedEvent.php',
198
-        'OCA\\DAV\\Events\\CalendarObjectDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarObjectDeletedEvent.php',
199
-        'OCA\\DAV\\Events\\CalendarObjectUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarObjectUpdatedEvent.php',
200
-        'OCA\\DAV\\Events\\CalendarPublishedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarPublishedEvent.php',
201
-        'OCA\\DAV\\Events\\CalendarShareUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarShareUpdatedEvent.php',
202
-        'OCA\\DAV\\Events\\CalendarUnpublishedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarUnpublishedEvent.php',
203
-        'OCA\\DAV\\Events\\CalendarUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarUpdatedEvent.php',
204
-        'OCA\\DAV\\Events\\CardCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CardCreatedEvent.php',
205
-        'OCA\\DAV\\Events\\CardDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CardDeletedEvent.php',
206
-        'OCA\\DAV\\Events\\CardUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CardUpdatedEvent.php',
207
-        'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => __DIR__ . '/..' . '/../lib/Events/SabrePluginAuthInitEvent.php',
208
-        'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionCreatedEvent.php',
209
-        'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionDeletedEvent.php',
210
-        'OCA\\DAV\\Events\\SubscriptionUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionUpdatedEvent.php',
211
-        'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => __DIR__ . '/..' . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
212
-        'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__ . '/..' . '/../lib/Files/BrowserErrorPagePlugin.php',
213
-        'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__ . '/..' . '/../lib/Files/FileSearchBackend.php',
214
-        'OCA\\DAV\\Files\\FilesHome' => __DIR__ . '/..' . '/../lib/Files/FilesHome.php',
215
-        'OCA\\DAV\\Files\\LazySearchBackend' => __DIR__ . '/..' . '/../lib/Files/LazySearchBackend.php',
216
-        'OCA\\DAV\\Files\\RootCollection' => __DIR__ . '/..' . '/../lib/Files/RootCollection.php',
217
-        'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/FilesDropPlugin.php',
218
-        'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
219
-        'OCA\\DAV\\HookManager' => __DIR__ . '/..' . '/../lib/HookManager.php',
220
-        'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndex.php',
221
-        'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',
222
-        'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => __DIR__ . '/..' . '/../lib/Migration/CalDAVRemoveEmptyValue.php',
223
-        'OCA\\DAV\\Migration\\ChunkCleanup' => __DIR__ . '/..' . '/../lib/Migration/ChunkCleanup.php',
224
-        'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => __DIR__ . '/..' . '/../lib/Migration/FixBirthdayCalendarComponent.php',
225
-        'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => __DIR__ . '/..' . '/../lib/Migration/RefreshWebcalJobRegistrar.php',
226
-        'OCA\\DAV\\Migration\\RegenerateBirthdayCalendars' => __DIR__ . '/..' . '/../lib/Migration/RegenerateBirthdayCalendars.php',
227
-        'OCA\\DAV\\Migration\\RegisterBuildReminderIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/RegisterBuildReminderIndexBackgroundJob.php',
228
-        'OCA\\DAV\\Migration\\RemoveClassifiedEventActivity' => __DIR__ . '/..' . '/../lib/Migration/RemoveClassifiedEventActivity.php',
229
-        'OCA\\DAV\\Migration\\RemoveOrphanEventsAndContacts' => __DIR__ . '/..' . '/../lib/Migration/RemoveOrphanEventsAndContacts.php',
230
-        'OCA\\DAV\\Migration\\Version1004Date20170825134824' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170825134824.php',
231
-        'OCA\\DAV\\Migration\\Version1004Date20170919104507' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170919104507.php',
232
-        'OCA\\DAV\\Migration\\Version1004Date20170924124212' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170924124212.php',
233
-        'OCA\\DAV\\Migration\\Version1004Date20170926103422' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170926103422.php',
234
-        'OCA\\DAV\\Migration\\Version1005Date20180413093149' => __DIR__ . '/..' . '/../lib/Migration/Version1005Date20180413093149.php',
235
-        'OCA\\DAV\\Migration\\Version1005Date20180530124431' => __DIR__ . '/..' . '/../lib/Migration/Version1005Date20180530124431.php',
236
-        'OCA\\DAV\\Migration\\Version1006Date20180619154313' => __DIR__ . '/..' . '/../lib/Migration/Version1006Date20180619154313.php',
237
-        'OCA\\DAV\\Migration\\Version1006Date20180628111625' => __DIR__ . '/..' . '/../lib/Migration/Version1006Date20180628111625.php',
238
-        'OCA\\DAV\\Migration\\Version1008Date20181030113700' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181030113700.php',
239
-        'OCA\\DAV\\Migration\\Version1008Date20181105104826' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181105104826.php',
240
-        'OCA\\DAV\\Migration\\Version1008Date20181105104833' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181105104833.php',
241
-        'OCA\\DAV\\Migration\\Version1008Date20181105110300' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181105110300.php',
242
-        'OCA\\DAV\\Migration\\Version1008Date20181105112049' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181105112049.php',
243
-        'OCA\\DAV\\Migration\\Version1008Date20181114084440' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181114084440.php',
244
-        'OCA\\DAV\\Migration\\Version1011Date20190725113607' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190725113607.php',
245
-        'OCA\\DAV\\Migration\\Version1011Date20190806104428' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190806104428.php',
246
-        'OCA\\DAV\\Migration\\Version1012Date20190808122342' => __DIR__ . '/..' . '/../lib/Migration/Version1012Date20190808122342.php',
247
-        'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
248
-        'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
249
-        'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php',
250
-        'OCA\\DAV\\Search\\ACalendarSearchProvider' => __DIR__ . '/..' . '/../lib/Search/ACalendarSearchProvider.php',
251
-        'OCA\\DAV\\Search\\ContactsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/ContactsSearchProvider.php',
252
-        'OCA\\DAV\\Search\\EventsSearchProvider' => __DIR__ . '/..' . '/../lib/Search/EventsSearchProvider.php',
253
-        'OCA\\DAV\\Search\\TasksSearchProvider' => __DIR__ . '/..' . '/../lib/Search/TasksSearchProvider.php',
254
-        'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php',
255
-        'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php',
256
-        'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicOwnerWrapper.php',
257
-        'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagMappingNode.php',
258
-        'OCA\\DAV\\SystemTag\\SystemTagNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagNode.php',
259
-        'OCA\\DAV\\SystemTag\\SystemTagPlugin' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagPlugin.php',
260
-        'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsByIdCollection.php',
261
-        'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsObjectMappingCollection.php',
262
-        'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsObjectTypeCollection.php',
263
-        'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsRelationsCollection.php',
264
-        'OCA\\DAV\\Traits\\PrincipalProxyTrait' => __DIR__ . '/..' . '/../lib/Traits/PrincipalProxyTrait.php',
265
-        'OCA\\DAV\\Upload\\AssemblyStream' => __DIR__ . '/..' . '/../lib/Upload/AssemblyStream.php',
266
-        'OCA\\DAV\\Upload\\ChunkingPlugin' => __DIR__ . '/..' . '/../lib/Upload/ChunkingPlugin.php',
267
-        'OCA\\DAV\\Upload\\CleanupService' => __DIR__ . '/..' . '/../lib/Upload/CleanupService.php',
268
-        'OCA\\DAV\\Upload\\FutureFile' => __DIR__ . '/..' . '/../lib/Upload/FutureFile.php',
269
-        'OCA\\DAV\\Upload\\RootCollection' => __DIR__ . '/..' . '/../lib/Upload/RootCollection.php',
270
-        'OCA\\DAV\\Upload\\UploadFile' => __DIR__ . '/..' . '/../lib/Upload/UploadFile.php',
271
-        'OCA\\DAV\\Upload\\UploadFolder' => __DIR__ . '/..' . '/../lib/Upload/UploadFolder.php',
272
-        'OCA\\DAV\\Upload\\UploadHome' => __DIR__ . '/..' . '/../lib/Upload/UploadHome.php',
23
+    public static $classMap = array(
24
+        'OCA\\DAV\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
25
+        'OCA\\DAV\\AppInfo\\PluginManager' => __DIR__.'/..'.'/../lib/AppInfo/PluginManager.php',
26
+        'OCA\\DAV\\Avatars\\AvatarHome' => __DIR__.'/..'.'/../lib/Avatars/AvatarHome.php',
27
+        'OCA\\DAV\\Avatars\\AvatarNode' => __DIR__.'/..'.'/../lib/Avatars/AvatarNode.php',
28
+        'OCA\\DAV\\Avatars\\RootCollection' => __DIR__.'/..'.'/../lib/Avatars/RootCollection.php',
29
+        'OCA\\DAV\\BackgroundJob\\BuildReminderIndexBackgroundJob' => __DIR__.'/..'.'/../lib/BackgroundJob/BuildReminderIndexBackgroundJob.php',
30
+        'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupDirectLinksJob.php',
31
+        'OCA\\DAV\\BackgroundJob\\CleanupInvitationTokenJob' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupInvitationTokenJob.php',
32
+        'OCA\\DAV\\BackgroundJob\\EventReminderJob' => __DIR__.'/..'.'/../lib/BackgroundJob/EventReminderJob.php',
33
+        'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => __DIR__.'/..'.'/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php',
34
+        'OCA\\DAV\\BackgroundJob\\RefreshWebcalJob' => __DIR__.'/..'.'/../lib/BackgroundJob/RefreshWebcalJob.php',
35
+        'OCA\\DAV\\BackgroundJob\\RegisterRegenerateBirthdayCalendars' => __DIR__.'/..'.'/../lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php',
36
+        'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => __DIR__.'/..'.'/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php',
37
+        'OCA\\DAV\\BackgroundJob\\UploadCleanup' => __DIR__.'/..'.'/../lib/BackgroundJob/UploadCleanup.php',
38
+        'OCA\\DAV\\CalDAV\\Activity\\Backend' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Backend.php',
39
+        'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Filter/Calendar.php',
40
+        'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Filter/Todo.php',
41
+        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Base.php',
42
+        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Calendar.php',
43
+        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Event.php',
44
+        'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Todo.php',
45
+        'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Setting/Calendar.php',
46
+        'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Setting/Event.php',
47
+        'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Setting/Todo.php',
48
+        'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => __DIR__.'/..'.'/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php',
49
+        'OCA\\DAV\\CalDAV\\BirthdayService' => __DIR__.'/..'.'/../lib/CalDAV/BirthdayService.php',
50
+        'OCA\\DAV\\CalDAV\\CachedSubscription' => __DIR__.'/..'.'/../lib/CalDAV/CachedSubscription.php',
51
+        'OCA\\DAV\\CalDAV\\CachedSubscriptionObject' => __DIR__.'/..'.'/../lib/CalDAV/CachedSubscriptionObject.php',
52
+        'OCA\\DAV\\CalDAV\\CalDavBackend' => __DIR__.'/..'.'/../lib/CalDAV/CalDavBackend.php',
53
+        'OCA\\DAV\\CalDAV\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Calendar.php',
54
+        'OCA\\DAV\\CalDAV\\CalendarHome' => __DIR__.'/..'.'/../lib/CalDAV/CalendarHome.php',
55
+        'OCA\\DAV\\CalDAV\\CalendarImpl' => __DIR__.'/..'.'/../lib/CalDAV/CalendarImpl.php',
56
+        'OCA\\DAV\\CalDAV\\CalendarManager' => __DIR__.'/..'.'/../lib/CalDAV/CalendarManager.php',
57
+        'OCA\\DAV\\CalDAV\\CalendarObject' => __DIR__.'/..'.'/../lib/CalDAV/CalendarObject.php',
58
+        'OCA\\DAV\\CalDAV\\CalendarRoot' => __DIR__.'/..'.'/../lib/CalDAV/CalendarRoot.php',
59
+        'OCA\\DAV\\CalDAV\\ICSExportPlugin\\ICSExportPlugin' => __DIR__.'/..'.'/../lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php',
60
+        'OCA\\DAV\\CalDAV\\Integration\\ExternalCalendar' => __DIR__.'/..'.'/../lib/CalDAV/Integration/ExternalCalendar.php',
61
+        'OCA\\DAV\\CalDAV\\Integration\\ICalendarProvider' => __DIR__.'/..'.'/../lib/CalDAV/Integration/ICalendarProvider.php',
62
+        'OCA\\DAV\\CalDAV\\InvitationResponse\\InvitationResponseServer' => __DIR__.'/..'.'/../lib/CalDAV/InvitationResponse/InvitationResponseServer.php',
63
+        'OCA\\DAV\\CalDAV\\Outbox' => __DIR__.'/..'.'/../lib/CalDAV/Outbox.php',
64
+        'OCA\\DAV\\CalDAV\\Plugin' => __DIR__.'/..'.'/../lib/CalDAV/Plugin.php',
65
+        'OCA\\DAV\\CalDAV\\Principal\\Collection' => __DIR__.'/..'.'/../lib/CalDAV/Principal/Collection.php',
66
+        'OCA\\DAV\\CalDAV\\Principal\\User' => __DIR__.'/..'.'/../lib/CalDAV/Principal/User.php',
67
+        'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => __DIR__.'/..'.'/../lib/CalDAV/Proxy/Proxy.php',
68
+        'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => __DIR__.'/..'.'/../lib/CalDAV/Proxy/ProxyMapper.php',
69
+        'OCA\\DAV\\CalDAV\\PublicCalendar' => __DIR__.'/..'.'/../lib/CalDAV/PublicCalendar.php',
70
+        'OCA\\DAV\\CalDAV\\PublicCalendarObject' => __DIR__.'/..'.'/../lib/CalDAV/PublicCalendarObject.php',
71
+        'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => __DIR__.'/..'.'/../lib/CalDAV/PublicCalendarRoot.php',
72
+        'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => __DIR__.'/..'.'/../lib/CalDAV/Publishing/PublishPlugin.php',
73
+        'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => __DIR__.'/..'.'/../lib/CalDAV/Publishing/Xml/Publisher.php',
74
+        'OCA\\DAV\\CalDAV\\Reminder\\Backend' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/Backend.php',
75
+        'OCA\\DAV\\CalDAV\\Reminder\\INotificationProvider' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/INotificationProvider.php',
76
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProviderManager' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationProviderManager.php',
77
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AbstractProvider' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php',
78
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AudioProvider' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php',
79
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\EmailProvider' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php',
80
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\ProviderNotAvailableException' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php',
81
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\PushProvider' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationProvider/PushProvider.php',
82
+        'OCA\\DAV\\CalDAV\\Reminder\\NotificationTypeDoesNotExistException' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php',
83
+        'OCA\\DAV\\CalDAV\\Reminder\\Notifier' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/Notifier.php',
84
+        'OCA\\DAV\\CalDAV\\Reminder\\ReminderService' => __DIR__.'/..'.'/../lib/CalDAV/Reminder/ReminderService.php',
85
+        'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => __DIR__.'/..'.'/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php',
86
+        'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => __DIR__.'/..'.'/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php',
87
+        'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => __DIR__.'/..'.'/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php',
88
+        'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => __DIR__.'/..'.'/../lib/CalDAV/Schedule/IMipPlugin.php',
89
+        'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => __DIR__.'/..'.'/../lib/CalDAV/Schedule/Plugin.php',
90
+        'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => __DIR__.'/..'.'/../lib/CalDAV/Search/SearchPlugin.php',
91
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/CompFilter.php',
92
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php',
93
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php',
94
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php',
95
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/PropFilter.php',
96
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php',
97
+        'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php',
98
+        'OCA\\DAV\\CalDAV\\WebcalCaching\\Plugin' => __DIR__.'/..'.'/../lib/CalDAV/WebcalCaching/Plugin.php',
99
+        'OCA\\DAV\\CalDAV\\WebcalCaching\\RefreshWebcalService' => __DIR__.'/..'.'/../lib/CalDAV/WebcalCaching/RefreshWebcalService.php',
100
+        'OCA\\DAV\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php',
101
+        'OCA\\DAV\\CardDAV\\AddressBook' => __DIR__.'/..'.'/../lib/CardDAV/AddressBook.php',
102
+        'OCA\\DAV\\CardDAV\\AddressBookImpl' => __DIR__.'/..'.'/../lib/CardDAV/AddressBookImpl.php',
103
+        'OCA\\DAV\\CardDAV\\AddressBookRoot' => __DIR__.'/..'.'/../lib/CardDAV/AddressBookRoot.php',
104
+        'OCA\\DAV\\CardDAV\\CardDavBackend' => __DIR__.'/..'.'/../lib/CardDAV/CardDavBackend.php',
105
+        'OCA\\DAV\\CardDAV\\ContactsManager' => __DIR__.'/..'.'/../lib/CardDAV/ContactsManager.php',
106
+        'OCA\\DAV\\CardDAV\\Converter' => __DIR__.'/..'.'/../lib/CardDAV/Converter.php',
107
+        'OCA\\DAV\\CardDAV\\HasPhotoPlugin' => __DIR__.'/..'.'/../lib/CardDAV/HasPhotoPlugin.php',
108
+        'OCA\\DAV\\CardDAV\\ImageExportPlugin' => __DIR__.'/..'.'/../lib/CardDAV/ImageExportPlugin.php',
109
+        'OCA\\DAV\\CardDAV\\Integration\\ExternalAddressBook' => __DIR__.'/..'.'/../lib/CardDAV/Integration/ExternalAddressBook.php',
110
+        'OCA\\DAV\\CardDAV\\Integration\\IAddressBookProvider' => __DIR__.'/..'.'/../lib/CardDAV/Integration/IAddressBookProvider.php',
111
+        'OCA\\DAV\\CardDAV\\MultiGetExportPlugin' => __DIR__.'/..'.'/../lib/CardDAV/MultiGetExportPlugin.php',
112
+        'OCA\\DAV\\CardDAV\\PhotoCache' => __DIR__.'/..'.'/../lib/CardDAV/PhotoCache.php',
113
+        'OCA\\DAV\\CardDAV\\Plugin' => __DIR__.'/..'.'/../lib/CardDAV/Plugin.php',
114
+        'OCA\\DAV\\CardDAV\\SyncService' => __DIR__.'/..'.'/../lib/CardDAV/SyncService.php',
115
+        'OCA\\DAV\\CardDAV\\SystemAddressbook' => __DIR__.'/..'.'/../lib/CardDAV/SystemAddressbook.php',
116
+        'OCA\\DAV\\CardDAV\\UserAddressBooks' => __DIR__.'/..'.'/../lib/CardDAV/UserAddressBooks.php',
117
+        'OCA\\DAV\\CardDAV\\Xml\\Groups' => __DIR__.'/..'.'/../lib/CardDAV/Xml/Groups.php',
118
+        'OCA\\DAV\\Command\\CreateAddressBook' => __DIR__.'/..'.'/../lib/Command/CreateAddressBook.php',
119
+        'OCA\\DAV\\Command\\CreateCalendar' => __DIR__.'/..'.'/../lib/Command/CreateCalendar.php',
120
+        'OCA\\DAV\\Command\\ListCalendars' => __DIR__.'/..'.'/../lib/Command/ListCalendars.php',
121
+        'OCA\\DAV\\Command\\MoveCalendar' => __DIR__.'/..'.'/../lib/Command/MoveCalendar.php',
122
+        'OCA\\DAV\\Command\\RemoveInvalidShares' => __DIR__.'/..'.'/../lib/Command/RemoveInvalidShares.php',
123
+        'OCA\\DAV\\Command\\SendEventReminders' => __DIR__.'/..'.'/../lib/Command/SendEventReminders.php',
124
+        'OCA\\DAV\\Command\\SyncBirthdayCalendar' => __DIR__.'/..'.'/../lib/Command/SyncBirthdayCalendar.php',
125
+        'OCA\\DAV\\Command\\SyncSystemAddressBook' => __DIR__.'/..'.'/../lib/Command/SyncSystemAddressBook.php',
126
+        'OCA\\DAV\\Comments\\CommentNode' => __DIR__.'/..'.'/../lib/Comments/CommentNode.php',
127
+        'OCA\\DAV\\Comments\\CommentsPlugin' => __DIR__.'/..'.'/../lib/Comments/CommentsPlugin.php',
128
+        'OCA\\DAV\\Comments\\EntityCollection' => __DIR__.'/..'.'/../lib/Comments/EntityCollection.php',
129
+        'OCA\\DAV\\Comments\\EntityTypeCollection' => __DIR__.'/..'.'/../lib/Comments/EntityTypeCollection.php',
130
+        'OCA\\DAV\\Comments\\RootCollection' => __DIR__.'/..'.'/../lib/Comments/RootCollection.php',
131
+        'OCA\\DAV\\Connector\\LegacyDAVACL' => __DIR__.'/..'.'/../lib/Connector/LegacyDAVACL.php',
132
+        'OCA\\DAV\\Connector\\PublicAuth' => __DIR__.'/..'.'/../lib/Connector/PublicAuth.php',
133
+        'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/AnonymousOptionsPlugin.php',
134
+        'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/AppEnabledPlugin.php',
135
+        'OCA\\DAV\\Connector\\Sabre\\Auth' => __DIR__.'/..'.'/../lib/Connector/Sabre/Auth.php',
136
+        'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => __DIR__.'/..'.'/../lib/Connector/Sabre/BearerAuth.php',
137
+        'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/BlockLegacyClientPlugin.php',
138
+        'OCA\\DAV\\Connector\\Sabre\\CachingTree' => __DIR__.'/..'.'/../lib/Connector/Sabre/CachingTree.php',
139
+        'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => __DIR__.'/..'.'/../lib/Connector/Sabre/ChecksumList.php',
140
+        'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/CommentPropertiesPlugin.php',
141
+        'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php',
142
+        'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/DavAclPlugin.php',
143
+        'OCA\\DAV\\Connector\\Sabre\\Directory' => __DIR__.'/..'.'/../lib/Connector/Sabre/Directory.php',
144
+        'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/DummyGetResponsePlugin.php',
145
+        'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/ExceptionLoggerPlugin.php',
146
+        'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/EntityTooLarge.php',
147
+        'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/FileLocked.php',
148
+        'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/Forbidden.php',
149
+        'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/InvalidPath.php',
150
+        'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php',
151
+        'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php',
152
+        'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/FakeLockerPlugin.php',
153
+        'OCA\\DAV\\Connector\\Sabre\\File' => __DIR__.'/..'.'/../lib/Connector/Sabre/File.php',
154
+        'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/FilesPlugin.php',
155
+        'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/FilesReportPlugin.php',
156
+        'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/LockPlugin.php',
157
+        'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/MaintenancePlugin.php',
158
+        'OCA\\DAV\\Connector\\Sabre\\Node' => __DIR__.'/..'.'/../lib/Connector/Sabre/Node.php',
159
+        'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => __DIR__.'/..'.'/../lib/Connector/Sabre/ObjectTree.php',
160
+        'OCA\\DAV\\Connector\\Sabre\\Principal' => __DIR__.'/..'.'/../lib/Connector/Sabre/Principal.php',
161
+        'OCA\\DAV\\Connector\\Sabre\\PropfindCompressionPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/PropfindCompressionPlugin.php',
162
+        'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/QuotaPlugin.php',
163
+        'OCA\\DAV\\Connector\\Sabre\\Server' => __DIR__.'/..'.'/../lib/Connector/Sabre/Server.php',
164
+        'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => __DIR__.'/..'.'/../lib/Connector/Sabre/ServerFactory.php',
165
+        'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => __DIR__.'/..'.'/../lib/Connector/Sabre/ShareTypeList.php',
166
+        'OCA\\DAV\\Connector\\Sabre\\ShareeList' => __DIR__.'/..'.'/../lib/Connector/Sabre/ShareeList.php',
167
+        'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/SharesPlugin.php',
168
+        'OCA\\DAV\\Connector\\Sabre\\TagList' => __DIR__.'/..'.'/../lib/Connector/Sabre/TagList.php',
169
+        'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/TagsPlugin.php',
170
+        'OCA\\DAV\\Controller\\BirthdayCalendarController' => __DIR__.'/..'.'/../lib/Controller/BirthdayCalendarController.php',
171
+        'OCA\\DAV\\Controller\\DirectController' => __DIR__.'/..'.'/../lib/Controller/DirectController.php',
172
+        'OCA\\DAV\\Controller\\InvitationResponseController' => __DIR__.'/..'.'/../lib/Controller/InvitationResponseController.php',
173
+        'OCA\\DAV\\DAV\\CustomPropertiesBackend' => __DIR__.'/..'.'/../lib/DAV/CustomPropertiesBackend.php',
174
+        'OCA\\DAV\\DAV\\GroupPrincipalBackend' => __DIR__.'/..'.'/../lib/DAV/GroupPrincipalBackend.php',
175
+        'OCA\\DAV\\DAV\\PublicAuth' => __DIR__.'/..'.'/../lib/DAV/PublicAuth.php',
176
+        'OCA\\DAV\\DAV\\Sharing\\Backend' => __DIR__.'/..'.'/../lib/DAV/Sharing/Backend.php',
177
+        'OCA\\DAV\\DAV\\Sharing\\IShareable' => __DIR__.'/..'.'/../lib/DAV/Sharing/IShareable.php',
178
+        'OCA\\DAV\\DAV\\Sharing\\Plugin' => __DIR__.'/..'.'/../lib/DAV/Sharing/Plugin.php',
179
+        'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => __DIR__.'/..'.'/../lib/DAV/Sharing/Xml/Invite.php',
180
+        'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => __DIR__.'/..'.'/../lib/DAV/Sharing/Xml/ShareRequest.php',
181
+        'OCA\\DAV\\DAV\\SystemPrincipalBackend' => __DIR__.'/..'.'/../lib/DAV/SystemPrincipalBackend.php',
182
+        'OCA\\DAV\\Db\\Direct' => __DIR__.'/..'.'/../lib/Db/Direct.php',
183
+        'OCA\\DAV\\Db\\DirectMapper' => __DIR__.'/..'.'/../lib/Db/DirectMapper.php',
184
+        'OCA\\DAV\\Direct\\DirectFile' => __DIR__.'/..'.'/../lib/Direct/DirectFile.php',
185
+        'OCA\\DAV\\Direct\\DirectHome' => __DIR__.'/..'.'/../lib/Direct/DirectHome.php',
186
+        'OCA\\DAV\\Direct\\Server' => __DIR__.'/..'.'/../lib/Direct/Server.php',
187
+        'OCA\\DAV\\Direct\\ServerFactory' => __DIR__.'/..'.'/../lib/Direct/ServerFactory.php',
188
+        'OCA\\DAV\\Events\\AddressBookCreatedEvent' => __DIR__.'/..'.'/../lib/Events/AddressBookCreatedEvent.php',
189
+        'OCA\\DAV\\Events\\AddressBookDeletedEvent' => __DIR__.'/..'.'/../lib/Events/AddressBookDeletedEvent.php',
190
+        'OCA\\DAV\\Events\\AddressBookShareUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/AddressBookShareUpdatedEvent.php',
191
+        'OCA\\DAV\\Events\\AddressBookUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/AddressBookUpdatedEvent.php',
192
+        'OCA\\DAV\\Events\\CachedCalendarObjectCreatedEvent' => __DIR__.'/..'.'/../lib/Events/CachedCalendarObjectCreatedEvent.php',
193
+        'OCA\\DAV\\Events\\CachedCalendarObjectDeletedEvent' => __DIR__.'/..'.'/../lib/Events/CachedCalendarObjectDeletedEvent.php',
194
+        'OCA\\DAV\\Events\\CachedCalendarObjectUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/CachedCalendarObjectUpdatedEvent.php',
195
+        'OCA\\DAV\\Events\\CalendarCreatedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarCreatedEvent.php',
196
+        'OCA\\DAV\\Events\\CalendarDeletedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarDeletedEvent.php',
197
+        'OCA\\DAV\\Events\\CalendarObjectCreatedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarObjectCreatedEvent.php',
198
+        'OCA\\DAV\\Events\\CalendarObjectDeletedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarObjectDeletedEvent.php',
199
+        'OCA\\DAV\\Events\\CalendarObjectUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarObjectUpdatedEvent.php',
200
+        'OCA\\DAV\\Events\\CalendarPublishedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarPublishedEvent.php',
201
+        'OCA\\DAV\\Events\\CalendarShareUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarShareUpdatedEvent.php',
202
+        'OCA\\DAV\\Events\\CalendarUnpublishedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarUnpublishedEvent.php',
203
+        'OCA\\DAV\\Events\\CalendarUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/CalendarUpdatedEvent.php',
204
+        'OCA\\DAV\\Events\\CardCreatedEvent' => __DIR__.'/..'.'/../lib/Events/CardCreatedEvent.php',
205
+        'OCA\\DAV\\Events\\CardDeletedEvent' => __DIR__.'/..'.'/../lib/Events/CardDeletedEvent.php',
206
+        'OCA\\DAV\\Events\\CardUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/CardUpdatedEvent.php',
207
+        'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => __DIR__.'/..'.'/../lib/Events/SabrePluginAuthInitEvent.php',
208
+        'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => __DIR__.'/..'.'/../lib/Events/SubscriptionCreatedEvent.php',
209
+        'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => __DIR__.'/..'.'/../lib/Events/SubscriptionDeletedEvent.php',
210
+        'OCA\\DAV\\Events\\SubscriptionUpdatedEvent' => __DIR__.'/..'.'/../lib/Events/SubscriptionUpdatedEvent.php',
211
+        'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => __DIR__.'/..'.'/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
212
+        'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__.'/..'.'/../lib/Files/BrowserErrorPagePlugin.php',
213
+        'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__.'/..'.'/../lib/Files/FileSearchBackend.php',
214
+        'OCA\\DAV\\Files\\FilesHome' => __DIR__.'/..'.'/../lib/Files/FilesHome.php',
215
+        'OCA\\DAV\\Files\\LazySearchBackend' => __DIR__.'/..'.'/../lib/Files/LazySearchBackend.php',
216
+        'OCA\\DAV\\Files\\RootCollection' => __DIR__.'/..'.'/../lib/Files/RootCollection.php',
217
+        'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__.'/..'.'/../lib/Files/Sharing/FilesDropPlugin.php',
218
+        'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__.'/..'.'/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
219
+        'OCA\\DAV\\HookManager' => __DIR__.'/..'.'/../lib/HookManager.php',
220
+        'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__.'/..'.'/../lib/Migration/BuildCalendarSearchIndex.php',
221
+        'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__.'/..'.'/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',
222
+        'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => __DIR__.'/..'.'/../lib/Migration/CalDAVRemoveEmptyValue.php',
223
+        'OCA\\DAV\\Migration\\ChunkCleanup' => __DIR__.'/..'.'/../lib/Migration/ChunkCleanup.php',
224
+        'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => __DIR__.'/..'.'/../lib/Migration/FixBirthdayCalendarComponent.php',
225
+        'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => __DIR__.'/..'.'/../lib/Migration/RefreshWebcalJobRegistrar.php',
226
+        'OCA\\DAV\\Migration\\RegenerateBirthdayCalendars' => __DIR__.'/..'.'/../lib/Migration/RegenerateBirthdayCalendars.php',
227
+        'OCA\\DAV\\Migration\\RegisterBuildReminderIndexBackgroundJob' => __DIR__.'/..'.'/../lib/Migration/RegisterBuildReminderIndexBackgroundJob.php',
228
+        'OCA\\DAV\\Migration\\RemoveClassifiedEventActivity' => __DIR__.'/..'.'/../lib/Migration/RemoveClassifiedEventActivity.php',
229
+        'OCA\\DAV\\Migration\\RemoveOrphanEventsAndContacts' => __DIR__.'/..'.'/../lib/Migration/RemoveOrphanEventsAndContacts.php',
230
+        'OCA\\DAV\\Migration\\Version1004Date20170825134824' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170825134824.php',
231
+        'OCA\\DAV\\Migration\\Version1004Date20170919104507' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170919104507.php',
232
+        'OCA\\DAV\\Migration\\Version1004Date20170924124212' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170924124212.php',
233
+        'OCA\\DAV\\Migration\\Version1004Date20170926103422' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170926103422.php',
234
+        'OCA\\DAV\\Migration\\Version1005Date20180413093149' => __DIR__.'/..'.'/../lib/Migration/Version1005Date20180413093149.php',
235
+        'OCA\\DAV\\Migration\\Version1005Date20180530124431' => __DIR__.'/..'.'/../lib/Migration/Version1005Date20180530124431.php',
236
+        'OCA\\DAV\\Migration\\Version1006Date20180619154313' => __DIR__.'/..'.'/../lib/Migration/Version1006Date20180619154313.php',
237
+        'OCA\\DAV\\Migration\\Version1006Date20180628111625' => __DIR__.'/..'.'/../lib/Migration/Version1006Date20180628111625.php',
238
+        'OCA\\DAV\\Migration\\Version1008Date20181030113700' => __DIR__.'/..'.'/../lib/Migration/Version1008Date20181030113700.php',
239
+        'OCA\\DAV\\Migration\\Version1008Date20181105104826' => __DIR__.'/..'.'/../lib/Migration/Version1008Date20181105104826.php',
240
+        'OCA\\DAV\\Migration\\Version1008Date20181105104833' => __DIR__.'/..'.'/../lib/Migration/Version1008Date20181105104833.php',
241
+        'OCA\\DAV\\Migration\\Version1008Date20181105110300' => __DIR__.'/..'.'/../lib/Migration/Version1008Date20181105110300.php',
242
+        'OCA\\DAV\\Migration\\Version1008Date20181105112049' => __DIR__.'/..'.'/../lib/Migration/Version1008Date20181105112049.php',
243
+        'OCA\\DAV\\Migration\\Version1008Date20181114084440' => __DIR__.'/..'.'/../lib/Migration/Version1008Date20181114084440.php',
244
+        'OCA\\DAV\\Migration\\Version1011Date20190725113607' => __DIR__.'/..'.'/../lib/Migration/Version1011Date20190725113607.php',
245
+        'OCA\\DAV\\Migration\\Version1011Date20190806104428' => __DIR__.'/..'.'/../lib/Migration/Version1011Date20190806104428.php',
246
+        'OCA\\DAV\\Migration\\Version1012Date20190808122342' => __DIR__.'/..'.'/../lib/Migration/Version1012Date20190808122342.php',
247
+        'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__.'/..'.'/../lib/Provisioning/Apple/AppleProvisioningNode.php',
248
+        'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__.'/..'.'/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
249
+        'OCA\\DAV\\RootCollection' => __DIR__.'/..'.'/../lib/RootCollection.php',
250
+        'OCA\\DAV\\Search\\ACalendarSearchProvider' => __DIR__.'/..'.'/../lib/Search/ACalendarSearchProvider.php',
251
+        'OCA\\DAV\\Search\\ContactsSearchProvider' => __DIR__.'/..'.'/../lib/Search/ContactsSearchProvider.php',
252
+        'OCA\\DAV\\Search\\EventsSearchProvider' => __DIR__.'/..'.'/../lib/Search/EventsSearchProvider.php',
253
+        'OCA\\DAV\\Search\\TasksSearchProvider' => __DIR__.'/..'.'/../lib/Search/TasksSearchProvider.php',
254
+        'OCA\\DAV\\Server' => __DIR__.'/..'.'/../lib/Server.php',
255
+        'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__.'/..'.'/../lib/Settings/CalDAVSettings.php',
256
+        'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__.'/..'.'/../lib/Storage/PublicOwnerWrapper.php',
257
+        'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagMappingNode.php',
258
+        'OCA\\DAV\\SystemTag\\SystemTagNode' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagNode.php',
259
+        'OCA\\DAV\\SystemTag\\SystemTagPlugin' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagPlugin.php',
260
+        'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsByIdCollection.php',
261
+        'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsObjectMappingCollection.php',
262
+        'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsObjectTypeCollection.php',
263
+        'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsRelationsCollection.php',
264
+        'OCA\\DAV\\Traits\\PrincipalProxyTrait' => __DIR__.'/..'.'/../lib/Traits/PrincipalProxyTrait.php',
265
+        'OCA\\DAV\\Upload\\AssemblyStream' => __DIR__.'/..'.'/../lib/Upload/AssemblyStream.php',
266
+        'OCA\\DAV\\Upload\\ChunkingPlugin' => __DIR__.'/..'.'/../lib/Upload/ChunkingPlugin.php',
267
+        'OCA\\DAV\\Upload\\CleanupService' => __DIR__.'/..'.'/../lib/Upload/CleanupService.php',
268
+        'OCA\\DAV\\Upload\\FutureFile' => __DIR__.'/..'.'/../lib/Upload/FutureFile.php',
269
+        'OCA\\DAV\\Upload\\RootCollection' => __DIR__.'/..'.'/../lib/Upload/RootCollection.php',
270
+        'OCA\\DAV\\Upload\\UploadFile' => __DIR__.'/..'.'/../lib/Upload/UploadFile.php',
271
+        'OCA\\DAV\\Upload\\UploadFolder' => __DIR__.'/..'.'/../lib/Upload/UploadFolder.php',
272
+        'OCA\\DAV\\Upload\\UploadHome' => __DIR__.'/..'.'/../lib/Upload/UploadHome.php',
273 273
     );
274 274
 
275 275
     public static function getInitializer(ClassLoader $loader)
276 276
     {
277
-        return \Closure::bind(function () use ($loader) {
277
+        return \Closure::bind(function() use ($loader) {
278 278
             $loader->prefixLengthsPsr4 = ComposerStaticInitDAV::$prefixLengthsPsr4;
279 279
             $loader->prefixDirsPsr4 = ComposerStaticInitDAV::$prefixDirsPsr4;
280 280
             $loader->classMap = ComposerStaticInitDAV::$classMap;
Please login to merge, or discard this patch.
apps/dav/composer/composer/autoload_classmap.php 1 patch
Spacing   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -6,253 +6,253 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\DAV\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
10
-    'OCA\\DAV\\AppInfo\\PluginManager' => $baseDir . '/../lib/AppInfo/PluginManager.php',
11
-    'OCA\\DAV\\Avatars\\AvatarHome' => $baseDir . '/../lib/Avatars/AvatarHome.php',
12
-    'OCA\\DAV\\Avatars\\AvatarNode' => $baseDir . '/../lib/Avatars/AvatarNode.php',
13
-    'OCA\\DAV\\Avatars\\RootCollection' => $baseDir . '/../lib/Avatars/RootCollection.php',
14
-    'OCA\\DAV\\BackgroundJob\\BuildReminderIndexBackgroundJob' => $baseDir . '/../lib/BackgroundJob/BuildReminderIndexBackgroundJob.php',
15
-    'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => $baseDir . '/../lib/BackgroundJob/CleanupDirectLinksJob.php',
16
-    'OCA\\DAV\\BackgroundJob\\CleanupInvitationTokenJob' => $baseDir . '/../lib/BackgroundJob/CleanupInvitationTokenJob.php',
17
-    'OCA\\DAV\\BackgroundJob\\EventReminderJob' => $baseDir . '/../lib/BackgroundJob/EventReminderJob.php',
18
-    'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => $baseDir . '/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php',
19
-    'OCA\\DAV\\BackgroundJob\\RefreshWebcalJob' => $baseDir . '/../lib/BackgroundJob/RefreshWebcalJob.php',
20
-    'OCA\\DAV\\BackgroundJob\\RegisterRegenerateBirthdayCalendars' => $baseDir . '/../lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php',
21
-    'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => $baseDir . '/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php',
22
-    'OCA\\DAV\\BackgroundJob\\UploadCleanup' => $baseDir . '/../lib/BackgroundJob/UploadCleanup.php',
23
-    'OCA\\DAV\\CalDAV\\Activity\\Backend' => $baseDir . '/../lib/CalDAV/Activity/Backend.php',
24
-    'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => $baseDir . '/../lib/CalDAV/Activity/Filter/Calendar.php',
25
-    'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => $baseDir . '/../lib/CalDAV/Activity/Filter/Todo.php',
26
-    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => $baseDir . '/../lib/CalDAV/Activity/Provider/Base.php',
27
-    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => $baseDir . '/../lib/CalDAV/Activity/Provider/Calendar.php',
28
-    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => $baseDir . '/../lib/CalDAV/Activity/Provider/Event.php',
29
-    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => $baseDir . '/../lib/CalDAV/Activity/Provider/Todo.php',
30
-    'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => $baseDir . '/../lib/CalDAV/Activity/Setting/Calendar.php',
31
-    'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => $baseDir . '/../lib/CalDAV/Activity/Setting/Event.php',
32
-    'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => $baseDir . '/../lib/CalDAV/Activity/Setting/Todo.php',
33
-    'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => $baseDir . '/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php',
34
-    'OCA\\DAV\\CalDAV\\BirthdayService' => $baseDir . '/../lib/CalDAV/BirthdayService.php',
35
-    'OCA\\DAV\\CalDAV\\CachedSubscription' => $baseDir . '/../lib/CalDAV/CachedSubscription.php',
36
-    'OCA\\DAV\\CalDAV\\CachedSubscriptionObject' => $baseDir . '/../lib/CalDAV/CachedSubscriptionObject.php',
37
-    'OCA\\DAV\\CalDAV\\CalDavBackend' => $baseDir . '/../lib/CalDAV/CalDavBackend.php',
38
-    'OCA\\DAV\\CalDAV\\Calendar' => $baseDir . '/../lib/CalDAV/Calendar.php',
39
-    'OCA\\DAV\\CalDAV\\CalendarHome' => $baseDir . '/../lib/CalDAV/CalendarHome.php',
40
-    'OCA\\DAV\\CalDAV\\CalendarImpl' => $baseDir . '/../lib/CalDAV/CalendarImpl.php',
41
-    'OCA\\DAV\\CalDAV\\CalendarManager' => $baseDir . '/../lib/CalDAV/CalendarManager.php',
42
-    'OCA\\DAV\\CalDAV\\CalendarObject' => $baseDir . '/../lib/CalDAV/CalendarObject.php',
43
-    'OCA\\DAV\\CalDAV\\CalendarRoot' => $baseDir . '/../lib/CalDAV/CalendarRoot.php',
44
-    'OCA\\DAV\\CalDAV\\ICSExportPlugin\\ICSExportPlugin' => $baseDir . '/../lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php',
45
-    'OCA\\DAV\\CalDAV\\Integration\\ExternalCalendar' => $baseDir . '/../lib/CalDAV/Integration/ExternalCalendar.php',
46
-    'OCA\\DAV\\CalDAV\\Integration\\ICalendarProvider' => $baseDir . '/../lib/CalDAV/Integration/ICalendarProvider.php',
47
-    'OCA\\DAV\\CalDAV\\InvitationResponse\\InvitationResponseServer' => $baseDir . '/../lib/CalDAV/InvitationResponse/InvitationResponseServer.php',
48
-    'OCA\\DAV\\CalDAV\\Outbox' => $baseDir . '/../lib/CalDAV/Outbox.php',
49
-    'OCA\\DAV\\CalDAV\\Plugin' => $baseDir . '/../lib/CalDAV/Plugin.php',
50
-    'OCA\\DAV\\CalDAV\\Principal\\Collection' => $baseDir . '/../lib/CalDAV/Principal/Collection.php',
51
-    'OCA\\DAV\\CalDAV\\Principal\\User' => $baseDir . '/../lib/CalDAV/Principal/User.php',
52
-    'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => $baseDir . '/../lib/CalDAV/Proxy/Proxy.php',
53
-    'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => $baseDir . '/../lib/CalDAV/Proxy/ProxyMapper.php',
54
-    'OCA\\DAV\\CalDAV\\PublicCalendar' => $baseDir . '/../lib/CalDAV/PublicCalendar.php',
55
-    'OCA\\DAV\\CalDAV\\PublicCalendarObject' => $baseDir . '/../lib/CalDAV/PublicCalendarObject.php',
56
-    'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => $baseDir . '/../lib/CalDAV/PublicCalendarRoot.php',
57
-    'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => $baseDir . '/../lib/CalDAV/Publishing/PublishPlugin.php',
58
-    'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => $baseDir . '/../lib/CalDAV/Publishing/Xml/Publisher.php',
59
-    'OCA\\DAV\\CalDAV\\Reminder\\Backend' => $baseDir . '/../lib/CalDAV/Reminder/Backend.php',
60
-    'OCA\\DAV\\CalDAV\\Reminder\\INotificationProvider' => $baseDir . '/../lib/CalDAV/Reminder/INotificationProvider.php',
61
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProviderManager' => $baseDir . '/../lib/CalDAV/Reminder/NotificationProviderManager.php',
62
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AbstractProvider' => $baseDir . '/../lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php',
63
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AudioProvider' => $baseDir . '/../lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php',
64
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\EmailProvider' => $baseDir . '/../lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php',
65
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\ProviderNotAvailableException' => $baseDir . '/../lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php',
66
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\PushProvider' => $baseDir . '/../lib/CalDAV/Reminder/NotificationProvider/PushProvider.php',
67
-    'OCA\\DAV\\CalDAV\\Reminder\\NotificationTypeDoesNotExistException' => $baseDir . '/../lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php',
68
-    'OCA\\DAV\\CalDAV\\Reminder\\Notifier' => $baseDir . '/../lib/CalDAV/Reminder/Notifier.php',
69
-    'OCA\\DAV\\CalDAV\\Reminder\\ReminderService' => $baseDir . '/../lib/CalDAV/Reminder/ReminderService.php',
70
-    'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => $baseDir . '/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php',
71
-    'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => $baseDir . '/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php',
72
-    'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => $baseDir . '/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php',
73
-    'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => $baseDir . '/../lib/CalDAV/Schedule/IMipPlugin.php',
74
-    'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => $baseDir . '/../lib/CalDAV/Schedule/Plugin.php',
75
-    'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => $baseDir . '/../lib/CalDAV/Search/SearchPlugin.php',
76
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/CompFilter.php',
77
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php',
78
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php',
79
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php',
80
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/PropFilter.php',
81
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php',
82
-    'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => $baseDir . '/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php',
83
-    'OCA\\DAV\\CalDAV\\WebcalCaching\\Plugin' => $baseDir . '/../lib/CalDAV/WebcalCaching/Plugin.php',
84
-    'OCA\\DAV\\CalDAV\\WebcalCaching\\RefreshWebcalService' => $baseDir . '/../lib/CalDAV/WebcalCaching/RefreshWebcalService.php',
85
-    'OCA\\DAV\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
86
-    'OCA\\DAV\\CardDAV\\AddressBook' => $baseDir . '/../lib/CardDAV/AddressBook.php',
87
-    'OCA\\DAV\\CardDAV\\AddressBookImpl' => $baseDir . '/../lib/CardDAV/AddressBookImpl.php',
88
-    'OCA\\DAV\\CardDAV\\AddressBookRoot' => $baseDir . '/../lib/CardDAV/AddressBookRoot.php',
89
-    'OCA\\DAV\\CardDAV\\CardDavBackend' => $baseDir . '/../lib/CardDAV/CardDavBackend.php',
90
-    'OCA\\DAV\\CardDAV\\ContactsManager' => $baseDir . '/../lib/CardDAV/ContactsManager.php',
91
-    'OCA\\DAV\\CardDAV\\Converter' => $baseDir . '/../lib/CardDAV/Converter.php',
92
-    'OCA\\DAV\\CardDAV\\HasPhotoPlugin' => $baseDir . '/../lib/CardDAV/HasPhotoPlugin.php',
93
-    'OCA\\DAV\\CardDAV\\ImageExportPlugin' => $baseDir . '/../lib/CardDAV/ImageExportPlugin.php',
94
-    'OCA\\DAV\\CardDAV\\Integration\\ExternalAddressBook' => $baseDir . '/../lib/CardDAV/Integration/ExternalAddressBook.php',
95
-    'OCA\\DAV\\CardDAV\\Integration\\IAddressBookProvider' => $baseDir . '/../lib/CardDAV/Integration/IAddressBookProvider.php',
96
-    'OCA\\DAV\\CardDAV\\MultiGetExportPlugin' => $baseDir . '/../lib/CardDAV/MultiGetExportPlugin.php',
97
-    'OCA\\DAV\\CardDAV\\PhotoCache' => $baseDir . '/../lib/CardDAV/PhotoCache.php',
98
-    'OCA\\DAV\\CardDAV\\Plugin' => $baseDir . '/../lib/CardDAV/Plugin.php',
99
-    'OCA\\DAV\\CardDAV\\SyncService' => $baseDir . '/../lib/CardDAV/SyncService.php',
100
-    'OCA\\DAV\\CardDAV\\SystemAddressbook' => $baseDir . '/../lib/CardDAV/SystemAddressbook.php',
101
-    'OCA\\DAV\\CardDAV\\UserAddressBooks' => $baseDir . '/../lib/CardDAV/UserAddressBooks.php',
102
-    'OCA\\DAV\\CardDAV\\Xml\\Groups' => $baseDir . '/../lib/CardDAV/Xml/Groups.php',
103
-    'OCA\\DAV\\Command\\CreateAddressBook' => $baseDir . '/../lib/Command/CreateAddressBook.php',
104
-    'OCA\\DAV\\Command\\CreateCalendar' => $baseDir . '/../lib/Command/CreateCalendar.php',
105
-    'OCA\\DAV\\Command\\ListCalendars' => $baseDir . '/../lib/Command/ListCalendars.php',
106
-    'OCA\\DAV\\Command\\MoveCalendar' => $baseDir . '/../lib/Command/MoveCalendar.php',
107
-    'OCA\\DAV\\Command\\RemoveInvalidShares' => $baseDir . '/../lib/Command/RemoveInvalidShares.php',
108
-    'OCA\\DAV\\Command\\SendEventReminders' => $baseDir . '/../lib/Command/SendEventReminders.php',
109
-    'OCA\\DAV\\Command\\SyncBirthdayCalendar' => $baseDir . '/../lib/Command/SyncBirthdayCalendar.php',
110
-    'OCA\\DAV\\Command\\SyncSystemAddressBook' => $baseDir . '/../lib/Command/SyncSystemAddressBook.php',
111
-    'OCA\\DAV\\Comments\\CommentNode' => $baseDir . '/../lib/Comments/CommentNode.php',
112
-    'OCA\\DAV\\Comments\\CommentsPlugin' => $baseDir . '/../lib/Comments/CommentsPlugin.php',
113
-    'OCA\\DAV\\Comments\\EntityCollection' => $baseDir . '/../lib/Comments/EntityCollection.php',
114
-    'OCA\\DAV\\Comments\\EntityTypeCollection' => $baseDir . '/../lib/Comments/EntityTypeCollection.php',
115
-    'OCA\\DAV\\Comments\\RootCollection' => $baseDir . '/../lib/Comments/RootCollection.php',
116
-    'OCA\\DAV\\Connector\\LegacyDAVACL' => $baseDir . '/../lib/Connector/LegacyDAVACL.php',
117
-    'OCA\\DAV\\Connector\\PublicAuth' => $baseDir . '/../lib/Connector/PublicAuth.php',
118
-    'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => $baseDir . '/../lib/Connector/Sabre/AnonymousOptionsPlugin.php',
119
-    'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => $baseDir . '/../lib/Connector/Sabre/AppEnabledPlugin.php',
120
-    'OCA\\DAV\\Connector\\Sabre\\Auth' => $baseDir . '/../lib/Connector/Sabre/Auth.php',
121
-    'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => $baseDir . '/../lib/Connector/Sabre/BearerAuth.php',
122
-    'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => $baseDir . '/../lib/Connector/Sabre/BlockLegacyClientPlugin.php',
123
-    'OCA\\DAV\\Connector\\Sabre\\CachingTree' => $baseDir . '/../lib/Connector/Sabre/CachingTree.php',
124
-    'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => $baseDir . '/../lib/Connector/Sabre/ChecksumList.php',
125
-    'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => $baseDir . '/../lib/Connector/Sabre/CommentPropertiesPlugin.php',
126
-    'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => $baseDir . '/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php',
127
-    'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => $baseDir . '/../lib/Connector/Sabre/DavAclPlugin.php',
128
-    'OCA\\DAV\\Connector\\Sabre\\Directory' => $baseDir . '/../lib/Connector/Sabre/Directory.php',
129
-    'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => $baseDir . '/../lib/Connector/Sabre/DummyGetResponsePlugin.php',
130
-    'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => $baseDir . '/../lib/Connector/Sabre/ExceptionLoggerPlugin.php',
131
-    'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => $baseDir . '/../lib/Connector/Sabre/Exception/EntityTooLarge.php',
132
-    'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => $baseDir . '/../lib/Connector/Sabre/Exception/FileLocked.php',
133
-    'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => $baseDir . '/../lib/Connector/Sabre/Exception/Forbidden.php',
134
-    'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => $baseDir . '/../lib/Connector/Sabre/Exception/InvalidPath.php',
135
-    'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => $baseDir . '/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php',
136
-    'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => $baseDir . '/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php',
137
-    'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => $baseDir . '/../lib/Connector/Sabre/FakeLockerPlugin.php',
138
-    'OCA\\DAV\\Connector\\Sabre\\File' => $baseDir . '/../lib/Connector/Sabre/File.php',
139
-    'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => $baseDir . '/../lib/Connector/Sabre/FilesPlugin.php',
140
-    'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => $baseDir . '/../lib/Connector/Sabre/FilesReportPlugin.php',
141
-    'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => $baseDir . '/../lib/Connector/Sabre/LockPlugin.php',
142
-    'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => $baseDir . '/../lib/Connector/Sabre/MaintenancePlugin.php',
143
-    'OCA\\DAV\\Connector\\Sabre\\Node' => $baseDir . '/../lib/Connector/Sabre/Node.php',
144
-    'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => $baseDir . '/../lib/Connector/Sabre/ObjectTree.php',
145
-    'OCA\\DAV\\Connector\\Sabre\\Principal' => $baseDir . '/../lib/Connector/Sabre/Principal.php',
146
-    'OCA\\DAV\\Connector\\Sabre\\PropfindCompressionPlugin' => $baseDir . '/../lib/Connector/Sabre/PropfindCompressionPlugin.php',
147
-    'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => $baseDir . '/../lib/Connector/Sabre/QuotaPlugin.php',
148
-    'OCA\\DAV\\Connector\\Sabre\\Server' => $baseDir . '/../lib/Connector/Sabre/Server.php',
149
-    'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => $baseDir . '/../lib/Connector/Sabre/ServerFactory.php',
150
-    'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => $baseDir . '/../lib/Connector/Sabre/ShareTypeList.php',
151
-    'OCA\\DAV\\Connector\\Sabre\\ShareeList' => $baseDir . '/../lib/Connector/Sabre/ShareeList.php',
152
-    'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => $baseDir . '/../lib/Connector/Sabre/SharesPlugin.php',
153
-    'OCA\\DAV\\Connector\\Sabre\\TagList' => $baseDir . '/../lib/Connector/Sabre/TagList.php',
154
-    'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => $baseDir . '/../lib/Connector/Sabre/TagsPlugin.php',
155
-    'OCA\\DAV\\Controller\\BirthdayCalendarController' => $baseDir . '/../lib/Controller/BirthdayCalendarController.php',
156
-    'OCA\\DAV\\Controller\\DirectController' => $baseDir . '/../lib/Controller/DirectController.php',
157
-    'OCA\\DAV\\Controller\\InvitationResponseController' => $baseDir . '/../lib/Controller/InvitationResponseController.php',
158
-    'OCA\\DAV\\DAV\\CustomPropertiesBackend' => $baseDir . '/../lib/DAV/CustomPropertiesBackend.php',
159
-    'OCA\\DAV\\DAV\\GroupPrincipalBackend' => $baseDir . '/../lib/DAV/GroupPrincipalBackend.php',
160
-    'OCA\\DAV\\DAV\\PublicAuth' => $baseDir . '/../lib/DAV/PublicAuth.php',
161
-    'OCA\\DAV\\DAV\\Sharing\\Backend' => $baseDir . '/../lib/DAV/Sharing/Backend.php',
162
-    'OCA\\DAV\\DAV\\Sharing\\IShareable' => $baseDir . '/../lib/DAV/Sharing/IShareable.php',
163
-    'OCA\\DAV\\DAV\\Sharing\\Plugin' => $baseDir . '/../lib/DAV/Sharing/Plugin.php',
164
-    'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => $baseDir . '/../lib/DAV/Sharing/Xml/Invite.php',
165
-    'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => $baseDir . '/../lib/DAV/Sharing/Xml/ShareRequest.php',
166
-    'OCA\\DAV\\DAV\\SystemPrincipalBackend' => $baseDir . '/../lib/DAV/SystemPrincipalBackend.php',
167
-    'OCA\\DAV\\Db\\Direct' => $baseDir . '/../lib/Db/Direct.php',
168
-    'OCA\\DAV\\Db\\DirectMapper' => $baseDir . '/../lib/Db/DirectMapper.php',
169
-    'OCA\\DAV\\Direct\\DirectFile' => $baseDir . '/../lib/Direct/DirectFile.php',
170
-    'OCA\\DAV\\Direct\\DirectHome' => $baseDir . '/../lib/Direct/DirectHome.php',
171
-    'OCA\\DAV\\Direct\\Server' => $baseDir . '/../lib/Direct/Server.php',
172
-    'OCA\\DAV\\Direct\\ServerFactory' => $baseDir . '/../lib/Direct/ServerFactory.php',
173
-    'OCA\\DAV\\Events\\AddressBookCreatedEvent' => $baseDir . '/../lib/Events/AddressBookCreatedEvent.php',
174
-    'OCA\\DAV\\Events\\AddressBookDeletedEvent' => $baseDir . '/../lib/Events/AddressBookDeletedEvent.php',
175
-    'OCA\\DAV\\Events\\AddressBookShareUpdatedEvent' => $baseDir . '/../lib/Events/AddressBookShareUpdatedEvent.php',
176
-    'OCA\\DAV\\Events\\AddressBookUpdatedEvent' => $baseDir . '/../lib/Events/AddressBookUpdatedEvent.php',
177
-    'OCA\\DAV\\Events\\CachedCalendarObjectCreatedEvent' => $baseDir . '/../lib/Events/CachedCalendarObjectCreatedEvent.php',
178
-    'OCA\\DAV\\Events\\CachedCalendarObjectDeletedEvent' => $baseDir . '/../lib/Events/CachedCalendarObjectDeletedEvent.php',
179
-    'OCA\\DAV\\Events\\CachedCalendarObjectUpdatedEvent' => $baseDir . '/../lib/Events/CachedCalendarObjectUpdatedEvent.php',
180
-    'OCA\\DAV\\Events\\CalendarCreatedEvent' => $baseDir . '/../lib/Events/CalendarCreatedEvent.php',
181
-    'OCA\\DAV\\Events\\CalendarDeletedEvent' => $baseDir . '/../lib/Events/CalendarDeletedEvent.php',
182
-    'OCA\\DAV\\Events\\CalendarObjectCreatedEvent' => $baseDir . '/../lib/Events/CalendarObjectCreatedEvent.php',
183
-    'OCA\\DAV\\Events\\CalendarObjectDeletedEvent' => $baseDir . '/../lib/Events/CalendarObjectDeletedEvent.php',
184
-    'OCA\\DAV\\Events\\CalendarObjectUpdatedEvent' => $baseDir . '/../lib/Events/CalendarObjectUpdatedEvent.php',
185
-    'OCA\\DAV\\Events\\CalendarPublishedEvent' => $baseDir . '/../lib/Events/CalendarPublishedEvent.php',
186
-    'OCA\\DAV\\Events\\CalendarShareUpdatedEvent' => $baseDir . '/../lib/Events/CalendarShareUpdatedEvent.php',
187
-    'OCA\\DAV\\Events\\CalendarUnpublishedEvent' => $baseDir . '/../lib/Events/CalendarUnpublishedEvent.php',
188
-    'OCA\\DAV\\Events\\CalendarUpdatedEvent' => $baseDir . '/../lib/Events/CalendarUpdatedEvent.php',
189
-    'OCA\\DAV\\Events\\CardCreatedEvent' => $baseDir . '/../lib/Events/CardCreatedEvent.php',
190
-    'OCA\\DAV\\Events\\CardDeletedEvent' => $baseDir . '/../lib/Events/CardDeletedEvent.php',
191
-    'OCA\\DAV\\Events\\CardUpdatedEvent' => $baseDir . '/../lib/Events/CardUpdatedEvent.php',
192
-    'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => $baseDir . '/../lib/Events/SabrePluginAuthInitEvent.php',
193
-    'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => $baseDir . '/../lib/Events/SubscriptionCreatedEvent.php',
194
-    'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => $baseDir . '/../lib/Events/SubscriptionDeletedEvent.php',
195
-    'OCA\\DAV\\Events\\SubscriptionUpdatedEvent' => $baseDir . '/../lib/Events/SubscriptionUpdatedEvent.php',
196
-    'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => $baseDir . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
197
-    'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir . '/../lib/Files/BrowserErrorPagePlugin.php',
198
-    'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir . '/../lib/Files/FileSearchBackend.php',
199
-    'OCA\\DAV\\Files\\FilesHome' => $baseDir . '/../lib/Files/FilesHome.php',
200
-    'OCA\\DAV\\Files\\LazySearchBackend' => $baseDir . '/../lib/Files/LazySearchBackend.php',
201
-    'OCA\\DAV\\Files\\RootCollection' => $baseDir . '/../lib/Files/RootCollection.php',
202
-    'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir . '/../lib/Files/Sharing/FilesDropPlugin.php',
203
-    'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
204
-    'OCA\\DAV\\HookManager' => $baseDir . '/../lib/HookManager.php',
205
-    'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndex.php',
206
-    'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',
207
-    'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => $baseDir . '/../lib/Migration/CalDAVRemoveEmptyValue.php',
208
-    'OCA\\DAV\\Migration\\ChunkCleanup' => $baseDir . '/../lib/Migration/ChunkCleanup.php',
209
-    'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => $baseDir . '/../lib/Migration/FixBirthdayCalendarComponent.php',
210
-    'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => $baseDir . '/../lib/Migration/RefreshWebcalJobRegistrar.php',
211
-    'OCA\\DAV\\Migration\\RegenerateBirthdayCalendars' => $baseDir . '/../lib/Migration/RegenerateBirthdayCalendars.php',
212
-    'OCA\\DAV\\Migration\\RegisterBuildReminderIndexBackgroundJob' => $baseDir . '/../lib/Migration/RegisterBuildReminderIndexBackgroundJob.php',
213
-    'OCA\\DAV\\Migration\\RemoveClassifiedEventActivity' => $baseDir . '/../lib/Migration/RemoveClassifiedEventActivity.php',
214
-    'OCA\\DAV\\Migration\\RemoveOrphanEventsAndContacts' => $baseDir . '/../lib/Migration/RemoveOrphanEventsAndContacts.php',
215
-    'OCA\\DAV\\Migration\\Version1004Date20170825134824' => $baseDir . '/../lib/Migration/Version1004Date20170825134824.php',
216
-    'OCA\\DAV\\Migration\\Version1004Date20170919104507' => $baseDir . '/../lib/Migration/Version1004Date20170919104507.php',
217
-    'OCA\\DAV\\Migration\\Version1004Date20170924124212' => $baseDir . '/../lib/Migration/Version1004Date20170924124212.php',
218
-    'OCA\\DAV\\Migration\\Version1004Date20170926103422' => $baseDir . '/../lib/Migration/Version1004Date20170926103422.php',
219
-    'OCA\\DAV\\Migration\\Version1005Date20180413093149' => $baseDir . '/../lib/Migration/Version1005Date20180413093149.php',
220
-    'OCA\\DAV\\Migration\\Version1005Date20180530124431' => $baseDir . '/../lib/Migration/Version1005Date20180530124431.php',
221
-    'OCA\\DAV\\Migration\\Version1006Date20180619154313' => $baseDir . '/../lib/Migration/Version1006Date20180619154313.php',
222
-    'OCA\\DAV\\Migration\\Version1006Date20180628111625' => $baseDir . '/../lib/Migration/Version1006Date20180628111625.php',
223
-    'OCA\\DAV\\Migration\\Version1008Date20181030113700' => $baseDir . '/../lib/Migration/Version1008Date20181030113700.php',
224
-    'OCA\\DAV\\Migration\\Version1008Date20181105104826' => $baseDir . '/../lib/Migration/Version1008Date20181105104826.php',
225
-    'OCA\\DAV\\Migration\\Version1008Date20181105104833' => $baseDir . '/../lib/Migration/Version1008Date20181105104833.php',
226
-    'OCA\\DAV\\Migration\\Version1008Date20181105110300' => $baseDir . '/../lib/Migration/Version1008Date20181105110300.php',
227
-    'OCA\\DAV\\Migration\\Version1008Date20181105112049' => $baseDir . '/../lib/Migration/Version1008Date20181105112049.php',
228
-    'OCA\\DAV\\Migration\\Version1008Date20181114084440' => $baseDir . '/../lib/Migration/Version1008Date20181114084440.php',
229
-    'OCA\\DAV\\Migration\\Version1011Date20190725113607' => $baseDir . '/../lib/Migration/Version1011Date20190725113607.php',
230
-    'OCA\\DAV\\Migration\\Version1011Date20190806104428' => $baseDir . '/../lib/Migration/Version1011Date20190806104428.php',
231
-    'OCA\\DAV\\Migration\\Version1012Date20190808122342' => $baseDir . '/../lib/Migration/Version1012Date20190808122342.php',
232
-    'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
233
-    'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
234
-    'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php',
235
-    'OCA\\DAV\\Search\\ACalendarSearchProvider' => $baseDir . '/../lib/Search/ACalendarSearchProvider.php',
236
-    'OCA\\DAV\\Search\\ContactsSearchProvider' => $baseDir . '/../lib/Search/ContactsSearchProvider.php',
237
-    'OCA\\DAV\\Search\\EventsSearchProvider' => $baseDir . '/../lib/Search/EventsSearchProvider.php',
238
-    'OCA\\DAV\\Search\\TasksSearchProvider' => $baseDir . '/../lib/Search/TasksSearchProvider.php',
239
-    'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php',
240
-    'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php',
241
-    'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir . '/../lib/Storage/PublicOwnerWrapper.php',
242
-    'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir . '/../lib/SystemTag/SystemTagMappingNode.php',
243
-    'OCA\\DAV\\SystemTag\\SystemTagNode' => $baseDir . '/../lib/SystemTag/SystemTagNode.php',
244
-    'OCA\\DAV\\SystemTag\\SystemTagPlugin' => $baseDir . '/../lib/SystemTag/SystemTagPlugin.php',
245
-    'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => $baseDir . '/../lib/SystemTag/SystemTagsByIdCollection.php',
246
-    'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => $baseDir . '/../lib/SystemTag/SystemTagsObjectMappingCollection.php',
247
-    'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => $baseDir . '/../lib/SystemTag/SystemTagsObjectTypeCollection.php',
248
-    'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => $baseDir . '/../lib/SystemTag/SystemTagsRelationsCollection.php',
249
-    'OCA\\DAV\\Traits\\PrincipalProxyTrait' => $baseDir . '/../lib/Traits/PrincipalProxyTrait.php',
250
-    'OCA\\DAV\\Upload\\AssemblyStream' => $baseDir . '/../lib/Upload/AssemblyStream.php',
251
-    'OCA\\DAV\\Upload\\ChunkingPlugin' => $baseDir . '/../lib/Upload/ChunkingPlugin.php',
252
-    'OCA\\DAV\\Upload\\CleanupService' => $baseDir . '/../lib/Upload/CleanupService.php',
253
-    'OCA\\DAV\\Upload\\FutureFile' => $baseDir . '/../lib/Upload/FutureFile.php',
254
-    'OCA\\DAV\\Upload\\RootCollection' => $baseDir . '/../lib/Upload/RootCollection.php',
255
-    'OCA\\DAV\\Upload\\UploadFile' => $baseDir . '/../lib/Upload/UploadFile.php',
256
-    'OCA\\DAV\\Upload\\UploadFolder' => $baseDir . '/../lib/Upload/UploadFolder.php',
257
-    'OCA\\DAV\\Upload\\UploadHome' => $baseDir . '/../lib/Upload/UploadHome.php',
9
+    'OCA\\DAV\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
10
+    'OCA\\DAV\\AppInfo\\PluginManager' => $baseDir.'/../lib/AppInfo/PluginManager.php',
11
+    'OCA\\DAV\\Avatars\\AvatarHome' => $baseDir.'/../lib/Avatars/AvatarHome.php',
12
+    'OCA\\DAV\\Avatars\\AvatarNode' => $baseDir.'/../lib/Avatars/AvatarNode.php',
13
+    'OCA\\DAV\\Avatars\\RootCollection' => $baseDir.'/../lib/Avatars/RootCollection.php',
14
+    'OCA\\DAV\\BackgroundJob\\BuildReminderIndexBackgroundJob' => $baseDir.'/../lib/BackgroundJob/BuildReminderIndexBackgroundJob.php',
15
+    'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => $baseDir.'/../lib/BackgroundJob/CleanupDirectLinksJob.php',
16
+    'OCA\\DAV\\BackgroundJob\\CleanupInvitationTokenJob' => $baseDir.'/../lib/BackgroundJob/CleanupInvitationTokenJob.php',
17
+    'OCA\\DAV\\BackgroundJob\\EventReminderJob' => $baseDir.'/../lib/BackgroundJob/EventReminderJob.php',
18
+    'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => $baseDir.'/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php',
19
+    'OCA\\DAV\\BackgroundJob\\RefreshWebcalJob' => $baseDir.'/../lib/BackgroundJob/RefreshWebcalJob.php',
20
+    'OCA\\DAV\\BackgroundJob\\RegisterRegenerateBirthdayCalendars' => $baseDir.'/../lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php',
21
+    'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => $baseDir.'/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php',
22
+    'OCA\\DAV\\BackgroundJob\\UploadCleanup' => $baseDir.'/../lib/BackgroundJob/UploadCleanup.php',
23
+    'OCA\\DAV\\CalDAV\\Activity\\Backend' => $baseDir.'/../lib/CalDAV/Activity/Backend.php',
24
+    'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => $baseDir.'/../lib/CalDAV/Activity/Filter/Calendar.php',
25
+    'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => $baseDir.'/../lib/CalDAV/Activity/Filter/Todo.php',
26
+    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => $baseDir.'/../lib/CalDAV/Activity/Provider/Base.php',
27
+    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => $baseDir.'/../lib/CalDAV/Activity/Provider/Calendar.php',
28
+    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => $baseDir.'/../lib/CalDAV/Activity/Provider/Event.php',
29
+    'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => $baseDir.'/../lib/CalDAV/Activity/Provider/Todo.php',
30
+    'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => $baseDir.'/../lib/CalDAV/Activity/Setting/Calendar.php',
31
+    'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => $baseDir.'/../lib/CalDAV/Activity/Setting/Event.php',
32
+    'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => $baseDir.'/../lib/CalDAV/Activity/Setting/Todo.php',
33
+    'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => $baseDir.'/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php',
34
+    'OCA\\DAV\\CalDAV\\BirthdayService' => $baseDir.'/../lib/CalDAV/BirthdayService.php',
35
+    'OCA\\DAV\\CalDAV\\CachedSubscription' => $baseDir.'/../lib/CalDAV/CachedSubscription.php',
36
+    'OCA\\DAV\\CalDAV\\CachedSubscriptionObject' => $baseDir.'/../lib/CalDAV/CachedSubscriptionObject.php',
37
+    'OCA\\DAV\\CalDAV\\CalDavBackend' => $baseDir.'/../lib/CalDAV/CalDavBackend.php',
38
+    'OCA\\DAV\\CalDAV\\Calendar' => $baseDir.'/../lib/CalDAV/Calendar.php',
39
+    'OCA\\DAV\\CalDAV\\CalendarHome' => $baseDir.'/../lib/CalDAV/CalendarHome.php',
40
+    'OCA\\DAV\\CalDAV\\CalendarImpl' => $baseDir.'/../lib/CalDAV/CalendarImpl.php',
41
+    'OCA\\DAV\\CalDAV\\CalendarManager' => $baseDir.'/../lib/CalDAV/CalendarManager.php',
42
+    'OCA\\DAV\\CalDAV\\CalendarObject' => $baseDir.'/../lib/CalDAV/CalendarObject.php',
43
+    'OCA\\DAV\\CalDAV\\CalendarRoot' => $baseDir.'/../lib/CalDAV/CalendarRoot.php',
44
+    'OCA\\DAV\\CalDAV\\ICSExportPlugin\\ICSExportPlugin' => $baseDir.'/../lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php',
45
+    'OCA\\DAV\\CalDAV\\Integration\\ExternalCalendar' => $baseDir.'/../lib/CalDAV/Integration/ExternalCalendar.php',
46
+    'OCA\\DAV\\CalDAV\\Integration\\ICalendarProvider' => $baseDir.'/../lib/CalDAV/Integration/ICalendarProvider.php',
47
+    'OCA\\DAV\\CalDAV\\InvitationResponse\\InvitationResponseServer' => $baseDir.'/../lib/CalDAV/InvitationResponse/InvitationResponseServer.php',
48
+    'OCA\\DAV\\CalDAV\\Outbox' => $baseDir.'/../lib/CalDAV/Outbox.php',
49
+    'OCA\\DAV\\CalDAV\\Plugin' => $baseDir.'/../lib/CalDAV/Plugin.php',
50
+    'OCA\\DAV\\CalDAV\\Principal\\Collection' => $baseDir.'/../lib/CalDAV/Principal/Collection.php',
51
+    'OCA\\DAV\\CalDAV\\Principal\\User' => $baseDir.'/../lib/CalDAV/Principal/User.php',
52
+    'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => $baseDir.'/../lib/CalDAV/Proxy/Proxy.php',
53
+    'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => $baseDir.'/../lib/CalDAV/Proxy/ProxyMapper.php',
54
+    'OCA\\DAV\\CalDAV\\PublicCalendar' => $baseDir.'/../lib/CalDAV/PublicCalendar.php',
55
+    'OCA\\DAV\\CalDAV\\PublicCalendarObject' => $baseDir.'/../lib/CalDAV/PublicCalendarObject.php',
56
+    'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => $baseDir.'/../lib/CalDAV/PublicCalendarRoot.php',
57
+    'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => $baseDir.'/../lib/CalDAV/Publishing/PublishPlugin.php',
58
+    'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => $baseDir.'/../lib/CalDAV/Publishing/Xml/Publisher.php',
59
+    'OCA\\DAV\\CalDAV\\Reminder\\Backend' => $baseDir.'/../lib/CalDAV/Reminder/Backend.php',
60
+    'OCA\\DAV\\CalDAV\\Reminder\\INotificationProvider' => $baseDir.'/../lib/CalDAV/Reminder/INotificationProvider.php',
61
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProviderManager' => $baseDir.'/../lib/CalDAV/Reminder/NotificationProviderManager.php',
62
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AbstractProvider' => $baseDir.'/../lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php',
63
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\AudioProvider' => $baseDir.'/../lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php',
64
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\EmailProvider' => $baseDir.'/../lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php',
65
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\ProviderNotAvailableException' => $baseDir.'/../lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php',
66
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationProvider\\PushProvider' => $baseDir.'/../lib/CalDAV/Reminder/NotificationProvider/PushProvider.php',
67
+    'OCA\\DAV\\CalDAV\\Reminder\\NotificationTypeDoesNotExistException' => $baseDir.'/../lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php',
68
+    'OCA\\DAV\\CalDAV\\Reminder\\Notifier' => $baseDir.'/../lib/CalDAV/Reminder/Notifier.php',
69
+    'OCA\\DAV\\CalDAV\\Reminder\\ReminderService' => $baseDir.'/../lib/CalDAV/Reminder/ReminderService.php',
70
+    'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => $baseDir.'/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php',
71
+    'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => $baseDir.'/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php',
72
+    'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => $baseDir.'/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php',
73
+    'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => $baseDir.'/../lib/CalDAV/Schedule/IMipPlugin.php',
74
+    'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => $baseDir.'/../lib/CalDAV/Schedule/Plugin.php',
75
+    'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => $baseDir.'/../lib/CalDAV/Search/SearchPlugin.php',
76
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/CompFilter.php',
77
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php',
78
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php',
79
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php',
80
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/PropFilter.php',
81
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php',
82
+    'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => $baseDir.'/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php',
83
+    'OCA\\DAV\\CalDAV\\WebcalCaching\\Plugin' => $baseDir.'/../lib/CalDAV/WebcalCaching/Plugin.php',
84
+    'OCA\\DAV\\CalDAV\\WebcalCaching\\RefreshWebcalService' => $baseDir.'/../lib/CalDAV/WebcalCaching/RefreshWebcalService.php',
85
+    'OCA\\DAV\\Capabilities' => $baseDir.'/../lib/Capabilities.php',
86
+    'OCA\\DAV\\CardDAV\\AddressBook' => $baseDir.'/../lib/CardDAV/AddressBook.php',
87
+    'OCA\\DAV\\CardDAV\\AddressBookImpl' => $baseDir.'/../lib/CardDAV/AddressBookImpl.php',
88
+    'OCA\\DAV\\CardDAV\\AddressBookRoot' => $baseDir.'/../lib/CardDAV/AddressBookRoot.php',
89
+    'OCA\\DAV\\CardDAV\\CardDavBackend' => $baseDir.'/../lib/CardDAV/CardDavBackend.php',
90
+    'OCA\\DAV\\CardDAV\\ContactsManager' => $baseDir.'/../lib/CardDAV/ContactsManager.php',
91
+    'OCA\\DAV\\CardDAV\\Converter' => $baseDir.'/../lib/CardDAV/Converter.php',
92
+    'OCA\\DAV\\CardDAV\\HasPhotoPlugin' => $baseDir.'/../lib/CardDAV/HasPhotoPlugin.php',
93
+    'OCA\\DAV\\CardDAV\\ImageExportPlugin' => $baseDir.'/../lib/CardDAV/ImageExportPlugin.php',
94
+    'OCA\\DAV\\CardDAV\\Integration\\ExternalAddressBook' => $baseDir.'/../lib/CardDAV/Integration/ExternalAddressBook.php',
95
+    'OCA\\DAV\\CardDAV\\Integration\\IAddressBookProvider' => $baseDir.'/../lib/CardDAV/Integration/IAddressBookProvider.php',
96
+    'OCA\\DAV\\CardDAV\\MultiGetExportPlugin' => $baseDir.'/../lib/CardDAV/MultiGetExportPlugin.php',
97
+    'OCA\\DAV\\CardDAV\\PhotoCache' => $baseDir.'/../lib/CardDAV/PhotoCache.php',
98
+    'OCA\\DAV\\CardDAV\\Plugin' => $baseDir.'/../lib/CardDAV/Plugin.php',
99
+    'OCA\\DAV\\CardDAV\\SyncService' => $baseDir.'/../lib/CardDAV/SyncService.php',
100
+    'OCA\\DAV\\CardDAV\\SystemAddressbook' => $baseDir.'/../lib/CardDAV/SystemAddressbook.php',
101
+    'OCA\\DAV\\CardDAV\\UserAddressBooks' => $baseDir.'/../lib/CardDAV/UserAddressBooks.php',
102
+    'OCA\\DAV\\CardDAV\\Xml\\Groups' => $baseDir.'/../lib/CardDAV/Xml/Groups.php',
103
+    'OCA\\DAV\\Command\\CreateAddressBook' => $baseDir.'/../lib/Command/CreateAddressBook.php',
104
+    'OCA\\DAV\\Command\\CreateCalendar' => $baseDir.'/../lib/Command/CreateCalendar.php',
105
+    'OCA\\DAV\\Command\\ListCalendars' => $baseDir.'/../lib/Command/ListCalendars.php',
106
+    'OCA\\DAV\\Command\\MoveCalendar' => $baseDir.'/../lib/Command/MoveCalendar.php',
107
+    'OCA\\DAV\\Command\\RemoveInvalidShares' => $baseDir.'/../lib/Command/RemoveInvalidShares.php',
108
+    'OCA\\DAV\\Command\\SendEventReminders' => $baseDir.'/../lib/Command/SendEventReminders.php',
109
+    'OCA\\DAV\\Command\\SyncBirthdayCalendar' => $baseDir.'/../lib/Command/SyncBirthdayCalendar.php',
110
+    'OCA\\DAV\\Command\\SyncSystemAddressBook' => $baseDir.'/../lib/Command/SyncSystemAddressBook.php',
111
+    'OCA\\DAV\\Comments\\CommentNode' => $baseDir.'/../lib/Comments/CommentNode.php',
112
+    'OCA\\DAV\\Comments\\CommentsPlugin' => $baseDir.'/../lib/Comments/CommentsPlugin.php',
113
+    'OCA\\DAV\\Comments\\EntityCollection' => $baseDir.'/../lib/Comments/EntityCollection.php',
114
+    'OCA\\DAV\\Comments\\EntityTypeCollection' => $baseDir.'/../lib/Comments/EntityTypeCollection.php',
115
+    'OCA\\DAV\\Comments\\RootCollection' => $baseDir.'/../lib/Comments/RootCollection.php',
116
+    'OCA\\DAV\\Connector\\LegacyDAVACL' => $baseDir.'/../lib/Connector/LegacyDAVACL.php',
117
+    'OCA\\DAV\\Connector\\PublicAuth' => $baseDir.'/../lib/Connector/PublicAuth.php',
118
+    'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => $baseDir.'/../lib/Connector/Sabre/AnonymousOptionsPlugin.php',
119
+    'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => $baseDir.'/../lib/Connector/Sabre/AppEnabledPlugin.php',
120
+    'OCA\\DAV\\Connector\\Sabre\\Auth' => $baseDir.'/../lib/Connector/Sabre/Auth.php',
121
+    'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => $baseDir.'/../lib/Connector/Sabre/BearerAuth.php',
122
+    'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => $baseDir.'/../lib/Connector/Sabre/BlockLegacyClientPlugin.php',
123
+    'OCA\\DAV\\Connector\\Sabre\\CachingTree' => $baseDir.'/../lib/Connector/Sabre/CachingTree.php',
124
+    'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => $baseDir.'/../lib/Connector/Sabre/ChecksumList.php',
125
+    'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => $baseDir.'/../lib/Connector/Sabre/CommentPropertiesPlugin.php',
126
+    'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => $baseDir.'/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php',
127
+    'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => $baseDir.'/../lib/Connector/Sabre/DavAclPlugin.php',
128
+    'OCA\\DAV\\Connector\\Sabre\\Directory' => $baseDir.'/../lib/Connector/Sabre/Directory.php',
129
+    'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => $baseDir.'/../lib/Connector/Sabre/DummyGetResponsePlugin.php',
130
+    'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => $baseDir.'/../lib/Connector/Sabre/ExceptionLoggerPlugin.php',
131
+    'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => $baseDir.'/../lib/Connector/Sabre/Exception/EntityTooLarge.php',
132
+    'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => $baseDir.'/../lib/Connector/Sabre/Exception/FileLocked.php',
133
+    'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => $baseDir.'/../lib/Connector/Sabre/Exception/Forbidden.php',
134
+    'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => $baseDir.'/../lib/Connector/Sabre/Exception/InvalidPath.php',
135
+    'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => $baseDir.'/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php',
136
+    'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => $baseDir.'/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php',
137
+    'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => $baseDir.'/../lib/Connector/Sabre/FakeLockerPlugin.php',
138
+    'OCA\\DAV\\Connector\\Sabre\\File' => $baseDir.'/../lib/Connector/Sabre/File.php',
139
+    'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => $baseDir.'/../lib/Connector/Sabre/FilesPlugin.php',
140
+    'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => $baseDir.'/../lib/Connector/Sabre/FilesReportPlugin.php',
141
+    'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => $baseDir.'/../lib/Connector/Sabre/LockPlugin.php',
142
+    'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => $baseDir.'/../lib/Connector/Sabre/MaintenancePlugin.php',
143
+    'OCA\\DAV\\Connector\\Sabre\\Node' => $baseDir.'/../lib/Connector/Sabre/Node.php',
144
+    'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => $baseDir.'/../lib/Connector/Sabre/ObjectTree.php',
145
+    'OCA\\DAV\\Connector\\Sabre\\Principal' => $baseDir.'/../lib/Connector/Sabre/Principal.php',
146
+    'OCA\\DAV\\Connector\\Sabre\\PropfindCompressionPlugin' => $baseDir.'/../lib/Connector/Sabre/PropfindCompressionPlugin.php',
147
+    'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => $baseDir.'/../lib/Connector/Sabre/QuotaPlugin.php',
148
+    'OCA\\DAV\\Connector\\Sabre\\Server' => $baseDir.'/../lib/Connector/Sabre/Server.php',
149
+    'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => $baseDir.'/../lib/Connector/Sabre/ServerFactory.php',
150
+    'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => $baseDir.'/../lib/Connector/Sabre/ShareTypeList.php',
151
+    'OCA\\DAV\\Connector\\Sabre\\ShareeList' => $baseDir.'/../lib/Connector/Sabre/ShareeList.php',
152
+    'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => $baseDir.'/../lib/Connector/Sabre/SharesPlugin.php',
153
+    'OCA\\DAV\\Connector\\Sabre\\TagList' => $baseDir.'/../lib/Connector/Sabre/TagList.php',
154
+    'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => $baseDir.'/../lib/Connector/Sabre/TagsPlugin.php',
155
+    'OCA\\DAV\\Controller\\BirthdayCalendarController' => $baseDir.'/../lib/Controller/BirthdayCalendarController.php',
156
+    'OCA\\DAV\\Controller\\DirectController' => $baseDir.'/../lib/Controller/DirectController.php',
157
+    'OCA\\DAV\\Controller\\InvitationResponseController' => $baseDir.'/../lib/Controller/InvitationResponseController.php',
158
+    'OCA\\DAV\\DAV\\CustomPropertiesBackend' => $baseDir.'/../lib/DAV/CustomPropertiesBackend.php',
159
+    'OCA\\DAV\\DAV\\GroupPrincipalBackend' => $baseDir.'/../lib/DAV/GroupPrincipalBackend.php',
160
+    'OCA\\DAV\\DAV\\PublicAuth' => $baseDir.'/../lib/DAV/PublicAuth.php',
161
+    'OCA\\DAV\\DAV\\Sharing\\Backend' => $baseDir.'/../lib/DAV/Sharing/Backend.php',
162
+    'OCA\\DAV\\DAV\\Sharing\\IShareable' => $baseDir.'/../lib/DAV/Sharing/IShareable.php',
163
+    'OCA\\DAV\\DAV\\Sharing\\Plugin' => $baseDir.'/../lib/DAV/Sharing/Plugin.php',
164
+    'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => $baseDir.'/../lib/DAV/Sharing/Xml/Invite.php',
165
+    'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => $baseDir.'/../lib/DAV/Sharing/Xml/ShareRequest.php',
166
+    'OCA\\DAV\\DAV\\SystemPrincipalBackend' => $baseDir.'/../lib/DAV/SystemPrincipalBackend.php',
167
+    'OCA\\DAV\\Db\\Direct' => $baseDir.'/../lib/Db/Direct.php',
168
+    'OCA\\DAV\\Db\\DirectMapper' => $baseDir.'/../lib/Db/DirectMapper.php',
169
+    'OCA\\DAV\\Direct\\DirectFile' => $baseDir.'/../lib/Direct/DirectFile.php',
170
+    'OCA\\DAV\\Direct\\DirectHome' => $baseDir.'/../lib/Direct/DirectHome.php',
171
+    'OCA\\DAV\\Direct\\Server' => $baseDir.'/../lib/Direct/Server.php',
172
+    'OCA\\DAV\\Direct\\ServerFactory' => $baseDir.'/../lib/Direct/ServerFactory.php',
173
+    'OCA\\DAV\\Events\\AddressBookCreatedEvent' => $baseDir.'/../lib/Events/AddressBookCreatedEvent.php',
174
+    'OCA\\DAV\\Events\\AddressBookDeletedEvent' => $baseDir.'/../lib/Events/AddressBookDeletedEvent.php',
175
+    'OCA\\DAV\\Events\\AddressBookShareUpdatedEvent' => $baseDir.'/../lib/Events/AddressBookShareUpdatedEvent.php',
176
+    'OCA\\DAV\\Events\\AddressBookUpdatedEvent' => $baseDir.'/../lib/Events/AddressBookUpdatedEvent.php',
177
+    'OCA\\DAV\\Events\\CachedCalendarObjectCreatedEvent' => $baseDir.'/../lib/Events/CachedCalendarObjectCreatedEvent.php',
178
+    'OCA\\DAV\\Events\\CachedCalendarObjectDeletedEvent' => $baseDir.'/../lib/Events/CachedCalendarObjectDeletedEvent.php',
179
+    'OCA\\DAV\\Events\\CachedCalendarObjectUpdatedEvent' => $baseDir.'/../lib/Events/CachedCalendarObjectUpdatedEvent.php',
180
+    'OCA\\DAV\\Events\\CalendarCreatedEvent' => $baseDir.'/../lib/Events/CalendarCreatedEvent.php',
181
+    'OCA\\DAV\\Events\\CalendarDeletedEvent' => $baseDir.'/../lib/Events/CalendarDeletedEvent.php',
182
+    'OCA\\DAV\\Events\\CalendarObjectCreatedEvent' => $baseDir.'/../lib/Events/CalendarObjectCreatedEvent.php',
183
+    'OCA\\DAV\\Events\\CalendarObjectDeletedEvent' => $baseDir.'/../lib/Events/CalendarObjectDeletedEvent.php',
184
+    'OCA\\DAV\\Events\\CalendarObjectUpdatedEvent' => $baseDir.'/../lib/Events/CalendarObjectUpdatedEvent.php',
185
+    'OCA\\DAV\\Events\\CalendarPublishedEvent' => $baseDir.'/../lib/Events/CalendarPublishedEvent.php',
186
+    'OCA\\DAV\\Events\\CalendarShareUpdatedEvent' => $baseDir.'/../lib/Events/CalendarShareUpdatedEvent.php',
187
+    'OCA\\DAV\\Events\\CalendarUnpublishedEvent' => $baseDir.'/../lib/Events/CalendarUnpublishedEvent.php',
188
+    'OCA\\DAV\\Events\\CalendarUpdatedEvent' => $baseDir.'/../lib/Events/CalendarUpdatedEvent.php',
189
+    'OCA\\DAV\\Events\\CardCreatedEvent' => $baseDir.'/../lib/Events/CardCreatedEvent.php',
190
+    'OCA\\DAV\\Events\\CardDeletedEvent' => $baseDir.'/../lib/Events/CardDeletedEvent.php',
191
+    'OCA\\DAV\\Events\\CardUpdatedEvent' => $baseDir.'/../lib/Events/CardUpdatedEvent.php',
192
+    'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => $baseDir.'/../lib/Events/SabrePluginAuthInitEvent.php',
193
+    'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => $baseDir.'/../lib/Events/SubscriptionCreatedEvent.php',
194
+    'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => $baseDir.'/../lib/Events/SubscriptionDeletedEvent.php',
195
+    'OCA\\DAV\\Events\\SubscriptionUpdatedEvent' => $baseDir.'/../lib/Events/SubscriptionUpdatedEvent.php',
196
+    'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => $baseDir.'/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
197
+    'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir.'/../lib/Files/BrowserErrorPagePlugin.php',
198
+    'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir.'/../lib/Files/FileSearchBackend.php',
199
+    'OCA\\DAV\\Files\\FilesHome' => $baseDir.'/../lib/Files/FilesHome.php',
200
+    'OCA\\DAV\\Files\\LazySearchBackend' => $baseDir.'/../lib/Files/LazySearchBackend.php',
201
+    'OCA\\DAV\\Files\\RootCollection' => $baseDir.'/../lib/Files/RootCollection.php',
202
+    'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir.'/../lib/Files/Sharing/FilesDropPlugin.php',
203
+    'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir.'/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
204
+    'OCA\\DAV\\HookManager' => $baseDir.'/../lib/HookManager.php',
205
+    'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir.'/../lib/Migration/BuildCalendarSearchIndex.php',
206
+    'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir.'/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',
207
+    'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => $baseDir.'/../lib/Migration/CalDAVRemoveEmptyValue.php',
208
+    'OCA\\DAV\\Migration\\ChunkCleanup' => $baseDir.'/../lib/Migration/ChunkCleanup.php',
209
+    'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => $baseDir.'/../lib/Migration/FixBirthdayCalendarComponent.php',
210
+    'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => $baseDir.'/../lib/Migration/RefreshWebcalJobRegistrar.php',
211
+    'OCA\\DAV\\Migration\\RegenerateBirthdayCalendars' => $baseDir.'/../lib/Migration/RegenerateBirthdayCalendars.php',
212
+    'OCA\\DAV\\Migration\\RegisterBuildReminderIndexBackgroundJob' => $baseDir.'/../lib/Migration/RegisterBuildReminderIndexBackgroundJob.php',
213
+    'OCA\\DAV\\Migration\\RemoveClassifiedEventActivity' => $baseDir.'/../lib/Migration/RemoveClassifiedEventActivity.php',
214
+    'OCA\\DAV\\Migration\\RemoveOrphanEventsAndContacts' => $baseDir.'/../lib/Migration/RemoveOrphanEventsAndContacts.php',
215
+    'OCA\\DAV\\Migration\\Version1004Date20170825134824' => $baseDir.'/../lib/Migration/Version1004Date20170825134824.php',
216
+    'OCA\\DAV\\Migration\\Version1004Date20170919104507' => $baseDir.'/../lib/Migration/Version1004Date20170919104507.php',
217
+    'OCA\\DAV\\Migration\\Version1004Date20170924124212' => $baseDir.'/../lib/Migration/Version1004Date20170924124212.php',
218
+    'OCA\\DAV\\Migration\\Version1004Date20170926103422' => $baseDir.'/../lib/Migration/Version1004Date20170926103422.php',
219
+    'OCA\\DAV\\Migration\\Version1005Date20180413093149' => $baseDir.'/../lib/Migration/Version1005Date20180413093149.php',
220
+    'OCA\\DAV\\Migration\\Version1005Date20180530124431' => $baseDir.'/../lib/Migration/Version1005Date20180530124431.php',
221
+    'OCA\\DAV\\Migration\\Version1006Date20180619154313' => $baseDir.'/../lib/Migration/Version1006Date20180619154313.php',
222
+    'OCA\\DAV\\Migration\\Version1006Date20180628111625' => $baseDir.'/../lib/Migration/Version1006Date20180628111625.php',
223
+    'OCA\\DAV\\Migration\\Version1008Date20181030113700' => $baseDir.'/../lib/Migration/Version1008Date20181030113700.php',
224
+    'OCA\\DAV\\Migration\\Version1008Date20181105104826' => $baseDir.'/../lib/Migration/Version1008Date20181105104826.php',
225
+    'OCA\\DAV\\Migration\\Version1008Date20181105104833' => $baseDir.'/../lib/Migration/Version1008Date20181105104833.php',
226
+    'OCA\\DAV\\Migration\\Version1008Date20181105110300' => $baseDir.'/../lib/Migration/Version1008Date20181105110300.php',
227
+    'OCA\\DAV\\Migration\\Version1008Date20181105112049' => $baseDir.'/../lib/Migration/Version1008Date20181105112049.php',
228
+    'OCA\\DAV\\Migration\\Version1008Date20181114084440' => $baseDir.'/../lib/Migration/Version1008Date20181114084440.php',
229
+    'OCA\\DAV\\Migration\\Version1011Date20190725113607' => $baseDir.'/../lib/Migration/Version1011Date20190725113607.php',
230
+    'OCA\\DAV\\Migration\\Version1011Date20190806104428' => $baseDir.'/../lib/Migration/Version1011Date20190806104428.php',
231
+    'OCA\\DAV\\Migration\\Version1012Date20190808122342' => $baseDir.'/../lib/Migration/Version1012Date20190808122342.php',
232
+    'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir.'/../lib/Provisioning/Apple/AppleProvisioningNode.php',
233
+    'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir.'/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
234
+    'OCA\\DAV\\RootCollection' => $baseDir.'/../lib/RootCollection.php',
235
+    'OCA\\DAV\\Search\\ACalendarSearchProvider' => $baseDir.'/../lib/Search/ACalendarSearchProvider.php',
236
+    'OCA\\DAV\\Search\\ContactsSearchProvider' => $baseDir.'/../lib/Search/ContactsSearchProvider.php',
237
+    'OCA\\DAV\\Search\\EventsSearchProvider' => $baseDir.'/../lib/Search/EventsSearchProvider.php',
238
+    'OCA\\DAV\\Search\\TasksSearchProvider' => $baseDir.'/../lib/Search/TasksSearchProvider.php',
239
+    'OCA\\DAV\\Server' => $baseDir.'/../lib/Server.php',
240
+    'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir.'/../lib/Settings/CalDAVSettings.php',
241
+    'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir.'/../lib/Storage/PublicOwnerWrapper.php',
242
+    'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir.'/../lib/SystemTag/SystemTagMappingNode.php',
243
+    'OCA\\DAV\\SystemTag\\SystemTagNode' => $baseDir.'/../lib/SystemTag/SystemTagNode.php',
244
+    'OCA\\DAV\\SystemTag\\SystemTagPlugin' => $baseDir.'/../lib/SystemTag/SystemTagPlugin.php',
245
+    'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => $baseDir.'/../lib/SystemTag/SystemTagsByIdCollection.php',
246
+    'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => $baseDir.'/../lib/SystemTag/SystemTagsObjectMappingCollection.php',
247
+    'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => $baseDir.'/../lib/SystemTag/SystemTagsObjectTypeCollection.php',
248
+    'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => $baseDir.'/../lib/SystemTag/SystemTagsRelationsCollection.php',
249
+    'OCA\\DAV\\Traits\\PrincipalProxyTrait' => $baseDir.'/../lib/Traits/PrincipalProxyTrait.php',
250
+    'OCA\\DAV\\Upload\\AssemblyStream' => $baseDir.'/../lib/Upload/AssemblyStream.php',
251
+    'OCA\\DAV\\Upload\\ChunkingPlugin' => $baseDir.'/../lib/Upload/ChunkingPlugin.php',
252
+    'OCA\\DAV\\Upload\\CleanupService' => $baseDir.'/../lib/Upload/CleanupService.php',
253
+    'OCA\\DAV\\Upload\\FutureFile' => $baseDir.'/../lib/Upload/FutureFile.php',
254
+    'OCA\\DAV\\Upload\\RootCollection' => $baseDir.'/../lib/Upload/RootCollection.php',
255
+    'OCA\\DAV\\Upload\\UploadFile' => $baseDir.'/../lib/Upload/UploadFile.php',
256
+    'OCA\\DAV\\Upload\\UploadFolder' => $baseDir.'/../lib/Upload/UploadFolder.php',
257
+    'OCA\\DAV\\Upload\\UploadHome' => $baseDir.'/../lib/Upload/UploadHome.php',
258 258
 );
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/carddav.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 use Sabre\CardDAV\Plugin;
40 40
 
41 41
 $authBackend = new Auth(
42
-	\OC::$server->getSession(),
43
-	\OC::$server->getUserSession(),
44
-	\OC::$server->getRequest(),
45
-	\OC::$server->getTwoFactorAuthManager(),
46
-	\OC::$server->getBruteForceThrottler(),
47
-	'principals/'
42
+    \OC::$server->getSession(),
43
+    \OC::$server->getUserSession(),
44
+    \OC::$server->getRequest(),
45
+    \OC::$server->getTwoFactorAuthManager(),
46
+    \OC::$server->getBruteForceThrottler(),
47
+    'principals/'
48 48
 );
49 49
 $principalBackend = new Principal(
50
-	\OC::$server->getUserManager(),
51
-	\OC::$server->getGroupManager(),
52
-	\OC::$server->getShareManager(),
53
-	\OC::$server->getUserSession(),
54
-	\OC::$server->getAppManager(),
55
-	\OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class),
56
-	\OC::$server->getConfig(),
57
-	'principals/'
50
+    \OC::$server->getUserManager(),
51
+    \OC::$server->getGroupManager(),
52
+    \OC::$server->getShareManager(),
53
+    \OC::$server->getUserSession(),
54
+    \OC::$server->getAppManager(),
55
+    \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class),
56
+    \OC::$server->getConfig(),
57
+    'principals/'
58 58
 );
59 59
 $db = \OC::$server->getDatabaseConnection();
60 60
 $cardDavBackend = new CardDavBackend($db, $principalBackend, \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->getEventDispatcher());
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 $addressBookRoot->disableListing = !$debugging; // Disable listing
71 71
 
72 72
 $nodes = [
73
-	$principalCollection,
74
-	$addressBookRoot,
73
+    $principalCollection,
74
+    $addressBookRoot,
75 75
 ];
76 76
 
77 77
 // Fire up server
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 
87 87
 $server->addPlugin(new LegacyDAVACL());
88 88
 if ($debugging) {
89
-	$server->addPlugin(new Sabre\DAV\Browser\Plugin());
89
+    $server->addPlugin(new Sabre\DAV\Browser\Plugin());
90 90
 }
91 91
 
92 92
 $server->addPlugin(new \Sabre\DAV\Sync\Plugin());
93 93
 $server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
94 94
 $server->addPlugin(new \OCA\DAV\CardDAV\ImageExportPlugin(new \OCA\DAV\CardDAV\PhotoCache(
95
-	\OC::$server->getAppDataDir('dav-photocache'),
96
-	\OC::$server->getLogger()
95
+    \OC::$server->getAppDataDir('dav-photocache'),
96
+    \OC::$server->getLogger()
97 97
 )));
98 98
 $server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->getLogger()));
99 99
 
Please login to merge, or discard this patch.