Esempio n. 1
0
 public static function add(&$param)
 {
     $std = (object) array('success' => false, 'msg' => array());
     if (($res = MotCle::checkLabel($param['label'])) !== true) {
         $std->msg[] = $res;
     }
     if (!empty($std->msg)) {
         return $std;
     }
     // Si c'est un modérateur ou un admin actif, sinon non actif
     $actif = $_SESSION['user']->groupe == 'Administrateur' || $_SESSION['user']->groupe == 'Modérateur' ? 1 : 0;
     $motCle = new MotCle(array('id_mot_cle' => DAO::UNKNOWN_ID, 'label' => $param['label'], 'actif' => $actif));
     $motCleDAO = new MotCleDAO(BDD::getInstancePDO());
     $resSave = $motCleDAO->save($motCle);
     if ($resSave !== false) {
         $std->msg[] = 'Mot clé créer avec succès';
     } else {
         $std->msg[] = 'Erreur BDD';
     }
     $actionDAO = new ActionDAO(BDD::getInstancePDO());
     $action = new Action(array('id_action' => DAO::UNKNOWN_ID, 'libelle' => "Création d\\'un mot clé (mot clé n°{$resSave->id_mot_cle} : {$resSave->label})", 'id_membre' => $_SESSION['user']->id_membre));
     $actionDAO->save($action);
     $std->success = true;
     return $std;
 }