/** * Enregistre le stage dans la base de donnée. * */ public function save() { $pdo = myPDO::getInstance(); //Vérifie si le stage exite pas déjà. if ($this->id != null) { $req = $pdo->prepare(<<<SQL UPDATE Stage SET titre, dateFin, dateDebut, description, domaine, nbPoste, gratification, dateCreation WHERE numEntreprise = ? AND titre = ? AND dateFin= ? AND dateDebut= ? AND description= ? AND domaine= ? AND nbPoste = ? AND gratification= ? AND dateCreation = now() SQL ); $update = $req->execute(array($this->entreprise->getId(), $this->titre, $this->dateFin, $this->dateDebut, $this->description, $this->domaine, $this->nbPoste, $this->gratification)); if ($update) { $this->notifyObs(); } } else { $req1 = $pdo->prepare(<<<SQL INSERT INTO Stage (numStage, titre, dateFin, dateDebut, description, domaine, nbPoste, gratification, numEntreprise, dateCreation) VALUES('',?,?,?,?,?,?,?,?, now()) SQL ); $ins = $req1->execute(array($this->titre, $this->dateFin, $this->dateDebut, $this->description, $this->domaine, $this->nbPoste, $this->gratification, $this->entreprise->getId())); // Si la BD a été modidé, on prévient l'entrepreneur if ($ins) { $this->notifyObs(); } } }
/** * Usine à Commentaire. Crée un Commentaire selon l'ID passé en paramètre * @param int $id : l'ID du commentaire à créer * @param Gestionnaire $gestionnaire : le gestionnaire courant * @return Commentaire : le commentaire voulu / null s'il n'existe pas */ public static function createFromID($id, $gestionnaire, $film) { $pdo = myPDO::getInstance(); $stmt = $pdo->prepare(<<<SQL SELECT * FROM commentaire WHERE id = :id SQL ); $stmt->execute(array("id" => $id)); $stmt->setFetchMode(PDO::FETCH_CLASS, 'Commentaire'); if (($object = $stmt->fetch()) !== false) { $object->membre = $gestionnaire->getMembre($object->id_membre); $object->film = $film; // Test si le membre connecté a lu ce comm if (isset($_SESSION["membre"]) && $_SESSION["membre"] instanceof Membre) { $stmt2 = $pdo->prepare(<<<SQL SELECT id_comm FROM lecture_comm WHERE id_comm = :id_comm AND id_membre = :id_membre SQL ); $stmt2->execute(array("id_comm" => $object->id, "id_membre" => $_SESSION["membre"]->getID())); if (($foo = $stmt2->fetch()) !== false) { $object->lu = true; } else { $object->lu = false; } } return $object; } }
/** * Usine à commentaire. Construit tous les commentaires d'un entreprise * @throws si le parametre n'est pas une instance de la class entreprise */ public static function createFromEntreprise($idEntreprise) { $pdo = myPDO::getInstance(); $req = $pdo->prepare(<<<SQL SELECT numCommentaire AS 'id', loginEnseignant, contenu, dateEnvoi FROM Commentaire WHERE numEntreprise= ? SQL ); $req->execute(array($idEntreprise)); $listCommentaire = $req->fetchAll(PDO::FETCH_CLASS, "Commentaire"); return $listCommentaire; }
/** * Constructeur d'une Convention en fonction de son login * @param login de Convention * @return une instance de Convention sinon renvoi null */ public static function createFromAdmin($numAdmin) { if (strlen($numAdmin) == 8) { $pdo = myPDO::getInstance(); $rq1 = $pdo->prepare(<<<SQL \t\t\t\tSELECT numConvention ,valide, loginEnseignant, numStage, loginEtudiant \t\t\t\tFROM Convention \t\t\t\tWHERE numAdmin = ? SQL ); $rq1->execute(array($numAdmin)); $rq1->setFetchMode(PDO::FETCH_CLASS, __CLASS__); return $rq1->fetchAll(); } }
public function valideAffectation($num) { $pdo = myPDO::getInstance(); $rq1 = $pdo->prepare(<<<SQL \t\t\tSELECT loginEnseignant AS 'enseignant' \t\t\tFROM Convention \t\t\tWHERE numConvention = ? SQL ); $rq1->execute(array($num)); $rq1->setFetchMode(PDO::FETCH_CLASS, __CLASS__); if (($rq1 = $rq1->fetch()) !== false) { $sql = "UPDATE Convention SET valide=1 WHERE id=?"; $stmt = $conn->prepare($sql); $stmt->execute($rq1); } }
/** * Usine à fabriquer des Stage * @param int $idEtudiant : l'ID de l'étudiant * @param int $idOffre : l'ID de l'offre * @param int $idEnseignant : l'ID de l'enseignant * @return Stage */ public static function createFromIDs($idEtudiant, $idOffre, $idEnseignant) { $pdo = myPDO::getInstance(); $stmt = $pdo->prepare(<<<SQL SELECT * FROM STAGE WHERE idEtu = :idEtu AND idOffre = :idOffre AND idEns = :idEns SQL ); $stmt->execute(array("idEtu" => $idEtudiant, "idOffre" => $idOffre, "idEns" => $idEnseignant)); $stmt->setFetchMode(PDO::FETCH_CLASS, 'Stage'); if (($object = $stmt->fetch()) !== false) { $object->entrepriseCorrespondante = Entreprise::createFromID(OffreStage::createFromID($idOffre)->getEntrepriseId()); return $object; } }
/** * Permet à un entrepreneur de s'inscrire dans la base de donnée * @throws si l'adresse mail est déja utilsé dans la base de donnée. */ public static function inscription($nom, $prenom, $mail, $pass, $tel = null, $fonction = "") { $pdo = myPDO::getInstance(); $req = $pdo->prepare(<<<SQL \t \tSELECT 'a' \t \tFROM Entrepreneur \t \tWHERE mail = ? SQL ); $req->execute(array($mail)); if ($req->fetch() != false) { throw new MailUtiliser("Cette adresse mail est déja utilisé."); } $req1 = $pdo->prepare(<<<SQL \t\t\tINSERT INTO Entrepreneur (numEntrepreneur,prenom,nom,mail,fonction,pass,tel) \t\t\tVALUES('',?,?,?,?,?,?) SQL ); $ins = $req1->execute(array($prenom, $nom, $mail, $fonction, sha1($pass), $tel)); }
/** * Usine à fabriquer des OffreStage. * @param int $id : l'ID de l'offre */ public static function createFromID($id) { $offre = new OffreStage(); // On récupère l'offre de stage $pdo = myPDO::getInstance(); $pdostat = $pdo->prepare("SELECT * FROM OFFRESTAGE WHERE idOffre=:id ORDER BY datePublication DESC"); $pdostat->execute(array(':id' => $id)); $pdostat->setFetchMode(PDO::FETCH_CLASS, __CLASS__); if (($obj = $pdostat->fetch()) !== false) { $offre = $obj; } // On récupère l'es id' $pdostat = $pdo->prepare("SELECT * FROM STAGE WHERE idOffre=:id"); $pdostat->execute(array(':id' => $id)); $pdostat->setFetchMode(PDO::FETCH_CLASS, __CLASS__); while (($obj = $pdostat->fetch()) !== false) { $offre->stagesCorrespondants[] = $obj; } $offre->datePublication = date('d/m/Y', strtotime($offre->datePublication)); $offre->dateDeb = date('d/m/Y', strtotime($offre->dateDeb)); $offre->dateFin = date('d/m/Y', strtotime($offre->dateFin)); return $offre; }
$p->appendCssUrl("style/searchEngine.css"); $p->appendJsUrl("js/request.js"); //inclusion de la barre de navigation include_once "navbar.inc.php"; $p->appendContent(<<<HTML <div class="panel panel-default"> <!-- Default panel contents --> <div class="panel-heading">Panel heading</div> <!-- Table --> <table class="table"> <tr><th scope="col">N°</th><th scope="col">Numéro convention</th><th scope="col">Entreprise</th><th scope="col">Enseignant réferent</th></tr> HTML ); require_once 'myPDO.include.php'; $db = myPDO::getInstance(); $stmt = $db->prepare(<<<SQL \t\t\t SELECT c.numConvention, e.nom, c.loginEnseignant \t\t\t FROM Convention c, Stage s, Entreprise e \t\t\t WHERE c.numStage = s.numStage AND s.numEntreprise = e.numEntreprise \t\t\t ORDER BY 1; SQL ); $stmt->setFetchMode(PDO::FETCH_CLASS, __CLASS__); $stmt->execute(); $res = null; $i = 1; while (($res[] = $stmt->fetch()) !== false) { $p->appendContent(<<<HTML <tr><th scope="row">{$i}</th><td>{$res['0']}</td><td>{$res['1']}</td><td>{$res['2']}</td></tr> HTML
public function applyChanges($post) { $pdo = myPDO::getInstance(); if (isset($post["email"])) { $stmt = $pdo->prepare(<<<SQL SELECT email FROM PERSONNE UNION SELECT email FROM ENTREPRISE SQL ); $stmt->execute(); while (($obj = $stmt->fetch()) !== false) { if ($obj["email"] == $post["email"]) { $post["email"] = ""; } } } $stmt = $pdo->prepare(<<<SQL UPDATE PERSONNE SET email = ?, numRue = ?, rue = ?, ville = ?, CP = ?, sha1mdp = ? WHERE idPers = ? SQL ); $stmt->execute(array(isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email, isset($post["num_rueEns"]) && $post["num_rueEns"] != "" ? $post["num_rueEns"] : $this->numRue, isset($post["nom_rueEns"]) && $post["nom_rueEns"] != "" ? $post["nom_rueEns"] : $this->rue, isset($post["villeEns"]) && $post["villeEns"] != "" ? $post["villeEns"] : $this->ville, isset($post["code_postalEns"]) && $post["code_postalEns"] != "" ? $post["code_postalEns"] : $this->CP, isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp, $this->idEns)); $stmt = $pdo->prepare(<<<SQL UPDATE ENSEIGNANT SET domainPredom = ? WHERE idEns = ? SQL ); $stmt->execute(array(isset($post["domainePredom"]) && $post["domainePredom"] != "" ? $post["domainePredom"] : $this->domainePredom, $this->idEns)); $this->email = isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email; $this->numRue = isset($post["num_rueEns"]) && $post["num_rueEns"] != "" ? $post["num_rueEns"] : $this->numRue; $this->rue = isset($post["nom_rueEns"]) && $post["nom_rueEns"] != "" ? $post["nom_rueEns"] : $this->rue; $this->ville = isset($post["villeEns"]) && $post["villeEns"] != "" ? $post["villeEns"] : $this->ville; $this->CP = isset($post["code_postalEns"]) && $post["code_postalEns"] != "" ? $post["code_postalEns"] : $this->CP; $this->sha1mdp = isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp; $this->domainePredom = isset($post["domaine"]) && $post["domaine"] != "" ? $post["domaine"] : $this->domainePredom; }
<?php require_once "../inc/config.inc.php"; session_start(); $idOffre = (int) $_POST["idOffre"]; if (isset($_SESSION["membre"]) && $_SESSION["membre"] instanceof Entreprise) { if (isset($_POST["idOffre"]) && isset($_POST["intitule"]) && isset($_POST["domaine"]) && isset($_POST["nbPlaces"]) && isset($_POST["competences"]) && isset($_POST["date_deb"]) && isset($_POST["date_fin"]) && !empty($_POST["intitule"]) && !empty($_POST["domaine"]) && !empty($_POST["nbPlaces"]) && !empty($_POST["competences"]) && !empty($_POST["date_deb"]) && !empty($_POST["date_fin"])) { if (is_numeric($_POST["nbPlaces"])) { if (in_array(OffreStage::createFromID($idOffre), $_SESSION["membre"]->getOffresProposees())) { $pdo = myPDO::getInstance(); $stmt = $pdo->prepare(<<<SQL UPDATE OFFRESTAGE SET idEnt = :idEnt, intitule = :intitule, domaine = :domaine, nbPlaces = :nbPlaces, descOffre = :descOffre, cptRequis = :cptRequis, dateDeb = :dateDeb, dateFin = :dateFin WHERE idOffre = :idOffre SQL ); $stmt->execute(array("idEnt" => $_SESSION["membre"]->getID(), "intitule" => $_POST["intitule"], "domaine" => $_POST["domaine"], "nbPlaces" => $_POST["nbPlaces"], "descOffre" => $_POST["description"], "cptRequis" => $_POST["competences"], "dateDeb" => $_POST["date_deb"], "dateFin" => $_POST["date_fin"], "idOffre" => $idOffre)); $message = "Offre modifiée. <a href=\"listeOffresEntreprise.php\">Retour à la liste des offres</a>"; // MAJ de l'objet en session : $_SESSION["membre"] = Entreprise::createFromID($_SESSION["membre"]->getID()); } else { $message = "Vous n'avez pas le droit de modifier cette offre <a href=\"index.php\">Retour</a>"; } } else { $message = "Le nombre de places doit être un nombre entier. <a href=\"modiferOffre.php?id={$idOffre}\">Retour</a>"; } } else { $message = "Tous les champs sont obligatoires. <a href=\"modiferOffre.php?id={$idOffre}\">Retour</a>";
public function applyChanges($post) { $pdo = myPDO::getInstance(); if (isset($post["email"])) { $stmt = $pdo->prepare(<<<SQL SELECT email FROM PERSONNE UNION SELECT email FROM ENTREPRISE SQL ); $stmt->execute(); while (($obj = $stmt->fetch()) !== false) { if ($obj["email"] == $post["email"]) { $post["email"] = ""; } } } $stmt = $pdo->prepare(<<<SQL UPDATE PERSONNE SET email = ?, numRue = ?, rue = ?, ville = ?, CP = ?, sha1mdp = ? WHERE idPers = ? SQL ); $stmt->execute(array(isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email, isset($post["num_rue"]) && $post["num_rue"] != "" ? $post["num_rue"] : $this->numRue, isset($post["nom_rue"]) && $post["nom_rue"] != "" ? $post["nom_rue"] : $this->rue, isset($post["ville"]) && $post["ville"] != "" ? $post["ville"] : $this->ville, isset($post["code_postal"]) && $post["code_postal"] != "" ? $post["code_postal"] : $this->CP, isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp, $this->idEtu)); $this->email = isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email; $this->numRue = isset($post["num_rue"]) && $post["num_rue"] != "" ? $post["num_rue"] : $this->numRue; $this->rue = isset($post["nom_rue"]) && $post["nom_rue"] != "" ? $post["nom_rue"] : $this->rue; $this->ville = isset($post["ville"]) && $post["ville"] != "" ? $post["ville"] : $this->ville; $this->CP = isset($post["code_postal"]) && $post["code_postal"] != "" ? $post["code_postal"] : $this->CP; $this->sha1mdp = isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp; if (isset($_FILES)) { $stmt = $pdo->prepare(<<<SQL UPDATE ETUDIANT SET cheminCV = ? WHERE idEtu = ? SQL ); $nameFile = SHA1("cv" . $this->idEtu); $stmt->execute(array($nameFile . ".pdf", $this->idEtu)); $this->cheminCV = $nameFile . ".pdf"; if (file_exists($nameFile . ".pdf")) { unlink("../CV/" . $nameFile . ".pdf"); } move_uploaded_file($_FILES['CV']['tmp_name'], "../CV/" . $nameFile . ".pdf"); } }
/** * Méthode statique, accès au nombre total de films présents dans la BD * @return int : le nombre de films dans la BD */ public static function nbTotalFilms() { $pdo = myPDO::getInstance(); $stmt = $pdo->prepare(<<<SQL SELECT COUNT(id) AS nb_films FROM film SQL ); $stmt->execute(); $data = $stmt->fetch(); return $data["nb_films"]; }
/** * Retourne la liste des tous les enseignants * */ public function getAll() { $pdo = myPDO::getInstance(); $req1 = $pdo->prepare(<<<SQL \t\tSELECT * \t\tFROM Enseignant SQL ); $rq1->execute(array()); $rq1->setFetchMode(PDO::FETCH_CLASS, __CLASS__); return $rq1->fetchAll(); }
/** * Ajoute un commentaire sur ce film * @param int $membre : l'ID du membre qui ajoute ce Commentaire * @param String $contenu : le contenu du Commentaire * @param boolean $spoiler : ce commentaire est-il un spoiler * @return void */ public function ajoutCommentaire($membre, $contenu, $spoiler = false) { $pdo = myPDO::getInstance(); $stmt = $pdo->prepare(<<<SQL INSERT INTO commentaire (id_film, id_membre, commentaire, spoiler, date_publication) VALUES (:idfilm, :idmembre, :commentaire, :spoiler, now()) SQL ); $stmt->execute(array("idfilm" => $this->id, "idmembre" => $membre, "commentaire" => $contenu, "spoiler" => $spoiler)); $idComm = $pdo->lastInsertId(); $membre_obj = Membre::createFromID($membre); $membre_obj->lireCommentaire($idComm); }
/** * Détermine le type d'un utilisateur * @param String $login : le login de l'utilisateur * @return String : le type de l'utilisateur */ private function typeUtilisateur($login) { $pdo = myPDO::getInstance(); // On récupère l'id de la Personne $stmt = $pdo->prepare(<<<SQL SELECT idPers FROM PERSONNE WHERE login = :log SQL ); $stmt->execute(array(':log' => $login)); $stmt->setFetchMode(PDO::FETCH_CLASS, ''); if (($object = $stmt->fetch()) !== false) { // On regarde si l'id correpond... $stmt2 = $pdo->prepare(<<<SQL SELECT * FROM ENSEIGNANT WHERE idEns = :id SQL ); $stmt2->execute(array(':id' => $object['idPers'])); if (($obj = $stmt2->fetch()) !== false) { // ...à un enseignant... return "enseignant"; } else { // ...ou à un étudiant return "etudiant"; } } else { // si le login n'existe pas dans Personne alors il est dans Entreprise return "entreprise"; } }
public function applyChanges($post) { $pdo = myPDO::getInstance(); if (isset($post["email"])) { $stmt = $pdo->prepare(<<<SQL SELECT email FROM PERSONNE UNION SELECT email FROM ENTREPRISE SQL ); $stmt->execute(); while (($obj = $stmt->fetch()) !== false) { if ($obj["email"] == $post["email"]) { $post["email"] = ""; } } } $stmt = $pdo->prepare(<<<SQL UPDATE ENTREPRISE SET email = ?, siteWebEnt = ?, description = ?, numRueEnt = ?, rueEnt = ?, villeEnt = ?, CPEnt = ?, sha1mdp = ? WHERE idEnt = ? SQL ); $stmt->execute(array(isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email, isset($post["siteWebEnt"]) && $post["siteWebEnt"] != "" ? $post["siteWebEnt"] : $this->siteWebEnt, isset($post["description"]) && $post["description"] != "" ? $post["description"] : $this->description, isset($post["num_rueEnt"]) && $post["num_rueEnt"] != "" ? $post["num_rueEnt"] : $this->numRueEnt, isset($post["nom_rueEnt"]) && $post["nom_rueEnt"] != "" ? $post["nom_rueEnt"] : $this->rueEnt, isset($post["villeEnt"]) && $post["villeEnt"] != "" ? $post["villeEnt"] : $this->villeEnt, isset($post["code_postalEnt"]) && $post["code_postalEnt"] != "" ? $post["code_postalEnt"] : $this->CPEnt, isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp, $this->idEnt)); $this->email = isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email; $this->siteWebEnt = isset($post["siteWebEnt"]) && $post["siteWebEnt"] != "" ? $post["siteWebEnt"] : $this->siteWebEnt; $this->description = isset($post["description"]) && $post["description"] != "" ? $post["description"] : $this->description; $this->numRueEnt = isset($post["num_rueEnt"]) && $post["num_rueEnt"] != "" ? $post["num_rueEnt"] : $this->numRueEnt; $this->rueEnt = isset($post["nom_rueEnt"]) && $post["nom_rueEnt"] != "" ? $post["nom_rueEnt"] : $this->rueEnt; $this->villeEnt = isset($post["villeEnt"]) && $post["villeEnt"] != "" ? $post["villeEnt"] : $this->villeEnt; $this->CPEnt = isset($post["code_postalEnt"]) && $post["code_postalEnt"] != "" ? $post["code_postalEnt"] : $this->CPEnt; $this->sha1mdp = isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp; }
/** * Faire lire tous les commentaires à ce membre * @return void */ public function lireTousCommentaires() { $pdo = myPDO::getInstance(); $stmt = $pdo->prepare(<<<SQL SELECT MAX(id) AS max_comm FROM commentaire SQL ); $stmt->execute(); $nbComm = $stmt->fetch()["max_comm"]; for ($i = 1; $i <= $nbComm; $i++) { $this->lireCommentaire($i); } }
/** * Permet à un etudiant de s'inscrire dans la base de donnée, seul le login est obligatoire * @throws si le login est déja utilsé dans la base de donnée. */ public static function inscription($login, $nom = "", $prenom = "", $mail = "", $tel = "") { $pdo = myPDO::getInstance(); $req = $pdo->prepare(<<<SQL \t \tSELECT 'a' \t \tFROM Etudiant \t \tWHERE loginEtudiant = ? SQL ); $req->execute(array($login)); if ($req->fetch() != false) { $req1 = $pdo->prepare(<<<SQL \t\t\tUPDATE Etudiant \t\t\tSET prenom = ?,nom = ?,mail= ?,tel= ? \t\t\tWHERE loginEtudiant = ? SQL ); $req1->execute(array($prenom, $nom, $mail, $tel, $login)); } else { $req1 = $pdo->prepare(<<<SQL \t\t\tINSERT INTO Etudiant (loginEtudiant,prenom,nom,mail,tel) \t\t\tVALUES(?,?,?,?,?) SQL ); $ins = $req1->execute(array($login, $prenom, $nom, $mail, $tel)); } }