version pour laura et besnik
This commit is contained in:
parent
024cf537ed
commit
4fd89380c0
6 changed files with 174 additions and 120 deletions
|
|
@ -3,7 +3,7 @@
|
|||
require("../app/entities/project_entity.php");
|
||||
|
||||
/**
|
||||
* Le controler des article
|
||||
* Le controler des Project
|
||||
* @author Yasser
|
||||
*/
|
||||
class ProjectCtrl{
|
||||
|
|
@ -29,4 +29,35 @@
|
|||
|
||||
}
|
||||
|
||||
public function search(){
|
||||
|
||||
// inclusion du header
|
||||
include('../app/views/partials/header.php');
|
||||
|
||||
//Récupérer les informations du Formulaire
|
||||
|
||||
// Récupération des Projects
|
||||
$objProjectModel = new ProjectModel;
|
||||
//$arrProject = findAll(0, $strKeywords, $intAuthor, $intPeriod, $strDate, $strStartDate, $strEndDate);
|
||||
// Depuis PHP 8 - accès direct aux paramètres
|
||||
$arrProject = $objProjectModel->findAll();
|
||||
|
||||
// Initialisation d'un tableau => objets
|
||||
$arrProjectToDisplay = array();
|
||||
// Boucle de transformation du tableau de tableau en tableau d'objets
|
||||
foreach($arrProject as $arrDetProject){
|
||||
$objProject = new Project;
|
||||
$objProject->hydrate($arrDetProject);
|
||||
|
||||
$arrProjectToDisplay[] = $objProject;
|
||||
}
|
||||
|
||||
// Récupération des utilisateurs
|
||||
require("../app/models/user_model.php");
|
||||
$objUserModel = new UserModel;
|
||||
$arrUser = $objUserModel->findAllUsers();
|
||||
|
||||
include('../app/views/search.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
}
|
||||
}
|
||||
|
|
@ -52,76 +52,6 @@ class UserCtrl{
|
|||
|
||||
}
|
||||
|
||||
public function create(){
|
||||
// Variables d'affichage
|
||||
$strH2 = "Créer un compte";
|
||||
$strP = "Inscrivez-vous";
|
||||
// Variables technique
|
||||
$strPage = "create_account";
|
||||
|
||||
// inclusion du header
|
||||
include("views/_partial/header.php");
|
||||
|
||||
// Traitement du formulaire
|
||||
//var_dump($_POST);
|
||||
$strName = $_POST['name']??"";
|
||||
$strFirstname = $_POST['firstname']??"";
|
||||
$strMail = $_POST['mail']??"";
|
||||
$strPwd = $_POST['pwd']??"";
|
||||
$strPwdConfirm = $_POST['pwd_confirm']??"";
|
||||
$objUser = new User;
|
||||
$objUser->hydrate($_POST);
|
||||
|
||||
/*
|
||||
$objUser->setName($strName);
|
||||
$objUser->setFirstname($strFirstname);
|
||||
$objUser->setMail($strMail);
|
||||
$objUser->setPwd($strPwd);
|
||||
*/
|
||||
// Tester le formulaire
|
||||
$arrError = [];
|
||||
if (count($_POST) > 0) {
|
||||
if ($objUser->getName() == ""){
|
||||
$arrError['name'] = "Le nom est obligatoire";
|
||||
}
|
||||
if ($objUser->getFirstname() == ""){
|
||||
$arrError['firstname'] = "Le prénom est obligatoire";
|
||||
}
|
||||
if ($objUser->getMail() == ""){
|
||||
$arrError['mail'] = "Le mail est obligatoire";
|
||||
}else if (!filter_var($objUser->getMail(), FILTER_VALIDATE_EMAIL)){
|
||||
$arrError['mail'] = "Le format du mail n'est pas correct";
|
||||
}
|
||||
$strRegex = "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{16,}$/";
|
||||
if ($objUser->getPwd() == ""){
|
||||
$arrError['pwd'] = "Le mot de passe est obligatoire";
|
||||
}else if (!preg_match($strRegex, $objUser->getPwd())){
|
||||
$arrError['pwd'] = "Le mot de passe ne correspond pas aux règles";
|
||||
}else if($objUser->getPwd() != $strPwdConfirm){
|
||||
$arrError['pwd_confirm'] = "Le mot de passe et sa confirmation ne sont pas identiques";
|
||||
}
|
||||
// Ajouter la vérification du mot de passe par regex
|
||||
|
||||
// Si le formulaire est rempli correctement
|
||||
if (count($arrError) == 0){
|
||||
// => Ajout dans la base de données
|
||||
$objUserModel = new UserModel;
|
||||
//$intNbInsert = $objUserModel->insert($strName, $strFirstname, $strMail, $strPwd);
|
||||
$boolInsert = $objUserModel->insert($objUser);
|
||||
if ($boolInsert === true){
|
||||
$_SESSION['success'] = "Le compte a bien été créé";
|
||||
//header("Location:index.php");
|
||||
//exit;
|
||||
}else{
|
||||
$arrError[] = "Erreur lors de l'ajout";
|
||||
}
|
||||
//var_dump("tout est ok");
|
||||
}
|
||||
}
|
||||
include("views/create_account.php");
|
||||
include("views/_partial/footer.php");
|
||||
}
|
||||
|
||||
|
||||
public function logout(){
|
||||
session_start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue