Esempio 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;
 }
Esempio n. 2
0
 public function autocomplete($action, $id, $vars)
 {
     switch ($action) {
         case 'get':
             if (!empty($_GET['type']) && !empty($_GET['term'])) {
                 $res = NULL;
                 if ($_GET['type'] == 'motcle') {
                     $motCleDAO = new MotCleDAO(BDD::getInstancePDO());
                     $res = $motCleDAO->getAllComposedOf($_GET['term']);
                 } elseif ($_GET['type'] == 'membre') {
                     $membreDAO = new MembreDAO(BDD::getInstancePDO());
                     $res = $membreDAO->getAllComposedOf($_GET['term']);
                 } elseif ($_GET['type'] == 'titreTechnote') {
                     $technoteDAO = new TechnoteDAO(BDD::getInstancePDO());
                     $res = $technoteDAO->getAllTitreComposedOf($_GET['term']);
                 } elseif ($_GET['type'] == 'titreQuestion') {
                     $questionDAO = new QuestionDAO(BDD::getInstancePDO());
                     $res = $questionDAO->getAllTitreComposedOf($_GET['term']);
                 }
                 echo json_encode($res);
                 exit;
             }
             $this->vue->display('404.twig', $vars);
             exit;
         default:
             $this->vue->display('404.twig', $vars);
             exit;
     }
 }
Esempio n. 3
0
 /**
  * Vérifie et ajoute une technote
  * @param array $param Les attributs de la technotes
  * @return object 2 attributs, bool success et array string msg
  * @static
  */
 public static function addTechnote(&$param, &$files)
 {
     $resCheck = self::checkTechnote($param, $files, 'add');
     $res = $resCheck;
     if ($resCheck->success === true) {
         $technoteDAO = new TechnoteDAO(BDD::getInstancePDO());
         $technote = new Technote(array('id_technote' => DAO::UNKNOWN_ID, 'titre' => $param['titre'], 'contenu' => $param['contenu'], 'id_auteur' => $_SESSION['user']->id_membre, 'url_image' => $param['url_image'], 'description' => $param['description'], 'publie' => $param['publie'], 'visible' => '1'));
         if (($resSaveTechnote = $technoteDAO->save($technote)) !== false) {
             $decrireDAO = new DecrireDAO(BDD::getInstancePDO());
             if (!empty($param['id_mot_cle'])) {
                 foreach ($param['id_mot_cle'] as $id_mot_cle) {
                     $decrire = new Decrire(array('id_technote' => $resSaveTechnote->id_technote, 'id_mot_cle' => $id_mot_cle));
                     $decrireDAO->save($decrire);
                 }
             }
             $actionDAO = new ActionDAO(BDD::getInstancePDO());
             $action = new Action(array('id_action' => DAO::UNKNOWN_ID, 'libelle' => "Ajout d\\'une technote (technote n°{$resSaveTechnote->id_technote})", 'id_membre' => $_SESSION['user']->id_membre));
             $actionDAO->save($action);
             $res->success = true;
             $res->id_technote = $resSaveTechnote->id_technote;
             $res->msg[] = 'Ajout de la technote réussie';
         } else {
             $res->success = false;
             $res->msg[] = 'Erreur BDD';
         }
     }
     return $res;
 }
Esempio n. 4
0
 private static function checkAdd(&$param)
 {
     $std = (object) array('success' => false, 'msg' => array());
     $technoteDAO = new TechnoteDAO(BDD::getInstancePDO());
     if (($res = $technoteDAO->getOne($param['id_technote'])) !== false) {
         if (($res = self::checkCommentaire($param['commentaire'])) !== true) {
             $std->msg[] = $res;
         }
         if (($res = self::checkCommentaireParent($param['id_commentaire_parent'], $param['id_technote'])) !== true) {
             $std->msg[] = $res;
         }
     } else {
         $std->msg[] = 'La technote n\'existe pas';
     }
     if (empty($std->msg)) {
         $std->success = true;
     }
     return $std;
 }