Completed
Pull Request — master (#4098)
by Georg
19:55
created
apps/dav/lib/CalDAV/CalDavBackend.php 1 patch
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
180 180
 		}
181 181
 
182
-		return (int)$query->execute()->fetchColumn();
182
+		return (int) $query->execute()->fetchColumn();
183 183
 	}
184 184
 
185 185
 	/**
@@ -226,25 +226,25 @@  discard block
 block discarded – undo
226 226
 		$stmt = $query->execute();
227 227
 
228 228
 		$calendars = [];
229
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
229
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
230 230
 
231 231
 			$components = [];
232 232
 			if ($row['components']) {
233
-				$components = explode(',',$row['components']);
233
+				$components = explode(',', $row['components']);
234 234
 			}
235 235
 
236 236
 			$calendar = [
237 237
 				'id' => $row['id'],
238 238
 				'uri' => $row['uri'],
239 239
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
240
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
241
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
242
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
243
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
244
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
240
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
241
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
242
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
243
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
244
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
245 245
 			];
246 246
 
247
-			foreach($this->propertyMap as $xmlName=>$dbName) {
247
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
248 248
 				$calendar[$xmlName] = $row[$dbName];
249 249
 			}
250 250
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
 		// query for shared calendars
259 259
 		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
260
-		$principals[]= $principalUri;
260
+		$principals[] = $principalUri;
261 261
 
262 262
 		$fields = array_values($this->propertyMap);
263 263
 		$fields[] = 'a.id';
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 			->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
278 278
 			->execute();
279 279
 
280
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
281
-		while($row = $result->fetch()) {
280
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
281
+		while ($row = $result->fetch()) {
282 282
 			if ($row['principaluri'] === $principalUri) {
283 283
 				continue;
284 284
 			}
@@ -297,25 +297,25 @@  discard block
 block discarded – undo
297 297
 			}
298 298
 
299 299
 			list(, $name) = URLUtil::splitPath($row['principaluri']);
300
-			$uri = $row['uri'] . '_shared_by_' . $name;
301
-			$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
300
+			$uri = $row['uri'].'_shared_by_'.$name;
301
+			$row['displayname'] = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
302 302
 			$components = [];
303 303
 			if ($row['components']) {
304
-				$components = explode(',',$row['components']);
304
+				$components = explode(',', $row['components']);
305 305
 			}
306 306
 			$calendar = [
307 307
 				'id' => $row['id'],
308 308
 				'uri' => $uri,
309 309
 				'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
310
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
311
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
312
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
313
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
314
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
310
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
311
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
312
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
313
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
314
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
315 315
 				$readOnlyPropertyName => $readOnly,
316 316
 			];
317 317
 
318
-			foreach($this->propertyMap as $xmlName=>$dbName) {
318
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
319 319
 				$calendar[$xmlName] = $row[$dbName];
320 320
 			}
321 321
 
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 			->orderBy('calendarorder', 'ASC');
343 343
 		$stmt = $query->execute();
344 344
 		$calendars = [];
345
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
345
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
346 346
 			$components = [];
347 347
 			if ($row['components']) {
348
-				$components = explode(',',$row['components']);
348
+				$components = explode(',', $row['components']);
349 349
 			}
350 350
 			$calendar = [
351 351
 				'id' => $row['id'],
352 352
 				'uri' => $row['uri'],
353 353
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
354
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
355
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
356
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
357
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
354
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
355
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
356
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
357
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
358 358
 			];
359
-			foreach($this->propertyMap as $xmlName=>$dbName) {
359
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
360 360
 				$calendar[$xmlName] = $row[$dbName];
361 361
 			}
362 362
 			if (!isset($calendars[$calendar['id']])) {
@@ -404,27 +404,27 @@  discard block
 block discarded – undo
404 404
 			->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
405 405
 			->execute();
406 406
 
407
-		while($row = $result->fetch()) {
407
+		while ($row = $result->fetch()) {
408 408
 			list(, $name) = URLUtil::splitPath($row['principaluri']);
409
-			$row['displayname'] = $row['displayname'] . "($name)";
409
+			$row['displayname'] = $row['displayname']."($name)";
410 410
 			$components = [];
411 411
 			if ($row['components']) {
412
-				$components = explode(',',$row['components']);
412
+				$components = explode(',', $row['components']);
413 413
 			}
414 414
 			$calendar = [
415 415
 				'id' => $row['id'],
416 416
 				'uri' => $row['publicuri'],
417 417
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
418
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
419
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
420
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
421
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
422
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
423
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
424
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
418
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
419
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
420
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
421
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
422
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
423
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
424
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
425 425
 			];
426 426
 
427
-			foreach($this->propertyMap as $xmlName=>$dbName) {
427
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
428 428
 				$calendar[$xmlName] = $row[$dbName];
429 429
 			}
430 430
 
@@ -466,29 +466,29 @@  discard block
 block discarded – undo
466 466
 		$result->closeCursor();
467 467
 
468 468
 		if ($row === false) {
469
-			throw new NotFound('Node with name \'' . $uri . '\' could not be found');
469
+			throw new NotFound('Node with name \''.$uri.'\' could not be found');
470 470
 		}
471 471
 
472 472
 		list(, $name) = URLUtil::splitPath($row['principaluri']);
473
-		$row['displayname'] = $row['displayname'] . ' ' . "($name)";
473
+		$row['displayname'] = $row['displayname'].' '."($name)";
474 474
 		$components = [];
475 475
 		if ($row['components']) {
476
-			$components = explode(',',$row['components']);
476
+			$components = explode(',', $row['components']);
477 477
 		}
478 478
 		$calendar = [
479 479
 			'id' => $row['id'],
480 480
 			'uri' => $row['publicuri'],
481 481
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
482
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
483
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
484
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
485
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
486
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
487
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
488
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
482
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
483
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
484
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
485
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
486
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
487
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
488
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
489 489
 		];
490 490
 
491
-		foreach($this->propertyMap as $xmlName=>$dbName) {
491
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
492 492
 			$calendar[$xmlName] = $row[$dbName];
493 493
 		}
494 494
 
@@ -526,20 +526,20 @@  discard block
 block discarded – undo
526 526
 
527 527
 		$components = [];
528 528
 		if ($row['components']) {
529
-			$components = explode(',',$row['components']);
529
+			$components = explode(',', $row['components']);
530 530
 		}
531 531
 
532 532
 		$calendar = [
533 533
 			'id' => $row['id'],
534 534
 			'uri' => $row['uri'],
535 535
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
536
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
537
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
538
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
539
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
536
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
537
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
538
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
539
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
540 540
 		];
541 541
 
542
-		foreach($this->propertyMap as $xmlName=>$dbName) {
542
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
543 543
 			$calendar[$xmlName] = $row[$dbName];
544 544
 		}
545 545
 
@@ -570,20 +570,20 @@  discard block
 block discarded – undo
570 570
 
571 571
 		$components = [];
572 572
 		if ($row['components']) {
573
-			$components = explode(',',$row['components']);
573
+			$components = explode(',', $row['components']);
574 574
 		}
575 575
 
576 576
 		$calendar = [
577 577
 			'id' => $row['id'],
578 578
 			'uri' => $row['uri'],
579 579
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
580
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
581
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
582
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
583
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
580
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
581
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
582
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
583
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
584 584
 		];
585 585
 
586
-		foreach($this->propertyMap as $xmlName=>$dbName) {
586
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
587 587
 			$calendar[$xmlName] = $row[$dbName];
588 588
 		}
589 589
 
@@ -615,16 +615,16 @@  discard block
 block discarded – undo
615 615
 		$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
616 616
 		if (isset($properties[$sccs])) {
617 617
 			if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
618
-				throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
618
+				throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
619 619
 			}
620
-			$values['components'] = implode(',',$properties[$sccs]->getValue());
620
+			$values['components'] = implode(',', $properties[$sccs]->getValue());
621 621
 		}
622
-		$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
622
+		$transp = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
623 623
 		if (isset($properties[$transp])) {
624 624
 			$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
625 625
 		}
626 626
 
627
-		foreach($this->propertyMap as $xmlName=>$dbName) {
627
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
628 628
 			if (isset($properties[$xmlName])) {
629 629
 				$values[$dbName] = $properties[$xmlName];
630 630
 			}
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 
633 633
 		$query = $this->db->getQueryBuilder();
634 634
 		$query->insert('calendars');
635
-		foreach($values as $column => $value) {
635
+		foreach ($values as $column => $value) {
636 636
 			$query->setValue($column, $query->createNamedParameter($value));
637 637
 		}
638 638
 		$query->execute();
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
 	 */
666 666
 	function updateCalendar($calendarId, PropPatch $propPatch) {
667 667
 		$supportedProperties = array_keys($this->propertyMap);
668
-		$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
668
+		$supportedProperties[] = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
669 669
 
670 670
 		$propPatch->handle($supportedProperties, function($mutations) use ($calendarId) {
671 671
 			$newValues = [];
672 672
 			foreach ($mutations as $propertyName => $propertyValue) {
673 673
 
674 674
 				switch ($propertyName) {
675
-					case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' :
675
+					case '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' :
676 676
 						$fieldName = 'transparent';
677 677
 						$newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
678 678
 						break;
@@ -782,16 +782,16 @@  discard block
 block discarded – undo
782 782
 		$stmt = $query->execute();
783 783
 
784 784
 		$result = [];
785
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
785
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
786 786
 			$result[] = [
787 787
 					'id'           => $row['id'],
788 788
 					'uri'          => $row['uri'],
789 789
 					'lastmodified' => $row['lastmodified'],
790
-					'etag'         => '"' . $row['etag'] . '"',
790
+					'etag'         => '"'.$row['etag'].'"',
791 791
 					'calendarid'   => $row['calendarid'],
792
-					'size'         => (int)$row['size'],
792
+					'size'         => (int) $row['size'],
793 793
 					'component'    => strtolower($row['componenttype']),
794
-					'classification'=> (int)$row['classification']
794
+					'classification'=> (int) $row['classification']
795 795
 			];
796 796
 		}
797 797
 
@@ -824,18 +824,18 @@  discard block
 block discarded – undo
824 824
 		$stmt = $query->execute();
825 825
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
826 826
 
827
-		if(!$row) return null;
827
+		if (!$row) return null;
828 828
 
829 829
 		return [
830 830
 				'id'            => $row['id'],
831 831
 				'uri'           => $row['uri'],
832 832
 				'lastmodified'  => $row['lastmodified'],
833
-				'etag'          => '"' . $row['etag'] . '"',
833
+				'etag'          => '"'.$row['etag'].'"',
834 834
 				'calendarid'    => $row['calendarid'],
835
-				'size'          => (int)$row['size'],
835
+				'size'          => (int) $row['size'],
836 836
 				'calendardata'  => $this->readBlob($row['calendardata']),
837 837
 				'component'     => strtolower($row['componenttype']),
838
-				'classification'=> (int)$row['classification']
838
+				'classification'=> (int) $row['classification']
839 839
 		];
840 840
 	}
841 841
 
@@ -874,12 +874,12 @@  discard block
 block discarded – undo
874 874
 					'id'           => $row['id'],
875 875
 					'uri'          => $row['uri'],
876 876
 					'lastmodified' => $row['lastmodified'],
877
-					'etag'         => '"' . $row['etag'] . '"',
877
+					'etag'         => '"'.$row['etag'].'"',
878 878
 					'calendarid'   => $row['calendarid'],
879
-					'size'         => (int)$row['size'],
879
+					'size'         => (int) $row['size'],
880 880
 					'calendardata' => $this->readBlob($row['calendardata']),
881 881
 					'component'    => strtolower($row['componenttype']),
882
-					'classification' => (int)$row['classification']
882
+					'classification' => (int) $row['classification']
883 883
 				];
884 884
 			}
885 885
 			$result->closeCursor();
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 		));
937 937
 		$this->addChange($calendarId, $objectUri, 1);
938 938
 
939
-		return '"' . $extraData['etag'] . '"';
939
+		return '"'.$extraData['etag'].'"';
940 940
 	}
941 941
 
942 942
 	/**
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 		}
990 990
 		$this->addChange($calendarId, $objectUri, 2);
991 991
 
992
-		return '"' . $extraData['etag'] . '"';
992
+		return '"'.$extraData['etag'].'"';
993 993
 	}
994 994
 
995 995
 	/**
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		$stmt = $query->execute();
1141 1141
 
1142 1142
 		$result = [];
1143
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1143
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1144 1144
 			if ($requirePostFilter) {
1145 1145
 				if (!$this->validateFilterForObject($row, $filters)) {
1146 1146
 					continue;
@@ -1161,14 +1161,14 @@  discard block
 block discarded – undo
1161 1161
 	 * @param integer|null $offset
1162 1162
 	 * @return array
1163 1163
 	 */
1164
-	public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1164
+	public function calendarSearch($principalUri, array $filters, $limit = null, $offset = null) {
1165 1165
 		$calendars = $this->getCalendarsForUser($principalUri);
1166 1166
 		$ownCalendars = [];
1167 1167
 		$sharedCalendars = [];
1168 1168
 
1169 1169
 		$uriMapper = [];
1170 1170
 
1171
-		foreach($calendars as $calendar) {
1171
+		foreach ($calendars as $calendar) {
1172 1172
 			if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
1173 1173
 				$ownCalendars[] = $calendar['id'];
1174 1174
 			} else {
@@ -1184,11 +1184,11 @@  discard block
 block discarded – undo
1184 1184
 
1185 1185
 		// Calendar id expressions
1186 1186
 		$calendarExpressions = [];
1187
-		foreach($ownCalendars as $id) {
1187
+		foreach ($ownCalendars as $id) {
1188 1188
 			$calendarExpressions[] = $query->expr()
1189 1189
 				->eq('calendarid', $query->createNamedParameter($id));
1190 1190
 		}
1191
-		foreach($sharedCalendars as $id) {
1191
+		foreach ($sharedCalendars as $id) {
1192 1192
 			$calendarExpressions[] = $query->expr()->andX(
1193 1193
 				$query->expr()->eq('calendarid',
1194 1194
 					$query->createNamedParameter($id)),
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 
1206 1206
 		// Component expressions
1207 1207
 		$compExpressions = [];
1208
-		foreach($filters['comps'] as $comp) {
1208
+		foreach ($filters['comps'] as $comp) {
1209 1209
 			$compExpressions[] = $query->expr()
1210 1210
 				->eq('componenttype', $query->createNamedParameter($comp));
1211 1211
 		}
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 
1219 1219
 		// property and filter expression
1220 1220
 		$searchTermFilter = $query->expr()->like('calendardata',
1221
-			$query->createNamedParameter('%' . $this->db->escapeLikeParameter($filters['search-term']) . '%'));
1221
+			$query->createNamedParameter('%'.$this->db->escapeLikeParameter($filters['search-term']).'%'));
1222 1222
 
1223 1223
 		$query->select(['calendarid', 'uri', 'calendardata'])
1224 1224
 			->from('calendarobjects')
@@ -1229,12 +1229,12 @@  discard block
 block discarded – undo
1229 1229
 		$stmt = $query->execute();
1230 1230
 
1231 1231
 		$result = [];
1232
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1232
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1233 1233
 			if (!$this->validateFilterForCalendarSearch($row, $filters)) {
1234 1234
 				continue;
1235 1235
 			}
1236 1236
 
1237
-			$result[] = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1237
+			$result[] = $uriMapper[$row['calendarid']].'/'.$row['uri'];
1238 1238
 		}
1239 1239
 
1240 1240
 		return $result;
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 		$stmt = $query->execute();
1292 1292
 
1293 1293
 		if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1294
-			return $row['calendaruri'] . '/' . $row['objecturi'];
1294
+			return $row['calendaruri'].'/'.$row['objecturi'];
1295 1295
 		}
1296 1296
 
1297 1297
 		return null;
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
 	function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) {
1357 1357
 		// Current synctoken
1358 1358
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1359
-		$stmt->execute([ $calendarId ]);
1359
+		$stmt->execute([$calendarId]);
1360 1360
 		$currentToken = $stmt->fetchColumn(0);
1361 1361
 
1362 1362
 		if (is_null($currentToken)) {
@@ -1373,8 +1373,8 @@  discard block
 block discarded – undo
1373 1373
 		if ($syncToken) {
1374 1374
 
1375 1375
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`";
1376
-			if ($limit>0) {
1377
-				$query.= " `LIMIT` " . (int)$limit;
1376
+			if ($limit > 0) {
1377
+				$query .= " `LIMIT` ".(int) $limit;
1378 1378
 			}
1379 1379
 
1380 1380
 			// Fetching all changes
@@ -1385,15 +1385,15 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
 			// This loop ensures that any duplicates are overwritten, only the
1387 1387
 			// last change on a node is relevant.
1388
-			while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1388
+			while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1389 1389
 
1390 1390
 				$changes[$row['uri']] = $row['operation'];
1391 1391
 
1392 1392
 			}
1393 1393
 
1394
-			foreach($changes as $uri => $operation) {
1394
+			foreach ($changes as $uri => $operation) {
1395 1395
 
1396
-				switch($operation) {
1396
+				switch ($operation) {
1397 1397
 					case 1 :
1398 1398
 						$result['added'][] = $uri;
1399 1399
 						break;
@@ -1463,10 +1463,10 @@  discard block
 block discarded – undo
1463 1463
 			->from('calendarsubscriptions')
1464 1464
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
1465 1465
 			->orderBy('calendarorder', 'asc');
1466
-		$stmt =$query->execute();
1466
+		$stmt = $query->execute();
1467 1467
 
1468 1468
 		$subscriptions = [];
1469
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1469
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1470 1470
 
1471 1471
 			$subscription = [
1472 1472
 				'id'           => $row['id'],
@@ -1475,10 +1475,10 @@  discard block
 block discarded – undo
1475 1475
 				'source'       => $row['source'],
1476 1476
 				'lastmodified' => $row['lastmodified'],
1477 1477
 
1478
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1478
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1479 1479
 			];
1480 1480
 
1481
-			foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1481
+			foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1482 1482
 				if (!is_null($row[$dbName])) {
1483 1483
 					$subscription[$xmlName] = $row[$dbName];
1484 1484
 				}
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
 
1518 1518
 		$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
1519 1519
 
1520
-		foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1520
+		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1521 1521
 			if (array_key_exists($xmlName, $properties)) {
1522 1522
 					$values[$dbName] = $properties[$xmlName];
1523 1523
 					if (in_array($dbName, $propertiesBoolean)) {
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
 			$newValues = [];
1567 1567
 
1568
-			foreach($mutations as $propertyName=>$propertyValue) {
1568
+			foreach ($mutations as $propertyName=>$propertyValue) {
1569 1569
 				if ($propertyName === '{http://calendarserver.org/ns/}source') {
1570 1570
 					$newValues['source'] = $propertyValue->getHref();
1571 1571
 				} else {
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
 			$query = $this->db->getQueryBuilder();
1578 1578
 			$query->update('calendarsubscriptions')
1579 1579
 				->set('lastmodified', $query->createNamedParameter(time()));
1580
-			foreach($newValues as $fieldName=>$value) {
1580
+			foreach ($newValues as $fieldName=>$value) {
1581 1581
 				$query->set($fieldName, $query->createNamedParameter($value));
1582 1582
 			}
1583 1583
 			$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 
1628 1628
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
1629 1629
 
1630
-		if(!$row) {
1630
+		if (!$row) {
1631 1631
 			return null;
1632 1632
 		}
1633 1633
 
@@ -1635,8 +1635,8 @@  discard block
 block discarded – undo
1635 1635
 				'uri'          => $row['uri'],
1636 1636
 				'calendardata' => $row['calendardata'],
1637 1637
 				'lastmodified' => $row['lastmodified'],
1638
-				'etag'         => '"' . $row['etag'] . '"',
1639
-				'size'         => (int)$row['size'],
1638
+				'etag'         => '"'.$row['etag'].'"',
1639
+				'size'         => (int) $row['size'],
1640 1640
 		];
1641 1641
 	}
1642 1642
 
@@ -1659,13 +1659,13 @@  discard block
 block discarded – undo
1659 1659
 				->execute();
1660 1660
 
1661 1661
 		$result = [];
1662
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1662
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1663 1663
 			$result[] = [
1664 1664
 					'calendardata' => $row['calendardata'],
1665 1665
 					'uri'          => $row['uri'],
1666 1666
 					'lastmodified' => $row['lastmodified'],
1667
-					'etag'         => '"' . $row['etag'] . '"',
1668
-					'size'         => (int)$row['size'],
1667
+					'etag'         => '"'.$row['etag'].'"',
1668
+					'size'         => (int) $row['size'],
1669 1669
 			];
1670 1670
 		}
1671 1671
 
@@ -1757,10 +1757,10 @@  discard block
 block discarded – undo
1757 1757
 		$lastOccurrence = null;
1758 1758
 		$uid = null;
1759 1759
 		$classification = self::CLASSIFICATION_PUBLIC;
1760
-		foreach($vObject->getComponents() as $component) {
1761
-			if ($component->name!=='VTIMEZONE') {
1760
+		foreach ($vObject->getComponents() as $component) {
1761
+			if ($component->name !== 'VTIMEZONE') {
1762 1762
 				$componentType = $component->name;
1763
-				$uid = (string)$component->UID;
1763
+				$uid = (string) $component->UID;
1764 1764
 				break;
1765 1765
 			}
1766 1766
 		}
@@ -1785,13 +1785,13 @@  discard block
 block discarded – undo
1785 1785
 					$lastOccurrence = $firstOccurrence;
1786 1786
 				}
1787 1787
 			} else {
1788
-				$it = new EventIterator($vObject, (string)$component->UID);
1788
+				$it = new EventIterator($vObject, (string) $component->UID);
1789 1789
 				$maxDate = new \DateTime(self::MAX_DATE);
1790 1790
 				if ($it->isInfinite()) {
1791 1791
 					$lastOccurrence = $maxDate->getTimestamp();
1792 1792
 				} else {
1793 1793
 					$end = $it->getDtEnd();
1794
-					while($it->valid() && $end < $maxDate) {
1794
+					while ($it->valid() && $end < $maxDate) {
1795 1795
 						$end = $it->getDtEnd();
1796 1796
 						$it->next();
1797 1797
 
Please login to merge, or discard this patch.