function delete_notice() { global $dbh; global $demandes_statut_notice, $pmb_type_audit; notice::del_notice($this->num_notice); // mise à jour de la demande $req = "UPDATE demandes SET num_notice=0 WHERE id_demande=" . $this->id_demande; pmb_mysql_query($req, $dbh); $this->num_notice = 0; }
function delete() { global $dbh; global $pmb_synchro_rdf; //suppression des notices de dépouillement $this->delete_analysis(); //synchro rdf if ($pmb_synchro_rdf) { $synchro_rdf = new synchro_rdf(); $synchro_rdf->delRdf(0, $this->bulletin_id); } //suppression des exemplaires $req_expl = "select expl_id from exemplaires where expl_bulletin ='" . $this->bulletin_id . "' "; $result_expl = @pmb_mysql_query($req_expl, $dbh); while ($expl = pmb_mysql_fetch_object($result_expl)) { exemplaire::del_expl($expl->expl_id); } // expl numériques $req_explNum = "select explnum_id from explnum where explnum_bulletin=" . $this->bulletin_id . " "; $result_explNum = @pmb_mysql_query($req_explNum, $dbh); while ($explNum = pmb_mysql_fetch_object($result_explNum)) { $myExplNum = new explnum($explNum->explnum_id); $myExplNum->delete(); } $requete = "delete from caddie_content using caddie, caddie_content where caddie_id=idcaddie and type='BULL' and object_id='" . $this->bulletin_id . "' "; @pmb_mysql_query($requete, $dbh); // Suppression des résas du bulletin $requete = "DELETE FROM resa WHERE resa_idbulletin=" . $this->bulletin_id; pmb_mysql_query($requete, $dbh); // Suppression des transferts_demande $requete = "DELETE FROM transferts_demande using transferts_demande, transferts WHERE num_transfert=id_transfert and num_bulletin=" . $this->bulletin_id; pmb_mysql_query($requete, $dbh); // Suppression des transferts $requete = "DELETE FROM transferts WHERE num_bulletin=" . $this->bulletin_id; pmb_mysql_query($requete, $dbh); //suppression de la notice du bulletin $requete = "select num_notice from bulletins where bulletin_id=" . $this->bulletin_id; $res_nbul = pmb_mysql_query($requete); if (pmb_mysql_num_rows($res_nbul)) { $num_notice = pmb_mysql_result($res_nbul, 0, 0); if ($num_notice) { notice::del_notice($num_notice); } } // Suppression de ce bulletin $requete = "DELETE FROM bulletins WHERE bulletin_id=" . $this->bulletin_id; pmb_mysql_query($requete, $dbh); audit::delete_audit(AUDIT_BULLETIN, $this->bulletin_id); }
function import_new_notice_suite() { global $dbh; global $notice_id, $bulletin_ex; global $info_461, $info_463, $info_464; global $info_606_a; global $info_900, $info_901, $info_902, $info_903, $info_904, $info_905, $info_906; global $pmb_keyword_sep; $bulletin_ex = 0; $is_object = false; //compatibilite avec import memonotices if (is_array($info_464)) { unset($info_461); unset($info_463); $info_461[0]['t'] = $info_464[0]['t']; $info_461[0]['9'] = 'lnk:perio'; $info_463[0]['v'] = $info_464[0]['v']; $info_463[0]['e'] = $info_464[0]['d']; $info_463[0]['9'] = 'lnk:bull'; if (strpos($info_904[0], "/") !== FALSE) { $dc = substr($info_904[0], 6, 4) . '-' . substr($info_904[0], 3, 2) . '-' . substr($info_904[0], 0, 2); $info_904[0] = $dc; } } //Si article if (is_array($info_461) && is_array($info_463)) { //recuperation infos notice $requete = "select * from notices where notice_id={$notice_id}"; $resultat = mysql_query($requete); $r = mysql_fetch_object($resultat); //Notice chapeau existe-t-elle ? $requete = "select notice_id from notices where tit1='" . addslashes($info_461[0]['t']) . "' and niveau_hierar='1' and niveau_biblio='s'"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = mysql_result($resultat, 0, 0); //Bulletin existe-t-il ? $requete = "select bulletin_id from bulletins where bulletin_numero='" . addslashes($info_463[0]['v']) . "' and mention_date='" . addslashes($info_463[0]['e']) . "' and bulletin_notice={$chapeau_id} "; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id bulletin $bulletin_id = mysql_result($resultat, 0, 0); } else { //Si non, création bulletin $info = array(); $bulletin = new bulletinage("", $chapeau_id); $info['bul_titre'] = "Bulletin " . $info_463[0]['v']; if ($info_463[0]['e']) { $info['bul_titre'] .= " - " . $info_463[0]['e']; } $info['bul_titre'] = addslashes($info['bul_titre']); $info['bul_no'] = addslashes($info_463[0]['v']); $info['bul_date'] = addslashes($info_463[0]['e']); $date_date = explode("/", $info_463[0]['e']); if (count($date_date)) { if (count($date_date) == 1) { $info['date_date'] = $date_date[0] . "-01-01"; } if (count($date_date) == 2) { $info['date_date'] = $date_date[1] . "-" . $date_date[0] . "-01"; } if (count($date_date) == 3) { $info['date_date'] = $date_date[2] . "-" . $date_date[1] . "-" . $date_date[0]; } } else { if ($info_904[0]) { $info['date_date'] = $info_904[0]; } } $bulletin_id = $bulletin->update($info); } } else { //Si non, création notice chapeau et bulletin $chapeau = new serial(); $info = array(); $info['tit1'] = addslashes($info_461[0]['t']); $info['niveau_biblio'] = 's'; $info['niveau_hierar'] = '1'; $info['typdoc'] = $r->typdoc; $chapeau->update($info); $chapeau_id = $chapeau->serial_id; $bulletin = new bulletinage("", $chapeau_id); $info = array(); $info['bul_titre'] = "Bulletin " . $info_463[0]['v']; if ($info_463[0]['e']) { $info['bul_titre'] .= " - " . $info_463[0]['e']; } $info['bul_titre'] = addslashes($info['bul_titre']); $info['bul_no'] = addslashes($info_463[0]['v']); $info['bul_date'] = addslashes($info_463[0]['e']); $date_date = explode("/", $info_463[0]['e']); if (count($date_date)) { if (count($date_date) == 1) { $info['date_date'] = $date_date[0] . "-01-01"; } if (count($date_date) == 2) { $info['date_date'] = $date_date[1] . "-" . $date_date[0] . "-01"; } if (count($date_date) == 3) { $info['date_date'] = $date_date[2] . "-" . $date_date[1] . "-" . $date_date[0]; } } else { if ($info_904[0]) { $info['date_date'] = $info_904[0]; } } $bulletin_id = $bulletin->update($info); } $bulletin_ex = $bulletin_id; if ($r->tit1 == '_OBJECT_BULLETIN_' || is_array($info_464) && $info_464[0]['z'] == 'objet') { //$info_464[0]['z']=='objet' >> Compatibilite import memonotices $is_object = true; //notice de bulletin a supprimer notice::del_notice($notice_id); } else { //Passage de la notice en article $np = ''; if (is_array($info_464) && $info_464[0]['p'] != '') { $np = ", npages='" . addslashes($info_464[0]['p']) . "' "; } $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($info_463[0]['e']) . "'" . $np . ", date_parution='" . $info['date_date'] . "' where notice_id={$notice_id}"; mysql_query($requete); $requete = "insert into analysis (analysis_bulletin,analysis_notice) values({$bulletin_id},{$notice_id})"; mysql_query($requete); } } if (!$is_object) { //Traitement du thésaurus $unknown_desc = array(); $ordre_categ = 0; for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur = $info_606_a[$i][$j]; //Recherche du terme //dans le thesaurus par defaut et dans la langue de l'interface $libelle = addslashes($descripteur); $categ_id = categories::searchLibelle($libelle); if ($categ_id) { $requete = "INSERT INTO notices_categories (notcateg_notice,num_noeud,ordre_categorie) values({$notice_id},{$categ_id},{$ordre_categ})"; mysql_query($requete, $dbh); $ordre_categ++; } else { $unknown_desc[] = $descripteur; } } } if ($unknown_desc) { $mots_cles = implode($pmb_keyword_sep, $unknown_desc); $il = ''; $qil = "select index_l from notices where notice_id={$notice_id} "; $ril = mysql_query($qil, $dbh); $il = trim(mysql_result($ril, 0, 0)); if ($il) { $mots_cles = $il . $pmb_keyword_sep . $mots_cles; } $requete = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes(strip_empty_words($mots_cles)) . " ' where notice_id={$notice_id}"; mysql_query($requete, $dbh); } $notes = ''; //Thème $qn = "select idchamp from notices_custom where name='theme' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_theme = mysql_result($rn, 0, 0); } if (count($info_900) && $idc_theme) { for ($i = 0; $i < count($info_900); $i++) { for ($j = 0; $j < count($info_900[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_900[$i][$j]) . "' and notices_custom_champ={$idc_theme} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_theme},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes $notes .= 'thème : ' . $info_900[$i][$j]; } } } } //Genres $qn = "select idchamp from notices_custom where name='genre' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_genre = mysql_result($rn, 0, 0); } if (count($info_901) && $idc_genre) { for ($i = 0; $i < count($info_901); $i++) { for ($j = 0; $j < count($info_901[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_901[$i][$j]) . "' and notices_custom_champ={$idc_genre} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_genre},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes if ($notes) { $notes .= "\n"; } $notes .= 'genre : ' . $info_901[$i][$j]; } } } } //Discipline $qn = "select idchamp from notices_custom where name='discipline' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_discipline = mysql_result($rn, 0, 0); } if (count($info_902) && $idc_discipline) { for ($i = 0; $i < count($info_902); $i++) { for ($j = 0; $j < count($info_902[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_902[$i][$j]) . "' and notices_custom_champ={$idc_discipline} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_discipline},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes if ($notes) { $notes .= "\n"; } $notes .= 'discipline : ' . $info_902[$i][$j]; } } } } //Type de nature $qn = "select idchamp from notices_custom where name='type_nature' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_type_nature = mysql_result($rn, 0, 0); } $qn = "select idchamp from notices_custom where name='pays' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_pays = mysql_result($rn, 0, 0); } $qn = "select idchamp from notices_custom where name='periode' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_periode = mysql_result($rn, 0, 0); } if (count($info_905)) { for ($i = 0; $i < count($info_905); $i++) { for ($j = 0; $j < count($info_905[$i]); $j++) { //essai dans type de nature $done = FALSE; if ($idc_type_nature) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_type_nature} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_type_nature},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans genre if (!$done && $idc_genre) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_genre} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_genre},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans theme if (!$done && $idc_theme) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_theme} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_theme},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans discipline if (!$done && $idc_discipline) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_discipline} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_discipline},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans pays if (!$done) { $done_pa = FALSE; if (!$done && $idc_pays) { $i_pays = strip_empty_chars($info_905[$i][$j]); $requete = "select notices_custom_list_value,notices_custom_list_lib from notices_custom_lists where notices_custom_champ={$idc_pays} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { while ($row = mysql_fetch_object($resultat)) { $r_pays = strip_empty_chars($row->notices_custom_list_lib); if (strpos($i_pays, $r_pays) !== FALSE) { $value = $row->notices_custom_list_value; $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_pays},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done_pa = TRUE; break; } } } } //essai dans periode $done_pe = FALSE; if (!$done && $idc_periode) { $i_periode = strip_empty_chars($info_905[$i][$j]); $requete = "select notices_custom_list_value,notices_custom_list_lib from notices_custom_lists where notices_custom_champ={$idc_periode} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { while ($row = mysql_fetch_object($resultat)) { $r_periode = strip_empty_chars($row->notices_custom_list_lib); if (strpos($i_periode, $r_periode) !== FALSE) { $value = $row->notices_custom_list_value; $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_periode},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done_pe = TRUE; break; } } } } if ($done_pa && $done_pe) { $done = TRUE; } } //sinon dans notes if (!$done) { if ($notes) { $notes .= "\n"; } $notes .= 'type de nature : ' . $info_905[$i][$j]; } } } } //Niveau if (count($info_906)) { $qn = "select idchamp from notices_custom where name='niveau' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_niveau = mysql_result($rn, 0, 0); for ($i = 0; $i < count($info_906); $i++) { for ($j = 0; $j < count($info_906[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_906[$i][$j]) . "' and notices_custom_champ={$idc_niveau} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_niveau},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes if ($notes) { $notes .= "\n"; } $notes .= 'niveau : ' . $info_906[$i][$j]; } } } } } //notes if ($notes) { $notes .= "\n"; $notes = addslashes($notes); $q = "update notices set n_contenu=concat('" . $notes . "',n_contenu) where notice_id='" . $notice_id . "' "; mysql_query($q, $dbh); } //Année de péremption if ($info_903[0]) { $qn = "select idchamp from notices_custom where name='annee_peremption' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_ap = mysql_result($rn, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$idc_ap},{$notice_id},'" . addslashes($info_903[0]) . "')"; mysql_query($requete, $dbh); } } //Date de saisie if ($info_904[0]) { $qn = "select idchamp from notices_custom where name='date_creation' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_ds = mysql_result($rn, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) values({$idc_ds},{$notice_id},'" . $info_904[0] . "')"; mysql_query($requete, $dbh); } } } }
function insert_in_database($addslashes = false) { global $dbh; global $class_path; global $gestion_acces_active, $gestion_acces_user_notice, $gestion_acces_empr_notice; global $res_prf, $chk_rights; global $pmb_synchro_rdf; global $opac_url_base, $pmb_notice_img_folder_id; if ($this->bibliographic_level == "s" && $this->hierarchic_level == "2") { $this->bibliographic_level = "b"; } $new_notice = 0; $notice_retour = 0; $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT code FROM notices limit 1"), 0); $isbn = rtrim(substr($this->isbn, 0, $long_maxi)); if ($isbn != "") { if (isISBN($isbn)) { if (strlen($isbn) == 13) { $isbn1 = formatISBN($isbn, 13); } else { $isbn1 = formatISBN($isbn, 10); } } $sql_rech = "select notice_id from notices where code = '" . $isbn . "' "; if ($isbn1) { $sql_rech .= " or code='" . $isbn1 . "' "; } $sql_result_rech = pmb_mysql_query($sql_rech) or die("Couldn't select notice ! = " . $sql_rech); if (pmb_mysql_num_rows($sql_result_rech) == 0) { $new_notice = 1; } else { $new_notice = 0; $lu = pmb_mysql_fetch_array($sql_result_rech); $notice_retour = $lu['notice_id']; } } else { $new_notice = 1; } if ($new_notice == 0) { $retour = array($new_notice, $notice_retour); return $retour; } for ($i = 0; $i < 2; $i++) { if ($this->editors[$i]['id']) { $editor_ids[$i] = $this->editors[$i]['id']; } else { $editor_ids[$i] = editeur::import($this->editors[$i]); } } $this->collection['parent'] = $editor_ids[0]; if ($this->collection["id"]) { $collection_id = $this->collection["id"]; } else { $collection_id = collection::import($this->collection); } $this->subcollection['coll_parent'] = $collection_id; if ($this->subcollection["id"]) { $subcollection_id = $this->subcollection["id"]; } else { $subcollection_id = subcollection::import($this->subcollection); } $serie_id = serie::import(stripslashes($this->serie)); /* traitement de Dewey */ if (!$this->internal_index) { if (!$this->dewey["new_comment"]) { $this->dewey["new_comment"] = ""; } if (!$this->dewey["new_pclass"]) { $this->dewey["new_pclass"] = ""; } $this->internal_index = indexint::import(clean_string($this->dewey[0]), clean_string($this->dewey["new_comment"]), clean_string($this->dewey["new_pclass"])); } $date_parution_z3950 = notice::get_date_parution($this->year); /* Origine de la notice */ $this->orinot_id = origine_notice::import($this->origine_notice); if ($this->orinot_id == 0) { $this->orinot_id = 1; } if ($addslashes) { $this->document_type = addslashes($this->document_type); $this->isbn = addslashes($this->isbn); $this->titles[0] = addslashes($this->titles[0]); $this->titles[1] = addslashes($this->titles[1]); $this->titles[2] = addslashes($this->titles[2]); $this->titles[3] = addslashes($this->titles[3]); $this->nbr_in_serie = addslashes($this->nbr_in_serie); $this->year = addslashes($this->year); $this->page_nbr = addslashes($this->page_nbr); $this->illustration = addslashes($this->illustration); $this->size = addslashes($this->size); $this->accompagnement = addslashes($this->accompagnement); $this->nbr_in_collection = addslashes($this->nbr_in_collection); $this->mention_edition = addslashes($this->mention_edition); $this->general_note = addslashes($this->general_note); $this->content_note = addslashes($this->content_note); $this->abstract_note = addslashes($this->abstract_note); $this->commentaire_gestion = addslashes($this->commentaire_gestion); $this->indexation_lang = addslashes($this->indexation_lang); $this->thumbnail_url = addslashes($this->thumbnail_url); $this->free_index = addslashes($this->free_index); $this->link_url = addslashes($this->link_url); $this->link_format = addslashes($this->link_format); $this->prix = addslashes($this->prix); //les oubliés du premier tour $serie_id = addslashes($serie_id); $this->bibliographic_level = addslashes($this->bibliographic_level); $this->hierarchic_level = addslashes($this->hierarchic_level); $date_parution_z3950 = addslashes($date_parution_z3950); } $sql_ins = "insert into notices (\n\t\t\ttypdoc ,\n\t\t\tcode \t,\n\t\t\ttit1 ,\n\t\t\ttit2 ,\n\t\t\ttit3 ,\n\t\t\ttit4 ,\n\t\t\ttparent_id ,\n\t\t\ttnvol ,\n\t\t\ted1_id ,\n\t\t\ted2_id ,\n\t\t\tyear ,\n\t\t\tnpages ,\n\t\t\till ,\n\t\t\tsize ,\n\t\t\taccomp ,\n\t\t\tcoll_id ,\n\t\t\tsubcoll_id ,\n\t\t\tnocoll ,\n\t\t\tmention_edition ,\n\t\t\tn_gen ,\n\t\t\tn_contenu ,\n\t\t\tn_resume ,\n\t\t\tindexint,\n\t\t\tstatut,\n\t\t\tcommentaire_gestion,\n\t\t\tsignature,\n\t\t\tthumbnail_url,\n\t\t\tindex_l,\n\t\t\tniveau_biblio,\n\t\t\tniveau_hierar,\n\t\t\tlien,\n\t\t\teformat,\n\t\t\torigine_catalogage,\n\t\t\tprix,\n\t\t\tcreate_date,\n\t\t\tdate_parution,\n\t\t\tindexation_lang\n\t\t\t) values (\n\t\t\t'" . $this->document_type . "',\t\n\t\t\t'" . $this->isbn . "',\t\n\t\t\t'" . $this->titles[0] . "',\n\t\t\t'" . $this->titles[1] . "',\n\t\t\t'" . $this->titles[2] . "',\n\t\t\t'" . $this->titles[3] . "',\n\t\t\t'" . $serie_id . "',\n\t\t\t'" . $this->nbr_in_serie . "',\n\t\t\t" . $editor_ids[0] . " ,\n\t\t\t" . $editor_ids[1] . " ,\n\t\t\t'" . $this->year . "',\n\t\t\t'" . $this->page_nbr . "',\n\t\t\t'" . $this->illustration . "',\n\t\t\t'" . $this->size . "',\n\t\t\t'" . $this->accompagnement . "',\n\t\t\t" . $collection_id . " ,\n\t\t\t" . $subcollection_id . " ,\n\t\t\t'" . $this->nbr_in_collection . "',\n\t\t\t'" . $this->mention_edition . "',\n\t\t\t'" . $this->general_note . "',\n\t\t\t'" . $this->content_note . "',\n\t\t\t'" . $this->abstract_note . "',\n\t\t\t'" . $this->internal_index . "',\n\t\t\t'" . $this->statut . "',\n\t\t\t'" . $this->commentaire_gestion . "',\n\t\t\t'" . $this->signature . "',\n\t\t\t'" . $this->thumbnail_url . "',\n\t\t\t'" . clean_tags($this->free_index) . "',\n\t\t\t'" . $this->bibliographic_level . "',\n\t\t\t'" . $this->hierarchic_level . "',\n\t\t\t'" . $this->link_url . "',\n\t\t\t'" . $this->link_format . "',\n\t\t\t'" . $this->orinot_id . "',\n\t\t\t'" . $this->prix . "',\n\t\t\tsysdate(),\n\t\t\t'" . $date_parution_z3950 . "',\n\t\t\t'" . $this->indexation_lang . "'\n\t\t )"; $sql_result_ins = pmb_mysql_query($sql_ins) or die("Couldn't insert into table notices : " . $sql_ins); $notice_retour = pmb_mysql_insert_id(); audit::insert_creation(AUDIT_NOTICE, $notice_retour); if ($gestion_acces_active == 1) { $ac = new acces(); //traitement des droits acces user_notice if ($gestion_acces_user_notice == 1) { $dom_1 = $ac->setDomain(1); $dom_1->storeUserRights(0, $notice_retour); } //traitement des droits acces empr_notice if ($gestion_acces_empr_notice == 1) { $dom_2 = $ac->setDomain(2); $dom_2->storeUserRights(0, $notice_retour); } } // purge de la base des responsabilités de la notice intégrée... if ($notice_retour) { $rqt_del = "delete from responsability where responsability_notice='{$notice_retour}'"; $sql_result_del = pmb_mysql_query($rqt_del) or die("Couldn't purge table responsability : " . $rqt_del); } $rqt_ins = "insert into responsability (responsability_author, responsability_notice, responsability_fonction, responsability_type, responsability_ordre ) VALUES "; for ($i = 0; $i < sizeof($this->aut_array); $i++) { $aut['id'] = clean_string($this->aut_array[$i]['id']); $aut['name'] = clean_string($this->aut_array[$i]['entree']); $aut['rejete'] = clean_string($this->aut_array[$i]['rejete']); $aut['date'] = clean_string($this->aut_array[$i]['date']); $aut['type'] = $this->aut_array[$i]['type_auteur']; $aut['subdivision'] = clean_string($this->aut_array[$i]['subdivision']); $aut['numero'] = clean_string($this->aut_array[$i]['numero']); $aut['lieu'] = clean_string($this->aut_array[$i]['lieu']); $aut['ville'] = clean_string($this->aut_array[$i]['ville']); $aut['pays'] = clean_string($this->aut_array[$i]['pays']); $aut['web'] = clean_string($this->aut_array[$i]['web']); $aut['author_comment'] = clean_string($this->aut_array[$i]['author_comment']); $aut['authority_number'] = clean_string($this->aut_array[$i]['authority_number']); /* Origine de l'autorité : on reprend les infos d'origine de la notice pour les attribuées aux origines des autorités */ $id_origine_auth = 0; $id_origine_auth = origin_authorities::import($this->origine_notice); if ($id_origine_auth == 0) { $id_origine_auth = 1; } // import de l'autorité auteur si elle existe et conservation des infos sur l'origine de l'autorité if ($aut['authority_number'] != '' && $id_origine_auth) { $this->aut_array[$i]["id"] = $this->insert_authority_infos($aut['authority_number'], "author", $id_origine_auth, $aut); } if (!$this->aut_array[$i]["id"]) { $this->aut_array[$i]["id"] = auteur::import($aut); } if ($this->aut_array[$i]["id"]) { $rqt = $rqt_ins . " (" . $this->aut_array[$i]["id"] . "," . $notice_retour . ",'" . $this->aut_array[$i]['fonction'] . "'," . $this->aut_array[$i]['responsabilite'] . "," . $i . ") "; $res_ins = pmb_mysql_query($rqt, $dbh); } } // traitement des titres uniformes global $pmb_use_uniform_title; if ($pmb_use_uniform_title) { if (count($this->titres_uniformes)) { $ntu = new tu_notice($notice_retour); $ntu->update($this->titres_uniformes); } } // traitement des langues // langues de la publication $rqt_del = "delete from notices_langues where num_notice='{$notice_retour}' "; $res_del = pmb_mysql_query($rqt_del, $dbh); if (is_array($this->language_code) && count($this->language_code)) { $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES "; foreach ($this->language_code as $ordre_lang => $code_lang) { if ($code_lang) { $rqt = $rqt_ins . " ('{$notice_retour}',0, '{$code_lang}', {$ordre_lang}) "; $res_ins = @pmb_mysql_query($rqt, $dbh); } } } // langues originales if (is_array($this->original_language_code) && count($this->original_language_code)) { $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES "; foreach ($this->original_language_code as $ordre_lang => $code_lang) { if ($code_lang) { $rqt = $rqt_ins . " ('{$notice_retour}',1, '{$code_lang}', {$ordre_lang}) "; $res_ins = @pmb_mysql_query($rqt, $dbh); } } } // traitement des categories if ($this->categorisation_type == "categorisation_auto") { traite_categories_enreg($notice_retour, $this->categories); } else { $rqt_del = "delete from notices_categories where notcateg_notice='{$notice_retour}' "; $res_del = @pmb_mysql_query($rqt_del, $dbh); $rqt_ins = "insert into notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES "; $rqt_ins_values = array(); foreach ($this->categories as $i => $category) { $id_categ = $category['categ_id']; if ($id_categ) { $rqt_ins_values[] = " ('{$notice_retour}','{$id_categ}', {$i}) "; } } $rqt_ins .= implode(",", $rqt_ins_values); $res_ins = @pmb_mysql_query($rqt_ins, $dbh); } //Traitement des champs personnalisés (du formulaire !!!) $p_perso = new parametres_perso("notices"); $nberrors = $p_perso->check_submited_fields(); $p_perso->rec_fields_perso($notice_retour); //Traitement import perso global $notice_id, $notice_org, $notice_type_org; if (function_exists('z_recup_noticeunimarc_suite') && function_exists('z_import_new_notice_suite')) { $notice_id = $notice_retour; if (!$notice_org) { $notice_tmp = $this->notice; } z_recup_noticeunimarc_suite($notice_tmp ? $notice_tmp : $notice_org); z_import_new_notice_suite(); $notice_tmp = ""; } //Recherche du titre uniforme automatique //global $opac_enrichment_bnf_sparql; //$opac_enrichment_bnf_sparql=1; $titre_uniforme = notice::getAutomaticTu($notice_retour); //Traitement upload vignette if (trim($this->flag_upload_vignette)) { $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'"; $res = pmb_mysql_query($req, $dbh); if (pmb_mysql_num_rows($res)) { $rep = pmb_mysql_fetch_object($res); } //le fichier if (file_exists($rep->repertoire_path . $this->flag_upload_vignette)) { rename($rep->repertoire_path . $this->flag_upload_vignette, $rep->repertoire_path . "img_" . $notice_retour); } //le champ $rqt_upd = "UPDATE notices SET thumbnail_url='" . addslashes($opac_url_base . "getimage.php?noticecode=&vigurl=¬ice_id=" . $notice_retour) . "' WHERE notice_id=" . $notice_retour; $res_ins = @pmb_mysql_query($rqt_upd, $dbh); } // Mise à jour des index de la notice notice::majNotices($notice_retour); // Mise à jour de la table notices_global_index notice::majNoticesGlobalIndex($notice_retour); // Mise à jour de la table notices_mots_global_index notice::majNoticesMotsGlobalIndex($notice_retour); //Calcul de la signature $sign = new notice_doublon(); $val = $sign->gen_signature($notice_retour); pmb_mysql_query("update notices set signature='{$val}' where notice_id=" . $notice_retour, $dbh); //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf = new synchro_rdf(); } //Si on catalogue un article on recrée l'arborescence global $biblio_notice; //TODO AR //gérer le cas du bulletin (revient à intégrer le pério uniquement) if ($biblio_notice == 'art') { //Perios if (!$this->perio_id) { $new_perio = new serial(); $values = array(); $values['tit1'] = $this->perio_titre; $values['code'] = $this->perio_issn; $values['niveau_biblio'] = "s"; $values['niveau_hierar'] = "1"; $this->perio_id = $new_perio->update($values); //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf($this->perio_id, 0); } } //Bulletin if ($this->bull_id) { $req_art = "insert into analysis set analysis_bulletin='" . $this->bull_id . "',\n\t\t\t\t\tanalysis_notice='" . $notice_retour . "'"; pmb_mysql_query($req_art, $dbh); $req = "update bulletins set bulletin_notice='" . $this->perio_id . "' where bulletin_id='" . $this->bull_id . "'"; pmb_mysql_query($req, $dbh); } else { $new_bull = new bulletinage(0, $this->perio_id); $values = array(); $values['bul_no'] = $this->bull_num; $values['bul_date'] = $this->bull_mention; $values['date_date'] = $this->bull_date; $values['bul_titre'] = $this->bull_titre; $new_bull->update($values); $this->bull_id = $new_bull->bulletin_id; $req_art = "insert into analysis set analysis_bulletin='" . $this->bull_id . "',\n\t\t\t\t\tanalysis_notice='" . $notice_retour . "'"; pmb_mysql_query($req_art, $dbh); //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf(0, $this->bull_id); } } } else { if ($biblio_notice == "bull") { //Perios if (!$this->perio_id) { $new_perio = new serial(); $values = array(); $values['tit1'] = $this->perio_titre; $values['code'] = $this->perio_issn; $values['niveau_biblio'] = "s"; $values['niveau_hierar'] = "1"; $this->perio_id = $new_perio->update($values); //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf($this->perio_id, 0); } } if (!$this->bull_id) { $new_bull = new bulletinage(0, $this->perio_id); $values = array(); $values['bul_no'] = $this->bull_num; $values['bul_date'] = $this->bull_mention; $values['date_date'] = $this->bull_date; $values['bul_titre'] = $this->bull_titre; $new_bull->update($values); $this->bull_id = $new_bull->bulletin_id; //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf(0, $this->bull_id); } // $req = "update bulletins set bulletin_notice='".$this->perio_id."',num_notice='".$notice_retour."' where bulletin_id='".$this->bull_id."'"; // pmb_mysql_query($req,$dbh); //Faire un update en mettant l'id de la notice crée //file_put_contents('php://stderr', print_r($this->bull_id, true)); } if ($this->bull_notice) { $notice_bulletin = new notice(); $notice_bulletin->del_notice($notice_retour); $notice_retour = $this->bull_notice; } //Mise à jour de la table bulletins, ajout de la relation entre le bulletins et sa notice $req = "update bulletins set bulletin_notice='" . $this->perio_id . "',num_notice='" . $notice_retour . "' where bulletin_id='" . $this->bull_id . "'"; pmb_mysql_query($req, $dbh); //Insertion dans la table notices_relation, ajout de la relatioin entre la notice de bulletin et la notice de perio $req = "insert into notices_relations (num_notice, linked_notice, relation_type,rank) values('" . $notice_retour . "', '" . $this->perio_id . "', 'b','1')"; pmb_mysql_query($req, $dbh); } } //file_put_contents('php://stderr', print_r($notice_retour."\n", true)); //Exemplaires if (count($this->exemplaires)) { // global $section_995, $typdoc_995, $codstatdoc_995; // , $nb_expl_ignores; $section_995_ = new marc_list("section_995"); $section_995 = $section_995_->table; $typdoc_995_ = new marc_list("typdoc_995"); $typdoc_995 = $typdoc_995_->table; $codstatdoc_995_ = new marc_list("codstatdoc_995"); $codstatdoc_995 = $codstatdoc_995_->table; // $nb_expl_ignores=0; global $deflt_docs_statut, $deflt_docs_location, $deflt_lenders; foreach ($this->exemplaires as $info_expl) { /* RAZ expl */ $expl = array(); if ($notice_retour) { /* préparation du tableau à passer à la méthode */ $expl['cb'] = $info_expl['f']; //TODO AR // les raccrocher au bulletin et non sa notice // dans un second temps if ($this->bibliographic_level == "s" && $this->hierarchic_level == "2") { if ($this->bull_id) { $expl['notice'] = 0; $expl['bulletin'] = $this->bull_id; } else { if (!$this->bull_id && $notice_retour) { $expl['notice'] = $notice_retour; $expl['bulletin'] = 0; } } } else { $expl['notice'] = $notice_retour; $expl['bulletin'] = 0; } //$expl['bulletin'] = 0; // $expl['typdoc'] = $info_995['r']; à chercher dans docs_typdoc $data_doc = array(); //$data_doc['tdoc_libelle'] = $info_995['r']." -Type doc importé (".$book_lender_id.")"; $data_doc['tdoc_libelle'] = $typdoc_995[$info_expl['r']]; if (!$data_doc['tdoc_libelle']) { $data_doc['tdoc_libelle'] = "\$r non conforme -" . $info_expl['r'] . "-"; } $data_doc['duree_pret'] = 0; /* valeur par défaut */ $data_doc['tdoc_codage_import'] = $info_expl['r']; if ($tdoc_codage) { $data_doc['tdoc_owner'] = $deflt_lenders; } else { $data_doc['tdoc_owner'] = 0; } $expl['typdoc'] = docs_type::import($data_doc); $expl['cote'] = $info_expl['k']; // $expl['section'] = $info_995['q']; à chercher dans docs_section $data_doc = array(); $info_expl['q'] = trim($info_expl['q']); if (!$info_expl['q']) { $info_expl['q'] = "u"; } $data_doc['section_libelle'] = $section_995[$info_expl['q']]; $data_doc['sdoc_codage_import'] = $info_expl['q']; if ($sdoc_codage) { $data_doc['sdoc_owner'] = $deflt_lenders; } else { $data_doc['sdoc_owner'] = 0; } $expl['section'] = docs_section::import($data_doc); $expl['statut'] = $deflt_docs_statut; if ($info_expl['a']) { $expl['location'] = $info_expl['a']; } else { $expl['location'] = $deflt_docs_location; } // $expl['codestat'] = $info_995['q']; 'q' utilisé, éventuellement à fixer par combo_box $data_doc = array(); //$data_doc['codestat_libelle'] = $info_995['q']." -Pub visé importé (".$book_lender_id.")"; $data_doc['codestat_libelle'] = $codstatdoc_995[$info_expl['q']]; $data_doc['statisdoc_codage_import'] = $info_expl['q']; if ($statisdoc_codage) { $data_doc['statisdoc_owner'] = $deflt_lenders; } else { $data_doc['statisdoc_owner'] = 0; } $expl['codestat'] = docs_codestat::import($data_doc); $expl['note'] = $info_expl['u']; $expl['expl_owner'] = $deflt_lenders; if ($info_expl['m']) { $expl['date_depot'] = substr($info_expl['m'], 0, 4) . "-" . substr($info_expl['m'], 4, 2) . "-" . substr($info_expl['m'], 6, 2); } if ($info_expl['n']) { $expl['date_retour'] = substr($info_expl['n'], 0, 4) . "-" . substr($info_expl['n'], 4, 2) . "-" . substr($info_expl['n'], 6, 2); } exemplaire::import($expl); } } } //Documents numériques global $deflt_explnum_statut; foreach ($this->doc_nums as $doc_num) { if (!$doc_num['a']) { continue; } if (!$doc_num['s']) { $doc_num['s'] = $deflt_explnum_statut; } if ($doc_num['__nodownload__']) { if ($this->bibliographic_level == "b" && $this->hierarchic_level == "2") { explnum_add_url($notice_retour, $this->bull_id, $doc_num['b'], $doc_num['a'], $doc_num['s']); } else { explnum_add_url($notice_retour, 0, $doc_num['b'], $doc_num['a'], $doc_num['s']); } } else { if ($this->bibliographic_level == "b" && $this->hierarchic_level == "2") { explnum_add_from_url($notice_retour, $this->bull_id, $doc_num['b'], $doc_num['a'], true, $this->source_id, $doc_num['f'], $doc_num['p'], $doc_num['s']); } else { explnum_add_from_url($notice_retour, 0, $doc_num['b'], $doc_num['a'], true, $this->source_id, $doc_num['f'], $doc_num['p'], $doc_num['s']); } } } //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf($notice_retour, 0); } $retour = array($new_notice, $notice_retour); return $retour; }
function genere_bulletin($perio_info, $bull_info, $isbull = true) { global $bl, $hl, $notice_id; //on récup et/ou génère le pério $perio_id = genere_perio($perio_info); //on s'occupe du cas ou on a pas de titre pour le bulletin // num (mention) [date] if ($bull_info['titre'] == "") { $bull_info['titre'] = $bull_info['num'] . ($bull_info['mention'] ? " (" . $bull_info['mention'] . ") " : " ") . ($bull_info['date'] ? "[" . $bull_info['date'] . "]" : ""); } $search = "select bulletin_id from bulletins where bulletin_titre LIKE '" . addslashes($bull_info['titre']) . "' and mention_date LIKE '" . $bull_info['mention'] . "' and bulletin_numero LIKE '" . $bull_info['num'] . "' and bulletin_notice = {$perio_id}"; $res = mysql_query($search); if (mysql_num_rows($res) == 0) { $insert = "insert into bulletins set bulletin_titre = '" . $bull_info['titre'] . "', date_date = '" . $bull_info['date'] . "', mention_date = '" . $bull_info['mention'] . "', bulletin_numero = '" . $bull_info['num'] . "', bulletin_notice = {$perio_id}"; if ($bl == "s" && $hl == "2") { $insert .= ", num_notice = {$notice_id}"; update_notice("b", "2"); } $result = mysql_query($insert); $bull_id = mysql_insert_id(); } else { $bull_id = mysql_result($res, 0, 0); //on regarde si une notice n'existe pas déjà pour ce bulletin $req = "select num_notice from bulletins where bulletin_id = {$bull_id} and num_notice != 0"; $res = mysql_query($req); //si oui on retire l'enregistrement en cours, et on continue sur la notice existante... if (mysql_num_rows($res) > 0) { notice::del_notice($notice_id); $notice_id = mysql_result($res, 0, 0); } } return $bull_id; }
function import_new_notice_suite() { global $dbh; global $notice_id; global $bl, $hl; global $infos_4XX; global $hierarchic_level; global $bibliographic_level; global $doc_type; global $origine_notice; global $notices_crees; global $issn_011, $info_900; global $tit_200a; global $isbn; global $statutnot; global $info_003; global $info_336, $info_337; global $isbn_only, $isbn_dedoublonnage; if (isset($bibliographic_level) && isset($hierarchic_level)) { $niveau_biblio = $bibliographic_level . $hierarchic_level; } else { $niveau_biblio = $bl . $hl; } //num_notice = fille //linked_notice = mere $sens = array('mother' => array("linked_notice", "num_notice"), 'child' => array("num_notice", "linked_notice")); $link_type = array('412' => array('code' => "v", 'sens_link' => "child"), '413' => array('code' => "v", 'sens_link' => "mother"), '421' => array('code' => "e", 'sens_link' => "mother"), '422' => array('code' => "e", 'sens_link' => "child"), '423' => array('code' => "k", 'sens_link' => "child"), '430' => array('code' => "l", 'sens_link' => "child"), '431' => array('code' => "o", 'sens_link' => "mother"), '432' => array('code' => "t", 'sens_link' => "child"), '433' => array('code' => "o", 'sens_link' => "mother"), '434' => array('code' => "m", 'sens_link' => "child"), '435' => array('code' => "s", 'sens_link' => "child"), '436' => array('code' => "n", 'sens_link' => "mother"), '437' => array('code' => "o", 'sens_link' => "mother"), '440' => array('code' => "l", 'sens_link' => "mother"), '441' => array('code' => "o", 'sens_link' => "child"), '442' => array('code' => "t", 'sens_link' => "mother"), '443' => array('code' => "o", 'sens_link' => "child"), '444' => array('code' => "m", 'sens_link' => "mother"), '445' => array('code' => "s", 'sens_link' => "mother"), '446' => array('code' => "o", 'sens_link' => "child"), '447' => array('code' => "n", 'sens_link' => "child"), '451' => array('code' => "u", 'sens_link' => "child"), '452' => array('code' => "p", 'sens_link' => "child"), '453' => array('code' => "h", 'sens_link' => "mother"), '454' => array('code' => "h", 'sens_link' => "child"), '455' => array('code' => "q", 'sens_link' => "mother"), '456' => array('code' => "q", 'sens_link' => "child"), '520' => array('code' => "f", 'sens_link' => "child")); //dédoublonnage ! if ($isbn && $isbn_dedoublonnage) { $query = "select notice_id from notices where code like '" . $isbn . "' and notice_id != " . $notice_id; $result = mysql_query($query); if (mysql_num_rows($result)) { $row = mysql_fetch_object($result); notice::del_notice($notice_id); $notice_id = $row->notice_id; mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', '" . addslashes("La notice (" . $tit_200a[0] . ", " . $isbn . ") n'a pas été reprise car elle existe déjà en base (notice id: " . $notice_id . ")") . "') "); } } if (!$isbn_dedoublonnage || $isbn_only == 1) { $rq = "UPDATE notices SET code=REPLACE(code, '_pasToucheACa', '') WHERE notice_id = " . $notice_id; mysql_query($rq); } elseif ($issn_011[0]) { $query = "select notice_id from notices where code like '" . $issn_011[0] . "' and notice_id != " . $notice_id; $result = mysql_query($query); if (mysql_num_rows($result)) { while ($row = mysql_fetch_object($result)) { if (in_array($row->notice_id, $notices_crees)) { $old = new notice($row->notice_id); $old->replace($notice_id); $tab = array_flip($notices_crees); unset($tab[$row->notice_id]); $notices_crees = array_flip($tab); } else { notice::del_notice($notice_id); $notice_id = $row->notice_id; mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', '" . addslashes("La notice (" . $tit_200a[0] . ", " . $isbn . ") n'a pas été reprise car elle existe déjà en base (notice id: " . $notice_id . ")") . "') "); } } } } $n_gen_plus = ""; if (count($info_336)) { foreach ($info_336 as $value) { if ($tmp = trim($value)) { if ($n_gen_plus) { $n_gen_plus .= "\n"; } $n_gen_plus .= $tmp; } } } if (count($info_337)) { foreach ($info_337 as $value) { if ($tmp = trim($value)) { if ($n_gen_plus) { $n_gen_plus .= "\n"; } $n_gen_plus .= $tmp; } } } if ($n_gen_plus) { $requ = "UPDATE notices SET n_gen=IF(n_gen != '',CONCAT(n_gen,'\n" . addslashes($n_gen_plus) . "'),'" . addslashes($n_gen_plus) . "') WHERE notice_id = " . $notice_id; if (!mysql_query($requ)) { echo "Requête echoué: " . $requ . "<br/>"; } } switch ($niveau_biblio) { case "s1": case "s0": foreach ($infos_4XX as $key => $children) { foreach ($children as $child) { $issn = ""; //on commence par chercher si la notice existe $issn = traite_code_ISSN($child['x']); if ($issn) { $query = "select notice_id from notices where code ='" . $issn . "' and niveau_biblio = 's' and niveau_hierar = '1'"; $result = mysql_query($query); if (!mysql_num_rows($result)) { //la notice n'existe pas, il faut la créer... /* Origine de la notice */ $origine_not['nom'] = clean_string($origine_notice[0]['b']); $origine_not['pays'] = clean_string($origine_notice[0]['a']); $orinot_id = origine_notice::import($origine_not); if ($orinot_id == 0) { $orinot_id = 1; } $query = "insert into notices set \n\t\t\t\t\t\t\t\ttypdoc = '" . $doc_type . "',\n\t\t\t\t\t\t\t\ttit1 = '" . addslashes(clean_string($child['t'])) . "',\n\t\t\t\t\t\t\t\tcode = '" . $issn . "',\n\t\t\t\t\t\t\t\tniveau_biblio = 's',\n\t\t\t\t\t\t\t\tniveau_hierar = '1',\n\t\t\t\t\t\t\t\tstatut = " . $statutnot . ",\n\t\t\t\t\t\t\t\torigine_catalogage = '" . $orinot_id . "',\n\t\t\t\t\t\t\t\tcreate_date = sysdate(),\n\t\t\t\t\t\t\t\tupdate_date = sysdate()\n\t\t\t\t\t\t\t"; mysql_query($query); $child_id = mysql_insert_id(); $notices_crees[$child[0]] = $child_id; notice::majNotices($child_id); notice::majNoticesGlobalIndex($child_id); notice::majNoticesMotsGlobalIndex($child_id); } else { $child_id = mysql_result($result, 0, 0); } if ($child_id) { // on regarde si une relation similaire existe déjà... $query = "select relation_type from notices_relations where relation_type = '" . $link_type[$key]['code'] . "' and ((num_notice = " . $notice_id . " and linked_notice = " . $child_id . ") or (num_notice = " . $child_id . " and linked_notice = " . $notice_id . "))"; $result = mysql_query($query); if (!mysql_num_rows($result)) { $rank = 0; $query = "select count(rank) from notices_relations where relation_type = '" . $link_type[$key]['code'] . "' and "; if ($link_type[$key]['sens_link'] == "mother") { $query .= "num_notice = " . $child_id; } else { $query .= "num_notice = " . $notice_id; } $result = mysql_query($query); if (mysql_num_rows($result)) { $rank = mysql_result($result, 0, 0); } $query = "insert into notices_relations set \n\t\t\t\t\t\t\t\t\t" . $sens[$link_type[$key]['sens_link']][0] . " = " . $notice_id . ",\n\t\t\t\t\t\t\t\t\t" . $sens[$link_type[$key]['sens_link']][1] . " = " . $child_id . ",\n\t\t\t\t\t\t\t\t\trelation_type = '" . $link_type[$key]['code'] . "',\n\t\t\t\t\t\t\t\t\trank = " . ($rank + 1) . "\n\t\t\t\t\t\t\t\t"; mysql_query($query); } } } } } break; } if (count($info_900)) { for ($i = 0; $i < count($info_900); $i++) { if (trim($info_900[$i]["a"])) { if (!renseigne_cp_agro($info_900[$i], $notice_id)) { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', '" . addslashes("La valeur : " . $info_900[$i]["a"] . " n'a pas été reprise dans le champ personnalisé : " . $info_900[$i]["n"] . " car le champ n'existe pas ou n'est pas défini de la même façon") . "') "); } } } } if ($tmp = trim($info_003[0])) { $requete = "SELECT notices_custom_origine FROM notices_custom_values WHERE notices_custom_champ=22 AND notices_custom_origine='" . $notice_id . "' AND notices_custom_small_text='" . addslashes($tmp) . "' "; $res = mysql_query($requete); if ($res && mysql_num_rows($res)) { } else { $requete = "INSERT INTO notices_custom_values(notices_custom_champ, notices_custom_origine, notices_custom_small_text) VALUES('22','" . $notice_id . "','" . addslashes($tmp) . "')"; mysql_query($requete); } } }
$ret_param = ""; $query = "select linked_notice from notices_relations where num_notice={$id}"; $result = mysql_query($query, $dbh); $not_mere = 0; if (mysql_numrows($result)) { $not_mere = mysql_result($result, 0, 0); } if ($not_mere > 0) { // perio ou mono? $n = mysql_fetch_object(@mysql_query("select * from notices where notice_id=" . $not_mere)); if ($n->niveau_biblio == 'm' || $n->niveau_biblio == 'b') { $ret_param = "?categ=isbd&id={$not_mere}"; } elseif ($n->niveau_biblio == 's' || $n->niveau_biblio == 'a') { $ret_param = "?categ=serials&sub=view&serial_id={$not_mere}"; } } //archivage if ($pmb_archive_warehouse) { notice::save_to_agnostic_warehouse(array(0 => $id), $pmb_archive_warehouse); } notice::del_notice($id); // affichage du message suppression en cours puis redirect vers page de catalogage print "<div class=\"row\"><div class='msg-perio'>" . $msg['suppression_en_cours'] . "</div></div>\n\t\t\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\t\t\tdocument.location='./catalog.php" . $ret_param . "';\n\t\t\t\t\t\t\t</script>"; } } } } } else { error_message($msg[416], "{$msg[417]} : {$msg[418]}", 1, "./catalog.php"); } }
function del_item_base($item = 0, $forcage = array()) { global $dbh; if (!$item) { return CADDIE_ITEM_NULL; } switch ($this->type) { case "EXPL": if (!$this->verif_expl_item($item)) { if ($forcage['source_id']) { exemplaire::save_to_agnostic_warehouse(array(0 => $item), $forcage['source_id']); } if (exemplaire::del_expl($item)) { return CADDIE_ITEM_SUPPR_BASE_OK; } else { return 0; } } else { return CADDIE_ITEM_EXPL_PRET; } break; case "BULL": if (!$this->verif_bull_item($item, $forcage)) { // aucun prêt d'exemplaire de ce bulletin en cours, on supprime : $myBulletinage = new bulletinage($item); $myBulletinage->delete(); return CADDIE_ITEM_SUPPR_BASE_OK; } else { return CADDIE_ITEM_BULL_USED; } break; case "NOTI": if (!$this->verif_noti_item($item, $forcage)) { if ($forcage['source_id']) { notice::save_to_agnostic_warehouse(array(0 => $item), $forcage['source_id']); } $requete = "SELECT niveau_biblio, niveau_hierar FROM notices WHERE notice_id='" . $item . "'"; $res = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($res) && pmb_mysql_result($res, 0, 0) == "s" && pmb_mysql_result($res, 0, 1) == "1") { $myBulletinage = new serial($item); $myBulletinage->serial_delete(); } else { notice::del_notice($item); } return CADDIE_ITEM_SUPPR_BASE_OK; } else { return CADDIE_ITEM_NOTI_USED; } break; } return CADDIE_ITEM_OK; }
function replace($by, $supp_notice = true) { global $msg; global $dbh; global $keep_categories; if ($this->id == $by) { return $msg[223]; } if ($this->id == $by || !$this->id) { return $msg[223]; } $by_notice = new notice($by); if ($this->biblio_level != $by_notice->biblio_level || $this->hierar_level != $by_notice->hierar_level) { return $msg[catal_rep_not_err1]; } // traitement des catégories (si conservation cochée) if ($keep_categories) { update_notice_categories_from_form($by); } // remplacement dans les exemplaires numériques $requete = "UPDATE explnum SET explnum_notice='{$by}' WHERE explnum_notice='{$this->id}' "; pmb_mysql_query($requete, $dbh); // remplacement dans les exemplaires $requete = "UPDATE exemplaires SET expl_notice='{$by}' WHERE expl_notice='{$this->id}' "; pmb_mysql_query($requete, $dbh); // remplacement dans les depouillements $requete = "UPDATE analysis SET analysis_notice='{$by}' WHERE analysis_notice='{$this->id}' "; pmb_mysql_query($requete, $dbh); // remplacement dans les bulletins $requete = "UPDATE bulletins SET bulletin_notice='{$by}' WHERE bulletin_notice='{$this->id}' "; pmb_mysql_query($requete, $dbh); // remplacement dans les notices filles /*$requete = "UPDATE notices_relations SET num_notice='$by' WHERE num_notice='$this->id' "; @pmb_mysql_query($requete, $dbh); $requete = "UPDATE notices_relations SET linked_notice='$by' WHERE linked_notice='$this->id' "; @pmb_mysql_query($requete, $dbh);*/ // remplacement dans les resas $requete = "UPDATE resa SET resa_idnotice='{$by}' WHERE resa_idnotice='{$this->id}' "; pmb_mysql_query($requete, $dbh); $req = "UPDATE notices_authperso SET notice_authperso_notice_num='{$by}' where notice_authperso_notice_num='{$this->id}' "; pmb_mysql_query($req, $dbh); //Suppression de la notice if ($supp_notice) { notice::del_notice($this->id); } return FALSE; }
function creer_lien_notice_bulletin($ancien_id = 0, $id_perio = 0, $id_bulletin = 0, $id_not_bull = 0, $titre_not_bull = "", $bulletin) { global $dbh, $msg, $isbn_OK, $tit_200a, $notice_id, $notices_crees, $statutnot; //On control que ce bulletin n'a pas déjà une notice $requete = "select num_notice from bulletins where bulletin_id='" . $id_bulletin . "'"; if ($id_not_bull) { $requete .= " and num_notice!='" . $id_not_bull . "'"; } $res = mysql_query($requete, $dbh); if (mysql_num_rows($res) && mysql_result($res, 0, 0)) { //Si j'ai déja une notice associé à ce bulletin je la récupère if ($id_not_bull) { //Si j'ai aussi un identifiant de notice de bulletin, je supprime le plus récent notice::del_notice($id_not_bull); mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[542] . " {$id_unimarc} " . " {$isbn_OK} " . addslashes(clean_string(implode(" ; ", $tit_200a))) . "') ", $dbh); $id_notice_bulletin = mysql_result($res, 0, 0); //A voir pr modif } else { $id_notice_bulletin = mysql_result($res, 0, 0); } $notice_id = $id_notice_bulletin; } else { if ($titre_not_bull) { //Si j'ai un titre je créé la notice de bulletin $requete = "insert into notices (tit1,niveau_biblio, niveau_hierar,statut) values ('" . addslashes(clean_string($titre_not_bull)) . "', 'b', '2','" . $statutnot . "')"; mysql_query($requete, $dbh); $id_notice_bulletin = mysql_insert_id(); audit::insert_creation(AUDIT_NOTICE, $id_notice_bulletin); //calcul des droits d'accès s'ils sont activés calc_notice_acces_rights($id_notice_bulletin); // Mise à jour des index de la notice notice::majNotices($id_notice_bulletin); // Mise à jour de la table "notices_global_index" notice::majNoticesGlobalIndex($id_notice_bulletin); // Mise à jour de la table "notices_mots_global_index" notice::majNoticesMotsGlobalIndex($id_notice_bulletin); } else { $id_notice_bulletin = $id_not_bull; } //On créer le lien entre le bulletin et la notice de bulletin $requete = "update bulletins set num_notice='" . $id_notice_bulletin . "' where bulletin_id='" . $id_bulletin . "'"; mysql_query($requete, $dbh); } $notices_crees[$ancien_id] = $id_notice_bulletin; //Lien entre la notice de bulletin et la notice de periodique $requete = "insert into notices_relations(num_notice,linked_notice,relation_type) values ('" . $id_notice_bulletin . "','" . $id_perio . "','b')"; mysql_query($requete); if ($id_notice_bulletin && $bulletin["date"]) { $requete = "UPDATE notices SET year='" . addslashes(substr($bulletin["date"], 0, 4)) . "', date_parution='" . addslashes($bulletin["date"]) . "' WHERE notice_id='" . $id_notice_bulletin . "'"; mysql_query($requete); } return $id_notice_bulletin; }
protected function dedoublonne($notice_id) { global $pmb_notice_controle_doublons; $sign = new \notice_doublon(); $signature = $sign->gen_signature($notice_id); if ($pmb_notice_controle_doublons) { $q = "select notice_id from notices where signature='" . $signature . "' and notice_id != " . $notice_id . " limit 1"; $res = pmb_mysql_query($q); if (pmb_mysql_num_rows($res)) { $r = pmb_mysql_fetch_object($res); // doublon existe, on supprime la notice créée \notice::del_notice($notice_id); return $r->notice_id; } } pmb_mysql_query("update notices set signature = '" . $signature . "' where notice_id = " . $notice_id); return $notice_id; }
function replace($by, $supp_notice = true) { global $msg; global $dbh; if ($this->id == $by) { return $msg[223]; } if ($this->id == $by || !$this->id) { return $msg[223]; } $by_notice = new notice($by); if ($this->biblio_level != $by_notice->biblio_level || $this->hierar_level != $by_notice->hierar_level) { return $msg[catal_rep_not_err1]; } // remplacement dans les exemplaires numériques $requete = "UPDATE explnum SET explnum_notice='{$by}' WHERE explnum_notice='{$this->id}' "; mysql_query($requete, $dbh); // remplacement dans les exemplaires $requete = "UPDATE exemplaires SET expl_notice='{$by}' WHERE expl_notice='{$this->id}' "; mysql_query($requete, $dbh); // remplacement dans les depouillements $requete = "UPDATE analysis SET analysis_notice='{$by}' WHERE analysis_notice='{$this->id}' "; mysql_query($requete, $dbh); // remplacement dans les bulletins $requete = "UPDATE bulletins SET bulletin_notice='{$by}' WHERE bulletin_notice='{$this->id}' "; mysql_query($requete, $dbh); // remplacement dans les notices filles /*$requete = "UPDATE notices_relations SET num_notice='$by' WHERE num_notice='$this->id' "; @mysql_query($requete, $dbh); $requete = "UPDATE notices_relations SET linked_notice='$by' WHERE linked_notice='$this->id' "; @mysql_query($requete, $dbh);*/ // remplacement dans les resas $requete = "UPDATE resa SET resa_idnotice='{$by}' WHERE resa_idnotice='{$this->id}' "; mysql_query($requete, $dbh); //Suppression de la notice if ($supp_notice) { notice::del_notice($this->id); } return FALSE; }
function doSync($id_connector, $id_source, $auto_import = false, $id_tache = '', $callback_listen_command = NULL, $callback_deals_command = NULL, $auto_delete = false) { global $base_path, $dbh, $PMBuserid, $PMBusername, $msg, $charset; if (!$id_connector || !$id_source) { return array(); } if (SESSrights & ADMINISTRATION_AUTH) { $this->callback_listen_command = $callback_listen_command; $this->callback_deals_command = $callback_deals_command; $result = array(); $this->id_source = $id_source; $this->id_tache = $id_tache; $contrs = new connecteurs(); require_once $base_path . "/admin/connecteurs/in/" . $contrs->catalog[$id_connector]["PATH"] . "/" . $contrs->catalog[$id_connector]["NAME"] . ".class.php"; eval("\$conn=new " . $contrs->catalog[$id_connector]["NAME"] . "(\"" . $base_path . "/admin/connecteurs/in/" . $contrs->catalog[$id_connector]["PATH"] . "\");"); //Vérification qu'il n'y a pas de synchronisation en cours... $is_already_sync = false; $recover_env = ""; $recover = false; $requete = "select * from source_sync where source_id={$id_source}"; $resultat = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($resultat)) { $rs_s = pmb_mysql_fetch_object($resultat); if (!$rs_s->cancel) { $result[] = $conn->msg["connecteurs_sync_currentexists"]; $is_already_sync = true; } else { $recover = true; $recover_env = $rs_s->env; $env = array(); } } else { $env = $conn->get_maj_environnement($id_source); } if (!$is_already_sync) { if (!$recover) { $requete = "insert into source_sync (source_id,nrecu,ntotal,date_sync) values({$id_source},0,0,now())"; $r = pmb_mysql_query($requete, $dbh); } else { $requete = "update source_sync set cancel=0 where source_id={$id_source}"; $r = pmb_mysql_query($requete, $dbh); } if ($r) { $n_maj = $conn->maj_entrepot($id_source, array(&$this, "callback_progress"), $recover, $recover_env); $result[] = sprintf($msg["connecteurs_count_notices"], $n_maj); $result[] = $conn->error_message; if (!$conn->error) { $this->callback_progress(1, $n_maj, $n_maj); $percent = 1; $requete = "update source_sync set percent=" . round($percent * 100) . " where source_id={$id_source}"; $r = pmb_mysql_query($requete, $dbh); $requete = "delete from source_sync where source_id=" . $id_source; pmb_mysql_query($requete); $requete = "update connectors_sources set last_sync_date=now() where source_id=" . $id_source; pmb_mysql_query($requete, $dbh); } else { if ($conn->break_maj($id_source)) { $requete = "delete from source_sync where source_id=" . $id_source; } else { $requete = "update source_sync set cancel=2 where source_id=" . $id_source; } pmb_mysql_query($requete, $dbh); $result[] = $conn->error_message; } } else { $result[] = pmb_mysql_error(); } } else { $result[] = $msg["connecteurs_sync_currentexists"]; } //si l'import automatique est activé if ($auto_import) { //on va chercher les notices non intégrées $query = "select distinct entrepot_source_" . $id_source . ".recid from entrepot_source_" . $id_source . " left join notices_externes on notices_externes.recid = concat(connector_id,' " . $id_source . " ',ref) where num_notice is null"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { $infos = entrepot_to_unimarc($row->recid); if ($infos['notice']) { $z = new z3950_notice("unimarc", $infos['notice'], $infos['source_id']); if ($pmb_notice_controle_doublons != 0) { $sign = new notice_doublon(true, $infos['source_id']); $signature = $sign->gen_signature($row->recid); } else { $signature = ""; } $z->signature = $signature; if ($infos['notice']) { $z->notice = $infos['notice']; } if ($infos['source_id']) { $z->source_id = $infos['source_id']; } $z->var_to_post(); $ret = $z->insert_in_database(false); $id_notice = $ret[1]; $rqt = "select recid from external_count where rid = '{$row->recid}'"; $res = pmb_mysql_query($rqt); if (pmb_mysql_num_rows($res)) { $recid = pmb_mysql_result($res, 0, 0); } $req = "insert into notices_externes set num_notice = '" . $id_notice . "', recid = '" . $recid . "'"; pmb_mysql_query($req); } } } if (!$conn->error && $auto_delete) { // On gère la suppression des notices qui ne sont plus présentes dans l'entrepôt $query = "select distinct num_notice from notices_externes left join external_count on notices_externes.recid = external_count.recid where rid is null and notices_externes.recid like '% " . $id_source . " %'"; $result = pmb_mysql_query($query, $dbh); if ($result && pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { // suppression de la notice notice::del_notice($row->num_notice); } } } } return $result; } else { return array(); } }