Merge branch 'main' into guillaume
This commit is contained in:
commit
8aed1e526b
18 changed files with 810 additions and 40 deletions
|
|
@ -3,6 +3,8 @@
|
|||
require("../app/entities/project_entity.php");
|
||||
require("../app/models/category_model.php");
|
||||
require("../app/entities/category_entity.php");
|
||||
require("../app/models/image_model.php");
|
||||
require("../app/entities/image_entity.php");
|
||||
|
||||
/**
|
||||
* Le controler des Project
|
||||
|
|
@ -37,23 +39,24 @@
|
|||
|
||||
public function search(){
|
||||
|
||||
//variable pour faire fonctionner le script en footer
|
||||
$strPage = "search";
|
||||
|
||||
// inclusion du header
|
||||
include('../app/views/partials/header.php');
|
||||
|
||||
//Récupérer les informations du Formulaire
|
||||
$strKeywords = $_GET['keywords']??'';
|
||||
$intAuthor = $_GET['author']??0;
|
||||
$intPeriod = $_GET['period']??0;
|
||||
$strDate = $_GET['date']??'';
|
||||
$strStartDate = $_GET['startdate']??'';
|
||||
$strEndDate = $_GET['enddate']??'';
|
||||
$intCategory = $_GET['category']??0;
|
||||
|
||||
// Récupération des Projects
|
||||
$strKeywords = $_POST['keywords']??'';
|
||||
$intAuthor = $_POST['author']??0;
|
||||
$intPeriod = $_POST['period']??0;
|
||||
$strDate = $_POST['date']??'';
|
||||
$strStartDate = $_POST['startdate']??'';
|
||||
$strEndDate = $_POST['enddate']??'';
|
||||
$intCategory = $_POST['category']??0;
|
||||
// Récupération des projetc
|
||||
$objProjectModel = new ProjectModel;
|
||||
|
||||
// Depuis PHP 8 - accès direct aux paramètres
|
||||
$arrProject = $objProjectModel->findAll();
|
||||
$arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate,
|
||||
strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory);
|
||||
|
||||
// Initialisation d'un tableau => objets
|
||||
$arrProjectToDisplay = array();
|
||||
|
|
@ -84,9 +87,30 @@
|
|||
* Fonction d'affichage de la page projet
|
||||
*/
|
||||
|
||||
|
||||
public function project (){
|
||||
|
||||
$objProjectModel = new ProjectModel;
|
||||
$arrProject = $objProjectModel->findAll(4);
|
||||
$arrProjectToDiplay = array();
|
||||
foreach($arrProject as $arrDetProject){
|
||||
$objProject = new Project;
|
||||
$objProject->hydrate($arrDetProject);
|
||||
$arrProjectToDiplay[] = $objProject;
|
||||
}
|
||||
|
||||
$objImageModel = new ImageModel;
|
||||
$arrImage = $objImageModel->findAllImage(4);
|
||||
$arrImageToDiplay = array();
|
||||
foreach($arrImage as $arrDetImage){
|
||||
$objImage = new Image;
|
||||
$objImage->hydrate($arrDetImage);
|
||||
$arrImageToDiplay[] = $objImage;
|
||||
}
|
||||
|
||||
include("../app/views/partials/header.php");
|
||||
include('../app/views/project.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -43,19 +43,105 @@ class UserCtrl{
|
|||
include("../app/views/login.php");
|
||||
include("../app/views/partials/footer.php");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function logout(){
|
||||
session_start();
|
||||
|
||||
// on supprime l'utilisateur en session
|
||||
unset($_SESSION['user']);
|
||||
|
||||
$_SESSION['success'] = "Vous êtes bien déconnecté";
|
||||
|
||||
header("Location:index.php");
|
||||
exit;
|
||||
session_start();
|
||||
/*session_destroy();
|
||||
session_start();*/
|
||||
|
||||
// on supprime l'utilisateur en session
|
||||
unset($_SESSION['user']);
|
||||
|
||||
$_SESSION['success'] = "Vous êtes bien déconnecté";
|
||||
|
||||
header("Location:index.php");
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function signin(){
|
||||
|
||||
// Inclusion du header
|
||||
include("../app/views/partials/header.php");
|
||||
|
||||
// Entité pour réafficher les valeurs dans le formulaire
|
||||
$objUser = new User();
|
||||
|
||||
// Récupération des champs
|
||||
$strPwdConfirm = $_POST['pwd_confirm'] ?? "";
|
||||
|
||||
// Tableau d'erreurs
|
||||
$arrError = [];
|
||||
|
||||
// Traitement du formulaire uniquement si POST
|
||||
if (!empty($_POST)) {
|
||||
|
||||
// Hydratation
|
||||
$objUser->setName($_POST['user_name'] ?? "");
|
||||
$objUser->setFirstname($_POST['user_firstname'] ?? "");
|
||||
$objUser->setMail($_POST['user_mail'] ?? "");
|
||||
$objUser->setPseudo($_POST['user_pseudo'] ?? "");
|
||||
$objUser->setPwd($_POST['user_password'] ?? "");
|
||||
|
||||
// Champs optionnels : on les stocke aussi même si ils sont vides
|
||||
$objUser->setPhone($_POST['user_phone'] ?? "");
|
||||
$objUser->setWork($_POST['user_work'] ?? "");
|
||||
$objUser->setLocation($_POST['user_location'] ?? "");
|
||||
$objUser->setDescription($_POST['user_description'] ?? "");
|
||||
|
||||
|
||||
// --- VALIDATIONS (obligatoires) ---
|
||||
if (trim($objUser->getName()) === "") {
|
||||
$arrError['user_name'] = "Le nom est obligatoire";
|
||||
}
|
||||
|
||||
if (trim($objUser->getFirstname()) === "") {
|
||||
$arrError['user_firstname'] = "Le prénom est obligatoire";
|
||||
}
|
||||
|
||||
if (trim($objUser->getMail()) === "") {
|
||||
$arrError['user_mail'] = "Le mail est obligatoire";
|
||||
} elseif (!filter_var($objUser->getMail(), FILTER_VALIDATE_EMAIL)) {
|
||||
$arrError['user_mail'] = "Le format du mail n'est pas correct";
|
||||
}
|
||||
|
||||
if (trim($objUser->getPseudo()) === "") {
|
||||
$arrError['user_pseudo'] = "Le pseudo est obligatoire";
|
||||
}
|
||||
|
||||
$strRegex = "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{16,}$/";
|
||||
if ($objUser->getPwd() == ""){
|
||||
$arrError['user_password'] = "Le mot de passe est obligatoire";
|
||||
}else if (!preg_match($strRegex, $objUser->getPwd())){
|
||||
$arrError['user_password'] = "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";
|
||||
}
|
||||
|
||||
|
||||
// Si pas d'erreurs => insertion
|
||||
if (count($arrError) === 0) {
|
||||
$objUserModel = new UserModel();
|
||||
$boolInsert = $objUserModel->insert($objUser);
|
||||
|
||||
if ($boolInsert === true) {
|
||||
$_SESSION['success'] = "Compte créé avec succès";
|
||||
header("Location:index.php?ctrl=user&action=login");
|
||||
exit;
|
||||
} else {
|
||||
// Erreur globale (pas liée à un champ)
|
||||
$arrError['global'] = "Erreur lors de l'ajout";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affichage de la vue inscription
|
||||
include("../app/views/inscription.php");
|
||||
include("../app/views/partials/footer.php");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue