@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | ->from('addressbooks') |
| 115 | 115 | ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); |
| 116 | 116 | |
| 117 | - return (int)$query->execute()->fetchColumn(); |
|
| 117 | + return (int) $query->execute()->fetchColumn(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | $addressBooks = []; |
| 146 | 146 | |
| 147 | 147 | $result = $query->execute(); |
| 148 | - while($row = $result->fetch()) { |
|
| 148 | + while ($row = $result->fetch()) { |
|
| 149 | 149 | $addressBooks[$row['id']] = [ |
| 150 | 150 | 'id' => $row['id'], |
| 151 | 151 | 'uri' => $row['uri'], |
| 152 | 152 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
| 153 | 153 | '{DAV:}displayname' => $row['displayname'], |
| 154 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 154 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 155 | 155 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 156 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 156 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 157 | 157 | ]; |
| 158 | 158 | |
| 159 | 159 | $this->addOwnerPrincipal($addressBooks[$row['id']]); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $principals = array_map(function($principal) { |
| 166 | 166 | return urldecode($principal); |
| 167 | 167 | }, $principals); |
| 168 | - $principals[]= $principalUri; |
|
| 168 | + $principals[] = $principalUri; |
|
| 169 | 169 | |
| 170 | 170 | $query = $this->db->getQueryBuilder(); |
| 171 | 171 | $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access']) |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | ->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY) |
| 178 | 178 | ->execute(); |
| 179 | 179 | |
| 180 | - $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
| 181 | - while($row = $result->fetch()) { |
|
| 180 | + $readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only'; |
|
| 181 | + while ($row = $result->fetch()) { |
|
| 182 | 182 | if ($row['principaluri'] === $principalUri) { |
| 183 | 183 | continue; |
| 184 | 184 | } |
@@ -197,18 +197,18 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | list(, $name) = \Sabre\Uri\split($row['principaluri']); |
| 200 | - $uri = $row['uri'] . '_shared_by_' . $name; |
|
| 201 | - $displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')'; |
|
| 200 | + $uri = $row['uri'].'_shared_by_'.$name; |
|
| 201 | + $displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')'; |
|
| 202 | 202 | |
| 203 | 203 | $addressBooks[$row['id']] = [ |
| 204 | 204 | 'id' => $row['id'], |
| 205 | 205 | 'uri' => $uri, |
| 206 | 206 | 'principaluri' => $principalUriOriginal, |
| 207 | 207 | '{DAV:}displayname' => $displayName, |
| 208 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 208 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 209 | 209 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 210 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 211 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], |
|
| 210 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 211 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'], |
|
| 212 | 212 | $readOnlyPropertyName => $readOnly, |
| 213 | 213 | ]; |
| 214 | 214 | |
@@ -229,15 +229,15 @@ discard block |
||
| 229 | 229 | $addressBooks = []; |
| 230 | 230 | |
| 231 | 231 | $result = $query->execute(); |
| 232 | - while($row = $result->fetch()) { |
|
| 232 | + while ($row = $result->fetch()) { |
|
| 233 | 233 | $addressBooks[$row['id']] = [ |
| 234 | 234 | 'id' => $row['id'], |
| 235 | 235 | 'uri' => $row['uri'], |
| 236 | 236 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
| 237 | 237 | '{DAV:}displayname' => $row['displayname'], |
| 238 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 238 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 239 | 239 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 240 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 240 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 241 | 241 | ]; |
| 242 | 242 | |
| 243 | 243 | $this->addOwnerPrincipal($addressBooks[$row['id']]); |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | 'uri' => $row['uri'], |
| 283 | 283 | 'principaluri' => $row['principaluri'], |
| 284 | 284 | '{DAV:}displayname' => $row['displayname'], |
| 285 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 285 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 286 | 286 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 287 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 287 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 288 | 288 | ]; |
| 289 | 289 | |
| 290 | 290 | $this->addOwnerPrincipal($addressBook); |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | 'uri' => $row['uri'], |
| 317 | 317 | 'principaluri' => $row['principaluri'], |
| 318 | 318 | '{DAV:}displayname' => $row['displayname'], |
| 319 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 319 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 320 | 320 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 321 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 321 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 322 | 322 | ]; |
| 323 | 323 | |
| 324 | 324 | $this->addOwnerPrincipal($addressBook); |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { |
| 346 | 346 | $supportedProperties = [ |
| 347 | 347 | '{DAV:}displayname', |
| 348 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description', |
|
| 348 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description', |
|
| 349 | 349 | ]; |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | $propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) { |
| 355 | 355 | |
| 356 | 356 | $updates = []; |
| 357 | - foreach($mutations as $property=>$newValue) { |
|
| 357 | + foreach ($mutations as $property=>$newValue) { |
|
| 358 | 358 | |
| 359 | - switch($property) { |
|
| 359 | + switch ($property) { |
|
| 360 | 360 | case '{DAV:}displayname' : |
| 361 | 361 | $updates['displayname'] = $newValue; |
| 362 | 362 | break; |
| 363 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
| 363 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
| 364 | 364 | $updates['description'] = $newValue; |
| 365 | 365 | break; |
| 366 | 366 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | $query = $this->db->getQueryBuilder(); |
| 369 | 369 | $query->update('addressbooks'); |
| 370 | 370 | |
| 371 | - foreach($updates as $key=>$value) { |
|
| 371 | + foreach ($updates as $key=>$value) { |
|
| 372 | 372 | $query->set($key, $query->createNamedParameter($value)); |
| 373 | 373 | } |
| 374 | 374 | $query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId))) |
@@ -399,24 +399,24 @@ discard block |
||
| 399 | 399 | 'synctoken' => 1 |
| 400 | 400 | ]; |
| 401 | 401 | |
| 402 | - foreach($properties as $property=>$newValue) { |
|
| 402 | + foreach ($properties as $property=>$newValue) { |
|
| 403 | 403 | |
| 404 | - switch($property) { |
|
| 404 | + switch ($property) { |
|
| 405 | 405 | case '{DAV:}displayname' : |
| 406 | 406 | $values['displayname'] = $newValue; |
| 407 | 407 | break; |
| 408 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
| 408 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
| 409 | 409 | $values['description'] = $newValue; |
| 410 | 410 | break; |
| 411 | 411 | default : |
| 412 | - throw new BadRequest('Unknown property: ' . $property); |
|
| 412 | + throw new BadRequest('Unknown property: '.$property); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Fallback to make sure the displayname is set. Some clients may refuse |
| 418 | 418 | // to work with addressbooks not having a displayname. |
| 419 | - if(is_null($values['displayname'])) { |
|
| 419 | + if (is_null($values['displayname'])) { |
|
| 420 | 420 | $values['displayname'] = $url; |
| 421 | 421 | } |
| 422 | 422 | |
@@ -494,8 +494,8 @@ discard block |
||
| 494 | 494 | $cards = []; |
| 495 | 495 | |
| 496 | 496 | $result = $query->execute(); |
| 497 | - while($row = $result->fetch()) { |
|
| 498 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 497 | + while ($row = $result->fetch()) { |
|
| 498 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 499 | 499 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 500 | 500 | $cards[] = $row; |
| 501 | 501 | } |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | if (!$row) { |
| 530 | 530 | return false; |
| 531 | 531 | } |
| 532 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 532 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 533 | 533 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 534 | 534 | |
| 535 | 535 | return $row; |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | $result = $query->execute(); |
| 567 | 567 | |
| 568 | 568 | while ($row = $result->fetch()) { |
| 569 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 569 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 570 | 570 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 571 | 571 | $cards[] = $row; |
| 572 | 572 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | 'cardUri' => $cardUri, |
| 625 | 625 | 'cardData' => $cardData])); |
| 626 | 626 | |
| 627 | - return '"' . $etag . '"'; |
|
| 627 | + return '"'.$etag.'"'; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | 'cardUri' => $cardUri, |
| 675 | 675 | 'cardData' => $cardData])); |
| 676 | 676 | |
| 677 | - return '"' . $etag . '"'; |
|
| 677 | + return '"'.$etag.'"'; |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { |
| 773 | 773 | // Current synctoken |
| 774 | 774 | $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?'); |
| 775 | - $stmt->execute([ $addressBookId ]); |
|
| 775 | + $stmt->execute([$addressBookId]); |
|
| 776 | 776 | $currentToken = $stmt->fetchColumn(0); |
| 777 | 777 | |
| 778 | 778 | if (is_null($currentToken)) return null; |
@@ -787,8 +787,8 @@ discard block |
||
| 787 | 787 | if ($syncToken) { |
| 788 | 788 | |
| 789 | 789 | $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`"; |
| 790 | - if ($limit>0) { |
|
| 791 | - $query .= " `LIMIT` " . (int)$limit; |
|
| 790 | + if ($limit > 0) { |
|
| 791 | + $query .= " `LIMIT` ".(int) $limit; |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | // Fetching all changes |
@@ -799,15 +799,15 @@ discard block |
||
| 799 | 799 | |
| 800 | 800 | // This loop ensures that any duplicates are overwritten, only the |
| 801 | 801 | // last change on a node is relevant. |
| 802 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 802 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 803 | 803 | |
| 804 | 804 | $changes[$row['uri']] = $row['operation']; |
| 805 | 805 | |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - foreach($changes as $uri => $operation) { |
|
| 808 | + foreach ($changes as $uri => $operation) { |
|
| 809 | 809 | |
| 810 | - switch($operation) { |
|
| 810 | + switch ($operation) { |
|
| 811 | 811 | case 1: |
| 812 | 812 | $result['added'][] = $uri; |
| 813 | 813 | break; |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | |
| 894 | 894 | // No need for like when the pattern is empty |
| 895 | 895 | if ('' !== $pattern) { |
| 896 | - $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); |
|
| 896 | + $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%'))); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | $query->select('c.carddata', 'c.uri')->from($this->dbCardsTable, 'c') |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | $result->closeCursor(); |
| 947 | 947 | |
| 948 | 948 | if (!isset($uri['uri'])) { |
| 949 | - throw new \InvalidArgumentException('Card does not exists: ' . $id); |
|
| 949 | + throw new \InvalidArgumentException('Card does not exists: '.$id); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | return $uri['uri']; |
@@ -1018,11 +1018,11 @@ discard block |
||
| 1018 | 1018 | ); |
| 1019 | 1019 | |
| 1020 | 1020 | foreach ($vCard->children() as $property) { |
| 1021 | - if(!in_array($property->name, self::$indexProperties)) { |
|
| 1021 | + if (!in_array($property->name, self::$indexProperties)) { |
|
| 1022 | 1022 | continue; |
| 1023 | 1023 | } |
| 1024 | 1024 | $preferred = 0; |
| 1025 | - foreach($property->parameters as $parameter) { |
|
| 1025 | + foreach ($property->parameters as $parameter) { |
|
| 1026 | 1026 | if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') { |
| 1027 | 1027 | $preferred = 1; |
| 1028 | 1028 | break; |
@@ -1077,10 +1077,10 @@ discard block |
||
| 1077 | 1077 | $result->closeCursor(); |
| 1078 | 1078 | |
| 1079 | 1079 | if (!isset($cardIds['id'])) { |
| 1080 | - throw new \InvalidArgumentException('Card does not exists: ' . $uri); |
|
| 1080 | + throw new \InvalidArgumentException('Card does not exists: '.$uri); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - return (int)$cardIds['id']; |
|
| 1083 | + return (int) $cardIds['id']; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1105,8 +1105,8 @@ discard block |
||
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | private function addOwnerPrincipal(&$addressbookInfo) { |
| 1108 | - $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'; |
|
| 1109 | - $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'; |
|
| 1108 | + $ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal'; |
|
| 1109 | + $displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname'; |
|
| 1110 | 1110 | if (isset($addressbookInfo[$ownerPrincipalKey])) { |
| 1111 | 1111 | $uri = $addressbookInfo[$ownerPrincipalKey]; |
| 1112 | 1112 | } else { |