Correction affichage recherche, maj bouton, suppression requêtes de controller, déplacer mention et about dans page_controller, nettoyage des commentaires pour ctrl, entities & models
This commit is contained in:
parent
8c89a6ec1b
commit
050c804d48
20 changed files with 244 additions and 282 deletions
|
|
@ -26,7 +26,6 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
//gestion de l'user
|
||||
$objCategoryModel = new CategoryModel;
|
||||
|
||||
if (!empty($_POST['new_category'])) {
|
||||
|
|
@ -48,7 +47,6 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
//affichage select des catégories
|
||||
$arrCategory = $objCategoryModel->findAllCategory();
|
||||
$arrCategoryToDisplay = array();
|
||||
|
||||
|
|
@ -58,7 +56,6 @@
|
|||
$arrCategoryToDisplay[] = $objCategory;
|
||||
}
|
||||
|
||||
//gestion de l'user
|
||||
$objUserModel = new UserModel;
|
||||
|
||||
if (!empty($_POST['action'])) {
|
||||
|
|
@ -82,7 +79,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
//affichage select des users
|
||||
$arrUser = $objUserModel->findAllUsers();
|
||||
$arrUserToDisplay = array();
|
||||
|
||||
|
|
@ -92,7 +88,6 @@
|
|||
$arrUserToDisplay[] = $objUser;
|
||||
}
|
||||
|
||||
//affichage select des authorisations
|
||||
$objAuthorisationModel = new AuthorisationModel;
|
||||
$arrAuthorisation = $objAuthorisationModel->findAllAuthorisation();
|
||||
$arrAuthorisationToDisplay = array();
|
||||
|
|
@ -103,7 +98,6 @@
|
|||
$arrAuthorisationToDisplay[] = $objAuthorisation;
|
||||
}
|
||||
|
||||
//gérer l'affichage
|
||||
$this->_arrData['arrCategoryToDisplay'] = $arrCategoryToDisplay;
|
||||
$this->_arrData['arrUserToDisplay'] = $arrUserToDisplay;
|
||||
$this->_arrData['arrAuthorisationToDisplay'] = $arrAuthorisationToDisplay;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
/**
|
||||
* Le contrôleur des erreurs
|
||||
* @author Laura (largement inspiré de Christel)
|
||||
* @author Laura
|
||||
*/
|
||||
class ErrorCtrl extends MotherCtrl{
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,35 @@
|
|||
|
||||
/**
|
||||
* Le controller de la page d'aide utilisateur
|
||||
* @author Laura
|
||||
* @author Laura & Besnik
|
||||
*/
|
||||
|
||||
class PageCtrl extends MotherCtrl{
|
||||
|
||||
|
||||
/**
|
||||
* Page aide utilisateur
|
||||
*/
|
||||
public function help(){
|
||||
|
||||
$this->_display("help");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Page mentions légales
|
||||
*/
|
||||
public function mentions(){
|
||||
// Afficher
|
||||
$this->_display("mentions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Page à propos
|
||||
*/
|
||||
public function about(){
|
||||
// Afficher
|
||||
$this->_display("about");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,12 +16,12 @@
|
|||
* Le controler des Project
|
||||
* @author Yasser, Laura, Besnik & Guillaume
|
||||
*/
|
||||
|
||||
class ProjectCtrl extends MotherCtrl{
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la page d'acceuil
|
||||
*/
|
||||
|
||||
public function home(){
|
||||
|
||||
|
||||
|
|
@ -75,7 +75,6 @@
|
|||
*/
|
||||
public function search(){
|
||||
|
||||
//Récupérer les informations du formulaire
|
||||
$strKeywords = $_POST['keywords']??'';
|
||||
$intAuthor = $_POST['author']??0;
|
||||
$intPeriod = $_POST['period']??0;
|
||||
|
|
@ -84,7 +83,6 @@
|
|||
$strEndDate = $_POST['enddate']??'';
|
||||
$intCategory = $_POST['category']??0;
|
||||
|
||||
// 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);
|
||||
|
|
@ -96,18 +94,23 @@
|
|||
$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();
|
||||
|
||||
$this->_arrData['arrProjectToDisplay'] = $arrProjectToDisplay;
|
||||
$this->_arrData['arrCategory'] = $arrCategory;
|
||||
$this->_arrData['arrProject'] = $arrProject;
|
||||
$this->_arrData['arrUser'] = $arrUser;
|
||||
$this->_arrData['arrProject'] = $arrProject;
|
||||
$this->_arrData['arrUser'] = $arrUser;
|
||||
$this->_arrData['strKeywords'] = $strKeywords;
|
||||
$this->_arrData['intAuthor'] = $intAuthor;
|
||||
$this->_arrData['intPeriod'] = $intPeriod;
|
||||
$this->_arrData['strDate'] = $strDate;
|
||||
$this->_arrData['strStartDate'] = $strStartDate;
|
||||
$this->_arrData['strEndDate'] = $strEndDate;
|
||||
$this->_arrData['intCategory'] = $intCategory;
|
||||
|
||||
$this->_display("search");
|
||||
}
|
||||
|
|
@ -131,7 +134,7 @@
|
|||
header("Location:index.php?ctrl=error&action=error_403");
|
||||
exit;
|
||||
}
|
||||
$objProject->hydrate($arrProject); // BDD
|
||||
$objProject->hydrate($arrProject);
|
||||
$this->_arrData['arrImages'] = $objProjectModel->getImagesByProjectId($objProject->getId());
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +154,6 @@
|
|||
$arrError['content'] = "Le contenu est obligatoire";
|
||||
}
|
||||
|
||||
// Vérification de l'image (Thumbnail)
|
||||
$arrTypeAllowed = array('image/jpeg', 'image/png', 'image/webp');
|
||||
if ($_FILES['thumbnail']['error'] != 4){
|
||||
if (!in_array($_FILES['thumbnail']['type'], $arrTypeAllowed)){
|
||||
|
|
@ -186,18 +188,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
// SI pas d'erreur : on traite l'image principale
|
||||
if (count($arrError) == 0){
|
||||
|
||||
$boolImageOk = true;
|
||||
|
||||
// On peux changer ces dimensions si on veux que la miniature soit plus grande/petite
|
||||
if (isset($strImageName)){
|
||||
$strDest = $_ENV['IMG_PROJECT_PATH'].$strImageName;
|
||||
$strSource = $_FILES['thumbnail']['tmp_name'];
|
||||
list($intWidth, $intHeight) = getimagesize($strSource);
|
||||
|
||||
// Redimensionnement de la Thumbnail
|
||||
$intDestWidth = 200; $intDestHeight = 250;
|
||||
$fltDestRatio = $intDestWidth / $intDestHeight;
|
||||
$fltSourceRatio = $intWidth / $intHeight;
|
||||
|
|
@ -230,12 +228,10 @@
|
|||
imagecopyresampled($objDest, $objSource, 0, 0, $intCropX, $intCropY, $intDestWidth, $intDestHeight, $intCropWidth, $intCropHeight);
|
||||
$boolImageOk = imagewebp($objDest, $strDest);
|
||||
|
||||
//Suppression des doublons pour la mémoire vive
|
||||
imagedestroy($objDest);
|
||||
imagedestroy($objSource);
|
||||
}
|
||||
|
||||
// SI image ok, on balance tout dans la bdd
|
||||
if ($boolImageOk){
|
||||
if (!isset($_GET['id'])){
|
||||
$objProject->setUser_id($_SESSION['user']['user_id']);
|
||||
|
|
@ -244,28 +240,21 @@
|
|||
$boolOk = $objProjectModel->updateProject($objProject);
|
||||
}
|
||||
|
||||
// Gestion des 20 Images après l'envoie de la Thumbnail en BDD
|
||||
if ($boolOk){
|
||||
//Si pas d'erreur
|
||||
if (isset($_FILES['imageProject']) && $_FILES['imageProject']['error'][0] != 4) {
|
||||
$files = $_FILES['imageProject'];
|
||||
$maxPhotos = 20;
|
||||
|
||||
// 1. On compte combien d'images le projet possède déjà en BDD
|
||||
$currentImages = $objProjectModel->getImagesByProjectId($objProject->getId());
|
||||
$totalExisting = count($currentImages);
|
||||
|
||||
// 2. On calcule combien de photos on peut encore ajouter
|
||||
$remainingSlots = $maxPhotos - $totalExisting;
|
||||
|
||||
// Si on a déjà atteint ou dépassé la limite, on ne traite même pas les fichiers
|
||||
if ($remainingSlots <= 0) {
|
||||
$_SESSION['error'] = "Limite de $maxPhotos photos atteinte. Supprimez-en pour en ajouter de nouvelles.";
|
||||
} else {
|
||||
$uploadedCount = 0;
|
||||
|
||||
foreach ($files['name'] as $key => $name) {
|
||||
// 3. On utilise le quota restant comme condition d'arrêt
|
||||
if ($uploadedCount >= $remainingSlots) break;
|
||||
|
||||
if ($files['error'][$key] === 0 && in_array($files['type'][$key], $arrTypeAllowed)) {
|
||||
|
|
@ -274,10 +263,8 @@
|
|||
$strDestGallery = $_ENV['IMG_PROJECT_PATH'].$galleryName;
|
||||
$strSourceGallery = $files['tmp_name'][$key];
|
||||
|
||||
// Reprise de la logique de redimensionnement
|
||||
list($intW, $intH) = getimagesize($strSourceGallery);
|
||||
|
||||
// On peux changer ces dimensions si on veux que la galerie soit plus grande/petite
|
||||
$intDestW = 150; $intDestH = 150;
|
||||
$fltDestR = $intDestW / $intDestH;
|
||||
$fltSourceR = $intW / $intH;
|
||||
|
|
@ -295,8 +282,7 @@
|
|||
}
|
||||
|
||||
$objDestGallery = imagecreatetruecolor($intDestW, $intDestH);
|
||||
|
||||
// Création de la source selon le type de chaque image de la boucle
|
||||
|
||||
switch ($files['type'][$key]) {
|
||||
case 'image/jpeg' :
|
||||
$objSourceGallery = imagecreatefromjpeg($strSourceGallery);
|
||||
|
|
@ -313,7 +299,6 @@
|
|||
imagecopyresampled($objDestGallery, $objSourceGallery, 0, 0, $intCropX, $intCropY, $intDestW, $intDestH, $intCropW, $intCropH);
|
||||
|
||||
if (imagewebp($objDestGallery, $strDestGallery)) {
|
||||
// Insertion en BDD
|
||||
$objProjectModel->addImageInProject($galleryName, $objProject->getId());
|
||||
$uploadedCount++;
|
||||
}
|
||||
|
|
@ -330,7 +315,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Suppression de l'ancienne miniature
|
||||
if(isset($strOldImg) && !empty($strOldImg) && isset($strImageName)){
|
||||
$strOldFile = $_ENV['IMG_PROJECT_PATH'].$strOldImg;
|
||||
if (file_exists($strOldFile)) unlink($strOldFile);
|
||||
|
|
@ -348,17 +332,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Données pour la vue
|
||||
$this->_arrData['arrCategory'] = $objCategoryModel->findAllCategory();
|
||||
$this->_arrData['objProject'] = $objProject;
|
||||
$this->_arrData['arrError'] = $arrError;
|
||||
|
||||
// Si on est en modifications de projet, on récupère les images pour les afficher dans le formulaire
|
||||
if ($objProject->getId()) {
|
||||
// On récupère les images via le modèle et on les stocke dans le tableau de données
|
||||
$this->_arrData['arrImages'] = $objProjectModel->getImagesByProjectId($objProject->getId());
|
||||
} else {
|
||||
// Sinon on initialise un tableau vide pour éviter que Smarty ne râle
|
||||
$this->_arrData['arrImages'] = [];
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +356,6 @@
|
|||
$objProjectModel = new ProjectModel();
|
||||
$arrProject = $objProjectModel->findOne((int)$intId);
|
||||
|
||||
// CORRECTION ICI : on utilise $intId (pas $id)
|
||||
$arrImages = $objProjectModel->getImagesByProjectId((int)$intId);
|
||||
|
||||
if ($arrProject) {
|
||||
|
|
@ -432,8 +411,6 @@
|
|||
$objMail->Username = 'a2a67e001@smtp-brevo.com';
|
||||
$objMail->Password = 'xsmtpsib-f2af87e12d3db6f1b99802a92c1acda32d45fc32a8446eeed7e49ec91c4ec7ef-AX8Y7YkRWYSmKHwS';
|
||||
|
||||
// Désactive la vérification du certificat SSL
|
||||
// Cela permet d'éviter les erreurs liées au certificat, mais réduit la sécurité de la connexion.
|
||||
$objMail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
|
|
@ -470,46 +447,37 @@
|
|||
|
||||
/**
|
||||
* Fonction de modération de projet = accepté
|
||||
* @author Guillaume
|
||||
*/
|
||||
public function accept(){
|
||||
|
||||
//Récupéré l'id dans l'url
|
||||
$intId = $_GET['id'];
|
||||
|
||||
//Je créer un nouveau model pour exec la commande SQL
|
||||
$objProjectModel = new ProjectModel;
|
||||
$objProjectModel->accept($intId);
|
||||
|
||||
//Redirection vers la page
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de modération de projet = refusé
|
||||
* @author Guillaume
|
||||
*/
|
||||
public function refuse(){
|
||||
|
||||
//Récupéré l'id dans l'url
|
||||
$intId = $_GET['id'];
|
||||
|
||||
//Je créer un nouveau model pour exec la commande SQL
|
||||
$objProjectModel = new ProjectModel;
|
||||
$objProjectModel->refuse($intId);
|
||||
|
||||
//Redirection vers la page
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de suppression de projet
|
||||
* @author Guillaume
|
||||
*/
|
||||
public function delete(){
|
||||
//Vérif utilisateur soit bien modérateur
|
||||
|
||||
if (!isset($_SESSION['user']) || $_SESSION['user']['user_status'] != 2) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
|
|
@ -526,29 +494,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
//Redirection vers la page
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de changement de statut (Approuvé, Refusé, En attente)
|
||||
* @author Guillaume
|
||||
*/
|
||||
public function change_image_status() {
|
||||
if (isset($_GET['id_img']) && isset($_GET['status'])) {
|
||||
$idImg = (int)$_GET['id_img'];
|
||||
$status = $_GET['status']; // "en_attente" passage à "approuvé"
|
||||
$status = $_GET['status'];
|
||||
|
||||
$objProjectModel = new ProjectModel();
|
||||
|
||||
// On passe le statut texte directement à ta méthode de modèle
|
||||
if ($objProjectModel->updateImageStatus($idImg, $status)) {
|
||||
$_SESSION['success'] = "Le statut de l'image est désormais : " . ucfirst($status);
|
||||
}
|
||||
}
|
||||
|
||||
// La redirection : Si on sait d'où on vient, on y retourne, sinon index
|
||||
$urlRedirect = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "index.php";
|
||||
header("Location: " . $urlRedirect);
|
||||
exit;
|
||||
|
|
@ -557,14 +521,12 @@
|
|||
|
||||
/**
|
||||
* Fonction de validation de l'image de projet
|
||||
* @author Guillaume
|
||||
*/
|
||||
public function delete_image() {
|
||||
// Vérifier l'id de l'image
|
||||
|
||||
$idImg = $_GET['id_img'];
|
||||
$objProjectModel = new ProjectModel();
|
||||
|
||||
// Récupérer le nom du fichier pour le supprimer physiquement
|
||||
$image = $objProjectModel->findImage($idImg);
|
||||
if ($image) {
|
||||
$filePath = $_ENV['IMG_PROJECT_PATH'] . $image['image_name'];
|
||||
|
|
@ -574,70 +536,10 @@
|
|||
$_SESSION['success'] = "Image supprimée !";
|
||||
}
|
||||
|
||||
// La redirection : Si on sait d'où on vient, on y retourne, sinon index
|
||||
$url = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : "index.php";
|
||||
header("Location: " . $url);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction d'ajout des 20 images max du projet
|
||||
* @author Guillaume
|
||||
* @param string $fileName = le nom de l'image, int $projectId = L'Id du projet que l'on veut afficher, string $alt = qui affichera pars défaut "Image de projet"
|
||||
* @return bool Est-ce que la requête s'est bien passée
|
||||
*/
|
||||
public function addImageInProject(string $fileName, int $projectId, string $alt = "Image de projet"): bool {
|
||||
$strRq = "INSERT INTO image (
|
||||
image_name,
|
||||
image_alt,
|
||||
image_status,
|
||||
image_project
|
||||
)
|
||||
VALUES (:name, :alt, :status, :project)";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
||||
$rqPrep->bindValue(":name", $fileName, PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":alt", $alt, PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":status", "en_attente", PDO::PARAM_STR); // Valeur string en brute
|
||||
$rqPrep->bindValue(":project", $projectId, PDO::PARAM_INT);
|
||||
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'affichage des 20 images max du projet
|
||||
* @author Guillaume
|
||||
* @param array $ProjectId L'Id du projet que l'on veut afficher
|
||||
* @return bool Est-ce que la requête s'est bien passée
|
||||
*/
|
||||
public function getImagesByProjectId(int $projectId): array {
|
||||
$strRq = "SELECT image_id, image_name, image_alt, image_status
|
||||
FROM image
|
||||
WHERE image_project = :id";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(":id", $projectId, PDO::PARAM_INT);
|
||||
$rqPrep->execute();
|
||||
|
||||
return $rqPrep->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Page mentions légales
|
||||
*/
|
||||
public function mentions(){
|
||||
// Afficher
|
||||
$this->_display("mentions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Page à propos
|
||||
*/
|
||||
public function about(){
|
||||
// Afficher
|
||||
$this->_display("about");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@
|
|||
require("./models/project_model.php");
|
||||
require("./entities/project_entity.php");
|
||||
|
||||
/**
|
||||
* Le controller de la page d'aide utilisateur
|
||||
* @author Guillaume & Besnik & Yasser
|
||||
*/
|
||||
|
||||
class UserCtrl extends MotherCtrl {
|
||||
|
||||
public function login(){
|
||||
|
|
@ -13,10 +18,8 @@ class UserCtrl extends MotherCtrl {
|
|||
$strMail = $_POST['user_mail']??"";
|
||||
$strPwd = $_POST['user_password']??"";
|
||||
|
||||
// Tester le formulaire
|
||||
$arrError = [];
|
||||
if (count($_POST) > 0) {
|
||||
// Vérifier le formulaire
|
||||
if ($strMail == ""){
|
||||
$arrError['mail'] = "Le mail est obligatoire";
|
||||
}
|
||||
|
|
@ -24,16 +27,12 @@ class UserCtrl extends MotherCtrl {
|
|||
$arrError['pwd'] = "Le mot de passe est obligatoire";
|
||||
}
|
||||
|
||||
// Si le formulaire est rempli correctement
|
||||
if (count($arrError) == 0){
|
||||
// Vérifier l'utilisateur en BDD
|
||||
$objUserModel = new UserModel;
|
||||
$arrResult = $objUserModel->verifUser($strMail, $strPwd);
|
||||
//var_dump($arrResult);
|
||||
if ($arrResult === false){ // Si la base de données ne renvoie rien
|
||||
if ($arrResult === false){
|
||||
$arrError[] = "Mail ou mot de passe invalide";
|
||||
}else{
|
||||
// Ajoute l'utilisateur en session
|
||||
$_SESSION['user'] = $arrResult;
|
||||
$_SESSION['success'] = "Bienvenue, vous êtes bien connecté";
|
||||
if (isset($_POST['remember_me'])) {
|
||||
|
|
@ -74,42 +73,30 @@ class UserCtrl extends MotherCtrl {
|
|||
exit;
|
||||
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Fonction d'inscription d'un utilisateur
|
||||
* Effectue les validations du formulaire,
|
||||
* vérifie l'unicité du mail et du pseudo,
|
||||
* puis insère l'utilisateur en base de données
|
||||
* vérifie l'unicité du mail et du pseudo, puis insère l'utilisateur en base de données
|
||||
* @return void
|
||||
*/
|
||||
public function signup(){
|
||||
|
||||
// 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";
|
||||
}
|
||||
|
|
@ -137,21 +124,14 @@ class UserCtrl extends MotherCtrl {
|
|||
$arrError['pwd_confirm'] = "La confirmation du mot de passe ne correspond pas";
|
||||
}
|
||||
|
||||
// Si pas d'erreurs => insertion
|
||||
if (count($arrError) === 0) {
|
||||
$objUserModel = new UserModel();
|
||||
|
||||
// Vérif mail
|
||||
if ($objUserModel->mailExists($objUser->getMail())) {
|
||||
$arrError['user_mail'] = "Impossible de créer le compte avec ces informations";
|
||||
}
|
||||
|
||||
// Vérif pseudo
|
||||
if ($objUserModel->pseudoExists($objUser->getPseudo())) {
|
||||
$arrError['user_pseudo'] = "Ce pseudo existe déjà";
|
||||
}
|
||||
|
||||
// Si aucune erreur => insert
|
||||
if (count($arrError) === 0) {
|
||||
$boolInsert = $objUserModel->insert($objUser);
|
||||
|
||||
|
|
@ -166,37 +146,17 @@ class UserCtrl extends MotherCtrl {
|
|||
}
|
||||
}
|
||||
|
||||
// Affichage de la vue inscription
|
||||
$this->_arrData['objUser'] = $objUser;
|
||||
$this->_arrData['arrError'] = $arrError;
|
||||
$this->_display("signup");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* le controlleur affichage de la page user
|
||||
*/
|
||||
public function user(){
|
||||
|
||||
/**$intId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
|
||||
if ($intId <= 0) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//affichage info utilisateur
|
||||
$objUserModel = new UserModel;
|
||||
$arrUserData = $objUserModel->findUserById($intId);
|
||||
|
||||
if ($arrUserData === false) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}*/
|
||||
|
||||
$strPseudo = $_GET['pseudo']??'';
|
||||
|
||||
$objUserModel = new UserModel;
|
||||
|
|
@ -209,8 +169,6 @@ class UserCtrl extends MotherCtrl {
|
|||
|
||||
$objUser = new User;
|
||||
$objUser->hydrate($arrUserData);
|
||||
|
||||
//affichage projet de l'utilisateur
|
||||
$objProjectModel = new ProjectModel;
|
||||
$arrProjects = $objProjectModel->findAll(0,'',$objUser->getId());
|
||||
|
||||
|
|
@ -226,12 +184,14 @@ class UserCtrl extends MotherCtrl {
|
|||
$this->_display("user");
|
||||
}
|
||||
|
||||
/**
|
||||
* le controlleur de la modification d'un user
|
||||
*/
|
||||
public function edit(){
|
||||
if(!isset($_SESSION['user'])){
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$objUserModel = new UserModel;
|
||||
$arrError = [];
|
||||
$objUser = new User;
|
||||
|
|
@ -248,7 +208,6 @@ class UserCtrl extends MotherCtrl {
|
|||
$objUser->hydrate($_POST);
|
||||
$objUser->setId($_SESSION['user']['user_id']);
|
||||
|
||||
// Vérification de l'image
|
||||
$arrTypeAllowed = array('image/jpeg', 'image/png', 'image/webp');
|
||||
$boolImageOk = true;
|
||||
|
||||
|
|
@ -279,7 +238,6 @@ class UserCtrl extends MotherCtrl {
|
|||
}
|
||||
}
|
||||
|
||||
// Traitement de l'image si pas d'erreur
|
||||
if (count($arrError) == 0 && isset($strImageName)) {
|
||||
$strDest = $_ENV['IMG_USER_PATH'] . $strImageName;
|
||||
$strSource = $_FILES['image']['tmp_name'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue