Merge pull request #939 from ByteHamster/fix-user-deletion

Fixed user deletion
This commit is contained in:
H. Lehmann 2020-06-12 23:18:45 +02:00 committed by GitHub
commit fd057223c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 6 deletions

View file

@ -257,7 +257,8 @@ class Calendar extends \Flake\Core\Model\Db {
}
function destroy() {
if (!$this->hasInstances()) {
$hasInstances = $this->hasInstances();
if (!$hasInstances) {
$oEvents = $this->getEventsBaseRequester()->execute();
foreach ($oEvents as $event) {
$event->destroy();
@ -265,6 +266,8 @@ class Calendar extends \Flake\Core\Model\Db {
}
parent::destroy();
$this->oCalendar->destroy();
if (!$hasInstances) {
$this->oCalendar->destroy();
}
}
}

View file

@ -40,7 +40,7 @@ class Calendar extends \Flake\Core\Model\Db {
$rSql = $GLOBALS["DB"]->exec_SELECTquery(
"count(*)",
"calendarinstances",
"calendarid" . "='" . $this->aData["calendarid"] . "'"
"calendarid" . "='" . $this->aData["id"] . "'"
);
if (($aRs = $rSql->fetch()) === false) {
@ -53,8 +53,9 @@ class Calendar extends \Flake\Core\Model\Db {
}
function destroy() {
if (!$this->hasInstances()) {
parent::destroy();
if ($this->hasInstances()) {
throw new \Exception("Trying to destroy a calendar with instances");
}
parent::destroy();
}
}

View file

@ -181,7 +181,9 @@ class User extends \Flake\Core\Model\Db {
# TODO: delete all related resources (principals, calendars, calendar events, contact books and contacts)
# Destroying identity principal
$this->oIdentityPrincipal->destroy();
if ($this->oIdentityPrincipal != null) {
$this->oIdentityPrincipal->destroy();
}
$oCalendars = $this->getCalendarsBaseRequester()->execute();
foreach ($oCalendars as $calendar) {

View file

@ -165,6 +165,7 @@ class Users extends \Flake\Core\Controller {
$oUser->destroy();
} catch (\Exception $e) {
# user is already deleted; silently discarding
error_log($e);
}
# Redirecting to admin home