return array_values($addressBooks);
}
+ public 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);
$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) {
// create a new address book
$this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
- $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
+ $books = $this->backend->getUsersOwnAddressBooks(self::UNIT_TEST_USER);
$this->assertEquals(1, count($books));
$bookId = $books[0]['id'];
$card = $this->getMockBuilder(CardDavBackend::class)
->disableOriginalConstructor()
->getMock();
- $card->expects($this->once())->method('getAddressBooksForUser')->willReturn([
+ $card->expects($this->once())->method('getUsersOwnAddressBooks')->willReturn([
['id' => 'personal']
]);
$card->expects($this->once())->method('deleteAddressBook');