Completed
Pull Request — master (#6715)
by Georg
16:04
created
apps/dav/lib/CalDAV/CalDavBackend.php 1 patch
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
218 218
 		}
219 219
 
220
-		return (int)$query->execute()->fetchColumn();
220
+		return (int) $query->execute()->fetchColumn();
221 221
 	}
222 222
 
223 223
 	/**
@@ -264,25 +264,25 @@  discard block
 block discarded – undo
264 264
 		$stmt = $query->execute();
265 265
 
266 266
 		$calendars = [];
267
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
267
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
268 268
 
269 269
 			$components = [];
270 270
 			if ($row['components']) {
271
-				$components = explode(',',$row['components']);
271
+				$components = explode(',', $row['components']);
272 272
 			}
273 273
 
274 274
 			$calendar = [
275 275
 				'id' => $row['id'],
276 276
 				'uri' => $row['uri'],
277 277
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
278
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
279
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
280
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
281
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
282
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
278
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
279
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
280
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
281
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
282
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
283 283
 			];
284 284
 
285
-			foreach($this->propertyMap as $xmlName=>$dbName) {
285
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
286 286
 				$calendar[$xmlName] = $row[$dbName];
287 287
 			}
288 288
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		$principals = array_map(function($principal) {
301 301
 			return urldecode($principal);
302 302
 		}, $principals);
303
-		$principals[]= $principalUri;
303
+		$principals[] = $principalUri;
304 304
 
305 305
 		$fields = array_values($this->propertyMap);
306 306
 		$fields[] = 'a.id';
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 			->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
321 321
 			->execute();
322 322
 
323
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
324
-		while($row = $result->fetch()) {
323
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
324
+		while ($row = $result->fetch()) {
325 325
 			if ($row['principaluri'] === $principalUri) {
326 326
 				continue;
327 327
 			}
@@ -340,25 +340,25 @@  discard block
 block discarded – undo
340 340
 			}
341 341
 
342 342
 			list(, $name) = Uri\split($row['principaluri']);
343
-			$uri = $row['uri'] . '_shared_by_' . $name;
344
-			$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
343
+			$uri = $row['uri'].'_shared_by_'.$name;
344
+			$row['displayname'] = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
345 345
 			$components = [];
346 346
 			if ($row['components']) {
347
-				$components = explode(',',$row['components']);
347
+				$components = explode(',', $row['components']);
348 348
 			}
349 349
 			$calendar = [
350 350
 				'id' => $row['id'],
351 351
 				'uri' => $uri,
352 352
 				'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
353
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
354
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
355
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
356
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'),
357
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
353
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
354
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
355
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
356
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'),
357
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
358 358
 				$readOnlyPropertyName => $readOnly,
359 359
 			];
360 360
 
361
-			foreach($this->propertyMap as $xmlName=>$dbName) {
361
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
362 362
 				$calendar[$xmlName] = $row[$dbName];
363 363
 			}
364 364
 
@@ -387,21 +387,21 @@  discard block
 block discarded – undo
387 387
 			->orderBy('calendarorder', 'ASC');
388 388
 		$stmt = $query->execute();
389 389
 		$calendars = [];
390
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
390
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
391 391
 			$components = [];
392 392
 			if ($row['components']) {
393
-				$components = explode(',',$row['components']);
393
+				$components = explode(',', $row['components']);
394 394
 			}
395 395
 			$calendar = [
396 396
 				'id' => $row['id'],
397 397
 				'uri' => $row['uri'],
398 398
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
399
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
400
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
401
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
402
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
399
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
400
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
401
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
402
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
403 403
 			];
404
-			foreach($this->propertyMap as $xmlName=>$dbName) {
404
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
405 405
 				$calendar[$xmlName] = $row[$dbName];
406 406
 			}
407 407
 
@@ -452,27 +452,27 @@  discard block
 block discarded – undo
452 452
 			->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
453 453
 			->execute();
454 454
 
455
-		while($row = $result->fetch()) {
455
+		while ($row = $result->fetch()) {
456 456
 			list(, $name) = Uri\split($row['principaluri']);
457
-			$row['displayname'] = $row['displayname'] . "($name)";
457
+			$row['displayname'] = $row['displayname']."($name)";
458 458
 			$components = [];
459 459
 			if ($row['components']) {
460
-				$components = explode(',',$row['components']);
460
+				$components = explode(',', $row['components']);
461 461
 			}
462 462
 			$calendar = [
463 463
 				'id' => $row['id'],
464 464
 				'uri' => $row['publicuri'],
465 465
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
466
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
467
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
468
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
469
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
470
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
471
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
472
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
466
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
467
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
468
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
469
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
470
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
471
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
472
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
473 473
 			];
474 474
 
475
-			foreach($this->propertyMap as $xmlName=>$dbName) {
475
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
476 476
 				$calendar[$xmlName] = $row[$dbName];
477 477
 			}
478 478
 
@@ -516,29 +516,29 @@  discard block
 block discarded – undo
516 516
 		$result->closeCursor();
517 517
 
518 518
 		if ($row === false) {
519
-			throw new NotFound('Node with name \'' . $uri . '\' could not be found');
519
+			throw new NotFound('Node with name \''.$uri.'\' could not be found');
520 520
 		}
521 521
 
522 522
 		list(, $name) = Uri\split($row['principaluri']);
523
-		$row['displayname'] = $row['displayname'] . ' ' . "($name)";
523
+		$row['displayname'] = $row['displayname'].' '."($name)";
524 524
 		$components = [];
525 525
 		if ($row['components']) {
526
-			$components = explode(',',$row['components']);
526
+			$components = explode(',', $row['components']);
527 527
 		}
528 528
 		$calendar = [
529 529
 			'id' => $row['id'],
530 530
 			'uri' => $row['publicuri'],
531 531
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
532
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
533
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
534
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
535
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
536
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
537
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
538
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
532
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
533
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
534
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
535
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
536
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
537
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
538
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
539 539
 		];
540 540
 
541
-		foreach($this->propertyMap as $xmlName=>$dbName) {
541
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
542 542
 			$calendar[$xmlName] = $row[$dbName];
543 543
 		}
544 544
 
@@ -578,20 +578,20 @@  discard block
 block discarded – undo
578 578
 
579 579
 		$components = [];
580 580
 		if ($row['components']) {
581
-			$components = explode(',',$row['components']);
581
+			$components = explode(',', $row['components']);
582 582
 		}
583 583
 
584 584
 		$calendar = [
585 585
 			'id' => $row['id'],
586 586
 			'uri' => $row['uri'],
587 587
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
588
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
589
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
590
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
591
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
588
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
589
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
590
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
591
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
592 592
 		];
593 593
 
594
-		foreach($this->propertyMap as $xmlName=>$dbName) {
594
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
595 595
 			$calendar[$xmlName] = $row[$dbName];
596 596
 		}
597 597
 
@@ -624,20 +624,20 @@  discard block
 block discarded – undo
624 624
 
625 625
 		$components = [];
626 626
 		if ($row['components']) {
627
-			$components = explode(',',$row['components']);
627
+			$components = explode(',', $row['components']);
628 628
 		}
629 629
 
630 630
 		$calendar = [
631 631
 			'id' => $row['id'],
632 632
 			'uri' => $row['uri'],
633 633
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
634
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
635
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
636
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
637
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
634
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
635
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
636
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
637
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
638 638
 		];
639 639
 
640
-		foreach($this->propertyMap as $xmlName=>$dbName) {
640
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
641 641
 			$calendar[$xmlName] = $row[$dbName];
642 642
 		}
643 643
 
@@ -672,16 +672,16 @@  discard block
 block discarded – undo
672 672
 		$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
673 673
 		if (isset($properties[$sccs])) {
674 674
 			if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
675
-				throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
675
+				throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
676 676
 			}
677
-			$values['components'] = implode(',',$properties[$sccs]->getValue());
677
+			$values['components'] = implode(',', $properties[$sccs]->getValue());
678 678
 		}
679
-		$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
679
+		$transp = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
680 680
 		if (isset($properties[$transp])) {
681 681
 			$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
682 682
 		}
683 683
 
684
-		foreach($this->propertyMap as $xmlName=>$dbName) {
684
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
685 685
 			if (isset($properties[$xmlName])) {
686 686
 				$values[$dbName] = $properties[$xmlName];
687 687
 			}
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 
690 690
 		$query = $this->db->getQueryBuilder();
691 691
 		$query->insert('calendars');
692
-		foreach($values as $column => $value) {
692
+		foreach ($values as $column => $value) {
693 693
 			$query->setValue($column, $query->createNamedParameter($value));
694 694
 		}
695 695
 		$query->execute();
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 */
724 724
 	function updateCalendar($calendarId, PropPatch $propPatch) {
725 725
 		$supportedProperties = array_keys($this->propertyMap);
726
-		$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
726
+		$supportedProperties[] = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
727 727
 
728 728
 		/**
729 729
 		 * @suppress SqlInjectionChecker
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 			foreach ($mutations as $propertyName => $propertyValue) {
734 734
 
735 735
 				switch ($propertyName) {
736
-					case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' :
736
+					case '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' :
737 737
 						$fieldName = 'transparent';
738 738
 						$newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
739 739
 						break;
@@ -848,16 +848,16 @@  discard block
 block discarded – undo
848 848
 		$stmt = $query->execute();
849 849
 
850 850
 		$result = [];
851
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
851
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
852 852
 			$result[] = [
853 853
 					'id'           => $row['id'],
854 854
 					'uri'          => $row['uri'],
855 855
 					'lastmodified' => $row['lastmodified'],
856
-					'etag'         => '"' . $row['etag'] . '"',
856
+					'etag'         => '"'.$row['etag'].'"',
857 857
 					'calendarid'   => $row['calendarid'],
858
-					'size'         => (int)$row['size'],
858
+					'size'         => (int) $row['size'],
859 859
 					'component'    => strtolower($row['componenttype']),
860
-					'classification'=> (int)$row['classification']
860
+					'classification'=> (int) $row['classification']
861 861
 			];
862 862
 		}
863 863
 
@@ -890,18 +890,18 @@  discard block
 block discarded – undo
890 890
 		$stmt = $query->execute();
891 891
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
892 892
 
893
-		if(!$row) return null;
893
+		if (!$row) return null;
894 894
 
895 895
 		return [
896 896
 				'id'            => $row['id'],
897 897
 				'uri'           => $row['uri'],
898 898
 				'lastmodified'  => $row['lastmodified'],
899
-				'etag'          => '"' . $row['etag'] . '"',
899
+				'etag'          => '"'.$row['etag'].'"',
900 900
 				'calendarid'    => $row['calendarid'],
901
-				'size'          => (int)$row['size'],
901
+				'size'          => (int) $row['size'],
902 902
 				'calendardata'  => $this->readBlob($row['calendardata']),
903 903
 				'component'     => strtolower($row['componenttype']),
904
-				'classification'=> (int)$row['classification']
904
+				'classification'=> (int) $row['classification']
905 905
 		];
906 906
 	}
907 907
 
@@ -940,12 +940,12 @@  discard block
 block discarded – undo
940 940
 					'id'           => $row['id'],
941 941
 					'uri'          => $row['uri'],
942 942
 					'lastmodified' => $row['lastmodified'],
943
-					'etag'         => '"' . $row['etag'] . '"',
943
+					'etag'         => '"'.$row['etag'].'"',
944 944
 					'calendarid'   => $row['calendarid'],
945
-					'size'         => (int)$row['size'],
945
+					'size'         => (int) $row['size'],
946 946
 					'calendardata' => $this->readBlob($row['calendardata']),
947 947
 					'component'    => strtolower($row['componenttype']),
948
-					'classification' => (int)$row['classification']
948
+					'classification' => (int) $row['classification']
949 949
 				];
950 950
 			}
951 951
 			$result->closeCursor();
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 		));
1019 1019
 		$this->addChange($calendarId, $objectUri, 1);
1020 1020
 
1021
-		return '"' . $extraData['etag'] . '"';
1021
+		return '"'.$extraData['etag'].'"';
1022 1022
 	}
1023 1023
 
1024 1024
 	/**
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 		}
1074 1074
 		$this->addChange($calendarId, $objectUri, 2);
1075 1075
 
1076
-		return '"' . $extraData['etag'] . '"';
1076
+		return '"'.$extraData['etag'].'"';
1077 1077
 	}
1078 1078
 
1079 1079
 	/**
@@ -1226,13 +1226,13 @@  discard block
 block discarded – undo
1226 1226
 		$stmt = $query->execute();
1227 1227
 
1228 1228
 		$result = [];
1229
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1229
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1230 1230
 			if ($requirePostFilter) {
1231 1231
 				// validateFilterForObject will parse the calendar data
1232 1232
 				// catch parsing errors
1233 1233
 				try {
1234 1234
 					$matches = $this->validateFilterForObject($row, $filters);
1235
-				} catch(ParseException $ex) {
1235
+				} catch (ParseException $ex) {
1236 1236
 					$this->logger->logException($ex, [
1237 1237
 						'app' => 'dav',
1238 1238
 						'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri']
@@ -1265,14 +1265,14 @@  discard block
 block discarded – undo
1265 1265
 	 * @param integer|null $offset
1266 1266
 	 * @return array
1267 1267
 	 */
1268
-	public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1268
+	public function calendarSearch($principalUri, array $filters, $limit = null, $offset = null) {
1269 1269
 		$calendars = $this->getCalendarsForUser($principalUri);
1270 1270
 		$ownCalendars = [];
1271 1271
 		$sharedCalendars = [];
1272 1272
 
1273 1273
 		$uriMapper = [];
1274 1274
 
1275
-		foreach($calendars as $calendar) {
1275
+		foreach ($calendars as $calendar) {
1276 1276
 			if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
1277 1277
 				$ownCalendars[] = $calendar['id'];
1278 1278
 			} else {
@@ -1287,11 +1287,11 @@  discard block
 block discarded – undo
1287 1287
 		$query = $this->db->getQueryBuilder();
1288 1288
 		// Calendar id expressions
1289 1289
 		$calendarExpressions = [];
1290
-		foreach($ownCalendars as $id) {
1290
+		foreach ($ownCalendars as $id) {
1291 1291
 			$calendarExpressions[] = $query->expr()
1292 1292
 				->eq('c.calendarid', $query->createNamedParameter($id));
1293 1293
 		}
1294
-		foreach($sharedCalendars as $id) {
1294
+		foreach ($sharedCalendars as $id) {
1295 1295
 			$calendarExpressions[] = $query->expr()->andX(
1296 1296
 				$query->expr()->eq('c.calendarid',
1297 1297
 					$query->createNamedParameter($id)),
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
 
1309 1309
 		// Component expressions
1310 1310
 		$compExpressions = [];
1311
-		foreach($filters['comps'] as $comp) {
1311
+		foreach ($filters['comps'] as $comp) {
1312 1312
 			$compExpressions[] = $query->expr()
1313 1313
 				->eq('c.componenttype', $query->createNamedParameter($comp));
1314 1314
 		}
@@ -1327,13 +1327,13 @@  discard block
 block discarded – undo
1327 1327
 		}
1328 1328
 
1329 1329
 		$propParamExpressions = [];
1330
-		foreach($filters['props'] as $prop) {
1330
+		foreach ($filters['props'] as $prop) {
1331 1331
 			$propParamExpressions[] = $query->expr()->andX(
1332 1332
 				$query->expr()->eq('i.name', $query->createNamedParameter($prop)),
1333 1333
 				$query->expr()->isNull('i.parameter')
1334 1334
 			);
1335 1335
 		}
1336
-		foreach($filters['params'] as $param) {
1336
+		foreach ($filters['params'] as $param) {
1337 1337
 			$propParamExpressions[] = $query->expr()->andX(
1338 1338
 				$query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
1339 1339
 				$query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
@@ -1365,8 +1365,8 @@  discard block
 block discarded – undo
1365 1365
 		$stmt = $query->execute();
1366 1366
 
1367 1367
 		$result = [];
1368
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1369
-			$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1368
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1369
+			$path = $uriMapper[$row['calendarid']].'/'.$row['uri'];
1370 1370
 			if (!in_array($path, $result)) {
1371 1371
 				$result[] = $path;
1372 1372
 			}
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
 		}
1405 1405
 
1406 1406
 		$or = $innerQuery->expr()->orX();
1407
-		foreach($searchProperties as $searchProperty) {
1407
+		foreach ($searchProperties as $searchProperty) {
1408 1408
 			$or->add($innerQuery->expr()->eq('op.name',
1409 1409
 				$outerQuery->createNamedParameter($searchProperty)));
1410 1410
 		}
@@ -1412,8 +1412,8 @@  discard block
 block discarded – undo
1412 1412
 
1413 1413
 		if ($pattern !== '') {
1414 1414
 			$innerQuery->andWhere($innerQuery->expr()->iLike('op.value',
1415
-				$outerQuery->createNamedParameter('%' .
1416
-					$this->db->escapeLikeParameter($pattern) . '%')));
1415
+				$outerQuery->createNamedParameter('%'.
1416
+					$this->db->escapeLikeParameter($pattern).'%')));
1417 1417
 		}
1418 1418
 
1419 1419
 		$outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri')
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 
1434 1434
 		if (isset($options['types'])) {
1435 1435
 			$or = $outerQuery->expr()->orX();
1436
-			foreach($options['types'] as $type) {
1436
+			foreach ($options['types'] as $type) {
1437 1437
 				$or->add($outerQuery->expr()->eq('componenttype',
1438 1438
 					$outerQuery->createNamedParameter($type)));
1439 1439
 			}
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 			$comps = $calendarData->getComponents();
1459 1459
 			$objects = [];
1460 1460
 			$timezones = [];
1461
-			foreach($comps as $comp) {
1461
+			foreach ($comps as $comp) {
1462 1462
 				if ($comp instanceof VTimeZone) {
1463 1463
 					$timezones[] = $comp;
1464 1464
 				} else {
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 		});
1496 1496
 		$validationRules = $comp->getValidationRules();
1497 1497
 
1498
-		foreach($subComponents as $subComponent) {
1498
+		foreach ($subComponents as $subComponent) {
1499 1499
 			$name = $subComponent->name;
1500 1500
 			if (!isset($data[$name])) {
1501 1501
 				$data[$name] = [];
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
 			$data[$name][] = $this->transformSearchData($subComponent);
1504 1504
 		}
1505 1505
 
1506
-		foreach($properties as $property) {
1506
+		foreach ($properties as $property) {
1507 1507
 			$name = $property->name;
1508 1508
 			if (!isset($validationRules[$name])) {
1509 1509
 				$validationRules[$name] = '*';
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
 		$stmt = $query->execute();
1574 1574
 
1575 1575
 		if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1576
-			return $row['calendaruri'] . '/' . $row['objecturi'];
1576
+			return $row['calendaruri'].'/'.$row['objecturi'];
1577 1577
 		}
1578 1578
 
1579 1579
 		return null;
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
 	function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) {
1639 1639
 		// Current synctoken
1640 1640
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1641
-		$stmt->execute([ $calendarId ]);
1641
+		$stmt->execute([$calendarId]);
1642 1642
 		$currentToken = $stmt->fetchColumn(0);
1643 1643
 
1644 1644
 		if (is_null($currentToken)) {
@@ -1655,8 +1655,8 @@  discard block
 block discarded – undo
1655 1655
 		if ($syncToken) {
1656 1656
 
1657 1657
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`";
1658
-			if ($limit>0) {
1659
-				$query.= " LIMIT " . (int)$limit;
1658
+			if ($limit > 0) {
1659
+				$query .= " LIMIT ".(int) $limit;
1660 1660
 			}
1661 1661
 
1662 1662
 			// Fetching all changes
@@ -1667,15 +1667,15 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
 			// This loop ensures that any duplicates are overwritten, only the
1669 1669
 			// last change on a node is relevant.
1670
-			while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1670
+			while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1671 1671
 
1672 1672
 				$changes[$row['uri']] = $row['operation'];
1673 1673
 
1674 1674
 			}
1675 1675
 
1676
-			foreach($changes as $uri => $operation) {
1676
+			foreach ($changes as $uri => $operation) {
1677 1677
 
1678
-				switch($operation) {
1678
+				switch ($operation) {
1679 1679
 					case 1 :
1680 1680
 						$result['added'][] = $uri;
1681 1681
 						break;
@@ -1745,10 +1745,10 @@  discard block
 block discarded – undo
1745 1745
 			->from('calendarsubscriptions')
1746 1746
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
1747 1747
 			->orderBy('calendarorder', 'asc');
1748
-		$stmt =$query->execute();
1748
+		$stmt = $query->execute();
1749 1749
 
1750 1750
 		$subscriptions = [];
1751
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1751
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1752 1752
 
1753 1753
 			$subscription = [
1754 1754
 				'id'           => $row['id'],
@@ -1757,10 +1757,10 @@  discard block
 block discarded – undo
1757 1757
 				'source'       => $row['source'],
1758 1758
 				'lastmodified' => $row['lastmodified'],
1759 1759
 
1760
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1760
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1761 1761
 			];
1762 1762
 
1763
-			foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1763
+			foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1764 1764
 				if (!is_null($row[$dbName])) {
1765 1765
 					$subscription[$xmlName] = $row[$dbName];
1766 1766
 				}
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
 
1800 1800
 		$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
1801 1801
 
1802
-		foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1802
+		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1803 1803
 			if (array_key_exists($xmlName, $properties)) {
1804 1804
 					$values[$dbName] = $properties[$xmlName];
1805 1805
 					if (in_array($dbName, $propertiesBoolean)) {
@@ -1850,7 +1850,7 @@  discard block
 block discarded – undo
1850 1850
 
1851 1851
 			$newValues = [];
1852 1852
 
1853
-			foreach($mutations as $propertyName=>$propertyValue) {
1853
+			foreach ($mutations as $propertyName=>$propertyValue) {
1854 1854
 				if ($propertyName === '{http://calendarserver.org/ns/}source') {
1855 1855
 					$newValues['source'] = $propertyValue->getHref();
1856 1856
 				} else {
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 			$query = $this->db->getQueryBuilder();
1863 1863
 			$query->update('calendarsubscriptions')
1864 1864
 				->set('lastmodified', $query->createNamedParameter(time()));
1865
-			foreach($newValues as $fieldName=>$value) {
1865
+			foreach ($newValues as $fieldName=>$value) {
1866 1866
 				$query->set($fieldName, $query->createNamedParameter($value));
1867 1867
 			}
1868 1868
 			$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
 
1913 1913
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
1914 1914
 
1915
-		if(!$row) {
1915
+		if (!$row) {
1916 1916
 			return null;
1917 1917
 		}
1918 1918
 
@@ -1920,8 +1920,8 @@  discard block
 block discarded – undo
1920 1920
 				'uri'          => $row['uri'],
1921 1921
 				'calendardata' => $row['calendardata'],
1922 1922
 				'lastmodified' => $row['lastmodified'],
1923
-				'etag'         => '"' . $row['etag'] . '"',
1924
-				'size'         => (int)$row['size'],
1923
+				'etag'         => '"'.$row['etag'].'"',
1924
+				'size'         => (int) $row['size'],
1925 1925
 		];
1926 1926
 	}
1927 1927
 
@@ -1944,13 +1944,13 @@  discard block
 block discarded – undo
1944 1944
 				->execute();
1945 1945
 
1946 1946
 		$result = [];
1947
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1947
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1948 1948
 			$result[] = [
1949 1949
 					'calendardata' => $row['calendardata'],
1950 1950
 					'uri'          => $row['uri'],
1951 1951
 					'lastmodified' => $row['lastmodified'],
1952
-					'etag'         => '"' . $row['etag'] . '"',
1953
-					'size'         => (int)$row['size'],
1952
+					'etag'         => '"'.$row['etag'].'"',
1953
+					'size'         => (int) $row['size'],
1954 1954
 			];
1955 1955
 		}
1956 1956
 
@@ -2042,10 +2042,10 @@  discard block
 block discarded – undo
2042 2042
 		$lastOccurrence = null;
2043 2043
 		$uid = null;
2044 2044
 		$classification = self::CLASSIFICATION_PUBLIC;
2045
-		foreach($vObject->getComponents() as $component) {
2046
-			if ($component->name!=='VTIMEZONE') {
2045
+		foreach ($vObject->getComponents() as $component) {
2046
+			if ($component->name !== 'VTIMEZONE') {
2047 2047
 				$componentType = $component->name;
2048
-				$uid = (string)$component->UID;
2048
+				$uid = (string) $component->UID;
2049 2049
 				break;
2050 2050
 			}
2051 2051
 		}
@@ -2070,13 +2070,13 @@  discard block
 block discarded – undo
2070 2070
 					$lastOccurrence = $firstOccurrence;
2071 2071
 				}
2072 2072
 			} else {
2073
-				$it = new EventIterator($vObject, (string)$component->UID);
2073
+				$it = new EventIterator($vObject, (string) $component->UID);
2074 2074
 				$maxDate = new \DateTime(self::MAX_DATE);
2075 2075
 				if ($it->isInfinite()) {
2076 2076
 					$lastOccurrence = $maxDate->getTimestamp();
2077 2077
 				} else {
2078 2078
 					$end = $it->getDtEnd();
2079
-					while($it->valid() && $end < $maxDate) {
2079
+					while ($it->valid() && $end < $maxDate) {
2080 2080
 						$end = $it->getDtEnd();
2081 2081
 						$it->next();
2082 2082
 
@@ -2316,10 +2316,10 @@  discard block
 block discarded – undo
2316 2316
 		$result->closeCursor();
2317 2317
 
2318 2318
 		if (!isset($objectIds['id'])) {
2319
-			throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2319
+			throw new \InvalidArgumentException('Calendarobject does not exists: '.$uri);
2320 2320
 		}
2321 2321
 
2322
-		return (int)$objectIds['id'];
2322
+		return (int) $objectIds['id'];
2323 2323
 	}
2324 2324
 
2325 2325
 	private function convertPrincipal($principalUri, $toV2) {
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
 	}
2335 2335
 
2336 2336
 	private function addOwnerPrincipal(&$calendarInfo) {
2337
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
2338
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
2337
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
2338
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
2339 2339
 		if (isset($calendarInfo[$ownerPrincipalKey])) {
2340 2340
 			$uri = $calendarInfo[$ownerPrincipalKey];
2341 2341
 		} else {
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Principal.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		$principals = [];
99 99
 
100 100
 		if ($prefixPath === $this->principalPrefix) {
101
-			foreach($this->userManager->search('') as $user) {
101
+			foreach ($this->userManager->search('') as $user) {
102 102
 				$principals[] = $this->userToPrincipal($user);
103 103
 			}
104 104
 		}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				$groups = $this->groupManager->getUserGroups($user);
166 166
 				$groups = array_map(function($group) {
167 167
 					/** @var IGroup $group */
168
-					return 'principals/groups/' . urlencode($group->getGID());
168
+					return 'principals/groups/'.urlencode($group->getGID());
169 169
 				}, $groups);
170 170
 
171 171
 				return $groups;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			switch ($prop) {
229 229
 				case '{http://sabredav.org/ns}email-address':
230 230
 					$users = $this->userManager->getByEmail($value);
231
-					$results[] = array_filter(array_map(function (IUser $user) use ($restrictGroups) {
231
+					$results[] = array_filter(array_map(function(IUser $user) use ($restrictGroups) {
232 232
 						if ($restrictGroups) {
233 233
 							$usersGroups = $this->groupManager->getUserGroupIds($user);
234 234
 							if (array_intersect($usersGroups, $restrictGroups)) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 							}
237 237
 						}
238 238
 
239
-						return $this->principalPrefix . '/' . $user->getUID();
239
+						return $this->principalPrefix.'/'.$user->getUID();
240 240
 					}, $users), function($userPrincipal) {
241 241
 						return $userPrincipal !== null;
242 242
 					});
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 				$email = substr($uri, 7);
296 296
 				$users = $this->userManager->getByEmail($email);
297 297
 				if (count($users) === 1) {
298
-					return $this->principalPrefix . '/' . $users[0]->getUID();
298
+					return $this->principalPrefix.'/'.$users[0]->getUID();
299 299
 				}
300 300
 			}
301 301
 		}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		$userId = $user->getUID();
312 312
 		$displayName = $user->getDisplayName();
313 313
 		$principal = [
314
-				'uri' => $this->principalPrefix . '/' . $userId,
314
+				'uri' => $this->principalPrefix.'/'.$userId,
315 315
 				'{DAV:}displayname' => is_null($displayName) ? $userId : $displayName,
316 316
 		];
317 317
 
Please login to merge, or discard this patch.