Completed
Pull Request — master (#4098)
by Georg
14:24
created
apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
 				case '{DAV:}prop':
108 108
 					$newProps['properties'] = array_keys($elem['value']);
109 109
 					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
110
+				case '{'.SearchPlugin::NS_Nextcloud.'}filter':
111 111
 					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
112
+						if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') {
113 113
 							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114 114
 								$newProps['filters']['comps'] = [];
115 115
 							}
116 116
 							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
117
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') {
118 118
 							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119 119
 								$newProps['filters']['props'] = [];
120 120
 							}
121 121
 							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
122
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') {
123 123
 							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124 124
 								$newProps['filters']['params'] = [];
125 125
 							}
126 126
 							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
127
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') {
128 128
 							$newProps['filters']['search-term'] = $subElem['value'];
129 129
 						}
130 130
 					}
131 131
 					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
132
+				case '{'.SearchPlugin::NS_Nextcloud.'}limit':
133 133
 					$newProps['limit'] = $elem['value'];
134 134
 					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
135
+				case '{'.SearchPlugin::NS_Nextcloud.'}offset':
136 136
 					$newProps['offset'] = $elem['value'];
137 137
 					break;
138 138
 
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 
142 142
 		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
143
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request');
144 144
 		}
145 145
 
146 146
 		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147 147
 		$noCompsDefined = empty($newProps['filters']['comps']);
148 148
 		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
149
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter');
150 150
 		}
151 151
 
152 152
 		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
153
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request');
154 154
 		}
155 155
 
156 156
 		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
157
+			throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request');
158 158
 		}
159 159
 
160 160
 
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/CalDavBackend.php 1 patch
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
197 197
 		}
198 198
 
199
-		return (int)$query->execute()->fetchColumn();
199
+		return (int) $query->execute()->fetchColumn();
200 200
 	}
201 201
 
202 202
 	/**
@@ -243,25 +243,25 @@  discard block
 block discarded – undo
243 243
 		$stmt = $query->execute();
244 244
 
245 245
 		$calendars = [];
246
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
246
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
247 247
 
248 248
 			$components = [];
249 249
 			if ($row['components']) {
250
-				$components = explode(',',$row['components']);
250
+				$components = explode(',', $row['components']);
251 251
 			}
252 252
 
253 253
 			$calendar = [
254 254
 				'id' => $row['id'],
255 255
 				'uri' => $row['uri'],
256 256
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
257
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
258
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
259
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
260
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
261
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
257
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
258
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
259
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
260
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
261
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
262 262
 			];
263 263
 
264
-			foreach($this->propertyMap as $xmlName=>$dbName) {
264
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
265 265
 				$calendar[$xmlName] = $row[$dbName];
266 266
 			}
267 267
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		// query for shared calendars
278 278
 		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
279
-		$principals[]= $principalUri;
279
+		$principals[] = $principalUri;
280 280
 
281 281
 		$fields = array_values($this->propertyMap);
282 282
 		$fields[] = 'a.id';
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 			->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
297 297
 			->execute();
298 298
 
299
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
300
-		while($row = $result->fetch()) {
299
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
300
+		while ($row = $result->fetch()) {
301 301
 			if ($row['principaluri'] === $principalUri) {
302 302
 				continue;
303 303
 			}
@@ -316,25 +316,25 @@  discard block
 block discarded – undo
316 316
 			}
317 317
 
318 318
 			list(, $name) = URLUtil::splitPath($row['principaluri']);
319
-			$uri = $row['uri'] . '_shared_by_' . $name;
320
-			$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
319
+			$uri = $row['uri'].'_shared_by_'.$name;
320
+			$row['displayname'] = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
321 321
 			$components = [];
322 322
 			if ($row['components']) {
323
-				$components = explode(',',$row['components']);
323
+				$components = explode(',', $row['components']);
324 324
 			}
325 325
 			$calendar = [
326 326
 				'id' => $row['id'],
327 327
 				'uri' => $uri,
328 328
 				'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
329
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
330
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
331
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
332
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
333
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
329
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
330
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
331
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
332
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
333
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
334 334
 				$readOnlyPropertyName => $readOnly,
335 335
 			];
336 336
 
337
-			foreach($this->propertyMap as $xmlName=>$dbName) {
337
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
338 338
 				$calendar[$xmlName] = $row[$dbName];
339 339
 			}
340 340
 
@@ -363,21 +363,21 @@  discard block
 block discarded – undo
363 363
 			->orderBy('calendarorder', 'ASC');
364 364
 		$stmt = $query->execute();
365 365
 		$calendars = [];
366
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
366
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
367 367
 			$components = [];
368 368
 			if ($row['components']) {
369
-				$components = explode(',',$row['components']);
369
+				$components = explode(',', $row['components']);
370 370
 			}
371 371
 			$calendar = [
372 372
 				'id' => $row['id'],
373 373
 				'uri' => $row['uri'],
374 374
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
375
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
376
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
377
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
378
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
375
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
376
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
377
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
378
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
379 379
 			];
380
-			foreach($this->propertyMap as $xmlName=>$dbName) {
380
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
381 381
 				$calendar[$xmlName] = $row[$dbName];
382 382
 			}
383 383
 
@@ -428,27 +428,27 @@  discard block
 block discarded – undo
428 428
 			->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
429 429
 			->execute();
430 430
 
431
-		while($row = $result->fetch()) {
431
+		while ($row = $result->fetch()) {
432 432
 			list(, $name) = URLUtil::splitPath($row['principaluri']);
433
-			$row['displayname'] = $row['displayname'] . "($name)";
433
+			$row['displayname'] = $row['displayname']."($name)";
434 434
 			$components = [];
435 435
 			if ($row['components']) {
436
-				$components = explode(',',$row['components']);
436
+				$components = explode(',', $row['components']);
437 437
 			}
438 438
 			$calendar = [
439 439
 				'id' => $row['id'],
440 440
 				'uri' => $row['publicuri'],
441 441
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
442
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
443
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
444
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
445
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
446
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
447
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
448
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
442
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
443
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
444
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
445
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
446
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
447
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
448
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
449 449
 			];
450 450
 
451
-			foreach($this->propertyMap as $xmlName=>$dbName) {
451
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
452 452
 				$calendar[$xmlName] = $row[$dbName];
453 453
 			}
454 454
 
@@ -492,29 +492,29 @@  discard block
 block discarded – undo
492 492
 		$result->closeCursor();
493 493
 
494 494
 		if ($row === false) {
495
-			throw new NotFound('Node with name \'' . $uri . '\' could not be found');
495
+			throw new NotFound('Node with name \''.$uri.'\' could not be found');
496 496
 		}
497 497
 
498 498
 		list(, $name) = URLUtil::splitPath($row['principaluri']);
499
-		$row['displayname'] = $row['displayname'] . ' ' . "($name)";
499
+		$row['displayname'] = $row['displayname'].' '."($name)";
500 500
 		$components = [];
501 501
 		if ($row['components']) {
502
-			$components = explode(',',$row['components']);
502
+			$components = explode(',', $row['components']);
503 503
 		}
504 504
 		$calendar = [
505 505
 			'id' => $row['id'],
506 506
 			'uri' => $row['publicuri'],
507 507
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
508
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
509
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
510
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
511
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
512
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
513
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
514
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
508
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
509
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
510
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
511
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
512
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
513
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
514
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
515 515
 		];
516 516
 
517
-		foreach($this->propertyMap as $xmlName=>$dbName) {
517
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
518 518
 			$calendar[$xmlName] = $row[$dbName];
519 519
 		}
520 520
 
@@ -554,20 +554,20 @@  discard block
 block discarded – undo
554 554
 
555 555
 		$components = [];
556 556
 		if ($row['components']) {
557
-			$components = explode(',',$row['components']);
557
+			$components = explode(',', $row['components']);
558 558
 		}
559 559
 
560 560
 		$calendar = [
561 561
 			'id' => $row['id'],
562 562
 			'uri' => $row['uri'],
563 563
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
564
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
565
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
566
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
567
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
564
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
565
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
566
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
567
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
568 568
 		];
569 569
 
570
-		foreach($this->propertyMap as $xmlName=>$dbName) {
570
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
571 571
 			$calendar[$xmlName] = $row[$dbName];
572 572
 		}
573 573
 
@@ -600,20 +600,20 @@  discard block
 block discarded – undo
600 600
 
601 601
 		$components = [];
602 602
 		if ($row['components']) {
603
-			$components = explode(',',$row['components']);
603
+			$components = explode(',', $row['components']);
604 604
 		}
605 605
 
606 606
 		$calendar = [
607 607
 			'id' => $row['id'],
608 608
 			'uri' => $row['uri'],
609 609
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
610
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
611
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
612
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
613
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
610
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
611
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
612
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
613
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
614 614
 		];
615 615
 
616
-		foreach($this->propertyMap as $xmlName=>$dbName) {
616
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
617 617
 			$calendar[$xmlName] = $row[$dbName];
618 618
 		}
619 619
 
@@ -647,16 +647,16 @@  discard block
 block discarded – undo
647 647
 		$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
648 648
 		if (isset($properties[$sccs])) {
649 649
 			if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
650
-				throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
650
+				throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
651 651
 			}
652
-			$values['components'] = implode(',',$properties[$sccs]->getValue());
652
+			$values['components'] = implode(',', $properties[$sccs]->getValue());
653 653
 		}
654
-		$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
654
+		$transp = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
655 655
 		if (isset($properties[$transp])) {
656 656
 			$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
657 657
 		}
658 658
 
659
-		foreach($this->propertyMap as $xmlName=>$dbName) {
659
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
660 660
 			if (isset($properties[$xmlName])) {
661 661
 				$values[$dbName] = $properties[$xmlName];
662 662
 			}
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 
665 665
 		$query = $this->db->getQueryBuilder();
666 666
 		$query->insert('calendars');
667
-		foreach($values as $column => $value) {
667
+		foreach ($values as $column => $value) {
668 668
 			$query->setValue($column, $query->createNamedParameter($value));
669 669
 		}
670 670
 		$query->execute();
@@ -697,14 +697,14 @@  discard block
 block discarded – undo
697 697
 	 */
698 698
 	function updateCalendar($calendarId, PropPatch $propPatch) {
699 699
 		$supportedProperties = array_keys($this->propertyMap);
700
-		$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
700
+		$supportedProperties[] = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
701 701
 
702 702
 		$propPatch->handle($supportedProperties, function($mutations) use ($calendarId) {
703 703
 			$newValues = [];
704 704
 			foreach ($mutations as $propertyName => $propertyValue) {
705 705
 
706 706
 				switch ($propertyName) {
707
-					case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' :
707
+					case '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' :
708 708
 						$fieldName = 'transparent';
709 709
 						$newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
710 710
 						break;
@@ -819,16 +819,16 @@  discard block
 block discarded – undo
819 819
 		$stmt = $query->execute();
820 820
 
821 821
 		$result = [];
822
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
822
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
823 823
 			$result[] = [
824 824
 					'id'           => $row['id'],
825 825
 					'uri'          => $row['uri'],
826 826
 					'lastmodified' => $row['lastmodified'],
827
-					'etag'         => '"' . $row['etag'] . '"',
827
+					'etag'         => '"'.$row['etag'].'"',
828 828
 					'calendarid'   => $row['calendarid'],
829
-					'size'         => (int)$row['size'],
829
+					'size'         => (int) $row['size'],
830 830
 					'component'    => strtolower($row['componenttype']),
831
-					'classification'=> (int)$row['classification']
831
+					'classification'=> (int) $row['classification']
832 832
 			];
833 833
 		}
834 834
 
@@ -861,18 +861,18 @@  discard block
 block discarded – undo
861 861
 		$stmt = $query->execute();
862 862
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
863 863
 
864
-		if(!$row) return null;
864
+		if (!$row) return null;
865 865
 
866 866
 		return [
867 867
 				'id'            => $row['id'],
868 868
 				'uri'           => $row['uri'],
869 869
 				'lastmodified'  => $row['lastmodified'],
870
-				'etag'          => '"' . $row['etag'] . '"',
870
+				'etag'          => '"'.$row['etag'].'"',
871 871
 				'calendarid'    => $row['calendarid'],
872
-				'size'          => (int)$row['size'],
872
+				'size'          => (int) $row['size'],
873 873
 				'calendardata'  => $this->readBlob($row['calendardata']),
874 874
 				'component'     => strtolower($row['componenttype']),
875
-				'classification'=> (int)$row['classification']
875
+				'classification'=> (int) $row['classification']
876 876
 		];
877 877
 	}
878 878
 
@@ -911,12 +911,12 @@  discard block
 block discarded – undo
911 911
 					'id'           => $row['id'],
912 912
 					'uri'          => $row['uri'],
913 913
 					'lastmodified' => $row['lastmodified'],
914
-					'etag'         => '"' . $row['etag'] . '"',
914
+					'etag'         => '"'.$row['etag'].'"',
915 915
 					'calendarid'   => $row['calendarid'],
916
-					'size'         => (int)$row['size'],
916
+					'size'         => (int) $row['size'],
917 917
 					'calendardata' => $this->readBlob($row['calendardata']),
918 918
 					'component'    => strtolower($row['componenttype']),
919
-					'classification' => (int)$row['classification']
919
+					'classification' => (int) $row['classification']
920 920
 				];
921 921
 			}
922 922
 			$result->closeCursor();
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 		));
976 976
 		$this->addChange($calendarId, $objectUri, 1);
977 977
 
978
-		return '"' . $extraData['etag'] . '"';
978
+		return '"'.$extraData['etag'].'"';
979 979
 	}
980 980
 
981 981
 	/**
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 		}
1031 1031
 		$this->addChange($calendarId, $objectUri, 2);
1032 1032
 
1033
-		return '"' . $extraData['etag'] . '"';
1033
+		return '"'.$extraData['etag'].'"';
1034 1034
 	}
1035 1035
 
1036 1036
 	/**
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 		$stmt = $query->execute();
1184 1184
 
1185 1185
 		$result = [];
1186
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1186
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1187 1187
 			if ($requirePostFilter) {
1188 1188
 				if (!$this->validateFilterForObject($row, $filters)) {
1189 1189
 					continue;
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
 	 * @param integer|null $offset
1205 1205
 	 * @return array
1206 1206
 	 */
1207
-	public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1207
+	public function calendarSearch($principalUri, array $filters, $limit = null, $offset = null) {
1208 1208
 		$calendars = $this->getCalendarsForUser($principalUri);
1209 1209
 		$ownCalendars = [];
1210 1210
 		$sharedCalendars = [];
1211 1211
 
1212 1212
 		$uriMapper = [];
1213 1213
 
1214
-		foreach($calendars as $calendar) {
1214
+		foreach ($calendars as $calendar) {
1215 1215
 			if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
1216 1216
 				$ownCalendars[] = $calendar['id'];
1217 1217
 			} else {
@@ -1226,11 +1226,11 @@  discard block
 block discarded – undo
1226 1226
 		$query = $this->db->getQueryBuilder();
1227 1227
 		// Calendar id expressions
1228 1228
 		$calendarExpressions = [];
1229
-		foreach($ownCalendars as $id) {
1229
+		foreach ($ownCalendars as $id) {
1230 1230
 			$calendarExpressions[] = $query->expr()
1231 1231
 				->eq('c.calendarid', $query->createNamedParameter($id));
1232 1232
 		}
1233
-		foreach($sharedCalendars as $id) {
1233
+		foreach ($sharedCalendars as $id) {
1234 1234
 			$calendarExpressions[] = $query->expr()->andX(
1235 1235
 				$query->expr()->eq('c.calendarid',
1236 1236
 					$query->createNamedParameter($id)),
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 
1248 1248
 		// Component expressions
1249 1249
 		$compExpressions = [];
1250
-		foreach($filters['comps'] as $comp) {
1250
+		foreach ($filters['comps'] as $comp) {
1251 1251
 			$compExpressions[] = $query->expr()
1252 1252
 				->eq('c.componenttype', $query->createNamedParameter($comp));
1253 1253
 		}
@@ -1266,13 +1266,13 @@  discard block
 block discarded – undo
1266 1266
 		}
1267 1267
 
1268 1268
 		$propParamExpressions = [];
1269
-		foreach($filters['props'] as $prop) {
1269
+		foreach ($filters['props'] as $prop) {
1270 1270
 			$propParamExpressions[] = $query->expr()->andX(
1271 1271
 				$query->expr()->eq('i.name', $query->createNamedParameter($prop)),
1272 1272
 				$query->expr()->isNull('i.parameter')
1273 1273
 			);
1274 1274
 		}
1275
-		foreach($filters['params'] as $param) {
1275
+		foreach ($filters['params'] as $param) {
1276 1276
 			$propParamExpressions[] = $query->expr()->andX(
1277 1277
 				$query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
1278 1278
 				$query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
 		$stmt = $query->execute();
1305 1305
 
1306 1306
 		$result = [];
1307
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1308
-			$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1307
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1308
+			$path = $uriMapper[$row['calendarid']].'/'.$row['uri'];
1309 1309
 			if (!in_array($path, $result)) {
1310 1310
 				$result[] = $path;
1311 1311
 			}
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
 		$stmt = $query->execute();
1346 1346
 
1347 1347
 		if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1348
-			return $row['calendaruri'] . '/' . $row['objecturi'];
1348
+			return $row['calendaruri'].'/'.$row['objecturi'];
1349 1349
 		}
1350 1350
 
1351 1351
 		return null;
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 	function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) {
1411 1411
 		// Current synctoken
1412 1412
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1413
-		$stmt->execute([ $calendarId ]);
1413
+		$stmt->execute([$calendarId]);
1414 1414
 		$currentToken = $stmt->fetchColumn(0);
1415 1415
 
1416 1416
 		if (is_null($currentToken)) {
@@ -1427,8 +1427,8 @@  discard block
 block discarded – undo
1427 1427
 		if ($syncToken) {
1428 1428
 
1429 1429
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`";
1430
-			if ($limit>0) {
1431
-				$query.= " `LIMIT` " . (int)$limit;
1430
+			if ($limit > 0) {
1431
+				$query .= " `LIMIT` ".(int) $limit;
1432 1432
 			}
1433 1433
 
1434 1434
 			// Fetching all changes
@@ -1439,15 +1439,15 @@  discard block
 block discarded – undo
1439 1439
 
1440 1440
 			// This loop ensures that any duplicates are overwritten, only the
1441 1441
 			// last change on a node is relevant.
1442
-			while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1442
+			while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1443 1443
 
1444 1444
 				$changes[$row['uri']] = $row['operation'];
1445 1445
 
1446 1446
 			}
1447 1447
 
1448
-			foreach($changes as $uri => $operation) {
1448
+			foreach ($changes as $uri => $operation) {
1449 1449
 
1450
-				switch($operation) {
1450
+				switch ($operation) {
1451 1451
 					case 1 :
1452 1452
 						$result['added'][] = $uri;
1453 1453
 						break;
@@ -1517,10 +1517,10 @@  discard block
 block discarded – undo
1517 1517
 			->from('calendarsubscriptions')
1518 1518
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
1519 1519
 			->orderBy('calendarorder', 'asc');
1520
-		$stmt =$query->execute();
1520
+		$stmt = $query->execute();
1521 1521
 
1522 1522
 		$subscriptions = [];
1523
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1523
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1524 1524
 
1525 1525
 			$subscription = [
1526 1526
 				'id'           => $row['id'],
@@ -1529,10 +1529,10 @@  discard block
 block discarded – undo
1529 1529
 				'source'       => $row['source'],
1530 1530
 				'lastmodified' => $row['lastmodified'],
1531 1531
 
1532
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1532
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1533 1533
 			];
1534 1534
 
1535
-			foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1535
+			foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1536 1536
 				if (!is_null($row[$dbName])) {
1537 1537
 					$subscription[$xmlName] = $row[$dbName];
1538 1538
 				}
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 
1572 1572
 		$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
1573 1573
 
1574
-		foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1574
+		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1575 1575
 			if (array_key_exists($xmlName, $properties)) {
1576 1576
 					$values[$dbName] = $properties[$xmlName];
1577 1577
 					if (in_array($dbName, $propertiesBoolean)) {
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 
1620 1620
 			$newValues = [];
1621 1621
 
1622
-			foreach($mutations as $propertyName=>$propertyValue) {
1622
+			foreach ($mutations as $propertyName=>$propertyValue) {
1623 1623
 				if ($propertyName === '{http://calendarserver.org/ns/}source') {
1624 1624
 					$newValues['source'] = $propertyValue->getHref();
1625 1625
 				} else {
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 			$query = $this->db->getQueryBuilder();
1632 1632
 			$query->update('calendarsubscriptions')
1633 1633
 				->set('lastmodified', $query->createNamedParameter(time()));
1634
-			foreach($newValues as $fieldName=>$value) {
1634
+			foreach ($newValues as $fieldName=>$value) {
1635 1635
 				$query->set($fieldName, $query->createNamedParameter($value));
1636 1636
 			}
1637 1637
 			$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
 
1682 1682
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
1683 1683
 
1684
-		if(!$row) {
1684
+		if (!$row) {
1685 1685
 			return null;
1686 1686
 		}
1687 1687
 
@@ -1689,8 +1689,8 @@  discard block
 block discarded – undo
1689 1689
 				'uri'          => $row['uri'],
1690 1690
 				'calendardata' => $row['calendardata'],
1691 1691
 				'lastmodified' => $row['lastmodified'],
1692
-				'etag'         => '"' . $row['etag'] . '"',
1693
-				'size'         => (int)$row['size'],
1692
+				'etag'         => '"'.$row['etag'].'"',
1693
+				'size'         => (int) $row['size'],
1694 1694
 		];
1695 1695
 	}
1696 1696
 
@@ -1713,13 +1713,13 @@  discard block
 block discarded – undo
1713 1713
 				->execute();
1714 1714
 
1715 1715
 		$result = [];
1716
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1716
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1717 1717
 			$result[] = [
1718 1718
 					'calendardata' => $row['calendardata'],
1719 1719
 					'uri'          => $row['uri'],
1720 1720
 					'lastmodified' => $row['lastmodified'],
1721
-					'etag'         => '"' . $row['etag'] . '"',
1722
-					'size'         => (int)$row['size'],
1721
+					'etag'         => '"'.$row['etag'].'"',
1722
+					'size'         => (int) $row['size'],
1723 1723
 			];
1724 1724
 		}
1725 1725
 
@@ -1811,10 +1811,10 @@  discard block
 block discarded – undo
1811 1811
 		$lastOccurrence = null;
1812 1812
 		$uid = null;
1813 1813
 		$classification = self::CLASSIFICATION_PUBLIC;
1814
-		foreach($vObject->getComponents() as $component) {
1815
-			if ($component->name!=='VTIMEZONE') {
1814
+		foreach ($vObject->getComponents() as $component) {
1815
+			if ($component->name !== 'VTIMEZONE') {
1816 1816
 				$componentType = $component->name;
1817
-				$uid = (string)$component->UID;
1817
+				$uid = (string) $component->UID;
1818 1818
 				break;
1819 1819
 			}
1820 1820
 		}
@@ -1839,13 +1839,13 @@  discard block
 block discarded – undo
1839 1839
 					$lastOccurrence = $firstOccurrence;
1840 1840
 				}
1841 1841
 			} else {
1842
-				$it = new EventIterator($vObject, (string)$component->UID);
1842
+				$it = new EventIterator($vObject, (string) $component->UID);
1843 1843
 				$maxDate = new \DateTime(self::MAX_DATE);
1844 1844
 				if ($it->isInfinite()) {
1845 1845
 					$lastOccurrence = $maxDate->getTimestamp();
1846 1846
 				} else {
1847 1847
 					$end = $it->getDtEnd();
1848
-					while($it->valid() && $end < $maxDate) {
1848
+					while ($it->valid() && $end < $maxDate) {
1849 1849
 						$end = $it->getDtEnd();
1850 1850
 						$it->next();
1851 1851
 
@@ -2085,10 +2085,10 @@  discard block
 block discarded – undo
2085 2085
 		$result->closeCursor();
2086 2086
 
2087 2087
 		if (!isset($objectIds['id'])) {
2088
-			throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2088
+			throw new \InvalidArgumentException('Calendarobject does not exists: '.$uri);
2089 2089
 		}
2090 2090
 
2091
-		return (int)$objectIds['id'];
2091
+		return (int) $objectIds['id'];
2092 2092
 	}
2093 2093
 
2094 2094
 	private function convertPrincipal($principalUri, $toV2) {
@@ -2103,8 +2103,8 @@  discard block
 block discarded – undo
2103 2103
 	}
2104 2104
 
2105 2105
 	private function addOwnerPrincipal(&$calendarInfo) {
2106
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
2107
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
2106
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
2107
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
2108 2108
 		if (isset($calendarInfo[$ownerPrincipalKey])) {
2109 2109
 			$uri = $calendarInfo[$ownerPrincipalKey];
2110 2110
 		} else {
Please login to merge, or discard this patch.