diff --git a/php/config/config.php b/php/config/config.php index 9755ecd..4dc3184 100755 --- a/php/config/config.php +++ b/php/config/config.php @@ -7,6 +7,6 @@ $rep = __DIR__ . '/../'; $dConfig['includes']= array('controleur/Validation.php'); //BD -$base = ''; -$login = ''; +$base = 'mysql:host=localhost;dbname=sae_test'; +$login = 'root'; $mdp = ''; diff --git a/php/controleur/FrontControleur.php b/php/controleur/FrontControleur.php index 89328d0..5781b29 100755 --- a/php/controleur/FrontControleur.php +++ b/php/controleur/FrontControleur.php @@ -1,8 +1,12 @@ con = $con; + parent::__construct($con); } - public function insert(string $email, int $id, string $motDePasse, Role $role){ - $query='INSERT INTO Alumni VALUES (:i, :e, :m, :r)'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':e' => array($email, PDO::PARAM_STR), - ':m' => array($motDePasse, PDO::PARAM_STR), - ':r' => array($role, PDO::PARAM_STR) - )); + public function insertAlumni(string $mail, string $mdp, string $role){ + try{ + $query='INSERT INTO Alumni(mail,mdp,role) VALUES (:mail, :mdp, :role)'; + $this->con->executeQuery($query, array( + ':mail' => array($mail, PDO::PARAM_STR), + ':mdp' => array($mdp, PDO::PARAM_STR), + ':role' => array($role, PDO::PARAM_STR) + )); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } } - public function updateEmail(int $id, string $newEmail){ - $query='UPDATE Alumni SET email=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newEmail, PDO::PARAM_STR) - )); + public function supprimeAlumni(string $id){ + try{ + $query='DELETE FROM Alumni WHERE id = (:id)'; + $this->con->executeQuery($query, array( + ':id' => array($id, PDO::PARAM_STR), + )); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } } - public function updateMotDePasse(int $id, string $password){ - $query='UPDATE Alumni SET motDePasse=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($password, PDO::PARAM_STR) - )); + public function modifieMdp(string $id,string $newMdp){ + try{ + $query='UPDATE ALumni SET mdp=(:mdp) WHERE id=(:id)'; + $this->con->executeQuery($query, array( + ':id' => array($id, PDO::PARAM_STR), + ':mdp' => array($newMdp, PDO::PARAM_STR), + )); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } } - public function updateRole(int $id, Role $newRole){ - $query='UPDATE Alumni SET role=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newRole, PDO::PARAM_STR) - )); + public function recupereAlumni(string $id){ + try{ + $query='SELECT * FROM Alumni WHERE id=(:id)'; + $this->con->executeQuery($query, array( + ':id' => array($id, PDO::PARAM_STR), + )); + $res = $this->con->getResults(); + $a=new Alumni($res['id'],$res['mail'],$res['mdp'],$res['role']); + return $a; + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } } - public function delete(int $id){ - $query='DELETE FROM Alumni WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT) - )); + public function recupereDataAlumni(){ + try{ + $query='SELECT * FROM Alumni'; + $this->con->executeQuery($query); + $res = $this->con->getResults(); + $AlumniArray = array(); + foreach($res as $v){ + $a=new Alumni($v['id'],$v['mail'],$v['mdp'],$v['role']); + array_push($AlumniArray,$a); + } + return $AlumniArray; + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } } - public function findById(int $id){ - $query = 'SELECT * FROM Alumni WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT) - )); - $res=$this->con->getResults(); - return new Alumni($res[0]['mail'],$res[0]['id'],$res[0]['mdp'],$res[0]['role']); - } - public function findByEmail(string $email){ - $query='SELECT * FROM Alumni WHERE email=:e'; - $this->con->executeQuery($query, array( - ':e' => array($email, PDO::PARAM_STR), - )); - $res=$this->con->getResults(); - return new Alumni($res[0]['mail'],$res[0]['id'],$res[0]['mdp'],$res[0]['role']); - } +} - public function getAll(){ - $query='SELECT * FROM Alumni'; - $this->con->executeQuery($query); - $res=$this->con->getResults(); - $array=[]; - foreach($res as $r){ - $array[]=new Alumni($r['mail'],$r['id'],$r['mdp'],$r['role']); - } - return $array; - } -} \ No newline at end of file +?> \ No newline at end of file diff --git a/php/dal/gateway/CompteGateway.php b/php/dal/gateway/CompteGateway.php new file mode 100644 index 0000000..b54023c --- /dev/null +++ b/php/dal/gateway/CompteGateway.php @@ -0,0 +1,82 @@ +con = $con; + } + + public function insert(string $email, string $pseudo, string $motDePasse){ + $query='INSERT INTO Compte VALUES (:e, :p, :m)'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + ':p' => array($pseudo, PDO::PARAM_STR), + ':m' => array($motDePasse, PDO::PARAM_STR) + )); + } + + public function updateEmail(string $email, string $newEmail){ + $query='UPDATE Compte SET email=:new WHERE email=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + ':new' => array($newEmail, PDO::PARAM_STR) + )); + } + + public function updatePseudo(string $email, string $pseudo){ + $query='UPDATE Compte SET pseudo=:new WHERE email=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + ':new' => array($pseudo, PDO::PARAM_STR) + )); + } + + public function updateMotDePasse(string $email, string $password){ + $query='UPDATE Compte SET motDePasse=:new WHERE email=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + ':new' => array($password, PDO::PARAM_STR) + )); + } + + public function delete(string $email){ + $query='DELETE FROM Compte WHERE email=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR) + )); + } + + public function findByPseudo(string $pseudo){ + $query = 'SELECT * FROM Compte WHERE pseudo=:p'; + $this->con->executeQuery($query, array( + ':p' => array($pseudo, PDO::PARAM_STR) + )); + $res=$this->con->getResults(); + return new Compte($res[0]['email'],$res[0]['pseudo'],$res[0]['motDePasse']); + } + + public function findByEmail(string $email){ + $query='SELECT * FROM Compte WHERE email=:e'; + $this->con->executeQuery($query, array( + ':e' => array($email, PDO::PARAM_STR), + )); + $res=$this->con->getResults(); + return new Compte($res[0]['email'],$res[0]['pseudo'],$res[0]['motDePasse']); + } + + public function getAll(){ + $query='SELECT * FROM Compte'; + $this->con->executeQuery($query); + $res=$this->con->getResults(); + $array=[]; + foreach($res as $r){ + $array[]=new Compte($r['email'],$r['pseudo'],$r['motDePasse']); + } + return $array; + } +} \ No newline at end of file diff --git a/php/dal/gateway/FormationGateway.php b/php/dal/gateway/FormationGateway.php new file mode 100644 index 0000000..dc10d56 --- /dev/null +++ b/php/dal/gateway/FormationGateway.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/php/dal/gateway/GatewayAbstrait.php b/php/dal/gateway/GatewayAbstrait.php new file mode 100644 index 0000000..f8455b1 --- /dev/null +++ b/php/dal/gateway/GatewayAbstrait.php @@ -0,0 +1,12 @@ +con = $con; + } + +} + +?> \ No newline at end of file diff --git a/php/dal/gateway/ProfilGateway.php b/php/dal/gateway/ProfilGateway.php new file mode 100644 index 0000000..4a73a04 --- /dev/null +++ b/php/dal/gateway/ProfilGateway.php @@ -0,0 +1,92 @@ +con = $con; + } + + public function insererProfil(string $email,string $alumni,string $cv, string $nom,string $prenom,string $linkedin,string $github,string $portfolio){ + try{ + $query='INSERT INTO Profil(id,alumni,email,cv,nom,prenom,linkedin_url,github_url,portfolio_url) VALUES (:id,:alumni,:email,:cv,:nom,:prenom,:linkedin_url,github_url,portfolio_url)'; + $this->con->executeQuery($query, array( + ':id' => array($id, PDO::PARAM_STR), + ':alumni' => array($alumni, PDO::PARAM_STR), + ':cv' => array($cv, PDO::PARAM_STR), + ':nom' => array($nom, PDO::PARAM_STR), + ':prenom' => array($prenom, PDO::PARAM_STR), + ':linkedin_url' => array($linkedin, PDO::PARAM_STR), + ':github_url' => array($github, PDO::PARAM_STR), + ':portfolio_url' => array($portfolio, PDO::PARAM_STR), + ':email' => array($email, PDO::PARAM_STR) + )); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } + } + + public function supprimeAlumni(string $id){ + try{ + $query='DELETE FROM Profil WHERE id = (:id)'; + $this->con->executeQuery($query, array( + ':id' => array($id, PDO::PARAM_STR), + )); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } + } + + public function editAlumni(string $id,string $email,string $alumni,string $cv, string $nom,string $prenom,string $linkedin,string $github,string $portfolio){ + try{ + supprimeAlumni($id); + insererProfil($email,$alumni,$cv,$nom,$prenom,$linkedin,$github,$portfolio); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } + + } + + public function recupereProfil(string $id){ + try{ + $query='SELECT * FROM Profil WHERE id=(:id)'; + $this->con->executeQuery($query, array( + ':id' => array($id, PDO::PARAM_STR), + )); + $res = $this->con->getResults(); + return new Profil($res['id'],$res['alumni'],$res['email'],$res['cv'],$res['nom'],$res['prenom'],$res['linkedin_url'],$res['github_url'],$res['portfolio_url']); + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } + } + + public function recupereDataProfil(){ + try{ + $query='SELECT * FROM Alumni'; + $this->con->executeQuery($query); + $res = $this->con->getResults(); + $AlumniArray = array(); + foreach($res as $v){ + $a=new Profil($v['id'],$v['alumni'],$v['email'],$v['cv'],$v['nom'],$v['prenom'],$v['linkedin_url'],$v['github_url'],$v['portfolio_url']); + array_push($AlumniArray,$a); + } + return $AlumniArray; + } catch(PDOException $Exception){ + require 'vues/erreur.html'; + } catch (Exception $Exception){ + require 'vues/erreur.html'; + } + } + +} + +?> \ No newline at end of file diff --git a/php/metier/Alumni.php b/php/metier/Alumni.php index d7455c5..9afadff 100644 --- a/php/metier/Alumni.php +++ b/php/metier/Alumni.php @@ -1,74 +1,19 @@ id = $id; - $this->email = $email; - $this->motDePasse = $motDePasse; - $this->role = $role; - } - - /** - * @return string - */ - public function getId() : string - { - return $this->id; - } - - /** - * @return string - */ - public function getEmail() : string - { - return $this->email; - } + private string $id; + private string $mail; + private string $mdp; + private string $role; + + public function __construct($id,$mail,$mdp,$role){ + $this->id=$id; + $this->mail=$mail; + $this->mdp=$mdp; + $this->role=$role; + } +} - /** - * @return string - */ - public function getMotDePasse(): string - { - return $this->motDePasse; - } - public function getRole(): Role - { - return $this->role; - } -} \ No newline at end of file +?> \ No newline at end of file diff --git a/php/metier/Article.php b/php/metier/Article.php deleted file mode 100644 index d09a3c6..0000000 --- a/php/metier/Article.php +++ /dev/null @@ -1,58 +0,0 @@ -id = $id; - $this->auteur = $auteur; - $this->sousTitre = $sousTitre; - $this->description = $description; - } - - public function getId(): int - { - return $this->id; - } - - public function getAuteur(): Alumni - { - return $this->auteur; - } - - public function getSousTitre(): string - { - return $this->sousTitre; - } - - public function getDescription(): string - { - return $this->description; - } -} \ No newline at end of file diff --git a/php/metier/Compte.php b/php/metier/Compte.php new file mode 100644 index 0000000..2ed68b3 --- /dev/null +++ b/php/metier/Compte.php @@ -0,0 +1,53 @@ +pseudo = $pseudo; + $this->email = $email; + $this->motDePasse = $motDePasse; + } + + /** + * @return string + */ + public function getPseudonyme() : string + { + return $this->pseudo; + } + + /** + * @return string + */ + public function getEmail() : string + { + return $this->email; + } + + /** + * @return string + */ + public function getMotDePasse(): string + { + return $this->motDePasse; + } +} \ No newline at end of file diff --git a/php/metier/Evenement.php b/php/metier/Evenement.php index 5feefe6..ec8782c 100755 --- a/php/metier/Evenement.php +++ b/php/metier/Evenement.php @@ -3,24 +3,19 @@ class Evenement { /** - * @var int Identifiant + * @var string Nom Evènement */ - private int $id; + private string $nameEvent; /** - * @var string Nom Evenement - */ - private string $nom; - - /** - * @var string Date de l'evenement + * @var string date Evenement */ private string $date; /** - * @var Alumni Organisateur + * @var Compte Organisateur */ - private Alumni $organisateur; + private Compte $organisator; /** * @var array Liste des Participants @@ -28,46 +23,26 @@ class Evenement private array $participants; /** - * @var int Nombre maximal d'inscrits - */ - private int $nbInscriptionMax; - - /** - * @var string Url de l'image - */ - private string $imageUrl; - - /** - * @param int $id - * @param string $nom + * @param string $nameEvent * @param string $date - * @param Alumni $organisateur + * @param Compte $organisator * @param array $participants - * @param int $nbInscriptionMax - * @param string $imageUrl */ - public function __construct(int $id, string $nom, string $date, Alumni $organisateur, array $participants, int $nbInscriptionMax, string $imageUrl) + public function __construct(string $nameEvent,string $date,Compte $organisator, + array $participants) { - $this->id = $id; - $this->nom = $nom; + $this->nameEvent = $nameEvent; $this->date = $date; - $this->organisateur = $organisateur; + $this->organisator = $organisator; $this->participants = $participants; - $this->nbInscriptionMax = $nbInscriptionMax; - $this->imageUrl = $imageUrl; } - public function getId(): int + public function getNameEvent() : string { - return $this->id; + return $this->nameEvent; } - public function getNom() : string - { - return $this->nom; - } - - public function getDate() : string + public function getDateEvent() : string { return $this->date; } @@ -77,18 +52,5 @@ class Evenement return $this->participants; } - public function getOrganisateur(): Alumni - { - return $this->organisateur; - } - public function getNbInscriptionMax(): int - { - return $this->nbInscriptionMax; - } - - public function getImageUrl(): string - { - return $this->imageUrl; - } } \ No newline at end of file diff --git a/php/metier/Experience.php b/php/metier/Experience.php deleted file mode 100644 index c0d89a2..0000000 --- a/php/metier/Experience.php +++ /dev/null @@ -1,94 +0,0 @@ -id = $id; - $this->profil = $profil; - $this->intitule = $intitule; - $this->dateDebut = $dateDebut; - $this->dateFin = $dateFin; - $this->nomEntreprise = $nomEntreprise; - $this->travailActuel = $travailActuel; - } - - public function getId(): int - { - return $this->id; - } - - public function getProfil(): Profil - { - return $this->profil; - } - - public function getIntitule(): string - { - return $this->intitule; - } - - public function getDateDebut(): string - { - return $this->dateDebut; - } - - public function getDateFin(): string - { - return $this->dateFin; - } - - public function getNomEntreprise(): string - { - return $this->nomEntreprise; - } - - public function isTravailActuel(): bool - { - return $this->travailActuel; - } -} \ No newline at end of file diff --git a/php/metier/Formation.php b/php/metier/Formation.php deleted file mode 100644 index 22cd70b..0000000 --- a/php/metier/Formation.php +++ /dev/null @@ -1,94 +0,0 @@ -id = $id; - $this->profil = $profil; - $this->nom = $nom; - $this->ville = $ville; - $this->dateDebut = $dateDebut; - $this->dateFin = $dateFin; - $this->formationActuelle = $formationActuelle; - } - - public function getId(): int - { - return $this->id; - } - - public function getProfil(): Profil - { - return $this->profil; - } - - public function getNom(): string - { - return $this->nom; - } - - public function getVille(): string - { - return $this->ville; - } - - public function getDateDebut(): string - { - return $this->dateDebut; - } - - public function getDateFin(): string - { - return $this->dateFin; - } - - public function isFormationActuelle(): bool - { - return $this->formationActuelle; - } -} \ No newline at end of file diff --git a/php/metier/Offre.php b/php/metier/Offre.php index f412345..2a79b64 100755 --- a/php/metier/Offre.php +++ b/php/metier/Offre.php @@ -1,213 +1,71 @@ id = $id; - $this->offreur = $offreur; - $this->nom = $nom; + $this->name = $offername; + $this->company = $offercompany; + $this->recruiter = $offermanager; $this->description = $description; - $this->imageUrl = $imageUrl; - $this->typeContrat = $typeContrat; - $this->ville = $ville; - $this->entreprise = $entreprise; - $this->descriptifPoste = $descriptifPoste; - $this->profil = $profil; - $this->experience = $experience; - $this->niveauEtudes = $niveauEtudes; - $this->mailContact = $mailContact; - $this->numero = $numero; - $this->siteUrl = $siteUrl; } - public function getId(): int + /** + * @return string + */ + public function getName(): string { - return $this->id; + return $this->name; } - public function getOffreur(): Alumni + /** + * @return string + */ + public function getCompany(): string { - return $this->offreur; + return $this->company; } - public function getNom(): string + /** + * @return Compte|string + */ + public function getRecruiter(): Compte|string { - return $this->nom; + return $this->recruiter; } + /** + * @return string + */ public function getDescription(): string { return $this->description; } - public function getImageUrl(): string - { - return $this->imageUrl; - } - public function getTypeContrat(): TypeContrat - { - return $this->typeContrat; - } - public function getVille(): string - { - return $this->ville; - } - public function getEntreprise(): string - { - return $this->entreprise; - } - public function getDescriptifPoste(): string - { - return $this->descriptifPoste; - } - - public function getProfil(): Profil - { - return $this->profil; - } - - public function getExperience(): string - { - return $this->experience; - } - - public function getNiveauEtudes(): NiveauEtudes - { - return $this->niveauEtudes; - } - - public function getMailContact(): string - { - return $this->mailContact; - } - - public function getNumero(): string - { - return $this->numero; - } - - public function getSiteUrl(): string - { - return $this->siteUrl; - } } \ No newline at end of file diff --git a/php/metier/Profil.php b/php/metier/Profil.php index f5cad7d..3e5dca1 100644 --- a/php/metier/Profil.php +++ b/php/metier/Profil.php @@ -1,105 +1,28 @@ id = $id; - $this->alumni = $alumni; - $this->cv = $cv; - $this->nom = $nom; - $this->prenom = $prenom; - $this->linkedinUrl = $linkedinUrl; - $this->githubUrl = $githubUrl; - $this->portfolioUrl = $portfolioUrl; - } - - public function getId(): int - { - return $this->id; - } - - public function getAlumni(): Alumni - { - return $this->alumni; - } - - public function getCv(): string - { - return $this->cv; - } - - public function getNom(): string - { - return $this->nom; - } - - public function getPrenom(): string - { - return $this->prenom; - } - - public function getLinkedinUrl(): string - { - return $this->linkedinUrl; - } - - public function getGithubUrl(): string - { - return $this->githubUrl; - } - - public function getPortfolioUrl(): string - { - return $this->portfolioUrl; - } -} \ No newline at end of file +class Alumni{ + + private string $id; + private string $alumni; + private string $email; + private string $cv; + private string $nom; + private string $prenom; + private string $linkedin; + private string $github; + private string $portfolio; + + public function __construct($id,$alumni,$email,$cv,$prenom,$linkedin,$github,$portfolio){ + $this->id=$id; + $this->alumni=$alumni; + $this->email=$email; + $this->cv=$cv; + $this->nom=$nom; + $this->prenom=$prenom; + $this->linkedin=$linkedin; + $this->github=$github; + $this->portfolio=$portfolio; + } +} + +?> \ No newline at end of file diff --git a/php/modeles/AdminModele.php b/php/modeles/AdminModele.php index 4103f26..a4031a1 100755 --- a/php/modeles/AdminModele.php +++ b/php/modeles/AdminModele.php @@ -6,9 +6,9 @@ class AdminModele extends MembreModele { /** * @description supprimer un compte - * @param \Alumni $account compte à supprimer + * @param \Compte $account compte à supprimer */ - public function deleteAccount(\Alumni $account) + public function deleteAccount(\Compte $account) { // TO DO } diff --git a/php/modeles/TestGateway.php b/php/modeles/TestGateway.php new file mode 100644 index 0000000..38987b1 --- /dev/null +++ b/php/modeles/TestGateway.php @@ -0,0 +1,26 @@ +insertAlumni('faa','fua','fia'); +//$gat->deleteAlumni(13); + +/*$gat->modifieMdp(10,'Bwaaa'); +*/ +//$gat->recupereAlumni(10); +//$gat->recupereDataAlumni(); + +?> \ No newline at end of file diff --git a/php/modeles/UtilisateurModele.php b/php/modeles/UtilisateurModele.php index f66b0c0..e60ee58 100755 --- a/php/modeles/UtilisateurModele.php +++ b/php/modeles/UtilisateurModele.php @@ -17,12 +17,12 @@ class UtilisateurModele * @description se connecter * @param string email * @param string hash - * @return \Alumni + * @return \Compte */ - public function Login(string $email,string $hash) : \Alumni + public function Login(string $email,string $hash) : \Compte { // TO DO - return new \Alumni(null,null,null); + return new \Compte(null,null,null); } /** @@ -30,9 +30,9 @@ class UtilisateurModele * @param string email * @param string hash * @param string $pseudo - * @return \Alumni chargé + * @return \Compte chargé */ - public function signIn(string $email,string $pseudo,string $hash) : \Alumni + public function signIn(string $email,string $pseudo,string $hash) : \Compte { // TO DO return new Compte(null,null,null); diff --git a/php/vues/connection.html b/php/vues/connection.html new file mode 100644 index 0000000..9d230f9 --- /dev/null +++ b/php/vues/connection.html @@ -0,0 +1,47 @@ + + +
+ + +