Possibilité de supprimer un compte

This commit is contained in:
Yohann D'ANELLO 2020-01-21 19:22:22 +01:00
parent 6fe398d965
commit 94f907abf2
2 changed files with 11 additions and 2 deletions

View File

@ -74,7 +74,8 @@ if (isset($_POST["delete_account"]) && $team == null && $_SESSION["role"] == Rol
foreach ($user->getAllDocuments($team->getTournamentId()) as $document)
unlink($LOCAL_PATH . "/files/" . $document->getFileId());
$DB->prepare("DELETE FROM `documents` WHERE `user` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `users` WHERE `id` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `organizers` WHERE `organizer` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `users` WHERE `id` = ?;")->execute([$user->getId()]);
header("Location: /");
exit();
}

View File

@ -178,7 +178,15 @@ elseif (($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCA
}
}
if ($_SESSION["role"] == Role::ADMIN) { ?>
if ($_SESSION["role"] == Role::ADMIN) {
if ($user->getRole() != Role::ADMIN && $team == null) { ?>
<hr/>
<form method="POST">
<input type="submit" name="delete_account" class="btn btn-secondary btn-lg btn-block"
style="background-color: #ff2e34" value="Supprimer le compte"/>
</form>
<?php } ?>
<hr />
<form method="POST">
<input type="submit" name="view_as" class="btn btn-secondary btn-lg btn-block" style="background-color: #2ba42b"