From b8fcd3ce2783835773e9d44d4ba1302529e1d57a Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Tue, 14 Feb 2017 09:21:33 +0100 Subject: getUsersOwnAddressBooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/dav/lib/CardDAV/CardDavBackend.php | 27 +++++++++++++++++++++++++++ apps/dav/lib/HookManager.php | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'apps') 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) { -- cgit v1.2.3