edit user
This commit is contained in:
parent
216de9c8df
commit
09ec39c7bb
11 changed files with 293 additions and 68 deletions
|
|
@ -151,37 +151,74 @@ class UserCtrl extends MotherCtrl {
|
|||
*/
|
||||
public function user(){
|
||||
|
||||
$intId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
$intId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
|
||||
if ($intId <= 0) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
if ($intId <= 0) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//affichage info utilisateur
|
||||
$objUserModel = new UserModel;
|
||||
$arrUserData = $objUserModel->findUserById($intId);
|
||||
//affichage info utilisateur
|
||||
$objUserModel = new UserModel;
|
||||
$arrUserData = $objUserModel->findUserById($intId);
|
||||
|
||||
if ($arrUserData === false) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
$objUser = new User;
|
||||
$objUser->hydrate($arrUserData);
|
||||
if ($arrUserData === false) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
$objUser = new User;
|
||||
$objUser->hydrate($arrUserData);
|
||||
|
||||
//affichage projet de l'utilisateur
|
||||
$objProjectModel = new ProjectModel;
|
||||
$arrProjects = $objProjectModel->findAll(0,'',$intId);
|
||||
//affichage projet de l'utilisateur
|
||||
$objProjectModel = new ProjectModel;
|
||||
$arrProjects = $objProjectModel->findAll(0,'',$intId);
|
||||
|
||||
$arrProjectToDisplay = array();
|
||||
foreach($arrProjects as $projectData) {
|
||||
$objProject = new Project();
|
||||
$objProject->hydrate($projectData);
|
||||
$arrProjectToDisplay[] = $objProject;
|
||||
}
|
||||
$arrProjectToDisplay = array();
|
||||
foreach($arrProjects as $projectData) {
|
||||
$objProject = new Project();
|
||||
$objProject->hydrate($projectData);
|
||||
$arrProjectToDisplay[] = $objProject;
|
||||
}
|
||||
|
||||
$this->_arrData['user'] = $objUser;
|
||||
$this->_arrData['arrProjectToDisplay'] = $arrProjectToDisplay;
|
||||
$this->_display("user");
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
if(!isset($_SESSION['user'])){
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$objUserModel = new UserModel;
|
||||
$arrError = [];
|
||||
$objUser = new User;
|
||||
$arrUserData = $objUserModel->findUserById($_SESSION['user']['user_id']);
|
||||
$objUser->hydrate($arrUserData);
|
||||
if (!empty($_POST)) {
|
||||
if ($objUserModel->mailExists($objUser->getMail()) && ($_POST['user_mail'] != $objUser->getMail())) {
|
||||
|
||||
$arrError['user_mail'] = "Ce mail est déjà associé";
|
||||
} else {
|
||||
$objUser->hydrate($_POST);
|
||||
$objUser->setId($_SESSION['user']['user_id']);
|
||||
$boolInsert = $objUserModel->update($objUser);
|
||||
|
||||
if ($boolInsert === true) {
|
||||
$_SESSION['success'] = "Compte créé avec succès";
|
||||
header("Location:?ctrl=user&action=user&id=".$objUser->getId());
|
||||
exit;
|
||||
} else {
|
||||
$arrError['global'] = "Erreur lors de l'update";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->_arrData["arrError"] = $arrError;
|
||||
$this->_arrData['objUser'] = $objUser;
|
||||
$this->_display("useredit");
|
||||
|
||||
$this->_arrData['user'] = $objUser;
|
||||
$this->_arrData['arrProjectToDisplay'] = $arrProjectToDisplay;
|
||||
$this->_display("user");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue