Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/CardDAV/CardDavBackend.php')
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php59
1 files changed, 27 insertions, 32 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index 745ca7801b7..2c99e6084c1 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -371,12 +371,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query->set($key, $query->createNamedParameter($value));
}
$query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
- ->execute();
+ ->executeStatement();
$this->addChange($addressBookId, "", 2);
$addressBookRow = $this->getAddressBookById((int)$addressBookId);
- $shares = $this->getShares($addressBookId);
+ $shares = $this->getShares((int)$addressBookId);
$this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
return true;
@@ -446,30 +446,31 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @return void
*/
public function deleteAddressBook($addressBookId) {
+ $addressBookId = (int)$addressBookId;
$addressBookData = $this->getAddressBookById($addressBookId);
$shares = $this->getShares($addressBookId);
$query = $this->db->getQueryBuilder();
$query->delete($this->dbCardsTable)
->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
- ->setParameter('addressbookid', $addressBookId)
- ->execute();
+ ->setParameter('addressbookid', $addressBookId, IQueryBuilder::PARAM_INT)
+ ->executeStatement();
$query->delete('addressbookchanges')
->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
- ->setParameter('addressbookid', $addressBookId)
- ->execute();
+ ->setParameter('addressbookid', $addressBookId, IQueryBuilder::PARAM_INT)
+ ->executeStatement();
$query->delete('addressbooks')
->where($query->expr()->eq('id', $query->createParameter('id')))
- ->setParameter('id', $addressBookId)
- ->execute();
+ ->setParameter('id', $addressBookId, IQueryBuilder::PARAM_INT)
+ ->executeStatement();
$this->sharingBackend->deleteAllShares($addressBookId);
$query->delete($this->dbCardsPropertiesTable)
- ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
- ->execute();
+ ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId, IQueryBuilder::PARAM_INT)))
+ ->executeStatement();
if ($addressBookData) {
$this->dispatcher->dispatchTyped(new AddressBookDeletedEvent($addressBookId, $addressBookData, $shares));
@@ -964,11 +965,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
}
/**
- * @param IShareable $shareable
- * @param string[] $add
- * @param string[] $remove
+ * @param list<array{href: string, commonName: string, readOnly: bool}> $add
+ * @param list<string> $remove
*/
- public function updateShares(IShareable $shareable, $add, $remove) {
+ public function updateShares(IShareable $shareable, array $add, array $remove): void {
$addressBookId = $shareable->getResourceId();
$addressBookData = $this->getAddressBookById($addressBookId);
$oldShares = $this->getShares($addressBookId);
@@ -1199,11 +1199,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* * commonName - Optional, for example a first + last name
* * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
* * readOnly - boolean
- * * summary - Optional, a description for the share
*
- * @return array
+ * @return list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}>
*/
- public function getShares($addressBookId) {
+ public function getShares(int $addressBookId): array {
return $this->sharingBackend->getShares($addressBookId);
}
@@ -1283,13 +1282,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
}
/**
- * get ID from a given contact
- *
- * @param int $addressBookId
- * @param string $uri
- * @return int
+ * Get ID from a given contact
*/
- protected function getCardId($addressBookId, $uri) {
+ protected function getCardId(int $addressBookId, string $uri): int {
$query = $this->db->getQueryBuilder();
$query->select('id')->from($this->dbCardsTable)
->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
@@ -1309,15 +1304,15 @@ class CardDavBackend implements BackendInterface, SyncSupport {
/**
* For shared address books the sharee is set in the ACL of the address book
*
- * @param $addressBookId
- * @param $acl
- * @return array
+ * @param int $addressBookId
+ * @param list<array{privilege: string, principal: string, protected: bool}> $acl
+ * @return list<array{privilege: string, principal: string, protected: bool}>
*/
- public function applyShareAcl($addressBookId, $acl) {
+ public function applyShareAcl(int $addressBookId, array $acl): array {
return $this->sharingBackend->applyShareAcl($addressBookId, $acl);
}
- private function convertPrincipal($principalUri, $toV2) {
+ private function convertPrincipal(string $principalUri, bool $toV2): string {
if ($this->principalBackend->getPrincipalPrefix() === 'principals') {
[, $name] = \Sabre\Uri\split($principalUri);
if ($toV2 === true) {
@@ -1328,7 +1323,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return $principalUri;
}
- private function addOwnerPrincipal(&$addressbookInfo) {
+ private function addOwnerPrincipal(array &$addressbookInfo): void {
$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
if (isset($addressbookInfo[$ownerPrincipalKey])) {
@@ -1348,10 +1343,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
*
* @param string $cardData the vcard raw data
* @return string the uid
- * @throws BadRequest if no UID is available
+ * @throws BadRequest if no UID is available or vcard is empty
*/
- private function getUID($cardData) {
- if ($cardData != '') {
+ private function getUID(string $cardData): string {
+ if ($cardData !== '') {
$vCard = Reader::read($cardData);
if ($vCard->UID) {
$uid = $vCard->UID->getValue();