delete calendars when users are deleted

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
Thomas Citharel 2016-08-23 15:43:54 +02:00 committed by Lukas Reschke
parent 6ca8ce6228
commit 7db01ff805
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
1 changed files with 13 additions and 1 deletions

View File

@ -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) {