diff --git a/php/.idea/.gitignore b/php/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/php/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/php/.idea/modules.xml b/php/.idea/modules.xml new file mode 100644 index 0000000..2047c36 --- /dev/null +++ b/php/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/php/.idea/php.iml b/php/.idea/php.iml new file mode 100644 index 0000000..d28f97f --- /dev/null +++ b/php/.idea/php.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/php/.idea/php.xml b/php/.idea/php.xml new file mode 100644 index 0000000..eed9a80 --- /dev/null +++ b/php/.idea/php.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/php/.idea/vcs.xml b/php/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/php/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/php/public/assets/close.png b/php/public/assets/close.png new file mode 100644 index 0000000..162cb0b Binary files /dev/null and b/php/public/assets/close.png differ diff --git a/php/public/assets/search.svg b/php/public/assets/search.svg new file mode 100644 index 0000000..4874e01 --- /dev/null +++ b/php/public/assets/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/php/public/css/evenement.css b/php/public/css/evenement.css new file mode 100644 index 0000000..56d1a21 --- /dev/null +++ b/php/public/css/evenement.css @@ -0,0 +1,54 @@ +/* styles.css */ + +/* Reset CSS pour normaliser le rendu sur tous les navigateurs */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: 'Arial', sans-serif; + background-color: #f8f9fa; + color: #333; +} + +.container { + margin-top: 20px; +} + +.div_titres { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +.div_titres a { + width: 20%; +} + +.div_titres h1 { + width: 50%; + color: #00DBFF; +} + +.div_titres a img { + margin-left: 40px; +} + +h1 { + display: flex; + justify-content: center; + color: #00DBFF; +} + +.list-group-item { + display: flex; + flex-direction: row; + justify-content: space-between; + margin-top: 20px; + padding: 15px; + border: 1px solid #dee2e6; + border-radius: 5px; +} diff --git a/php/public/uploads/10246LOGO-CGI-1993-1998.svg.png b/php/public/uploads/10246LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/10246LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/1037575640739_2017832954986003_3631312063273369600 b/php/public/uploads/1037575640739_2017832954986003_3631312063273369600 new file mode 100644 index 0000000..4e07958 Binary files /dev/null and b/php/public/uploads/1037575640739_2017832954986003_3631312063273369600 differ diff --git a/php/public/uploads/10412LOGO-CGI-1993-1998.svg.png b/php/public/uploads/10412LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/10412LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/10989LOGO-CGI-1993-1998.svg.png b/php/public/uploads/10989LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/10989LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/11118LOGO-CGI-1993-1998.svg.png b/php/public/uploads/11118LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/11118LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/11258148705384_3066830383419583_836309298646490890 b/php/public/uploads/11258148705384_3066830383419583_836309298646490890 new file mode 100644 index 0000000..273aea0 Binary files /dev/null and b/php/public/uploads/11258148705384_3066830383419583_836309298646490890 differ diff --git a/php/public/uploads/11371LOGO-CGI-1993-1998.svg.png b/php/public/uploads/11371LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/11371LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/11560Adidas 3D LOGO.jpg b/php/public/uploads/11560Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/11560Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/11575LOGO-CGI-1993-1998.svg.png b/php/public/uploads/11575LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/11575LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/11596Adidas 3D LOGO.jpg b/php/public/uploads/11596Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/11596Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/12020LOGO-CGI-1993-1998.svg.png b/php/public/uploads/12020LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/12020LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/12211 .png b/php/public/uploads/12211 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/12211 .png differ diff --git a/php/public/uploads/12228Adidas 3D LOGO.jpg b/php/public/uploads/12228Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/12228Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/1223075640739_2017832954986003_3631312063273369600 b/php/public/uploads/1223075640739_2017832954986003_3631312063273369600 new file mode 100644 index 0000000..4e07958 Binary files /dev/null and b/php/public/uploads/1223075640739_2017832954986003_3631312063273369600 differ diff --git a/php/public/uploads/1303975640739_2017832954986003_3631312063273369600 b/php/public/uploads/1303975640739_2017832954986003_3631312063273369600 new file mode 100644 index 0000000..4e07958 Binary files /dev/null and b/php/public/uploads/1303975640739_2017832954986003_3631312063273369600 differ diff --git a/php/public/uploads/13807LOGO-CGI-1993-1998.svg.png b/php/public/uploads/13807LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/13807LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/13811Capture_decran_2023-11-01_a_10.56.59.png b/php/public/uploads/13811Capture_decran_2023-11-01_a_10.56.59.png new file mode 100644 index 0000000..7290ba7 Binary files /dev/null and b/php/public/uploads/13811Capture_decran_2023-11-01_a_10.56.59.png differ diff --git a/php/public/uploads/13822Adidas 3D LOGO.jpg b/php/public/uploads/13822Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/13822Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/14330Adidas 3D LOGO.jpg b/php/public/uploads/14330Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/14330Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/14902LOGO-CGI-1993-1998.svg.png b/php/public/uploads/14902LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/14902LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/15529LOGO-CGI-1993-1998.svg.png b/php/public/uploads/15529LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/15529LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/16163 .png b/php/public/uploads/16163 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/16163 .png differ diff --git a/php/public/uploads/17005 .png b/php/public/uploads/17005 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/17005 .png differ diff --git a/php/public/uploads/17285LOGO-CGI-1993-1998.svg.png b/php/public/uploads/17285LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/17285LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/17669LOGO-CGI-1993-1998.svg.png b/php/public/uploads/17669LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/17669LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/17854LOGO-CGI-1993-1998.svg.png b/php/public/uploads/17854LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/17854LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/18355 .png b/php/public/uploads/18355 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/18355 .png differ diff --git a/php/public/uploads/18652Adidas 3D LOGO.jpg b/php/public/uploads/18652Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/18652Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/18887LOGO-CGI-1993-1998.svg.png b/php/public/uploads/18887LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/18887LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/19015LOGO-CGI-1993-1998.svg.png b/php/public/uploads/19015LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/19015LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/19023Adidas 3D LOGO.jpg b/php/public/uploads/19023Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/19023Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/19821Adidas 3D LOGO.jpg b/php/public/uploads/19821Adidas 3D LOGO.jpg new file mode 100644 index 0000000..b3a36a5 Binary files /dev/null and b/php/public/uploads/19821Adidas 3D LOGO.jpg differ diff --git a/php/public/uploads/19858LOGO-CGI-1993-1998.svg.png b/php/public/uploads/19858LOGO-CGI-1993-1998.svg.png new file mode 100644 index 0000000..b02459b Binary files /dev/null and b/php/public/uploads/19858LOGO-CGI-1993-1998.svg.png differ diff --git a/php/public/uploads/19879 .png b/php/public/uploads/19879 .png new file mode 100644 index 0000000..955bdb3 Binary files /dev/null and b/php/public/uploads/19879 .png differ diff --git a/php/src/config/Validation.php b/php/src/config/Validation.php index 05d2f4e..62d1465 100755 --- a/php/src/config/Validation.php +++ b/php/src/config/Validation.php @@ -63,6 +63,7 @@ class Validation return filter_var($str, FILTER_VALIDATE_EMAIL); } + public static function validateImage($img) : bool { if(isset($_FILES[$img])) @@ -79,6 +80,20 @@ class Validation return false; } + public static function validerEvenement(string $titre, string $description, string $date, int $nbPlaceMax, string $img) : bool + { + if(!empty($titre) && !empty($description) && !empty($date) && !empty($nbPlaceMax) && !empty($img)) + { + if(self::validerIntPossitif($nbPlaceMax)) + { + if(self::validateImage($img)) + { + return true; + } + } + } + return false; + } public static function validateNumber($number) : bool { diff --git a/php/src/config/config.php b/php/src/config/config.php index ff7c8f1..5baebeb 100755 --- a/php/src/config/config.php +++ b/php/src/config/config.php @@ -12,3 +12,7 @@ static $OffersByPage = 5; define('DB_HOST', 'mysql:host=localhost;dbname=dbAlica'); define('DB_USER', 'Dev'); define('DB_PASS', 'Dev'); +//BD +// $dsn = 'mysql:host=localhost;dbname=dbAlica'; +// $username = 'test'; +// $password = 'test'; diff --git a/php/src/controleur/FrontControleur.php b/php/src/controleur/FrontControleur.php index 4c8043d..594bd18 100755 --- a/php/src/controleur/FrontControleur.php +++ b/php/src/controleur/FrontControleur.php @@ -10,7 +10,7 @@ class FrontControleur $dVueErreur = []; $actions = array( "Admin" => [ - "supprimerCompte", "consulterSignalement", "creerEvenement", "supprimerEvenement","supprimerOffre" + "supprimerCompte", "consulterSignalement","supprimerOffre" ], "Moderateur" => [ //TODO @@ -20,8 +20,7 @@ class FrontControleur ], "Utilisateur" => [ - "connexion", "inscription", "accueil","consulterProfilLimite","publierOffre" - + "connexion", "inscription", "accueil", "consulterProfilLimite", "publierOffre", "listerEvenement", "creerEvenement", "supprimerEvenement", "avoirDetailEvenement", "rechercherEvenement" ] ); diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index 3f48296..cd0bdd1 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -2,17 +2,11 @@ namespace App\controleur; +use App\config; use App\config\Validation; -use App\gateway\Connection; -use App\gateway\ImageGateway; use App\gateway\ImageSaver; -use App\gateway\OffreGateway; -use App\metier\Image; use App\modele\OffreModele; -use App\modele\ImageModele; -use App\TwigExtensions; - -use APp\config; +use App\modele\UtilisateurModele; class UtilisateurControleur { @@ -21,10 +15,10 @@ class UtilisateurControleur { global $twig; if (!isset($_REQUEST["action"])) { - //$action = NULL; - $action = "consultOffers"; + //$action = NULL; + $action = "listerEvenement"; } else { - $action = \App\config\Validation::nettoyerString($_REQUEST["action"]); + $action = Validation::nettoyerString($_REQUEST["action"]); } switch ($action) { case NULL: @@ -39,7 +33,6 @@ class UtilisateurControleur break; case "inscription": $this->inscription(); - break; case "consultOffers": $this->consultOffers(); @@ -56,10 +49,24 @@ class UtilisateurControleur case "displayOffer": $this->displayOffer(); break; + case "listerEvenement": + $this->listerEvenement(); + break; + case "creerEvenement": + $this->creerEvenement(); + break; + case "supprimerEvenement": + $this->supprimerEvenement(); + break; + case "avoirDetailEvenement": + $this->avoirDetailEvenement(); + break; + case "rechercherEvenement": + $this->rechercherEvenement(); + break; default: $dVueErreur[] = "Action inconnue ou non autorisée"; echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); - } } @@ -163,7 +170,6 @@ class UtilisateurControleur $offerMdl = new OffreModele(); global $twig; - $niveauEtudes=null; $typeContrat=null; $exp = null; @@ -241,9 +247,6 @@ class UtilisateurControleur ]); } - - - protected function createOfferForm() { global $twig; @@ -336,4 +339,65 @@ class UtilisateurControleur echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur]); } + protected function listerEvenement() + { + $mdl = new UtilisateurModele(); + $evenements = $mdl->getEvenement(); + global $twig; + + echo $twig->render('evenement.html', ['evenements' => $evenements]); + } + + protected function creerEvenement() + { + global $twig; + + if (isset($_FILES["image"])) { + $img = ImageSaver::SaveImage('image'); + + if (!Validation::validerEvenement($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1])) { + $mdl = new UtilisateurModele(); + $mdl->ajouterEvenement($_POST["titre"], $_POST["description"], $_POST["date"], $_POST["nbPlaceMax"], $img[1]); + + $this->listerEvenement(); + } else { + $dVueErreur[] ="Erreur lors de la création de l'évènement"; + echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); + } + } else { + echo $twig->render('creerEvenement.html', []); + } + } + + protected function supprimerEvenement() + { + $mdl = new UtilisateurModele(); + $mdl->deleteEvenement($_GET["id"]); + + $this->listerEvenement(); + } + + protected function avoirDetailEvenement() + { + $mdl = new UtilisateurModele(); + $evenement = $mdl->getEvenementById($_GET["id"]); + + global $twig; + echo $twig->render('detailEvenement.html', ['evenement' => $evenement]); + } + + protected function rechercherEvenement() + { + $mdl = new UtilisateurModele(); + $evenements = $mdl->getEvenement(); + + if(isset($_POST["recherche"]) AND !empty($_POST["recherche"])) + { + $recherche = Validation::nettoyerString($_POST["recherche"]); + $evenements = $mdl->getEvenementByTitre($recherche); + } + + global $twig; + echo $twig->render('evenement.html', ['evenements' => $evenements]); + } } \ No newline at end of file diff --git a/php/src/gateway/AlumniGateway.php b/php/src/gateway/AlumniGateway.php index 0047b0b..533dbed 100644 --- a/php/src/gateway/AlumniGateway.php +++ b/php/src/gateway/AlumniGateway.php @@ -1,6 +1,8 @@ con = $con; } - public function insert(){ - $query='INSERT INTO Evenement VALUES ()'; - $this->con->executeQuery($query, array()); + public function getNewId() + { + $query='SELECT MAX(id) FROM Evenement'; + $this->con->executeQuery($query); + $res=$this->con->getResults(); + return $res[0]['MAX(id)']+1; + } + + public function insertEvenement(Evenement $evenement) + { + + $query = 'INSERT INTO Evenement VALUES (:i, :o, :t, :d, :img, :date, :nb)'; + + $this->con->executeQuery($query,$params = array( + ':i' => array($evenement->getId(), \PDO::PARAM_INT), + ':o' => array($evenement->getOrganisateurId(), \PDO::PARAM_INT), + ':t' => array($evenement->getTitre(), \PDO::PARAM_STR), + ':d' => array($evenement->getDescription(), \PDO::PARAM_STR), + ':img' => array($evenement->getImage(), \PDO::PARAM_STR), + ':date' => array($evenement->getDate(), \PDO::PARAM_STR), + ':nb' => array($evenement->getNbPlaceMax(), \PDO::PARAM_INT), + )); + } + + + public function getAllEvenement() + { + $query = 'SELECT * FROM Evenement ORDER BY id DESC'; + $this->con->executeQuery($query); + $res = $this->con->getResults(); + return $res; } + + public function deleteEvenement($id) + { + $query='DELETE FROM Evenement WHERE id=:id'; + $this->con->executeQuery($query, array( + ':id' => array($id, \PDO::PARAM_INT) + )); + } + + public function findById($id) + { + $query='SELECT * FROM Evenement WHERE id=:id'; + $this->con->executeQuery($query, array( + ':id' => array($id, \PDO::PARAM_INT) + )); + $res=$this->con->getResults(); + return $res; + } + + public function findByTitle($titre) + { + $query = 'SELECT * FROM Evenement WHERE titre LIKE :titre'; + $this->con->executeQuery($query, array( + ':titre' => array("%$titre%", \PDO::PARAM_STR) + )); + $res = $this->con->getResults(); + return $res; + } + } \ No newline at end of file diff --git a/php/src/metier/Alumni.php b/php/src/metier/Alumni.php index 9765cd1..7b61e8a 100644 --- a/php/src/metier/Alumni.php +++ b/php/src/metier/Alumni.php @@ -3,8 +3,7 @@ namespace App\metier; class Alumni{ - - + /** * @var string Email */ diff --git a/php/src/metier/Evenement.php b/php/src/metier/Evenement.php index 69d43e0..0f26b13 100755 --- a/php/src/metier/Evenement.php +++ b/php/src/metier/Evenement.php @@ -1,5 +1,6 @@ id = $id; - $this->nom = $nom; - $this->date = $date; $this->organisateur = $organisateur; - $this->participants = $participants; - $this->nbInscriptionMax = $nbInscriptionMax; - $this->imageUrl = $imageUrl; + $this->titre = $titre; + $this->description = $description; + $this->date = $date; + $this->nbPlaceMax = $nbPlaceMax; + $this->image = $image; + } + /** + * @return int + */ public function getId(): int { return $this->id; } - public function getNom() : string + /** + * @return string + */ + public function getTitre(): string { - return $this->nom; + return $this->titre; } - public function getDate() : string + /** + * @return int + */ + public function getOrganisateurId(): int { - return $this->date; + return $this->organisateur; } - public function getParticipants() : array + /** + * @return string + */ + public function getDescription(): string { - return $this->participants; + return $this->description; } - public function getOrganisateur(): Alumni + /** + * @return string + */ + public function getDate(): string { - return $this->organisateur; + return $this->date; } - public function getNbInscriptionMax(): int + /** + * @return int + */ + public function getNbPlaceMax(): int { - return $this->nbInscriptionMax; + return $this->nbPlaceMax; } - public function getImageUrl(): string + /** + * @return int + */ + public function getImage(): string { - return $this->imageUrl; + return $this->image; } } \ No newline at end of file diff --git a/php/src/modele/ImageModele.php b/php/src/modele/ImageModele.php deleted file mode 100644 index 26743c0..0000000 --- a/php/src/modele/ImageModele.php +++ /dev/null @@ -1,52 +0,0 @@ -gw = new ImageGateway(new Connection(DB_HOST,DB_USER,DB_PASS)); - } - - public function publierImage(string $file) : Image - { - $img = new Image($this->gw->getNewId(), - $_FILES[$file]["name"], - $_FILES[$file]["size"], - $_FILES[$file]["type"], - file_get_contents($_FILES[$file]["tmp_name"])); - - $this->insertImage($img); - - return $img; - } - - public function insertImage(Image $img) - { - $this->gw->insertImage($img); - } - - public function obtenirParId(int $id) - { - $this->gw->getFromId($id); - $res = $this->gw->getResults(); - return new Image($this->gw->getNewId(),$res[0]['nom'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']); - } - - public function obtenirToutesImages() : array - { - $this->gw->obtenirToutesImages(); - $res = $this->gw->getResults(); - foreach ($res as $r) { - $array[] = new Image($this->gw->getNewId(),$r['nom'], $r['taille'], $r['type'], $r['blob']); - } - return $array; - } - - -} \ No newline at end of file diff --git a/php/src/modele/UtilisateurModele.php b/php/src/modele/UtilisateurModele.php index 25e39a7..d4fb1fa 100755 --- a/php/src/modele/UtilisateurModele.php +++ b/php/src/modele/UtilisateurModele.php @@ -1,15 +1,18 @@ con = new Connection(DB_HOST,DB_USER,DB_PASS); } /** @@ -19,27 +22,27 @@ class UtilisateurModele * @return \App\metier\Alumni */ - public function connection(string $email, string $mdp) : ? \App\metier\Alumni - { - $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); - $gate = new \App\gateway\AlumniGateway($con); - // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway - $utilisateur = $gate->findByEmail($email); - if ($utilisateur instanceof \App\metier\Alumni) { - // L'utilisateur existe, vérifiez le mot de passe - if (password_verify($mdp, $utilisateur->getPassword())) { - // Le mot de passe est correct, retournez l'utilisateur - session_start(); - return $utilisateur; - } else { - // Le mot de passe est incorrect, renvoyez null - return null; - } - } else { - // L'utilisateur n'existe pas, renvoyez null - return null; - } - } + public function connection(string $email, string $mdp) : ? \App\metier\Alumni + { + $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); + $gate = new \App\gateway\AlumniGateway($con); + // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway + $utilisateur = $gate->findByEmail($email); + if ($utilisateur instanceof \App\metier\Alumni) { + // L'utilisateur existe, vérifiez le mot de passe + if (password_verify($mdp, $utilisateur->getPassword())) { + // Le mot de passe est correct, retournez l'utilisateur + session_start(); + return $utilisateur; + } else { + // Le mot de passe est incorrect, renvoyez null + return null; + } + } else { + // L'utilisateur n'existe pas, renvoyez null + return null; + } + } /** * @description s'inscrire @@ -49,47 +52,128 @@ class UtilisateurModele * @return \Alumni chargé */ - public function inscription(string $prenom, string $nom,string $email, string $hashpassword):? \App\metier\Alumni + public function inscription(string $prenom, string $nom,string $email, string $hashpassword):? \App\metier\Alumni + { + $role = "Membre"; + $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); + $gate = new \App\gateway\AlumniGateway($con); + $profilGate = new \App\gateway\ProfilGateway($con); + // Insérez le nouvel utilisateur dans la base de données en utilisant AlumniGateway + if ($gate->insert($email, $hashpassword, $role)) { + $alumni = $gate->getID($email); + if($profilGate->insert($alumni,$nom, $prenom,$email)){ + // L'insertion a réussi, retournez le nouvel utilisateur + $nouvelUtilisateur = new \App\metier\Alumni($email, $hashpassword, $role,$nom,$prenom); + return $nouvelUtilisateur; + } + return null; + } else { + // L'insertion a échoué, renvoyez un utilisateur vide pour indiquer l'échec + return null; + } + } + + public function getUtilisateurByEmail(string $email) + { + $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); + $gate = new \App\gateway\AlumniGateway($con); + // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway + $utilisateur = $gate->findByEmail($email); + if ($utilisateur instanceof \App\metier\Alumni) { + // L'utilisateur existe, retournez-le + return $utilisateur; + } else { + // L'utilisateur n'existe pas, renvoyez null + return null; + } + } + + public function getEvenement() : array { - $role = "Membre"; - $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); - $gate = new \App\gateway\AlumniGateway($con); - $profilGate = new \App\gateway\ProfilGateway($con); - // Insérez le nouvel utilisateur dans la base de données en utilisant AlumniGateway - if ($gate->insert($email, $hashpassword, $role)) { -// <<<<<<< HEAD -// // L'insertion a réussi, retournez le nouvel utilisateur -// $nouvelUtilisateur = new \App\metier\Alumni($email, $hashpassword, $role); -// return $nouvelUtilisateur; -// } else { -// // L'insertion a échoué, renvoyez un utilisateur vide pour indiquer l'échec -// return new \App\metier\Alumni(null, null, null); -// ======= - $alumni = $gate->getID($email); - if($profilGate->insert($alumni,$nom, $prenom,$email)){ - // L'insertion a réussi, retournez le nouvel utilisateur - $nouvelUtilisateur = new \App\metier\Alumni($email, $hashpassword, $role,$nom,$prenom); - return $nouvelUtilisateur; - } - return null; - } else { - // L'insertion a échoué, renvoyez un utilisateur vide pour indiquer l'échec - return null; + $gate = new EvenementGateway($this->con); + + $data = $gate->getAllEvenement(); + + $evenement = array(); + + foreach($data as $row) + { + $evenement[] = new Evenement( + $row['id'], + $row['organisateur'], + $row['titre'], + $row['description'], + $row['date'], + $row['nbPlaceMax'], + $row['image'] + ); } + return $evenement; } - public function getUtilisateurByEmail(string $email) + public function ajouterEvenement(string $titre, string $description, string $date, int $nbPlaceMax, string $img) { - $con = new \App\gateway\Connection(DB_HOST,DB_USER,DB_PASS); - $gate = new \App\gateway\AlumniGateway($con); - // Récupérez l'utilisateur avec l'email donné en utilisant AlumniGateway - $utilisateur = $gate->findByEmail($email); - if ($utilisateur instanceof \App\metier\Alumni) { - // L'utilisateur existe, retournez-le - return $utilisateur; - } else { - // L'utilisateur n'existe pas, renvoyez null - return null; + $gate = new EvenementGateway($this->con); + + $evenement = new Evenement( + $gate->getNewId(), + '1', //TODO : Ajouter l'ID de l'admin connecté + $titre, + $description, + $date, + $nbPlaceMax, + $img + ); + + $gate->insertEvenement($evenement); + } + + public function deleteEvenement(int $id) + { + $gate = new EvenementGateway($this->con); + $gate->deleteEvenement($id); + } + + public function getEvenementById(int $id) : Evenement + { + $gate = new EvenementGateway($this->con); + + $data = $gate->findById($id); + + $evenement = new Evenement( + $data[0]['id'], + $data[0]['organisateur'], + $data[0]['titre'], + $data[0]['description'], + $data[0]['date'], + $data[0]['nbPlaceMax'], + $data[0]['image'] + ); + + return $evenement; + } + + public function getEvenementByTitre(string $titre) : array + { + $gate = new EvenementGateway($this->con); + + $data = $gate->findByTitle($titre); + + $evenement = array(); + + foreach($data as $row) + { + $evenement[] = new Evenement( + $row['id'], + $row['organisateur'], + $row['titre'], + $row['description'], + $row['date'], + $row['nbPlaceMax'], + $row['image'] + ); } + + return $evenement; } -} +} \ No newline at end of file diff --git a/php/templates/creerEvenement.html b/php/templates/creerEvenement.html new file mode 100644 index 0000000..7b7b28d --- /dev/null +++ b/php/templates/creerEvenement.html @@ -0,0 +1,49 @@ + + + + + + Créer un Événement + + + +
+

Créer un Événement

+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+ + + + + + diff --git a/php/templates/creerOffre.html b/php/templates/creerOffre.html new file mode 100644 index 0000000..8a1e867 --- /dev/null +++ b/php/templates/creerOffre.html @@ -0,0 +1,125 @@ + + + + + Publier une Offre + + + + + +
+ {% include "menu.html" %} +
+ +
+

Publier Une Offre

+ +
+ + {% if tabError is defined %} + {% for error in tabError %} +

{{ error }}

+ {% endfor %} + {% endif %} + + +

Les champs contenant des astrérisques * sont obligatoires.

+
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + + + +

Les images doivent être de type png, jpg, jpeg, bmp, webp & inférieures à 10MB

+
+ +
+ + + + + + + + + diff --git a/php/templates/detailEvenement.html b/php/templates/detailEvenement.html new file mode 100644 index 0000000..fd9e78d --- /dev/null +++ b/php/templates/detailEvenement.html @@ -0,0 +1,38 @@ + + + + + + {% if evenement %} + {{evenement.titre}} + {% endif %} + + + + + +
+ {% include "menu.html" %} +
+ +
+ {% if evenement %} +

Détails de l'Événement : {{evenement.titre}}

+
+

Organisateur: {{ evenement.organisateurId }}

+

Date: {{ evenement.date }}

+

Description: {{ evenement.description }}

+ Event Image +

Places disponibles: {{ evenement.nbPlaceMax }}

+ Retour +
+ {% else %} +

L'événement n'existe pas ou n'est pas disponible.

+ {% endif %} +
+ + + + + + diff --git a/php/templates/evenement.html b/php/templates/evenement.html new file mode 100644 index 0000000..8d45c2e --- /dev/null +++ b/php/templates/evenement.html @@ -0,0 +1,58 @@ + + + + + + Liste des Événements + + + + + +
+ {% include "menu.html" %} +
+ +
+
+
+ + +
+

Liste des Événements

+ Publier événement +
+ + +
+ + + + + +