From 7db01ff8055c660dfaa2ab9d88865245dcac9e62 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 23 Aug 2016 15:43:54 +0200 Subject: delete calendars when users are deleted Signed-off-by: Lukas Reschke --- apps/dav/lib/HookManager.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php index 5a3e328f707..9a14c322d01 100644 --- a/apps/dav/lib/HookManager.php +++ b/apps/dav/lib/HookManager.php @@ -40,6 +40,9 @@ class HookManager { /** @var IUser[] */ private $usersToDelete; + /** @var array */ + private $calendarsToDelete; + /** @var CalDavBackend */ private $calDav; @@ -85,7 +88,11 @@ class HookManager { } public function preDeleteUser($params) { - $this->usersToDelete[$params['uid']] = $this->userManager->get($params['uid']); + $user = $this->userManager->get($params['uid']); + + $this->usersToDelete[$params['uid']] = $user; + + $this->calendarsToDelete = $this->calDav->getCalendarsForUser('principals/users/' . $user->getUID()); } public function postDeleteUser($params) { @@ -93,6 +100,11 @@ class HookManager { if (isset($this->usersToDelete[$uid])){ $this->syncService->deleteUser($this->usersToDelete[$uid]); } + if (!is_null($this->calendarsToDelete)) { + foreach ($this->calendarsToDelete as $calendar) { + $this->calDav->deleteCalendar($calendar['id']); + } + } } public function changeUser($params) { -- cgit v1.2.3