Completed
Pull Request — master (#5881)
by Thomas
18:04
created
apps/dav/lib/CalDAV/CalDavBackend.php 1 patch
Spacing   +123 added lines, -123 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
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		$principals = array_map(function($principal) {
280 280
 			return urldecode($principal);
281 281
 		}, $principals);
282
-		$principals[]= $principalUri;
282
+		$principals[] = $principalUri;
283 283
 
284 284
 		$fields = array_values($this->propertyMap);
285 285
 		$fields[] = 'a.id';
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 			->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
300 300
 			->execute();
301 301
 
302
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
303
-		while($row = $result->fetch()) {
302
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
303
+		while ($row = $result->fetch()) {
304 304
 			if ($row['principaluri'] === $principalUri) {
305 305
 				continue;
306 306
 			}
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
 			}
320 320
 
321 321
 			list(, $name) = URLUtil::splitPath($row['principaluri']);
322
-			$uri = $row['uri'] . '_shared_by_' . $name;
323
-			$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
322
+			$uri = $row['uri'].'_shared_by_'.$name;
323
+			$row['displayname'] = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
324 324
 			$components = [];
325 325
 			if ($row['components']) {
326
-				$components = explode(',',$row['components']);
326
+				$components = explode(',', $row['components']);
327 327
 			}
328 328
 			$calendar = [
329 329
 				'id' => $row['id'],
330 330
 				'uri' => $uri,
331 331
 				'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
332
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
333
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
334
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
335
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
336
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
332
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
333
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
334
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
335
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
336
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
337 337
 				$readOnlyPropertyName => $readOnly,
338 338
 			];
339 339
 
340
-			foreach($this->propertyMap as $xmlName=>$dbName) {
340
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
341 341
 				$calendar[$xmlName] = $row[$dbName];
342 342
 			}
343 343
 
@@ -366,21 +366,21 @@  discard block
 block discarded – undo
366 366
 			->orderBy('calendarorder', 'ASC');
367 367
 		$stmt = $query->execute();
368 368
 		$calendars = [];
369
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
369
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
370 370
 			$components = [];
371 371
 			if ($row['components']) {
372
-				$components = explode(',',$row['components']);
372
+				$components = explode(',', $row['components']);
373 373
 			}
374 374
 			$calendar = [
375 375
 				'id' => $row['id'],
376 376
 				'uri' => $row['uri'],
377 377
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
378
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
379
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
380
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
381
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
378
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
379
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
380
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
381
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
382 382
 			];
383
-			foreach($this->propertyMap as $xmlName=>$dbName) {
383
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
384 384
 				$calendar[$xmlName] = $row[$dbName];
385 385
 			}
386 386
 
@@ -431,27 +431,27 @@  discard block
 block discarded – undo
431 431
 			->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
432 432
 			->execute();
433 433
 
434
-		while($row = $result->fetch()) {
434
+		while ($row = $result->fetch()) {
435 435
 			list(, $name) = URLUtil::splitPath($row['principaluri']);
436
-			$row['displayname'] = $row['displayname'] . "($name)";
436
+			$row['displayname'] = $row['displayname']."($name)";
437 437
 			$components = [];
438 438
 			if ($row['components']) {
439
-				$components = explode(',',$row['components']);
439
+				$components = explode(',', $row['components']);
440 440
 			}
441 441
 			$calendar = [
442 442
 				'id' => $row['id'],
443 443
 				'uri' => $row['publicuri'],
444 444
 				'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
445
-				'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
446
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
447
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
448
-				'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
449
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
450
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
451
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
445
+				'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
446
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
447
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
448
+				'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
449
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint),
450
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
451
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
452 452
 			];
453 453
 
454
-			foreach($this->propertyMap as $xmlName=>$dbName) {
454
+			foreach ($this->propertyMap as $xmlName=>$dbName) {
455 455
 				$calendar[$xmlName] = $row[$dbName];
456 456
 			}
457 457
 
@@ -495,29 +495,29 @@  discard block
 block discarded – undo
495 495
 		$result->closeCursor();
496 496
 
497 497
 		if ($row === false) {
498
-			throw new NotFound('Node with name \'' . $uri . '\' could not be found');
498
+			throw new NotFound('Node with name \''.$uri.'\' could not be found');
499 499
 		}
500 500
 
501 501
 		list(, $name) = URLUtil::splitPath($row['principaluri']);
502
-		$row['displayname'] = $row['displayname'] . ' ' . "($name)";
502
+		$row['displayname'] = $row['displayname'].' '."($name)";
503 503
 		$components = [];
504 504
 		if ($row['components']) {
505
-			$components = explode(',',$row['components']);
505
+			$components = explode(',', $row['components']);
506 506
 		}
507 507
 		$calendar = [
508 508
 			'id' => $row['id'],
509 509
 			'uri' => $row['publicuri'],
510 510
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
511
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
512
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
513
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
514
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
515
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
516
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
517
-			'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
511
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
512
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
513
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
514
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
515
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
516
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ,
517
+			'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}public' => (int) $row['access'] === self::ACCESS_PUBLIC,
518 518
 		];
519 519
 
520
-		foreach($this->propertyMap as $xmlName=>$dbName) {
520
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
521 521
 			$calendar[$xmlName] = $row[$dbName];
522 522
 		}
523 523
 
@@ -557,20 +557,20 @@  discard block
 block discarded – undo
557 557
 
558 558
 		$components = [];
559 559
 		if ($row['components']) {
560
-			$components = explode(',',$row['components']);
560
+			$components = explode(',', $row['components']);
561 561
 		}
562 562
 
563 563
 		$calendar = [
564 564
 			'id' => $row['id'],
565 565
 			'uri' => $row['uri'],
566 566
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
567
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
568
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
569
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
570
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
567
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
568
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
569
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
570
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
571 571
 		];
572 572
 
573
-		foreach($this->propertyMap as $xmlName=>$dbName) {
573
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
574 574
 			$calendar[$xmlName] = $row[$dbName];
575 575
 		}
576 576
 
@@ -603,20 +603,20 @@  discard block
 block discarded – undo
603 603
 
604 604
 		$components = [];
605 605
 		if ($row['components']) {
606
-			$components = explode(',',$row['components']);
606
+			$components = explode(',', $row['components']);
607 607
 		}
608 608
 
609 609
 		$calendar = [
610 610
 			'id' => $row['id'],
611 611
 			'uri' => $row['uri'],
612 612
 			'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint),
613
-			'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
614
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
615
-			'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
616
-			'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
613
+			'{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
614
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
615
+			'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
616
+			'{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
617 617
 		];
618 618
 
619
-		foreach($this->propertyMap as $xmlName=>$dbName) {
619
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
620 620
 			$calendar[$xmlName] = $row[$dbName];
621 621
 		}
622 622
 
@@ -651,16 +651,16 @@  discard block
 block discarded – undo
651 651
 		$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
652 652
 		if (isset($properties[$sccs])) {
653 653
 			if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
654
-				throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
654
+				throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
655 655
 			}
656
-			$values['components'] = implode(',',$properties[$sccs]->getValue());
656
+			$values['components'] = implode(',', $properties[$sccs]->getValue());
657 657
 		}
658
-		$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
658
+		$transp = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
659 659
 		if (isset($properties[$transp])) {
660 660
 			$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
661 661
 		}
662 662
 
663
-		foreach($this->propertyMap as $xmlName=>$dbName) {
663
+		foreach ($this->propertyMap as $xmlName=>$dbName) {
664 664
 			if (isset($properties[$xmlName])) {
665 665
 				$values[$dbName] = $properties[$xmlName];
666 666
 			}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 
669 669
 		$query = $this->db->getQueryBuilder();
670 670
 		$query->insert('calendars');
671
-		foreach($values as $column => $value) {
671
+		foreach ($values as $column => $value) {
672 672
 			$query->setValue($column, $query->createNamedParameter($value));
673 673
 		}
674 674
 		$query->execute();
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 */
703 703
 	function updateCalendar($calendarId, PropPatch $propPatch) {
704 704
 		$supportedProperties = array_keys($this->propertyMap);
705
-		$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
705
+		$supportedProperties[] = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp';
706 706
 
707 707
 		/**
708 708
 		 * @suppress SqlInjectionChecker
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			foreach ($mutations as $propertyName => $propertyValue) {
713 713
 
714 714
 				switch ($propertyName) {
715
-					case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' :
715
+					case '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' :
716 716
 						$fieldName = 'transparent';
717 717
 						$newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
718 718
 						break;
@@ -827,16 +827,16 @@  discard block
 block discarded – undo
827 827
 		$stmt = $query->execute();
828 828
 
829 829
 		$result = [];
830
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
830
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
831 831
 			$result[] = [
832 832
 					'id'           => $row['id'],
833 833
 					'uri'          => $row['uri'],
834 834
 					'lastmodified' => $row['lastmodified'],
835
-					'etag'         => '"' . $row['etag'] . '"',
835
+					'etag'         => '"'.$row['etag'].'"',
836 836
 					'calendarid'   => $row['calendarid'],
837
-					'size'         => (int)$row['size'],
837
+					'size'         => (int) $row['size'],
838 838
 					'component'    => strtolower($row['componenttype']),
839
-					'classification'=> (int)$row['classification']
839
+					'classification'=> (int) $row['classification']
840 840
 			];
841 841
 		}
842 842
 
@@ -869,18 +869,18 @@  discard block
 block discarded – undo
869 869
 		$stmt = $query->execute();
870 870
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
871 871
 
872
-		if(!$row) return null;
872
+		if (!$row) return null;
873 873
 
874 874
 		return [
875 875
 				'id'            => $row['id'],
876 876
 				'uri'           => $row['uri'],
877 877
 				'lastmodified'  => $row['lastmodified'],
878
-				'etag'          => '"' . $row['etag'] . '"',
878
+				'etag'          => '"'.$row['etag'].'"',
879 879
 				'calendarid'    => $row['calendarid'],
880
-				'size'          => (int)$row['size'],
880
+				'size'          => (int) $row['size'],
881 881
 				'calendardata'  => $this->readBlob($row['calendardata']),
882 882
 				'component'     => strtolower($row['componenttype']),
883
-				'classification'=> (int)$row['classification']
883
+				'classification'=> (int) $row['classification']
884 884
 		];
885 885
 	}
886 886
 
@@ -919,12 +919,12 @@  discard block
 block discarded – undo
919 919
 					'id'           => $row['id'],
920 920
 					'uri'          => $row['uri'],
921 921
 					'lastmodified' => $row['lastmodified'],
922
-					'etag'         => '"' . $row['etag'] . '"',
922
+					'etag'         => '"'.$row['etag'].'"',
923 923
 					'calendarid'   => $row['calendarid'],
924
-					'size'         => (int)$row['size'],
924
+					'size'         => (int) $row['size'],
925 925
 					'calendardata' => $this->readBlob($row['calendardata']),
926 926
 					'component'    => strtolower($row['componenttype']),
927
-					'classification' => (int)$row['classification']
927
+					'classification' => (int) $row['classification']
928 928
 				];
929 929
 			}
930 930
 			$result->closeCursor();
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 		));
984 984
 		$this->addChange($calendarId, $objectUri, 1);
985 985
 
986
-		return '"' . $extraData['etag'] . '"';
986
+		return '"'.$extraData['etag'].'"';
987 987
 	}
988 988
 
989 989
 	/**
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 		}
1039 1039
 		$this->addChange($calendarId, $objectUri, 2);
1040 1040
 
1041
-		return '"' . $extraData['etag'] . '"';
1041
+		return '"'.$extraData['etag'].'"';
1042 1042
 	}
1043 1043
 
1044 1044
 	/**
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 		$stmt = $query->execute();
1192 1192
 
1193 1193
 		$result = [];
1194
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1194
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1195 1195
 			if ($requirePostFilter) {
1196 1196
 				if (!$this->validateFilterForObject($row, $filters)) {
1197 1197
 					continue;
@@ -1212,14 +1212,14 @@  discard block
 block discarded – undo
1212 1212
 	 * @param integer|null $offset
1213 1213
 	 * @return array
1214 1214
 	 */
1215
-	public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) {
1215
+	public function calendarSearch($principalUri, array $filters, $limit = null, $offset = null) {
1216 1216
 		$calendars = $this->getCalendarsForUser($principalUri);
1217 1217
 		$ownCalendars = [];
1218 1218
 		$sharedCalendars = [];
1219 1219
 
1220 1220
 		$uriMapper = [];
1221 1221
 
1222
-		foreach($calendars as $calendar) {
1222
+		foreach ($calendars as $calendar) {
1223 1223
 			if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
1224 1224
 				$ownCalendars[] = $calendar['id'];
1225 1225
 			} else {
@@ -1234,11 +1234,11 @@  discard block
 block discarded – undo
1234 1234
 		$query = $this->db->getQueryBuilder();
1235 1235
 		// Calendar id expressions
1236 1236
 		$calendarExpressions = [];
1237
-		foreach($ownCalendars as $id) {
1237
+		foreach ($ownCalendars as $id) {
1238 1238
 			$calendarExpressions[] = $query->expr()
1239 1239
 				->eq('c.calendarid', $query->createNamedParameter($id));
1240 1240
 		}
1241
-		foreach($sharedCalendars as $id) {
1241
+		foreach ($sharedCalendars as $id) {
1242 1242
 			$calendarExpressions[] = $query->expr()->andX(
1243 1243
 				$query->expr()->eq('c.calendarid',
1244 1244
 					$query->createNamedParameter($id)),
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 
1256 1256
 		// Component expressions
1257 1257
 		$compExpressions = [];
1258
-		foreach($filters['comps'] as $comp) {
1258
+		foreach ($filters['comps'] as $comp) {
1259 1259
 			$compExpressions[] = $query->expr()
1260 1260
 				->eq('c.componenttype', $query->createNamedParameter($comp));
1261 1261
 		}
@@ -1274,13 +1274,13 @@  discard block
 block discarded – undo
1274 1274
 		}
1275 1275
 
1276 1276
 		$propParamExpressions = [];
1277
-		foreach($filters['props'] as $prop) {
1277
+		foreach ($filters['props'] as $prop) {
1278 1278
 			$propParamExpressions[] = $query->expr()->andX(
1279 1279
 				$query->expr()->eq('i.name', $query->createNamedParameter($prop)),
1280 1280
 				$query->expr()->isNull('i.parameter')
1281 1281
 			);
1282 1282
 		}
1283
-		foreach($filters['params'] as $param) {
1283
+		foreach ($filters['params'] as $param) {
1284 1284
 			$propParamExpressions[] = $query->expr()->andX(
1285 1285
 				$query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
1286 1286
 				$query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
@@ -1312,8 +1312,8 @@  discard block
 block discarded – undo
1312 1312
 		$stmt = $query->execute();
1313 1313
 
1314 1314
 		$result = [];
1315
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1316
-			$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
1315
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1316
+			$path = $uriMapper[$row['calendarid']].'/'.$row['uri'];
1317 1317
 			if (!in_array($path, $result)) {
1318 1318
 				$result[] = $path;
1319 1319
 			}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		$stmt = $query->execute();
1354 1354
 
1355 1355
 		if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1356
-			return $row['calendaruri'] . '/' . $row['objecturi'];
1356
+			return $row['calendaruri'].'/'.$row['objecturi'];
1357 1357
 		}
1358 1358
 
1359 1359
 		return null;
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 	function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) {
1419 1419
 		// Current synctoken
1420 1420
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
1421
-		$stmt->execute([ $calendarId ]);
1421
+		$stmt->execute([$calendarId]);
1422 1422
 		$currentToken = $stmt->fetchColumn(0);
1423 1423
 
1424 1424
 		if (is_null($currentToken)) {
@@ -1435,8 +1435,8 @@  discard block
 block discarded – undo
1435 1435
 		if ($syncToken) {
1436 1436
 
1437 1437
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`";
1438
-			if ($limit>0) {
1439
-				$query.= " `LIMIT` " . (int)$limit;
1438
+			if ($limit > 0) {
1439
+				$query .= " `LIMIT` ".(int) $limit;
1440 1440
 			}
1441 1441
 
1442 1442
 			// Fetching all changes
@@ -1447,15 +1447,15 @@  discard block
 block discarded – undo
1447 1447
 
1448 1448
 			// This loop ensures that any duplicates are overwritten, only the
1449 1449
 			// last change on a node is relevant.
1450
-			while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1450
+			while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1451 1451
 
1452 1452
 				$changes[$row['uri']] = $row['operation'];
1453 1453
 
1454 1454
 			}
1455 1455
 
1456
-			foreach($changes as $uri => $operation) {
1456
+			foreach ($changes as $uri => $operation) {
1457 1457
 
1458
-				switch($operation) {
1458
+				switch ($operation) {
1459 1459
 					case 1 :
1460 1460
 						$result['added'][] = $uri;
1461 1461
 						break;
@@ -1525,10 +1525,10 @@  discard block
 block discarded – undo
1525 1525
 			->from('calendarsubscriptions')
1526 1526
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
1527 1527
 			->orderBy('calendarorder', 'asc');
1528
-		$stmt =$query->execute();
1528
+		$stmt = $query->execute();
1529 1529
 
1530 1530
 		$subscriptions = [];
1531
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1531
+		while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
1532 1532
 
1533 1533
 			$subscription = [
1534 1534
 				'id'           => $row['id'],
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
 				'source'       => $row['source'],
1538 1538
 				'lastmodified' => $row['lastmodified'],
1539 1539
 
1540
-				'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1540
+				'{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
1541 1541
 			];
1542 1542
 
1543
-			foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1543
+			foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1544 1544
 				if (!is_null($row[$dbName])) {
1545 1545
 					$subscription[$xmlName] = $row[$dbName];
1546 1546
 				}
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
 
1580 1580
 		$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
1581 1581
 
1582
-		foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1582
+		foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
1583 1583
 			if (array_key_exists($xmlName, $properties)) {
1584 1584
 					$values[$dbName] = $properties[$xmlName];
1585 1585
 					if (in_array($dbName, $propertiesBoolean)) {
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 
1631 1631
 			$newValues = [];
1632 1632
 
1633
-			foreach($mutations as $propertyName=>$propertyValue) {
1633
+			foreach ($mutations as $propertyName=>$propertyValue) {
1634 1634
 				if ($propertyName === '{http://calendarserver.org/ns/}source') {
1635 1635
 					$newValues['source'] = $propertyValue->getHref();
1636 1636
 				} else {
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
 			$query = $this->db->getQueryBuilder();
1643 1643
 			$query->update('calendarsubscriptions')
1644 1644
 				->set('lastmodified', $query->createNamedParameter(time()));
1645
-			foreach($newValues as $fieldName=>$value) {
1645
+			foreach ($newValues as $fieldName=>$value) {
1646 1646
 				$query->set($fieldName, $query->createNamedParameter($value));
1647 1647
 			}
1648 1648
 			$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 
1693 1693
 		$row = $stmt->fetch(\PDO::FETCH_ASSOC);
1694 1694
 
1695
-		if(!$row) {
1695
+		if (!$row) {
1696 1696
 			return null;
1697 1697
 		}
1698 1698
 
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 				'uri'          => $row['uri'],
1701 1701
 				'calendardata' => $row['calendardata'],
1702 1702
 				'lastmodified' => $row['lastmodified'],
1703
-				'etag'         => '"' . $row['etag'] . '"',
1704
-				'size'         => (int)$row['size'],
1703
+				'etag'         => '"'.$row['etag'].'"',
1704
+				'size'         => (int) $row['size'],
1705 1705
 		];
1706 1706
 	}
1707 1707
 
@@ -1724,13 +1724,13 @@  discard block
 block discarded – undo
1724 1724
 				->execute();
1725 1725
 
1726 1726
 		$result = [];
1727
-		foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1727
+		foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
1728 1728
 			$result[] = [
1729 1729
 					'calendardata' => $row['calendardata'],
1730 1730
 					'uri'          => $row['uri'],
1731 1731
 					'lastmodified' => $row['lastmodified'],
1732
-					'etag'         => '"' . $row['etag'] . '"',
1733
-					'size'         => (int)$row['size'],
1732
+					'etag'         => '"'.$row['etag'].'"',
1733
+					'size'         => (int) $row['size'],
1734 1734
 			];
1735 1735
 		}
1736 1736
 
@@ -1822,10 +1822,10 @@  discard block
 block discarded – undo
1822 1822
 		$lastOccurrence = null;
1823 1823
 		$uid = null;
1824 1824
 		$classification = self::CLASSIFICATION_PUBLIC;
1825
-		foreach($vObject->getComponents() as $component) {
1826
-			if ($component->name!=='VTIMEZONE') {
1825
+		foreach ($vObject->getComponents() as $component) {
1826
+			if ($component->name !== 'VTIMEZONE') {
1827 1827
 				$componentType = $component->name;
1828
-				$uid = (string)$component->UID;
1828
+				$uid = (string) $component->UID;
1829 1829
 				break;
1830 1830
 			}
1831 1831
 		}
@@ -1850,13 +1850,13 @@  discard block
 block discarded – undo
1850 1850
 					$lastOccurrence = $firstOccurrence;
1851 1851
 				}
1852 1852
 			} else {
1853
-				$it = new EventIterator($vObject, (string)$component->UID);
1853
+				$it = new EventIterator($vObject, (string) $component->UID);
1854 1854
 				$maxDate = new \DateTime(self::MAX_DATE);
1855 1855
 				if ($it->isInfinite()) {
1856 1856
 					$lastOccurrence = $maxDate->getTimestamp();
1857 1857
 				} else {
1858 1858
 					$end = $it->getDtEnd();
1859
-					while($it->valid() && $end < $maxDate) {
1859
+					while ($it->valid() && $end < $maxDate) {
1860 1860
 						$end = $it->getDtEnd();
1861 1861
 						$it->next();
1862 1862
 
@@ -2065,8 +2065,8 @@  discard block
 block discarded – undo
2065 2065
 	{
2066 2066
 		$query = $this->db->getQueryBuilder();
2067 2067
 		$query->update('calendars')
2068
-			->set('principaluri', 'principals/users/' . $userDestination)
2069
-			->where($query->expr()->eq('principaluri', $query->createNamedParameter('principals/users/'. $userOrigin)))
2068
+			->set('principaluri', 'principals/users/'.$userDestination)
2069
+			->where($query->expr()->eq('principaluri', $query->createNamedParameter('principals/users/'.$userOrigin)))
2070 2070
 			->andWhere($query->expr()->eq('uri', $query->createNamedParameter($uri)))
2071 2071
 			->execute();
2072 2072
 	}
@@ -2113,10 +2113,10 @@  discard block
 block discarded – undo
2113 2113
 		$result->closeCursor();
2114 2114
 
2115 2115
 		if (!isset($objectIds['id'])) {
2116
-			throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2116
+			throw new \InvalidArgumentException('Calendarobject does not exists: '.$uri);
2117 2117
 		}
2118 2118
 
2119
-		return (int)$objectIds['id'];
2119
+		return (int) $objectIds['id'];
2120 2120
 	}
2121 2121
 
2122 2122
 	private function convertPrincipal($principalUri, $toV2) {
@@ -2131,8 +2131,8 @@  discard block
 block discarded – undo
2131 2131
 	}
2132 2132
 
2133 2133
 	private function addOwnerPrincipal(&$calendarInfo) {
2134
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
2135
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
2134
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
2135
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
2136 2136
 		if (isset($calendarInfo[$ownerPrincipalKey])) {
2137 2137
 			$uri = $calendarInfo[$ownerPrincipalKey];
2138 2138
 		} else {
Please login to merge, or discard this patch.
apps/dav/lib/Command/MoveCalendar.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 		$name = $input->getArgument('name');
104 104
 		$caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $random, $dispatcher);
105 105
 
106
-		$calendar = $caldav->getCalendarByUri("principals/users/" . $userOrigin, $name);
106
+		$calendar = $caldav->getCalendarByUri("principals/users/".$userOrigin, $name);
107 107
 		if (null === $calendar) {
108 108
 			throw new \InvalidArgumentException("User <$userOrigin> has no calendar named <$name>.");
109 109
 		}
110 110
 
111
-		if (null !== $caldav->getCalendarByUri("principals/users/" . $userDestination, $name)) {
111
+		if (null !== $caldav->getCalendarByUri("principals/users/".$userDestination, $name)) {
112 112
 			throw new \InvalidArgumentException("User <$userDestination> already has a calendar named <$name>.");
113 113
 		}
114 114
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			list($prefix, $group) = str_split($share['href'], 28);
122 122
 			if ('principal:principals/groups/' === $prefix && !$this->groupManager->isInGroup($userDestination, $group)) {
123 123
 				if ($input->getOption('force')) {
124
-					$caldav->updateShares(new Calendar($caldav, $calendar, $this->l10n), [], ['href' => 'principal:principals/groups/' . $group]);
124
+					$caldav->updateShares(new Calendar($caldav, $calendar, $this->l10n), [], ['href' => 'principal:principals/groups/'.$group]);
125 125
 				} else {
126 126
 					throw new \InvalidArgumentException("User <$userDestination> is not part of the group <$group> with which the calendar <$name> was shared. You may use -f to move the calendar while deleting this share.");
127 127
 				}
Please login to merge, or discard this patch.