예제 #1
0
 static function import($title, $statut = 1)
 {
     global $dbh;
     // check sur la variable passée en paramètre
     if (!$title) {
         return 0;
     }
     // tentative de récupérer l'id associée dans la base (implique que l'autorité existe)
     // préparation de la requête
     $key = addslashes($title);
     $query = "SELECT serie_id FROM series WHERE serie_name='" . rtrim(substr($key, 0, 255)) . "' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT series " . $query);
     }
     // résultat
     // récupération du résultat de la recherche
     $tserie = pmb_mysql_fetch_object($result);
     // du résultat et récupération éventuelle de l'id
     if ($tserie->serie_id) {
         return $tserie->serie_id;
     }
     // id non-récupérée, il faut créer la forme.
     $index = addslashes(strip_empty_words($title));
     $query = 'INSERT INTO series SET serie_name="' . $key . '", serie_index=" ' . $index . ' "';
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into series" . $query);
     }
     $id = pmb_mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_SERIE, $id);
     //update authority informations
     $authority = new authority(0, $id, AUT_TABLE_SERIES);
     $authority->set_num_statut($statut);
     $authority->update();
     serie::update_index($id);
     return $id;
 }
예제 #2
0
파일: serie.class.php 프로젝트: hogsim/PMB
 function update($value)
 {
     global $dbh;
     global $msg;
     global $include_path;
     global $thesaurus_concepts_active;
     if (!$value) {
         return false;
     }
     // nettoyage de la chaîne en entrée
     $value = clean_string($value);
     $requete = "SET serie_name='" . $value . "', ";
     $requete .= "serie_index=' " . strip_empty_words($value) . " '";
     if ($this->s_id) {
         // update
         $requete = 'UPDATE series ' . $requete;
         $requete .= ' WHERE serie_id=' . $this->s_id . ' LIMIT 1;';
         if (pmb_mysql_query($requete, $dbh)) {
             $rqt_notice = "select notice_id,tit1,tit2,tit3,tit4 from notices where tparent_id=" . $this->s_id;
             $r_notice = pmb_mysql_query($rqt_notice);
             while ($r = pmb_mysql_fetch_object($r_notice)) {
                 $rq_serie = "update notices, series set notices.index_serie=serie_index, notices.index_wew=concat(serie_name,' ',tit1,' ',tit2,' ',tit3,' ',tit4),notices.index_sew=concat(' ',serie_index,' ','" . addslashes(strip_empty_words($r->tit1 . " " . $r->tit2 . " " . $r->tit3 . " " . $r->tit4)) . "',' ') where notice_id=" . $r->notice_id . " and serie_id=tparent_id";
                 pmb_mysql_query($rq_serie);
             }
             $aut_link = new aut_link(AUT_TABLE_SERIES, $this->s_id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("serie", $this->s_id);
             $aut_pperso->save_form();
             serie::update_index($this->s_id);
             audit::insert_modif(AUDIT_SERIE, $this->s_id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[337], $msg[341]);
             return FALSE;
         }
     } else {
         // création : s'assurer que le titre n'existe pas déjà
         $dummy = "SELECT * FROM series WHERE serie_name REGEXP '^{$value}\$' LIMIT 1 ";
         $check = pmb_mysql_query($dummy, $dbh);
         if (pmb_mysql_num_rows($check)) {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[336], $msg[340]);
             return FALSE;
         }
         $requete = 'INSERT INTO series ' . $requete . ';';
         if (pmb_mysql_query($requete, $dbh)) {
             $this->s_id = pmb_mysql_insert_id();
             $aut_link = new aut_link(AUT_TABLE_SERIES, $this->s_id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("serie", $this->s_id);
             $aut_pperso->save_form();
             audit::insert_creation(AUDIT_SERIE, $this->s_id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[336], $msg[342]);
             return FALSE;
         }
     }
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->s_id, TYPE_SERIE);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->s_id, "serie");
     return TRUE;
 }