aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
commitcaff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch)
tree186d494c2aea5dea7255d3584ef5d595fc6e6194 /apps/dav/lib/CardDAV
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
downloadnextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz
nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib/CardDAV')
-rw-r--r--apps/dav/lib/CardDAV/AddressBook.php2
-rw-r--r--apps/dav/lib/CardDAV/AddressBookImpl.php9
-rw-r--r--apps/dav/lib/CardDAV/AddressBookRoot.php3
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php49
-rw-r--r--apps/dav/lib/CardDAV/ContactsManager.php1
-rw-r--r--apps/dav/lib/CardDAV/Converter.php3
-rw-r--r--apps/dav/lib/CardDAV/HasPhotoPlugin.php3
-rw-r--r--apps/dav/lib/CardDAV/ImageExportPlugin.php1
-rw-r--r--apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php2
-rw-r--r--apps/dav/lib/CardDAV/Integration/IAddressBookProvider.php1
-rw-r--r--apps/dav/lib/CardDAV/MultiGetExportPlugin.php3
-rw-r--r--apps/dav/lib/CardDAV/PhotoCache.php3
-rw-r--r--apps/dav/lib/CardDAV/Plugin.php3
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php23
-rw-r--r--apps/dav/lib/CardDAV/UserAddressBooks.php2
15 files changed, 32 insertions, 76 deletions
diff --git a/apps/dav/lib/CardDAV/AddressBook.php b/apps/dav/lib/CardDAV/AddressBook.php
index 010e98d18e7..4a9df56e6b4 100644
--- a/apps/dav/lib/CardDAV/AddressBook.php
+++ b/apps/dav/lib/CardDAV/AddressBook.php
@@ -155,14 +155,12 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
}
public function getChild($name) {
-
$obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name);
if (!$obj) {
throw new NotFound('Card not found');
}
$obj['acl'] = $this->getChildACL();
return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
-
}
/**
diff --git a/apps/dav/lib/CardDAV/AddressBookImpl.php b/apps/dav/lib/CardDAV/AddressBookImpl.php
index 01ebdcd7019..c63955202f4 100644
--- a/apps/dav/lib/CardDAV/AddressBookImpl.php
+++ b/apps/dav/lib/CardDAV/AddressBookImpl.php
@@ -65,7 +65,6 @@ class AddressBookImpl implements IAddressBook {
array $addressBookInfo,
CardDavBackend $backend,
IURLGenerator $urlGenerator) {
-
$this->addressBook = $addressBook;
$this->addressBookInfo = $addressBookInfo;
$this->backend = $backend;
@@ -156,7 +155,6 @@ class AddressBookImpl implements IAddressBook {
}
return $this->vCard2Array($uri, $vCard);
-
}
/**
@@ -167,7 +165,7 @@ class AddressBookImpl implements IAddressBook {
$permissions = $this->addressBook->getACL();
$result = 0;
foreach ($permissions as $permission) {
- switch($permission['privilege']) {
+ switch ($permission['privilege']) {
case '{DAV:}read':
$result |= Constants::PERMISSION_READ;
break;
@@ -261,7 +259,6 @@ class AddressBookImpl implements IAddressBook {
]) . '?photo';
$result['PHOTO'] = 'VALUE=uri:' . $url;
-
} elseif ($property->name === 'X-SOCIALPROFILE') {
$type = $this->getTypeFromProperty($property);
@@ -273,7 +270,7 @@ class AddressBookImpl implements IAddressBook {
$result[$property->name][$type] = $property->getValue();
}
- // The following properties can be set multiple times
+ // The following properties can be set multiple times
} elseif (in_array($property->name, ['CLOUD', 'EMAIL', 'IMPP', 'TEL', 'URL', 'X-ADDRESSBOOKSERVER-MEMBER'])) {
if (!isset($result[$property->name])) {
$result[$property->name] = [];
@@ -288,8 +285,6 @@ class AddressBookImpl implements IAddressBook {
} else {
$result[$property->name][] = $property->getValue();
}
-
-
} else {
$result[$property->name] = $property->getValue();
}
diff --git a/apps/dav/lib/CardDAV/AddressBookRoot.php b/apps/dav/lib/CardDAV/AddressBookRoot.php
index 254f3e0a8e9..771e44b7d32 100644
--- a/apps/dav/lib/CardDAV/AddressBookRoot.php
+++ b/apps/dav/lib/CardDAV/AddressBookRoot.php
@@ -61,7 +61,6 @@ class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
}
function getName() {
-
if ($this->principalPrefix === 'principals') {
return parent::getName();
}
@@ -70,7 +69,5 @@ class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
// We are only interested in the second part.
return $parts[1];
-
}
-
}
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index 54427404db5..47551c8f170 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -55,7 +55,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class CardDavBackend implements BackendInterface, SyncSupport {
-
const PERSONAL_ADDRESSBOOK_URI = 'contacts';
const PERSONAL_ADDRESSBOOK_NAME = 'Contacts';
@@ -155,7 +154,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$addressBooks = [];
$result = $query->execute();
- while($row = $result->fetch()) {
+ while ($row = $result->fetch()) {
$addressBooks[$row['id']] = [
'id' => $row['id'],
'uri' => $row['uri'],
@@ -190,7 +189,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
->execute();
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
- while($row = $result->fetch()) {
+ while ($row = $result->fetch()) {
if ($row['principaluri'] === $principalUri) {
continue;
}
@@ -241,7 +240,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$addressBooks = [];
$result = $query->execute();
- while($row = $result->fetch()) {
+ while ($row = $result->fetch()) {
$addressBooks[$row['id']] = [
'id' => $row['id'],
'uri' => $row['uri'],
@@ -364,11 +363,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @suppress SqlInjectionChecker
*/
$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
-
$updates = [];
- foreach($mutations as $property=>$newValue) {
-
- switch($property) {
+ foreach ($mutations as $property=>$newValue) {
+ switch ($property) {
case '{DAV:}displayname':
$updates['displayname'] = $newValue;
break;
@@ -380,7 +377,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query = $this->db->getQueryBuilder();
$query->update('addressbooks');
- foreach($updates as $key=>$value) {
+ foreach ($updates as $key=>$value) {
$query->set($key, $query->createNamedParameter($value));
}
$query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
@@ -389,7 +386,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$this->addChange($addressBookId, "", 2);
return true;
-
});
}
@@ -411,9 +407,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'synctoken' => 1
];
- foreach($properties as $property=>$newValue) {
-
- switch($property) {
+ foreach ($properties as $property=>$newValue) {
+ switch ($property) {
case '{DAV:}displayname':
$values['displayname'] = $newValue;
break;
@@ -423,12 +418,11 @@ class CardDavBackend implements BackendInterface, SyncSupport {
default:
throw new BadRequest('Unknown property: ' . $property);
}
-
}
// Fallback to make sure the displayname is set. Some clients may refuse
// to work with addressbooks not having a displayname.
- if(is_null($values['displayname'])) {
+ if (is_null($values['displayname'])) {
$values['displayname'] = $url;
}
@@ -475,7 +469,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query->delete($this->dbCardsPropertiesTable)
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
->execute();
-
}
/**
@@ -506,7 +499,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$cards = [];
$result = $query->execute();
- while($row = $result->fetch()) {
+ while ($row = $result->fetch()) {
$row['etag'] = '"' . $row['etag'] . '"';
$row['carddata'] = $this->readBlob($row['carddata']);
$cards[] = $row;
@@ -680,7 +673,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @return string
*/
function updateCard($addressBookId, $cardUri, $cardData) {
-
$uid = $this->getUID($cardData);
$etag = md5($cardData);
$query = $this->db->getQueryBuilder();
@@ -804,7 +796,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$stmt->execute([ $addressBookId ]);
$currentToken = $stmt->fetchColumn(0);
- if (is_null($currentToken)) return null;
+ if (is_null($currentToken)) {
+ return null;
+ }
$result = [
'syncToken' => $currentToken,
@@ -814,7 +808,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
];
if ($syncToken) {
-
$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
if ($limit>0) {
$query .= " LIMIT " . (int)$limit;
@@ -828,15 +821,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
// This loop ensures that any duplicates are overwritten, only the
// last change on a node is relevant.
- while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
-
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$changes[$row['uri']] = $row['operation'];
-
}
- foreach($changes as $uri => $operation) {
-
- switch($operation) {
+ foreach ($changes as $uri => $operation) {
+ switch ($operation) {
case 1:
$result['added'][] = $uri;
break;
@@ -847,7 +837,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$result['deleted'][] = $uri;
break;
}
-
}
} else {
// No synctoken supplied, this is the initial sync.
@@ -924,7 +913,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
// No need for like when the pattern is empty
if ('' !== $pattern) {
- if(\array_key_exists('escape_like_param', $options) && $options['escape_like_param'] === false) {
+ if (\array_key_exists('escape_like_param', $options) && $options['escape_like_param'] === false) {
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter($pattern)));
} else {
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
@@ -1053,11 +1042,11 @@ class CardDavBackend implements BackendInterface, SyncSupport {
);
foreach ($vCard->children() as $property) {
- if(!in_array($property->name, self::$indexProperties)) {
+ if (!in_array($property->name, self::$indexProperties)) {
continue;
}
$preferred = 0;
- foreach($property->parameters as $parameter) {
+ foreach ($property->parameters as $parameter) {
if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') {
$preferred = 1;
break;
diff --git a/apps/dav/lib/CardDAV/ContactsManager.php b/apps/dav/lib/CardDAV/ContactsManager.php
index ae4906c7d15..20616a65edc 100644
--- a/apps/dav/lib/CardDAV/ContactsManager.php
+++ b/apps/dav/lib/CardDAV/ContactsManager.php
@@ -86,5 +86,4 @@ class ContactsManager {
);
}
}
-
}
diff --git a/apps/dav/lib/CardDAV/Converter.php b/apps/dav/lib/CardDAV/Converter.php
index f3b55ac4a30..8dea77bd0a6 100644
--- a/apps/dav/lib/CardDAV/Converter.php
+++ b/apps/dav/lib/CardDAV/Converter.php
@@ -50,7 +50,6 @@ class Converter {
* @return VCard|null
*/
public function createCardFromUser(IUser $user) {
-
$userData = $this->accountManager->getUser($user);
$uid = $user->getUID();
@@ -68,7 +67,6 @@ class Converter {
}
foreach ($userData as $property => $value) {
-
$shareWithTrustedServers =
$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
@@ -150,5 +148,4 @@ class Converter {
return null;
}
}
-
}
diff --git a/apps/dav/lib/CardDAV/HasPhotoPlugin.php b/apps/dav/lib/CardDAV/HasPhotoPlugin.php
index 4d4af47f812..3cf9e0f9a61 100644
--- a/apps/dav/lib/CardDAV/HasPhotoPlugin.php
+++ b/apps/dav/lib/CardDAV/HasPhotoPlugin.php
@@ -57,7 +57,6 @@ class HasPhotoPlugin extends ServerPlugin {
* @return void
*/
function propFind(PropFind $propFind, INode $node) {
-
$ns = '{http://nextcloud.com/ns}';
if ($node instanceof Card) {
@@ -96,7 +95,5 @@ class HasPhotoPlugin extends ServerPlugin {
'name' => $this->getPluginName(),
'description' => 'Return a boolean stating if the vcard have a photo property set or not.'
];
-
}
-
}
diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php
index 74faa5d7df9..097f52f9576 100644
--- a/apps/dav/lib/CardDAV/ImageExportPlugin.php
+++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php
@@ -65,7 +65,6 @@ class ImageExportPlugin extends ServerPlugin {
* @return bool
*/
public function httpGet(RequestInterface $request, ResponseInterface $response) {
-
$queryParams = $request->getQueryParameters();
// TODO: in addition to photo we should also add logo some point in time
if (!array_key_exists('photo', $queryParams)) {
diff --git a/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php b/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
index 1bcd3fbe419..0bd01184eba 100644
--- a/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
+++ b/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
@@ -87,7 +87,6 @@ abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {
*/
final public function createDirectory($name) {
throw new DAV\Exception\MethodNotAllowed('Creating collections in address book objects is not allowed');
-
}
/**
@@ -130,5 +129,4 @@ abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {
public static function doesViolateReservedName(string $uri): bool {
return strpos($uri, self::PREFIX) === 0;
}
-
}
diff --git a/apps/dav/lib/CardDAV/Integration/IAddressBookProvider.php b/apps/dav/lib/CardDAV/Integration/IAddressBookProvider.php
index 6542db23650..4fb3ccf5337 100644
--- a/apps/dav/lib/CardDAV/Integration/IAddressBookProvider.php
+++ b/apps/dav/lib/CardDAV/Integration/IAddressBookProvider.php
@@ -68,5 +68,4 @@ interface IAddressBookProvider {
*@since 19.0.0
*/
public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook;
-
}
diff --git a/apps/dav/lib/CardDAV/MultiGetExportPlugin.php b/apps/dav/lib/CardDAV/MultiGetExportPlugin.php
index 1a1900b2633..bb911ffc033 100644
--- a/apps/dav/lib/CardDAV/MultiGetExportPlugin.php
+++ b/apps/dav/lib/CardDAV/MultiGetExportPlugin.php
@@ -55,7 +55,6 @@ class MultiGetExportPlugin extends DAV\ServerPlugin {
* @return bool
*/
public function httpReport(RequestInterface $request, ResponseInterface $response) {
-
$queryParams = $request->getQueryParameters();
if (!array_key_exists('export', $queryParams)) {
return;
@@ -118,7 +117,5 @@ class MultiGetExportPlugin extends DAV\ServerPlugin {
'name' => $this->getPluginName(),
'description' => 'Intercept a multi-get request and return a single vcf file instead.'
];
-
}
-
}
diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php
index 2244e99170c..81067f15b17 100644
--- a/apps/dav/lib/CardDAV/PhotoCache.php
+++ b/apps/dav/lib/CardDAV/PhotoCache.php
@@ -164,7 +164,6 @@ class PhotoCache {
$file = $folder->newFile($path);
$file->putContent($photo->data());
} catch (NotPermittedException $e) {
-
}
}
@@ -180,7 +179,7 @@ class PhotoCache {
try {
return $this->appData->getFolder($hash);
} catch (NotFoundException $e) {
- if($createIfNotExists) {
+ if ($createIfNotExists) {
return $this->appData->newFolder($hash);
} else {
throw $e;
diff --git a/apps/dav/lib/CardDAV/Plugin.php b/apps/dav/lib/CardDAV/Plugin.php
index 1d615a13ced..430fda4578d 100644
--- a/apps/dav/lib/CardDAV/Plugin.php
+++ b/apps/dav/lib/CardDAV/Plugin.php
@@ -30,7 +30,6 @@ use Sabre\DAV\PropFind;
use Sabre\DAV\Server;
class Plugin extends \Sabre\CardDAV\Plugin {
-
function initialize(Server $server) {
$server->on('propFind', [$this, 'propFind']);
parent::initialize($server);
@@ -65,11 +64,9 @@ class Plugin extends \Sabre\CardDAV\Plugin {
* @return void
*/
function propFind(PropFind $propFind, INode $node) {
-
$ns = '{http://owncloud.org/ns}';
if ($node instanceof AddressBook) {
-
$propFind->handle($ns . 'groups', function () use ($node) {
return new Groups($node->getContactsGroups());
});
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index c0241de2076..daced49373e 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -196,17 +196,17 @@ class SyncService {
* @param string $syncToken
* @return array
*/
- protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
- $client = $this->getClient($url, $userName, $sharedSecret);
+ protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
+ $client = $this->getClient($url, $userName, $sharedSecret);
- $body = $this->buildSyncCollectionRequestBody($syncToken);
+ $body = $this->buildSyncCollectionRequestBody($syncToken);
- $response = $client->request('REPORT', $addressBookUrl, $body, [
- 'Content-Type' => 'application/xml'
- ]);
+ $response = $client->request('REPORT', $addressBookUrl, $body, [
+ 'Content-Type' => 'application/xml'
+ ]);
- return $this->parseMultiStatus($response['body']);
- }
+ return $this->parseMultiStatus($response['body']);
+ }
/**
* @param string $url
@@ -225,7 +225,6 @@ class SyncService {
* @return string
*/
private function buildSyncCollectionRequestBody($syncToken) {
-
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$root = $dom->createElementNS('DAV:', 'd:sync-collection');
@@ -297,7 +296,7 @@ class SyncService {
*/
public function deleteUser($userOrCardId) {
$systemAddressBook = $this->getLocalSystemAddressBook();
- if ($userOrCardId instanceof IUser){
+ if ($userOrCardId instanceof IUser) {
$name = $userOrCardId->getBackendClassName();
$userId = $userOrCardId->getUID();
@@ -331,7 +330,7 @@ class SyncService {
// remove no longer existing
$allCards = $this->backend->getCards($systemAddressBook['id']);
- foreach($allCards as $card) {
+ foreach ($allCards as $card) {
$vCard = Reader::read($card['carddata']);
$uid = $vCard->UID->getValue();
// load backend and see if user exists
@@ -340,6 +339,4 @@ class SyncService {
}
}
}
-
-
}
diff --git a/apps/dav/lib/CardDAV/UserAddressBooks.php b/apps/dav/lib/CardDAV/UserAddressBooks.php
index 7ebe3b03d11..18fc286fdd9 100644
--- a/apps/dav/lib/CardDAV/UserAddressBooks.php
+++ b/apps/dav/lib/CardDAV/UserAddressBooks.php
@@ -108,7 +108,6 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
* @return array
*/
function getACL() {
-
$acl = parent::getACL();
if ($this->principalUri === 'principals/system/system') {
$acl[] = [
@@ -120,5 +119,4 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
return $acl;
}
-
}