Exemplo n.º 1
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;
 }