Création entity et model d'authorisation. Création de toute la fonctionnalité de modifier le statut et supprimer un user ok fonction et verif bdd
This commit is contained in:
parent
3a80108ba5
commit
3af2e8a056
14 changed files with 456 additions and 76 deletions
|
|
@ -8,6 +8,8 @@
|
|||
require("./entities/image_entity.php");
|
||||
require("./models/user_model.php");
|
||||
require("./entities/user_entity.php");
|
||||
require("./models/authorisation_model.php");
|
||||
require("./entities/authorisation_entity.php");
|
||||
require("mother_controller.php");
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +25,8 @@
|
|||
header("Location:index.php?ctrl=error&action=error_403");
|
||||
exit;
|
||||
}
|
||||
|
||||
//gestion de l'user
|
||||
$objCategoryModel = new CategoryModel;
|
||||
|
||||
if (!empty($_POST['new_category'])) {
|
||||
|
|
@ -42,6 +46,7 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
//affichage select des catégories
|
||||
$arrCategory = $objCategoryModel->findAllCategory();
|
||||
$arrCategoryToDisplay = array();
|
||||
|
||||
|
|
@ -50,9 +55,56 @@
|
|||
$objCategory->hydrate($arrDetCategory);
|
||||
$arrCategoryToDisplay[] = $objCategory;
|
||||
}
|
||||
|
||||
//gestion de l'user
|
||||
$objUserModel = new UserModel;
|
||||
|
||||
if (!empty($_POST['action'])) {
|
||||
$intUserId = (int)$_POST['user_id'];
|
||||
|
||||
if ($intUserId > 0) {
|
||||
if ($_POST['action'] === 'update_status' && !empty($_POST['new_status'])) {
|
||||
$objUser = new User();
|
||||
$objUser->setId($intUserId);
|
||||
$objUser->setStatus((int)$_POST['new_status']);
|
||||
if ($objUserModel->editStatus($objUser)) {
|
||||
$_SESSION['message_success'] = "Le statut a bien été modifié !";
|
||||
}
|
||||
}
|
||||
elseif ($_POST['action'] === 'delete_user') {
|
||||
$objUserModel->delete_soft($intUserId);
|
||||
$_SESSION['message_success'] = "L'utilisateur a été supprimé.";
|
||||
}
|
||||
header("Location: index.php?ctrl=admin&action=admin");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//affichage select des users
|
||||
$arrUser = $objUserModel->findAllUsers();
|
||||
$arrUserToDisplay = array();
|
||||
|
||||
foreach($arrUser as $arrDetUser){
|
||||
$objUser = new User;
|
||||
$objUser->hydrate($arrDetUser);
|
||||
$arrUserToDisplay[] = $objUser;
|
||||
}
|
||||
|
||||
//affichage select des authorisations
|
||||
$objAuthorisationModel = new AuthorisationModel;
|
||||
$arrAuthorisation = $objAuthorisationModel->findAllAuthorisation();
|
||||
$arrAuthorisationToDisplay = array();
|
||||
|
||||
foreach($arrAuthorisation as $arrDetAuthorisation){
|
||||
$objAuthorisation = new Authorisation;
|
||||
$objAuthorisation->hydrate($arrDetAuthorisation);
|
||||
$arrAuthorisationToDisplay[] = $objAuthorisation;
|
||||
}
|
||||
|
||||
//gérer l'affichage
|
||||
$this->_arrData['arrCategoryToDisplay'] = $arrCategoryToDisplay;
|
||||
$this->_arrData['arrCategoryToDisplay'] = $arrCategoryToDisplay;
|
||||
$this->_arrData['arrUserToDisplay'] = $arrUserToDisplay;
|
||||
$this->_arrData['arrAuthorisationToDisplay'] = $arrAuthorisationToDisplay;
|
||||
$this->_display("admin");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue