@@ -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,22 +145,22 @@ 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 | $result->closeCursor(); |
| 160 | 160 | |
| 161 | 161 | // query for shared calendars |
| 162 | 162 | $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); |
| 163 | - $principals[]= $principalUri; |
|
| 163 | + $principals[] = $principalUri; |
|
| 164 | 164 | |
| 165 | 165 | $query = $this->db->getQueryBuilder(); |
| 166 | 166 | $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access']) |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | ->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY) |
| 173 | 173 | ->execute(); |
| 174 | 174 | |
| 175 | - $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
| 176 | - while($row = $result->fetch()) { |
|
| 175 | + $readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only'; |
|
| 176 | + while ($row = $result->fetch()) { |
|
| 177 | 177 | $readOnly = (int) $row['access'] === Backend::ACCESS_READ; |
| 178 | 178 | if (isset($addressBooks[$row['id']])) { |
| 179 | 179 | if ($readOnly) { |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | list(, $name) = URLUtil::splitPath($row['principaluri']); |
| 191 | - $uri = $row['uri'] . '_shared_by_' . $name; |
|
| 192 | - $displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')'; |
|
| 191 | + $uri = $row['uri'].'_shared_by_'.$name; |
|
| 192 | + $displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')'; |
|
| 193 | 193 | |
| 194 | 194 | $addressBooks[$row['id']] = [ |
| 195 | 195 | 'id' => $row['id'], |
| 196 | 196 | 'uri' => $uri, |
| 197 | 197 | 'principaluri' => $principalUriOriginal, |
| 198 | 198 | '{DAV:}displayname' => $displayName, |
| 199 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 199 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 200 | 200 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 201 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 202 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], |
|
| 201 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 202 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'], |
|
| 203 | 203 | $readOnlyPropertyName => $readOnly, |
| 204 | 204 | ]; |
| 205 | 205 | } |
@@ -219,15 +219,15 @@ discard block |
||
| 219 | 219 | $addressBooks = []; |
| 220 | 220 | |
| 221 | 221 | $result = $query->execute(); |
| 222 | - while($row = $result->fetch()) { |
|
| 222 | + while ($row = $result->fetch()) { |
|
| 223 | 223 | $addressBooks[$row['id']] = [ |
| 224 | 224 | 'id' => $row['id'], |
| 225 | 225 | 'uri' => $row['uri'], |
| 226 | 226 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
| 227 | 227 | '{DAV:}displayname' => $row['displayname'], |
| 228 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 228 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 229 | 229 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 230 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 230 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 231 | 231 | ]; |
| 232 | 232 | } |
| 233 | 233 | $result->closeCursor(); |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | 'uri' => $row['uri'], |
| 271 | 271 | 'principaluri' => $row['principaluri'], |
| 272 | 272 | '{DAV:}displayname' => $row['displayname'], |
| 273 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 273 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 274 | 274 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 275 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 275 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 276 | 276 | ]; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -300,9 +300,9 @@ discard block |
||
| 300 | 300 | 'uri' => $row['uri'], |
| 301 | 301 | 'principaluri' => $row['principaluri'], |
| 302 | 302 | '{DAV:}displayname' => $row['displayname'], |
| 303 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 303 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 304 | 304 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 305 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 305 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 306 | 306 | ]; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -325,19 +325,19 @@ discard block |
||
| 325 | 325 | function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { |
| 326 | 326 | $supportedProperties = [ |
| 327 | 327 | '{DAV:}displayname', |
| 328 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description', |
|
| 328 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description', |
|
| 329 | 329 | ]; |
| 330 | 330 | |
| 331 | 331 | $propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) { |
| 332 | 332 | |
| 333 | 333 | $updates = []; |
| 334 | - foreach($mutations as $property=>$newValue) { |
|
| 334 | + foreach ($mutations as $property=>$newValue) { |
|
| 335 | 335 | |
| 336 | - switch($property) { |
|
| 336 | + switch ($property) { |
|
| 337 | 337 | case '{DAV:}displayname' : |
| 338 | 338 | $updates['displayname'] = $newValue; |
| 339 | 339 | break; |
| 340 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
| 340 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
| 341 | 341 | $updates['description'] = $newValue; |
| 342 | 342 | break; |
| 343 | 343 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | $query = $this->db->getQueryBuilder(); |
| 346 | 346 | $query->update('addressbooks'); |
| 347 | 347 | |
| 348 | - foreach($updates as $key=>$value) { |
|
| 348 | + foreach ($updates as $key=>$value) { |
|
| 349 | 349 | $query->set($key, $query->createNamedParameter($value)); |
| 350 | 350 | } |
| 351 | 351 | $query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId))) |
@@ -376,24 +376,24 @@ discard block |
||
| 376 | 376 | 'synctoken' => 1 |
| 377 | 377 | ]; |
| 378 | 378 | |
| 379 | - foreach($properties as $property=>$newValue) { |
|
| 379 | + foreach ($properties as $property=>$newValue) { |
|
| 380 | 380 | |
| 381 | - switch($property) { |
|
| 381 | + switch ($property) { |
|
| 382 | 382 | case '{DAV:}displayname' : |
| 383 | 383 | $values['displayname'] = $newValue; |
| 384 | 384 | break; |
| 385 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
| 385 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
| 386 | 386 | $values['description'] = $newValue; |
| 387 | 387 | break; |
| 388 | 388 | default : |
| 389 | - throw new BadRequest('Unknown property: ' . $property); |
|
| 389 | + throw new BadRequest('Unknown property: '.$property); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // Fallback to make sure the displayname is set. Some clients may refuse |
| 395 | 395 | // to work with addressbooks not having a displayname. |
| 396 | - if(is_null($values['displayname'])) { |
|
| 396 | + if (is_null($values['displayname'])) { |
|
| 397 | 397 | $values['displayname'] = $url; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -471,8 +471,8 @@ discard block |
||
| 471 | 471 | $cards = []; |
| 472 | 472 | |
| 473 | 473 | $result = $query->execute(); |
| 474 | - while($row = $result->fetch()) { |
|
| 475 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 474 | + while ($row = $result->fetch()) { |
|
| 475 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 476 | 476 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 477 | 477 | $cards[] = $row; |
| 478 | 478 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | if (!$row) { |
| 507 | 507 | return false; |
| 508 | 508 | } |
| 509 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 509 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 510 | 510 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 511 | 511 | |
| 512 | 512 | return $row; |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | $result = $query->execute(); |
| 544 | 544 | |
| 545 | 545 | while ($row = $result->fetch()) { |
| 546 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 546 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 547 | 547 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 548 | 548 | $cards[] = $row; |
| 549 | 549 | } |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | 'cardData' => $cardData])); |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - return '"' . $etag . '"'; |
|
| 606 | + return '"'.$etag.'"'; |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | 'cardData' => $cardData])); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - return '"' . $etag . '"'; |
|
| 658 | + return '"'.$etag.'"'; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { |
| 756 | 756 | // Current synctoken |
| 757 | 757 | $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?'); |
| 758 | - $stmt->execute([ $addressBookId ]); |
|
| 758 | + $stmt->execute([$addressBookId]); |
|
| 759 | 759 | $currentToken = $stmt->fetchColumn(0); |
| 760 | 760 | |
| 761 | 761 | if (is_null($currentToken)) return null; |
@@ -770,8 +770,8 @@ discard block |
||
| 770 | 770 | if ($syncToken) { |
| 771 | 771 | |
| 772 | 772 | $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`"; |
| 773 | - if ($limit>0) { |
|
| 774 | - $query .= " `LIMIT` " . (int)$limit; |
|
| 773 | + if ($limit > 0) { |
|
| 774 | + $query .= " `LIMIT` ".(int) $limit; |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | // Fetching all changes |
@@ -782,15 +782,15 @@ discard block |
||
| 782 | 782 | |
| 783 | 783 | // This loop ensures that any duplicates are overwritten, only the |
| 784 | 784 | // last change on a node is relevant. |
| 785 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 785 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 786 | 786 | |
| 787 | 787 | $changes[$row['uri']] = $row['operation']; |
| 788 | 788 | |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | - foreach($changes as $uri => $operation) { |
|
| 791 | + foreach ($changes as $uri => $operation) { |
|
| 792 | 792 | |
| 793 | - switch($operation) { |
|
| 793 | + switch ($operation) { |
|
| 794 | 794 | case 1: |
| 795 | 795 | $result['added'][] = $uri; |
| 796 | 796 | break; |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | $query2->selectDistinct('cp.cardid')->from($this->dbCardsPropertiesTable, 'cp'); |
| 870 | 870 | $query2->andWhere($query2->expr()->eq('cp.addressbookid', $query->createNamedParameter($addressBookId))); |
| 871 | - $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); |
|
| 871 | + $query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%'))); |
|
| 872 | 872 | foreach ($searchProperties as $property) { |
| 873 | 873 | $query2->expr()->orX($query2->expr()->eq('cp.name', $query->createNamedParameter($property))); |
| 874 | 874 | } |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | $result->closeCursor(); |
| 924 | 924 | |
| 925 | 925 | if (!isset($uri['uri'])) { |
| 926 | - throw new \InvalidArgumentException('Card does not exists: ' . $id); |
|
| 926 | + throw new \InvalidArgumentException('Card does not exists: '.$id); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | return $uri['uri']; |
@@ -995,11 +995,11 @@ discard block |
||
| 995 | 995 | ); |
| 996 | 996 | |
| 997 | 997 | foreach ($vCard->children() as $property) { |
| 998 | - if(!in_array($property->name, self::$indexProperties)) { |
|
| 998 | + if (!in_array($property->name, self::$indexProperties)) { |
|
| 999 | 999 | continue; |
| 1000 | 1000 | } |
| 1001 | 1001 | $preferred = 0; |
| 1002 | - foreach($property->parameters as $parameter) { |
|
| 1002 | + foreach ($property->parameters as $parameter) { |
|
| 1003 | 1003 | if ($parameter->name == 'TYPE' && strtoupper($parameter->getValue()) == 'PREF') { |
| 1004 | 1004 | $preferred = 1; |
| 1005 | 1005 | break; |
@@ -1054,10 +1054,10 @@ discard block |
||
| 1054 | 1054 | $result->closeCursor(); |
| 1055 | 1055 | |
| 1056 | 1056 | if (!isset($cardIds['id'])) { |
| 1057 | - throw new \InvalidArgumentException('Card does not exists: ' . $uri); |
|
| 1057 | + throw new \InvalidArgumentException('Card does not exists: '.$uri); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - return (int)$cardIds['id']; |
|
| 1060 | + return (int) $cardIds['id']; |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | /** |