Passed
Push — master ( fb69d6...db782f )
by Morris
22:51 queued 08:21
created
apps/dav/lib/CardDAV/CardDavBackend.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 			->from('addressbooks')
125 125
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
126 126
 
127
-		return (int)$query->execute()->fetchColumn();
127
+		return (int) $query->execute()->fetchColumn();
128 128
 	}
129 129
 
130 130
 	/**
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 				'uri' => $row['uri'],
162 162
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
163 163
 				'{DAV:}displayname' => $row['displayname'],
164
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
164
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
165 165
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
166
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
166
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
167 167
 			];
168 168
 
169 169
 			$this->addOwnerPrincipal($addressBooks[$row['id']]);
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
175 175
 		$principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
176 176
 
177
-		$principals = array_map(function ($principal) {
177
+		$principals = array_map(function($principal) {
178 178
 			return urldecode($principal);
179 179
 		}, $principals);
180
-		$principals[]= $principalUri;
180
+		$principals[] = $principalUri;
181 181
 
182 182
 		$query = $this->db->getQueryBuilder();
183 183
 		$result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
190 190
 			->execute();
191 191
 
192
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
192
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
193 193
 		while ($row = $result->fetch()) {
194 194
 			if ($row['principaluri'] === $principalUri) {
195 195
 				continue;
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
 			}
210 210
 
211 211
 			list(, $name) = \Sabre\Uri\split($row['principaluri']);
212
-			$uri = $row['uri'] . '_shared_by_' . $name;
213
-			$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
212
+			$uri = $row['uri'].'_shared_by_'.$name;
213
+			$displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
214 214
 
215 215
 			$addressBooks[$row['id']] = [
216 216
 				'id'  => $row['id'],
217 217
 				'uri' => $uri,
218 218
 				'principaluri' => $principalUriOriginal,
219 219
 				'{DAV:}displayname' => $displayName,
220
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
220
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
221 221
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
222
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
223
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
222
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
223
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'],
224 224
 				$readOnlyPropertyName => $readOnly,
225 225
 			];
226 226
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 				'uri' => $row['uri'],
248 248
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
249 249
 				'{DAV:}displayname' => $row['displayname'],
250
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
250
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
251 251
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
252
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
252
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
253 253
 			];
254 254
 
255 255
 			$this->addOwnerPrincipal($addressBooks[$row['id']]);
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 			'uri' => $row['uri'],
295 295
 			'principaluri' => $row['principaluri'],
296 296
 			'{DAV:}displayname' => $row['displayname'],
297
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
297
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
298 298
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
299
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
299
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
300 300
 		];
301 301
 
302 302
 		$this->addOwnerPrincipal($addressBook);
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 			'uri' => $row['uri'],
329 329
 			'principaluri' => $row['principaluri'],
330 330
 			'{DAV:}displayname' => $row['displayname'],
331
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
331
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
332 332
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
333
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
333
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
334 334
 		];
335 335
 
336 336
 		$this->addOwnerPrincipal($addressBook);
@@ -357,20 +357,20 @@  discard block
 block discarded – undo
357 357
 	public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
358 358
 		$supportedProperties = [
359 359
 			'{DAV:}displayname',
360
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description',
360
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description',
361 361
 		];
362 362
 
363 363
 		/**
364 364
 		 * @suppress SqlInjectionChecker
365 365
 		 */
366
-		$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
366
+		$propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) {
367 367
 			$updates = [];
368 368
 			foreach ($mutations as $property=>$newValue) {
369 369
 				switch ($property) {
370 370
 					case '{DAV:}displayname':
371 371
 						$updates['displayname'] = $newValue;
372 372
 						break;
373
-					case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
373
+					case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
374 374
 						$updates['description'] = $newValue;
375 375
 						break;
376 376
 				}
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 				case '{DAV:}displayname':
414 414
 					$values['displayname'] = $newValue;
415 415
 					break;
416
-				case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
416
+				case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
417 417
 					$values['description'] = $newValue;
418 418
 					break;
419 419
 				default:
420
-					throw new BadRequest('Unknown property: ' . $property);
420
+					throw new BadRequest('Unknown property: '.$property);
421 421
 			}
422 422
 		}
423 423
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
 		$result = $query->execute();
503 503
 		while ($row = $result->fetch()) {
504
-			$row['etag'] = '"' . $row['etag'] . '"';
504
+			$row['etag'] = '"'.$row['etag'].'"';
505 505
 
506 506
 			$modified = false;
507 507
 			$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		if (!$row) {
542 542
 			return false;
543 543
 		}
544
-		$row['etag'] = '"' . $row['etag'] . '"';
544
+		$row['etag'] = '"'.$row['etag'].'"';
545 545
 
546 546
 		$modified = false;
547 547
 		$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			$result = $query->execute();
584 584
 
585 585
 			while ($row = $result->fetch()) {
586
-				$row['etag'] = '"' . $row['etag'] . '"';
586
+				$row['etag'] = '"'.$row['etag'].'"';
587 587
 
588 588
 				$modified = false;
589 589
 				$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 				'cardUri' => $cardUri,
663 663
 				'cardData' => $cardData]));
664 664
 
665
-		return '"' . $etag . '"';
665
+		return '"'.$etag.'"';
666 666
 	}
667 667
 
668 668
 	/**
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 				'cardUri' => $cardUri,
714 714
 				'cardData' => $cardData]));
715 715
 
716
-		return '"' . $etag . '"';
716
+		return '"'.$etag.'"';
717 717
 	}
718 718
 
719 719
 	/**
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 	public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) {
812 812
 		// Current synctoken
813 813
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?');
814
-		$stmt->execute([ $addressBookId ]);
814
+		$stmt->execute([$addressBookId]);
815 815
 		$currentToken = $stmt->fetchColumn(0);
816 816
 
817 817
 		if (is_null($currentToken)) {
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 
828 828
 		if ($syncToken) {
829 829
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
830
-			if ($limit>0) {
831
-				$query .= " LIMIT " . (int)$limit;
830
+			if ($limit > 0) {
831
+				$query .= " LIMIT ".(int) $limit;
832 832
 			}
833 833
 
834 834
 			// Fetching all changes
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 	 * @param bool $modified
896 896
 	 * @return string
897 897
 	 */
898
-	private function readBlob($cardData, &$modified=false) {
898
+	private function readBlob($cardData, &$modified = false) {
899 899
 		if (is_resource($cardData)) {
900 900
 			$cardData = stream_get_contents($cardData);
901 901
 		}
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 			if (!$escapePattern) {
984 984
 				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern)));
985 985
 			} else {
986
-				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
986
+				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%')));
987 987
 			}
988 988
 		}
989 989
 
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 		$result = $query2->execute();
998 998
 		$matches = $result->fetchAll();
999 999
 		$result->closeCursor();
1000
-		$matches = array_map(function ($match) {
1000
+		$matches = array_map(function($match) {
1001 1001
 			return (int) $match['cardid'];
1002 1002
 		}, $matches);
1003 1003
 
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 
1012 1012
 		$result->closeCursor();
1013 1013
 
1014
-		return array_map(function ($array) {
1014
+		return array_map(function($array) {
1015 1015
 			$modified = false;
1016 1016
 			$array['carddata'] = $this->readBlob($array['carddata'], $modified);
1017 1017
 			if ($modified) {
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 		$result->closeCursor();
1058 1058
 
1059 1059
 		if (!isset($uri['uri'])) {
1060
-			throw new \InvalidArgumentException('Card does not exists: ' . $id);
1060
+			throw new \InvalidArgumentException('Card does not exists: '.$id);
1061 1061
 		}
1062 1062
 
1063 1063
 		return $uri['uri'];
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 
1083 1083
 		if (is_array($contact)) {
1084 1084
 			$modified = false;
1085
-			$contact['etag'] = '"' . $contact['etag'] . '"';
1085
+			$contact['etag'] = '"'.$contact['etag'].'"';
1086 1086
 			$contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
1087 1087
 			if ($modified) {
1088 1088
 				$contact['size'] = strlen($contact['carddata']);
@@ -1195,10 +1195,10 @@  discard block
 block discarded – undo
1195 1195
 		$result->closeCursor();
1196 1196
 
1197 1197
 		if (!isset($cardIds['id'])) {
1198
-			throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1198
+			throw new \InvalidArgumentException('Card does not exists: '.$uri);
1199 1199
 		}
1200 1200
 
1201
-		return (int)$cardIds['id'];
1201
+		return (int) $cardIds['id'];
1202 1202
 	}
1203 1203
 
1204 1204
 	/**
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
 	}
1224 1224
 
1225 1225
 	private function addOwnerPrincipal(&$addressbookInfo) {
1226
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
1227
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
1226
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
1227
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
1228 1228
 		if (isset($addressbookInfo[$ownerPrincipalKey])) {
1229 1229
 			$uri = $addressbookInfo[$ownerPrincipalKey];
1230 1230
 		} else {
Please login to merge, or discard this patch.