Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
delete calendars when users are deleted
  • Loading branch information
tcitworld authored and DeepDiver1975 committed Sep 22, 2016
commit af4cc4282582432f578dcd28cdb70befbb2e765b
14 changes: 13 additions & 1 deletion apps/dav/lib/HookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class HookManager {
/** @var IUser[] */
private $usersToDelete;

/** @var array */
private $calendarsToDelete;

/** @var CalDavBackend */
private $calDav;

Expand Down Expand Up @@ -90,14 +93,23 @@ public function postCreateUser($params) {
}

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) {
$uid = $params['uid'];
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) {
Expand Down