Skip to content

Commit e7324e8

Browse files
committed
delete also addressbooks on user deletion
1 parent beaf904 commit e7324e8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

apps/dav/lib/HookManager.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class HookManager {
4343
/** @var array */
4444
private $calendarsToDelete;
4545

46+
/** @var array */
47+
private $addressBooksToDelete;
48+
4649
/** @var CalDavBackend */
4750
private $calDav;
4851

@@ -98,6 +101,7 @@ public function preDeleteUser($params) {
98101
$this->usersToDelete[$params['uid']] = $user;
99102

100103
$this->calendarsToDelete = $this->calDav->getCalendarsForUser('principals/users/' . $user->getUID());
104+
$this->addressBooksToDelete = $this->cardDav->getAddressBooksForUser('principals/users/' . $user->getUID());
101105
}
102106

103107
public function postDeleteUser($params) {
@@ -110,6 +114,11 @@ public function postDeleteUser($params) {
110114
$this->calDav->deleteCalendar($calendar['id']);
111115
}
112116
}
117+
if (!is_null($this->addressBooksToDelete)) {
118+
foreach ($this->addressBooksToDelete as $addressBook) {
119+
$this->cardDav->deleteAddressBook($addressBook['id']);
120+
}
121+
}
113122
}
114123

115124
public function changeUser($params) {

0 commit comments

Comments
 (0)