Ejemplo n.º 1
0
 /**
  * @return \stdClass Objet Contient les informations du profil d'un membre
  */
 public function getProfil()
 {
     $tokenDAO = new TokenDAO(BDD::getInstancePDO());
     $technoteDAO = new TechnoteDAO(BDD::getInstancePDO());
     $commentaireDAO = new CommentaireDAO(BDD::getInstancePDO());
     $questionDAO = new QuestionDAO(BDD::getInstancePDO());
     $reponseDAO = new ReponseDAO(BDD::getInstancePDO());
     $actionDAO = new ActionDAO(BDD::getInstancePDO());
     $res = new stdClass();
     $res->nbTokenActif = $tokenDAO->getNbActif($this->id_membre);
     $res->tokenActif = $tokenDAO->getActif($this->id_membre);
     $res->nbTechnoteRedige = $technoteDAO->getNbRedige($this->id_membre);
     $res->nbCommentaireRedige = $commentaireDAO->getNbRedige($this->id_membre);
     $res->nbQuestionRedige = $questionDAO->getNbRedige($this->id_membre);
     $res->nbReponseRedige = $reponseDAO->getNbRedige($this->id_membre);
     $res->actions = $actionDAO->getLast($this->id_membre);
     return $res;
 }
Ejemplo n.º 2
0
    public function getOne($id)
    {
        $req = $this->pdo->prepare('
			SELECT t.*, ma.pseudo auteur, mm.pseudo modificateur
			FROM technote t
			INNER JOIN membre ma ON ma.id_membre=t.id_auteur
			LEFT JOIN membre mm ON mm.id_membre=t.id_modificateur
			WHERE id_technote = :id_technote
		');
        $req->execute(array('id_technote' => $id));
        if (($res = $req->fetch()) === false) {
            return false;
        }
        $decrireDAO = new DecrireDAO(BDD::getInstancePDO());
        $res->motsCles = $decrireDAO->getAllForOneTechnote($id);
        $commentaireDAO = new CommentaireDAO(BDD::getInstancePDO());
        $res->commentaires = $commentaireDAO->getTreeForOneTechnote($id, NULL);
        return new Technote(get_object_vars($res));
    }
Ejemplo n.º 3
0
    public function getTreeForOneTechnote($id_technote, $id_commentaire_parent)
    {
        $res = array();
        $op = empty($id_commentaire_parent) ? 'IS' : '=';
        $req = $this->pdo->prepare('SELECT c.*, ma.pseudo auteur, mm.pseudo modificateur 
									FROM commentaire c 
									INNER JOIN membre ma ON ma.id_membre=c.id_auteur 
									LEFT JOIN membre mm ON mm.id_membre=c.id_modificateur 
									WHERE id_technote = :id_technote 
										AND id_commentaire_parent ' . $op . ' :id_commentaire_parent');
        $req->execute(array('id_technote' => $id_technote, 'id_commentaire_parent' => $id_commentaire_parent));
        $commentaireDAO = new CommentaireDAO(BDD::getInstancePDO());
        foreach ($req->fetchAll() as $ligne) {
            $ligne->commentaires = $commentaireDAO->getTreeForOneTechnote($id_technote, $ligne->id_commentaire);
            $res[] = new Commentaire(get_object_vars($ligne));
        }
        return $res;
    }
Ejemplo n.º 4
0
 private static function checkCommentaireParent(&$id_commentaire_parent, $id_technote)
 {
     if (!empty($id_commentaire_parent)) {
         $commentaireDAO = new CommentaireDAO(BDD::getInstancePDO());
         if (($res = $commentaireDAO->getOne($id_commentaire_parent)) !== false) {
             if ($res->id_technote == $id_technote) {
                 return true;
             } else {
                 return 'Le commentaire parent n\'appartient pas à la même technote';
             }
         } else {
             return 'Le commentaire parent n\'existe pas ou plus';
         }
     }
     $id_commentaire_parent = NULL;
     return true;
 }