bug message succès fixed

This commit is contained in:
laura.chevillet 2026-02-16 16:26:58 +01:00
parent 432e111c47
commit d0ac49f024
5 changed files with 33 additions and 7 deletions

View file

@ -25,6 +25,7 @@
header("Location:index.php?ctrl=error&action=error_403");
exit;
}
var_dump($_SESSION);
//gestion de l'user
$objCategoryModel = new CategoryModel;
@ -33,6 +34,7 @@
$newCat = new Category();
$newCat->setName($_POST['new_category']);
$objCategoryModel->insertCategory($newCat);
$_SESSION['success'] = "La catégorie a bien été ajoutée";
header('Location: index.php?ctrl=admin&action=admin');
exit;
}
@ -68,12 +70,12 @@
$objUser->setId($intUserId);
$objUser->setStatus((int)$_POST['new_status']);
if ($objUserModel->editStatus($objUser)) {
$_SESSION['message_success'] = "Le statut a bien été modifié !";
$_SESSION['success'] = "Le statut a bien été modifié !";
}
}
elseif ($_POST['action'] === 'delete_user') {
$objUserModel->delete_soft($intUserId);
$_SESSION['message_success'] = "L'utilisateur a été supprimé.";
$_SESSION['success'] = "L'utilisateur a été supprimé.";
}
header("Location: index.php?ctrl=admin&action=admin");
exit;

View file

@ -10,7 +10,7 @@
/**
* Méthode d'affichage des pages
*/
protected function _display($strView){
protected function _display($strView, bool $boolDisplay = true){
// Création de l'objet Smarty
$objSmarty = new Smarty();
// Ajouter le var_dump au modificateur de smarty : vardump est le nom appelé après le |
@ -32,8 +32,18 @@
// Message de succès
$objSmarty->assign("success_message", $_SESSION['success']??'');
unset($_SESSION['success']);
if (isset($_SESSION['error'])){
$objSmarty->assign("arrError", array($_SESSION['error']));
unset($_SESSION['error']);
}
if ($boolDisplay){
$objSmarty->display("views/".$strView.".tpl");
}else{
return $objSmarty->fetch("views/".$strView.".tpl");
}
$objSmarty->display("views/".$strView.".tpl");
// inclusion du header