@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ->from('addressbooks') |
122 | 122 | ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); |
123 | 123 | |
124 | - return (int)$query->execute()->fetchColumn(); |
|
124 | + return (int) $query->execute()->fetchColumn(); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | $addressBooks = []; |
153 | 153 | |
154 | 154 | $result = $query->execute(); |
155 | - while($row = $result->fetch()) { |
|
155 | + while ($row = $result->fetch()) { |
|
156 | 156 | $addressBooks[$row['id']] = [ |
157 | 157 | 'id' => $row['id'], |
158 | 158 | 'uri' => $row['uri'], |
159 | 159 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
160 | 160 | '{DAV:}displayname' => $row['displayname'], |
161 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
161 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
162 | 162 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
163 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
163 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
164 | 164 | ]; |
165 | 165 | |
166 | 166 | $this->addOwnerPrincipal($addressBooks[$row['id']]); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $principals = array_map(function($principal) { |
175 | 175 | return urldecode($principal); |
176 | 176 | }, $principals); |
177 | - $principals[]= $principalUri; |
|
177 | + $principals[] = $principalUri; |
|
178 | 178 | |
179 | 179 | $query = $this->db->getQueryBuilder(); |
180 | 180 | $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access']) |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | ->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY) |
187 | 187 | ->execute(); |
188 | 188 | |
189 | - $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
190 | - while($row = $result->fetch()) { |
|
189 | + $readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only'; |
|
190 | + while ($row = $result->fetch()) { |
|
191 | 191 | if ($row['principaluri'] === $principalUri) { |
192 | 192 | continue; |
193 | 193 | } |
@@ -206,18 +206,18 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | list(, $name) = \Sabre\Uri\split($row['principaluri']); |
209 | - $uri = $row['uri'] . '_shared_by_' . $name; |
|
210 | - $displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')'; |
|
209 | + $uri = $row['uri'].'_shared_by_'.$name; |
|
210 | + $displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')'; |
|
211 | 211 | |
212 | 212 | $addressBooks[$row['id']] = [ |
213 | 213 | 'id' => $row['id'], |
214 | 214 | 'uri' => $uri, |
215 | 215 | 'principaluri' => $principalUriOriginal, |
216 | 216 | '{DAV:}displayname' => $displayName, |
217 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
217 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
218 | 218 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
219 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
220 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], |
|
219 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
220 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'], |
|
221 | 221 | $readOnlyPropertyName => $readOnly, |
222 | 222 | ]; |
223 | 223 | |
@@ -238,15 +238,15 @@ discard block |
||
238 | 238 | $addressBooks = []; |
239 | 239 | |
240 | 240 | $result = $query->execute(); |
241 | - while($row = $result->fetch()) { |
|
241 | + while ($row = $result->fetch()) { |
|
242 | 242 | $addressBooks[$row['id']] = [ |
243 | 243 | 'id' => $row['id'], |
244 | 244 | 'uri' => $row['uri'], |
245 | 245 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
246 | 246 | '{DAV:}displayname' => $row['displayname'], |
247 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
247 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
248 | 248 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
249 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
249 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
250 | 250 | ]; |
251 | 251 | |
252 | 252 | $this->addOwnerPrincipal($addressBooks[$row['id']]); |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | 'uri' => $row['uri'], |
292 | 292 | 'principaluri' => $row['principaluri'], |
293 | 293 | '{DAV:}displayname' => $row['displayname'], |
294 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
294 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
295 | 295 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
296 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
296 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
297 | 297 | ]; |
298 | 298 | |
299 | 299 | $this->addOwnerPrincipal($addressBook); |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | 'uri' => $row['uri'], |
326 | 326 | 'principaluri' => $row['principaluri'], |
327 | 327 | '{DAV:}displayname' => $row['displayname'], |
328 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
328 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
329 | 329 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
330 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
330 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
331 | 331 | ]; |
332 | 332 | |
333 | 333 | $this->addOwnerPrincipal($addressBook); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { |
355 | 355 | $supportedProperties = [ |
356 | 356 | '{DAV:}displayname', |
357 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description', |
|
357 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description', |
|
358 | 358 | ]; |
359 | 359 | |
360 | 360 | /** |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | $propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) { |
364 | 364 | |
365 | 365 | $updates = []; |
366 | - foreach($mutations as $property=>$newValue) { |
|
366 | + foreach ($mutations as $property=>$newValue) { |
|
367 | 367 | |
368 | - switch($property) { |
|
368 | + switch ($property) { |
|
369 | 369 | case '{DAV:}displayname' : |
370 | 370 | $updates['displayname'] = $newValue; |
371 | 371 | break; |
372 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
372 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
373 | 373 | $updates['description'] = $newValue; |
374 | 374 | break; |
375 | 375 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $query = $this->db->getQueryBuilder(); |
378 | 378 | $query->update('addressbooks'); |
379 | 379 | |
380 | - foreach($updates as $key=>$value) { |
|
380 | + foreach ($updates as $key=>$value) { |
|
381 | 381 | $query->set($key, $query->createNamedParameter($value)); |
382 | 382 | } |
383 | 383 | $query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId))) |
@@ -408,24 +408,24 @@ discard block |
||
408 | 408 | 'synctoken' => 1 |
409 | 409 | ]; |
410 | 410 | |
411 | - foreach($properties as $property=>$newValue) { |
|
411 | + foreach ($properties as $property=>$newValue) { |
|
412 | 412 | |
413 | - switch($property) { |
|
413 | + switch ($property) { |
|
414 | 414 | case '{DAV:}displayname' : |
415 | 415 | $values['displayname'] = $newValue; |
416 | 416 | break; |
417 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
417 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
418 | 418 | $values['description'] = $newValue; |
419 | 419 | break; |
420 | 420 | default : |
421 | - throw new BadRequest('Unknown property: ' . $property); |
|
421 | + throw new BadRequest('Unknown property: '.$property); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | } |
425 | 425 | |
426 | 426 | // Fallback to make sure the displayname is set. Some clients may refuse |
427 | 427 | // to work with addressbooks not having a displayname. |
428 | - if(is_null($values['displayname'])) { |
|
428 | + if (is_null($values['displayname'])) { |
|
429 | 429 | $values['displayname'] = $url; |
430 | 430 | } |
431 | 431 | |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | $cards = []; |
504 | 504 | |
505 | 505 | $result = $query->execute(); |
506 | - while($row = $result->fetch()) { |
|
507 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
506 | + while ($row = $result->fetch()) { |
|
507 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
508 | 508 | $row['carddata'] = $this->readBlob($row['carddata']); |
509 | 509 | $cards[] = $row; |
510 | 510 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | if (!$row) { |
539 | 539 | return false; |
540 | 540 | } |
541 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
541 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
542 | 542 | $row['carddata'] = $this->readBlob($row['carddata']); |
543 | 543 | |
544 | 544 | return $row; |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $result = $query->execute(); |
576 | 576 | |
577 | 577 | while ($row = $result->fetch()) { |
578 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
578 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
579 | 579 | $row['carddata'] = $this->readBlob($row['carddata']); |
580 | 580 | $cards[] = $row; |
581 | 581 | } |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | 'cardUri' => $cardUri, |
649 | 649 | 'cardData' => $cardData])); |
650 | 650 | |
651 | - return '"' . $etag . '"'; |
|
651 | + return '"'.$etag.'"'; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'cardUri' => $cardUri, |
701 | 701 | 'cardData' => $cardData])); |
702 | 702 | |
703 | - return '"' . $etag . '"'; |
|
703 | + return '"'.$etag.'"'; |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { |
799 | 799 | // Current synctoken |
800 | 800 | $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?'); |
801 | - $stmt->execute([ $addressBookId ]); |
|
801 | + $stmt->execute([$addressBookId]); |
|
802 | 802 | $currentToken = $stmt->fetchColumn(0); |
803 | 803 | |
804 | 804 | if (is_null($currentToken)) return null; |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | if ($syncToken) { |
814 | 814 | |
815 | 815 | $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`"; |
816 | - if ($limit>0) { |
|
817 | - $query .= " LIMIT " . (int)$limit; |
|
816 | + if ($limit > 0) { |
|
817 | + $query .= " LIMIT ".(int) $limit; |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | // Fetching all changes |
@@ -825,15 +825,15 @@ discard block |
||
825 | 825 | |
826 | 826 | // This loop ensures that any duplicates are overwritten, only the |
827 | 827 | // last change on a node is relevant. |
828 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
828 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
829 | 829 | |
830 | 830 | $changes[$row['uri']] = $row['operation']; |
831 | 831 | |
832 | 832 | } |
833 | 833 | |
834 | - foreach($changes as $uri => $operation) { |
|
834 | + foreach ($changes as $uri => $operation) { |
|
835 | 835 | |
836 | - switch($operation) { |
|
836 | + switch ($operation) { |
|
837 | 837 | case 1: |
838 | 838 | $result['added'][] = $uri; |
839 | 839 | break; |
@@ -921,10 +921,10 @@ discard block |
||
921 | 921 | |
922 | 922 | // No need for like when the pattern is empty |
923 | 923 | if ('' !== $pattern) { |
924 | - if(\array_key_exists('escape_like_param', $options) && $options['escape_like_param'] === false) { |
|
924 | + if (\array_key_exists('escape_like_param', $options) && $options['escape_like_param'] === false) { |
|
925 | 925 | $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter($pattern))); |
926 | 926 | } else { |
927 | - $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); |
|
927 | + $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%'))); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | $result->closeCursor(); |
979 | 979 | |
980 | 980 | if (!isset($uri['uri'])) { |
981 | - throw new \InvalidArgumentException('Card does not exists: ' . $id); |
|
981 | + throw new \InvalidArgumentException('Card does not exists: '.$id); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | return $uri['uri']; |
@@ -1050,11 +1050,11 @@ discard block |
||
1050 | 1050 | ); |
1051 | 1051 | |
1052 | 1052 | foreach ($vCard->children() as $property) { |
1053 | - if(!in_array($property->name, self::$indexProperties)) { |
|
1053 | + if (!in_array($property->name, self::$indexProperties)) { |
|
1054 | 1054 | continue; |
1055 | 1055 | } |
1056 | 1056 | $preferred = 0; |
1057 | - foreach($property->parameters as $parameter) { |
|
1057 | + foreach ($property->parameters as $parameter) { |
|
1058 | 1058 | if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') { |
1059 | 1059 | $preferred = 1; |
1060 | 1060 | break; |
@@ -1109,10 +1109,10 @@ discard block |
||
1109 | 1109 | $result->closeCursor(); |
1110 | 1110 | |
1111 | 1111 | if (!isset($cardIds['id'])) { |
1112 | - throw new \InvalidArgumentException('Card does not exists: ' . $uri); |
|
1112 | + throw new \InvalidArgumentException('Card does not exists: '.$uri); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | - return (int)$cardIds['id']; |
|
1115 | + return (int) $cardIds['id']; |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | /** |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | private function addOwnerPrincipal(&$addressbookInfo) { |
1140 | - $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'; |
|
1141 | - $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'; |
|
1140 | + $ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal'; |
|
1141 | + $displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname'; |
|
1142 | 1142 | if (isset($addressbookInfo[$ownerPrincipalKey])) { |
1143 | 1143 | $uri = $addressbookInfo[$ownerPrincipalKey]; |
1144 | 1144 | } else { |