Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
coding style fixes
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Aug 6, 2020
commit f13d5a3ec0e3bacec53ea64ee360aae000413b16
69 changes: 35 additions & 34 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ public function getAddressBooksForUser($principalUri) {
$result = $query->execute();
while ($row = $result->fetch()) {
$addressBooks[$row['id']] = [
'id' => $row['id'],
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $this->convertPrincipal($row['principaluri'], false),
'{DAV:}displayname' => $row['displayname'],
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
];

$this->addOwnerPrincipal($addressBooks[$row['id']]);
Expand All @@ -177,7 +177,7 @@ public function getAddressBooksForUser($principalUri) {
$principals = array_map(function ($principal) {
return urldecode($principal);
}, $principals);
$principals[]= $principalUri;
$principals[] = $principalUri;

$query = $this->db->getQueryBuilder();
$result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])
Expand All @@ -195,7 +195,7 @@ public function getAddressBooksForUser($principalUri) {
continue;
}

$readOnly = (int) $row['access'] === Backend::ACCESS_READ;
$readOnly = (int)$row['access'] === Backend::ACCESS_READ;
if (isset($addressBooks[$row['id']])) {
if ($readOnly) {
// New share can not have more permissions then the old one.
Expand All @@ -213,13 +213,13 @@ public function getAddressBooksForUser($principalUri) {
$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';

$addressBooks[$row['id']] = [
'id' => $row['id'],
'id' => $row['id'],
'uri' => $uri,
'principaluri' => $principalUriOriginal,
'{DAV:}displayname' => $displayName,
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
$readOnlyPropertyName => $readOnly,
];
Expand All @@ -235,21 +235,21 @@ public function getUsersOwnAddressBooks($principalUri) {
$principalUri = $this->convertPrincipal($principalUri, true);
$query = $this->db->getQueryBuilder();
$query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])
->from('addressbooks')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
->from('addressbooks')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));

$addressBooks = [];

$result = $query->execute();
while ($row = $result->fetch()) {
$addressBooks[$row['id']] = [
'id' => $row['id'],
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $this->convertPrincipal($row['principaluri'], false),
'{DAV:}displayname' => $row['displayname'],
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
];

$this->addOwnerPrincipal($addressBooks[$row['id']]);
Expand Down Expand Up @@ -290,13 +290,13 @@ public function getAddressBookById($addressBookId) {
}

$addressBook = [
'id' => $row['id'],
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $row['principaluri'],
'{DAV:}displayname' => $row['displayname'],
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
];

$this->addOwnerPrincipal($addressBook);
Expand Down Expand Up @@ -324,13 +324,13 @@ public function getAddressBooksByUri($principal, $addressBookUri) {
}

$addressBook = [
'id' => $row['id'],
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $row['principaluri'],
'{DAV:}displayname' => $row['displayname'],
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
];

$this->addOwnerPrincipal($addressBook);
Expand Down Expand Up @@ -365,7 +365,7 @@ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatc
*/
$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
$updates = [];
foreach ($mutations as $property=>$newValue) {
foreach ($mutations as $property => $newValue) {
switch ($property) {
case '{DAV:}displayname':
$updates['displayname'] = $newValue;
Expand All @@ -378,11 +378,11 @@ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatc
$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)))
->execute();
->execute();

$this->addChange($addressBookId, "", 2);

Expand All @@ -408,7 +408,7 @@ public function createAddressBook($principalUri, $url, array $properties) {
'synctoken' => 1
];

foreach ($properties as $property=>$newValue) {
foreach ($properties as $property => $newValue) {
switch ($property) {
case '{DAV:}displayname':
$values['displayname'] = $newValue;
Expand Down Expand Up @@ -634,7 +634,7 @@ public function createCard($addressBookId, $cardUri, $cardData) {
->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid)))
->setMaxResults(1);
$result = $q->execute();
$count = (bool) $result->fetchColumn();
$count = (bool)$result->fetchColumn();
$result->closeCursor();
if ($count) {
throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.');
Expand Down Expand Up @@ -811,7 +811,7 @@ public function deleteCard($addressBookId, $cardUri) {
public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) {
// Current synctoken
$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?');
$stmt->execute([ $addressBookId ]);
$stmt->execute([$addressBookId]);
$currentToken = $stmt->fetchColumn(0);

if (is_null($currentToken)) {
Expand All @@ -820,14 +820,14 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel,

$result = [
'syncToken' => $currentToken,
'added' => [],
'modified' => [],
'deleted' => [],
'added' => [],
'modified' => [],
'deleted' => [],
];

if ($syncToken) {
$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
if ($limit>0) {
if ($limit > 0) {
$query .= " LIMIT " . (int)$limit;
}

Expand Down Expand Up @@ -895,7 +895,7 @@ protected function addChange($addressBookId, $objectUri, $operation) {
* @param bool $modified
* @return string
*/
private function readBlob($cardData, &$modified=false) {
private function readBlob($cardData, &$modified = false) {
if (is_resource($cardData)) {
$cardData = stream_get_contents($cardData);
}
Expand Down Expand Up @@ -943,9 +943,9 @@ public function updateShares(IShareable $shareable, $add, $remove) {
* @param string $pattern which should match within the $searchProperties
* @param array $searchProperties defines the properties within the query pattern should match
* @param array $options = array() to define the search behavior
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are
* - 'limit' - Set a numeric limit for the search results
* - 'offset' - Set the offset for the limited search results
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are
* - 'limit' - Set a numeric limit for the search results
* - 'offset' - Set the offset for the limited search results
* @return array an array of contacts which are arrays of key-value-pairs
*/
public function search($addressBookId, $pattern, $searchProperties, $options = []) {
Expand Down Expand Up @@ -980,7 +980,7 @@ public function search($addressBookId, $pattern, $searchProperties, $options = [
$matches = $result->fetchAll();
$result->closeCursor();
$matches = array_map(function ($match) {
return (int) $match['cardid'];
return (int)$match['cardid'];
}, $matches);

$query = $this->db->getQueryBuilder();
Expand Down Expand Up @@ -1031,8 +1031,8 @@ public function collectCardProperties($bookId, $name) {
public function getCardUri($id) {
$query = $this->db->getQueryBuilder();
$query->select('uri')->from($this->dbCardsTable)
->where($query->expr()->eq('id', $query->createParameter('id')))
->setParameter('id', $id);
->where($query->expr()->eq('id', $query->createParameter('id')))
->setParameter('id', $id);

$result = $query->execute();
$uri = $result->fetch();
Expand All @@ -1056,8 +1056,8 @@ public function getContact($addressBookId, $uri) {
$result = [];
$query = $this->db->getQueryBuilder();
$query->select('*')->from($this->dbCardsTable)
->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
$queryResult = $query->execute();
$contact = $queryResult->fetch();
$queryResult->closeCursor();
Expand Down Expand Up @@ -1142,7 +1142,7 @@ protected function updateProperties($addressBookId, $cardUri, $vCardSerialized)
* @return VCard
*/
protected function readCard($cardData) {
return Reader::read($cardData);
return Reader::read($cardData);
}

/**
Expand Down Expand Up @@ -1185,6 +1185,7 @@ protected function getCardId($addressBookId, $uri) {

/**
* For shared address books the sharee is set in the ACL of the address book
*
* @param $addressBookId
* @param $acl
* @return array
Expand Down
6 changes: 3 additions & 3 deletions apps/federatedfilesharing/lib/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ public function prepare(INotification $notification, string $languageCode): INot
switch ($action->getLabel()) {
case 'accept':
$action->setParsedLabel(
(string) $l->t('Accept')
(string)$l->t('Accept')
)
->setPrimary(true);
->setPrimary(true);
break;

case 'decline':
$action->setParsedLabel(
(string) $l->t('Decline')
(string)$l->t('Decline')
);
break;
}
Expand Down