smarty et merge de tout fini ( ദ്ദി ˙ᗜ˙ )

This commit is contained in:
Yasder5 2026-02-09 11:19:00 +01:00
parent a774205594
commit 6ed4394dda
113 changed files with 11964 additions and 1192 deletions

View file

@ -8,6 +8,9 @@
require("./models/user_model.php");
require("./entities/user_entity.php");
require("mother_controller.php");
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
/**
* Le controler des Project
@ -50,25 +53,24 @@
$strStartDate = $_POST['startdate']??'';
$strEndDate = $_POST['enddate']??'';
$intCategory = $_POST['category']??0;
// Récupération des projetc
// Récupération des projets
$objProjectModel = new ProjectModel;
$arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate,
strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory);
// 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
$objUserModel = new UserModel;
$arrUser = $objUserModel->findAllUsers();
// Récupération des catégories
$objCategoryModel = new CategoryModel;
$arrCategory = $objCategoryModel->findAllCategory();
@ -159,9 +161,99 @@
}
public function admin(){
$this->_display("admin");
}
public function display() {
$intId = $_GET['id'] ?? null;
if ($intId) {
$objProjectModel = new ProjectModel();
$arrProject = $objProjectModel->findOne((int)$intId);
if ($arrProject) {
$objProject = new Project();
$objProject->hydrate($arrProject);
$this->_arrData["objProject"] = $objProject;
$this->_display("projet_display");
} else {
header("Location: index.php?ctrl=project&action=home");
exit;
}
} else {
header("Location: index.php?ctrl=project&action=home");
exit;
}
}
public function sendEmail()
{
if (count($_POST) > 0) {
$projectId = (int)($_POST['project_id'] ?? 0);
$toEmail = trim($_POST['to_email'] ?? '');
if ($projectId <= 0 || !filter_var($toEmail, FILTER_VALIDATE_EMAIL)) {
header("Location: index.php?ctrl=project&action=display&id=".$projectId."&mail=fail");
exit;
}
$objProjectModel = new ProjectModel();
$arrProject = $objProjectModel->findOne($projectId);
if (!$arrProject) {
header("Location: index.php?ctrl=project&action=home");
exit;
}
$objProject = new Project();
$objProject->hydrate($arrProject);
$objMail = new PHPMailer(); // Nouvel objet Mail
$objMail->IsSMTP();
$objMail->Mailer = "smtp";
$objMail->CharSet = PHPMailer::CHARSET_UTF8;
$objMail->SMTPDebug = 0;
$objMail->SMTPAuth = TRUE;
$objMail->SMTPSecure = "tls";
$objMail->Port = 587;
$objMail->Host = "smtp.gmail.com";
$objMail->Username = "projet.folliow@gmail.com";
$objMail->Password = "dqnw mqbu cwvg enbp";
$objMail->IsHTML(true);
$objMail->setFrom('projet.folliow@gmail.com', 'Projet Folliow');
// Destinataire
$objMail->addAddress($toEmail);
// Mail
$objMail->Subject = "Projet : " . $objProject->getTitle();
$url = "http://localhost/projet_php/public/index.php?ctrl=project&action=display&id=" . $projectId;
$objMail->Body =
"<h3>" . $objProject->getTitle() . "</h3>" .
"<p>" . $objProject->getDescription() . "</p>" .
"<p><a href='" . $url . "'>Voir le projet</a></p>";
// Envoi + redirection
if ($objMail->Send()) {
header("Location: index.php?ctrl=project&action=display&id=".$projectId."&mail=ok");
} else {
// Pour debug si besoin: echo $objMail->ErrorInfo; exit;
header("Location: index.php?ctrl=project&action=display&id=".$projectId."&mail=fail");
}
exit;
}
header("Location: index.php?ctrl=project&action=home");
exit;
}
}