summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2017-02-14 09:21:33 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2017-02-14 09:21:33 +0100
commitb8fcd3ce2783835773e9d44d4ba1302529e1d57a (patch)
tree00d2a721a7dcfc915c3c26c807b20a6e1f1174d2 /apps
parent7113af3f9102ca4e27350786934df9de3c54f71b (diff)
downloadnextcloud-server-b8fcd3ce2783835773e9d44d4ba1302529e1d57a.tar.gz
nextcloud-server-b8fcd3ce2783835773e9d44d4ba1302529e1d57a.zip
getUsersOwnAddressBooks
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php27
-rw-r--r--apps/dav/lib/HookManager.php2
2 files changed, 28 insertions, 1 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index a320984c1fe..e62a3e4dae0 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -195,6 +195,33 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return array_values($addressBooks);
}
+ function getUsersOwnAddressBooks($principalUri) {
+ $principalUriOriginal = $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)));
+
+ $addressBooks = [];
+
+ $result = $query->execute();
+ while($row = $result->fetch()) {
+ $addressBooks[$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',
+ ];
+ }
+ $result->closeCursor();
+
+ return array_values($addressBooks);
+ }
+
private function getUserDisplayName($uid) {
if (!isset($this->userDisplayNames[$uid])) {
$user = $this->userManager->get($uid);
diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php
index 26f3895a459..8148df2d37b 100644
--- a/apps/dav/lib/HookManager.php
+++ b/apps/dav/lib/HookManager.php
@@ -96,7 +96,7 @@ class HookManager {
$uid = $params['uid'];
$this->usersToDelete[$uid] = $this->userManager->get($uid);
$this->calendarsToDelete = $this->calDav->getUsersOwnCalendars('principals/users/' . $uid);
- $this->addressBooksToDelete = $this->cardDav->getAddressBooksForUser('principals/users/' . $uid);
+ $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks('principals/users/' . $uid);
}
public function postDeleteUser($params) {