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=&notice_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;
 }
Example #2
0
function import_new_notice_suite()
{
    global $dbh;
    global $notice_id;
    global $info_464;
    global $info_606_a;
    global $info_900, $info_901, $info_902, $info_903, $info_904, $info_905, $info_906, $info_610;
    global $pmb_keyword_sep;
    global $bulletin_ex;
    //Cas des périodiques
    if (is_array($info_464)) {
        $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_464[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_464[0]['v']) . "' and  mention_date='" . addslashes($info_464[0]['d']) . "' and bulletin_notice={$chapeau_id}";
            //$requete="select bulletin_id from bulletins where bulletin_numero='".addslashes($info_464[0]['v'])."' 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 bulltin
                $info = array();
                $bulletin = new bulletinage("", $chapeau_id);
                $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']);
                $info['bul_no'] = addslashes($info_464[0]['v']);
                $info['bul_date'] = addslashes($info_464[0]['d']);
                if (!$info_464[0]['e']) {
                    $date_date = explode("/", $info_464[0]['d']);
                    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];
                        }
                    }
                } else {
                    $info['date_date'] = $info_464[0]['e'];
                }
                $bulletin_id = $bulletin->update($info);
            }
        } else {
            //Si non, création notice chapeau et bulletin
            $chapeau = new serial();
            $info = array();
            $info['tit1'] = addslashes($info_464[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'] = addslashes("Bulletin N°" . $info_464[0]['v']);
            $info['bul_no'] = addslashes($info_464[0]['v']);
            $info['bul_date'] = addslashes($info_464[0]['d']);
            if (!$info_464[0]['e']) {
                $date_date = explode("/", $info_464[0]['d']);
                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];
                    }
                }
            } else {
                $info['date_date'] = $info_464[0]['e'];
            }
            $bulletin_id = $bulletin->update($info);
        }
        //Notice objet ?
        if ($info_464[0]['z'] == 'objet') {
            //Supression de la notice
            $requete = "delete from notices where notice_id={$notice_id}";
            mysql_query($requete);
            $bulletin_ex = $bulletin_id;
        } else {
            $annee = $info_464[0]['d'];
            $date_parution = $info['date_date'];
            //Récupère la date du bulletin (non disponible autrement si il existe déjà) pour l'article
            $select = "SELECT date_date FROM bulletins WHERE bulletin_id='" . $bulletin_id . "'";
            $res_date = mysql_query($select);
            if ($res_date && mysql_num_rows($res_date)) {
                $date_parution = mysql_result($res_date, 0, 0);
                $annee = substr($date_parution, 0, 4);
            }
            //Passage de la notice en article
            $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($annee) . "', npages='" . addslashes($info_464[0]['p']) . "', date_parution='" . addslashes($date_parution) . "' where notice_id={$notice_id}";
            mysql_query($requete);
            $requete = "insert into analysis (analysis_bulletin,analysis_notice) values({$bulletin_id},{$notice_id})";
            mysql_query($requete);
            $bulletin_ex = $bulletin_id;
        }
    } else {
        $bulletin_ex = 0;
    }
    //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 = trim($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);
                $ordre_categ++;
            } else {
                $unknown_desc[] = $descripteur;
            }
        }
    }
    if (count($info_610)) {
        for ($i = 0; $i < count($info_610); $i++) {
            $tmp = explode($pmb_keyword_sep, $info_610[$i]);
            if (count($tmp)) {
                foreach ($tmp as $value) {
                    if ($libelle = addslashes(trim($value))) {
                        $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);
                            $ordre_categ++;
                        } else {
                            $unknown_desc[] = trim($value);
                        }
                    }
                }
            }
        }
    }
    if ($unknown_desc) {
        $mots_cles = implode($pmb_keyword_sep, $unknown_desc);
        $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);
    }
    //Thème
    if (count($info_900)) {
        $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=1";
        $resultat = mysql_query($requete);
        $max = @mysql_result($resultat, 0, 0);
        $n = $max + 1;
        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=1";
                $resultat = mysql_query($requete);
                if (mysql_num_rows($resultat)) {
                    $value = mysql_result($resultat, 0, 0);
                } else {
                    $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(1,{$n},'" . addslashes($info_900[$i][$j]) . "')";
                    mysql_query($requete);
                    $value = $n;
                    $n++;
                }
                $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(1,{$notice_id},{$value})";
                mysql_query($requete);
            }
        }
    }
    //Genres
    if (count($info_901)) {
        $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=2";
        $resultat = mysql_query($requete);
        $max = @mysql_result($resultat, 0, 0);
        $n = $max + 1;
        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=2";
                $resultat = mysql_query($requete);
                if (mysql_num_rows($resultat)) {
                    $value = mysql_result($resultat, 0, 0);
                } else {
                    $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(2,{$n},'" . addslashes($info_901[$i][$j]) . "')";
                    mysql_query($requete);
                    $value = $n;
                    $n++;
                }
                $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(2,{$notice_id},{$value})";
                mysql_query($requete);
            }
        }
    }
    //Discipline
    if (count($info_902)) {
        $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=3";
        $resultat = mysql_query($requete);
        $max = @mysql_result($resultat, 0, 0);
        $n = $max + 1;
        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=3";
                $resultat = mysql_query($requete);
                if (mysql_num_rows($resultat)) {
                    $value = mysql_result($resultat, 0, 0);
                } else {
                    $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(3,{$n},'" . addslashes($info_902[$i][$j]) . "')";
                    mysql_query($requete);
                    $value = $n;
                    $n++;
                }
                $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(3,{$notice_id},{$value})";
                mysql_query($requete);
            }
        }
    }
    //Type de nature
    if ($info_905[0]) {
        $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=6";
        $resultat = mysql_query($requete);
        $max = @mysql_result($resultat, 0, 0);
        $n = $max + 1;
        $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[0]) . "' and notices_custom_champ=6";
        $resultat = mysql_query($requete);
        if (mysql_num_rows($resultat)) {
            $value = mysql_result($resultat, 0, 0);
        } else {
            $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(6,{$n},'" . addslashes($info_905[0]) . "')";
            mysql_query($requete);
            $value = $n;
            $n++;
        }
        $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(6,{$notice_id},{$value})";
        mysql_query($requete);
    }
    //Niveau
    if (count($info_906)) {
        for ($i = 0; $i < count($info_906); $i++) {
            for ($j = 0; $j < count($info_906[$i]); $j++) {
                $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=7";
                $resultat = mysql_query($requete);
                $max = @mysql_result($resultat, 0, 0);
                $n = $max + 1;
                $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_906[$i][$j]) . "' and notices_custom_champ=7";
                $resultat = mysql_query($requete);
                if (mysql_num_rows($resultat)) {
                    $value = mysql_result($resultat, 0, 0);
                } else {
                    $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(7,{$n},'" . addslashes($info_906[$i][$j]) . "')";
                    mysql_query($requete);
                    $value = $n;
                    $n++;
                }
                $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(7,{$notice_id},{$value})";
                mysql_query($requete);
            }
        }
    }
    //Année de péremption
    if ($info_903[0]) {
        $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(4,{$notice_id},'" . addslashes($info_903[0]) . "')";
        mysql_query($requete);
    }
    //Date de saisie
    if ($info_904[0]) {
        $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) values(5,{$notice_id},'" . $info_904[0] . "')";
        mysql_query($requete);
    }
}
                utility::jsAlert(__('Subscription Data Successfully Updated'));
                utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'serial_control', $_SESSION['realname'] . ' update subcription(' . $updateRecordID . ') ' . $period);
            } else {
                utility::jsAlert(__('Subscription Data FAILED to Updated. Please Contact System Administrator') . "\nDEBUG : " . $sql_op->error);
            }
            echo '<script type="text/javascript">self.location.href = \'' . MODULES_WEB_ROOT_DIR . 'serial_control/subscription.php?biblioID=' . $biblioID . '\';</script>';
            exit;
        } else {
            /* INSERT RECORD MODE */
            // insert the data
            $insert = $sql_op->insert('serial', $data);
            $serial_id = $sql_op->insert_id;
            if ($insert) {
                $exemplar = (int) $_POST['exemplar'];
                // generate kardex entry
                $serial = new serial($dbs, $serial_id);
                $serial->generateKardexes($exemplar, true);
                // alert
                utility::jsAlert(__('New Subscription Data Successfully Saved'));
                utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'serial_control', $_SESSION['realname'] . ' add new subcription(' . $sql_op->insert_id . ') ' . $period);
            } else {
                utility::jsAlert(__('Subscription Data FAILED to Save. Please Contact System Administrator') . "\n" . $sql_op->error);
            }
            echo '<script type="text/javascript">self.location.href = \'' . MODULES_WEB_ROOT_DIR . 'serial_control/subscription.php?biblioID=' . $biblioID . '\';</script>';
            exit;
        }
    }
    exit;
} else {
    if (isset($_POST['itemID']) and !empty($_POST['itemID']) and isset($_POST['itemAction'])) {
        if (!($can_read and $can_write)) {
Example #4
0
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);
            }
        }
    }
}
Example #5
0
 function fetch_serial_data()
 {
     global $dbh;
     global $fonction_auteur;
     $myQuery = pmb_mysql_query("SELECT * FROM notices WHERE notice_id='" . $this->serial_id . "' LIMIT 1", $dbh);
     $myPerio = pmb_mysql_fetch_object($myQuery);
     // type du document
     $this->typdoc = $myPerio->typdoc;
     // statut de la notice
     $this->statut = $myPerio->statut;
     $this->commentaire_gestion = $myPerio->commentaire_gestion;
     $this->thumbnail_url = $myPerio->thumbnail_url;
     // code-barre
     $this->code = $myPerio->code;
     // mentions de titre
     $this->tit1 = $myPerio->tit1;
     $this->tit3 = $myPerio->tit3;
     $this->tit4 = $myPerio->tit4;
     // libelle des auteurs
     $this->responsabilites = get_notice_authors($this->serial_id);
     // libelle des éditeurs
     if ($myPerio->ed1_id) {
         $this->ed1_id = $myPerio->ed1_id;
         $editeur = new editeur($this->ed1_id);
         $this->ed1 = $editeur->display;
     }
     if ($myPerio->ed2_id) {
         $this->ed2_id = $myPerio->ed2_id;
         $editeur = new editeur($this->ed2_id);
         $this->ed2 = $editeur->display;
     }
     // année d'édition
     $this->year = $myPerio->year;
     $this->date_parution_perio = serial::get_date_parution($this->year);
     // zone des notes
     $this->n_gen = $myPerio->n_gen;
     $this->n_contenu = $myPerio->n_contenu;
     $this->n_resume = $myPerio->n_resume;
     // mise à jour des catégories
     $this->categories = get_notice_categories($this->serial_id);
     // indexation interne
     if ($myPerio->indexint) {
         $this->indexint = $myPerio->indexint;
         $indexint = new indexint($this->indexint);
         if ($indexint->comment) {
             $this->indexint_lib = $indexint->name . " - " . $indexint->comment;
         } else {
             $this->indexint_lib = $indexint->name;
         }
     }
     // indexation libre
     $this->index_l = $myPerio->index_l;
     // libelle des langues
     $this->langues = get_notice_langues($this->serial_id, 0);
     // langues de la publication
     $this->languesorg = get_notice_langues($this->serial_id, 1);
     // langues originales
     // lien vers une ressource électronique
     $this->lien = $myPerio->lien;
     $this->eformat = $myPerio->eformat;
     $this->signature = $myPerio->signature;
     // Montrer ou pas le bulletinage en opac
     $this->opac_visible_bulletinage = $myPerio->opac_visible_bulletinage;
     // Autoriser la demande d'abonnement à l'OPAC
     $this->opac_serialcirc_demande = $myPerio->opac_serialcirc_demande;
     $this->indexation_lang = $myPerio->indexation_lang;
     $this->is_new = $myPerio->notice_is_new;
     $this->date_is_new = $myPerio->notice_date_is_new;
     $this->notice_link = array();
     //liens vers autres notices
     $requete = "\n\t\tSELECT notices_relations.* FROM notices_relations\n\t\tLEFT OUTER JOIN bulletins ON bulletins.num_notice=notices_relations.num_notice AND bulletins.bulletin_notice=notices_relations.linked_notice\n\t\tWHERE (notices_relations.num_notice=" . $this->serial_id . " OR notices_relations.linked_notice=" . $this->serial_id . ")\n\t\tAND (bulletin_notice IS NULL OR bulletins.bulletin_notice!=" . $this->serial_id . ")\n\t\tORDER BY rank";
     $result_rel = pmb_mysql_query($requete) or die(pmb_mysql_error());
     if (pmb_mysql_num_rows($result_rel)) {
         $i = 0;
         while ($r_rel = pmb_mysql_fetch_object($result_rel)) {
             if ($r_rel->linked_notice == $this->serial_id) {
                 //notice en cours est notice fille
                 $this->notice_link['down'][$i]['relation_direction'] = 'down';
                 $this->notice_link['down'][$i]['id_notice'] = $r_rel->num_notice;
                 $this->notice_link['down'][$i]['title_notice'] = $this->get_notice_title($r_rel->num_notice);
                 $this->notice_link['down'][$i]['rank'] = $r_rel->rank;
                 $this->notice_link['down'][$i]['relation_type'] = $r_rel->relation_type;
             } elseif ($r_rel->num_notice == $this->serial_id) {
                 //notice en cours est notice mere
                 $this->notice_link['up'][$i]['relation_direction'] = 'up';
                 $this->notice_link['up'][$i]['id_notice'] = $r_rel->linked_notice;
                 $this->notice_link['up'][$i]['title_notice'] = $this->get_notice_title($r_rel->linked_notice);
                 $this->notice_link['up'][$i]['rank'] = $r_rel->rank;
                 $this->notice_link['up'][$i]['relation_type'] = $r_rel->relation_type;
             }
             $i++;
         }
     }
     $this->create_date = $myPerio->create_date;
     $this->update_date = $myPerio->update_date;
     return $myQuery->nbr_rows;
 }
 case 'view':
     include './catalog/serials/serial_view.inc.php';
     break;
 case 'bulletinage':
     include './catalog/serials/bulletinage/bul_main.inc.php';
     break;
 case 'analysis':
     include './catalog/serials/analysis/analysis_main.inc.php';
     break;
 case 'serial_replace':
     include './catalog/serials/serial_replace.inc.php';
     break;
 case 'serial_duplicate':
     print "<h1>{$msg['catal_duplicate_serial']}</h1>";
     // routine de copie
     $serial = new serial($serial_id);
     $serial->serial_id = 0;
     $serial->code = "";
     $serial->duplicate_from_serial_id = $serial_id;
     print pmb_bidi($serial->do_form());
     break;
 case 'bulletin_replace':
     include './catalog/serials/bulletinage/bul_replace.inc.php';
     break;
 case 'modele':
     include './catalog/serials/modele/modele_main.inc.php';
     //TODO
     break;
 case 'abon':
     include './catalog/serials/abonnement/abonnement_main.inc.php';
     //TODO
Example #7
0
 } else {
     $val = 0x10;
 }
 $table['opac_visible_bulletinage'] = $opac_visible_bulletinage | $val;
 $p_perso = new parametres_perso("notices");
 $nberrors = $p_perso->check_submited_fields();
 if (!$nberrors) {
     //Pour la synchro rdf
     if ($pmb_synchro_rdf) {
         require_once $class_path . "/synchro_rdf.class.php";
         $synchro_rdf = new synchro_rdf();
         if ($serial_id) {
             $synchro_rdf->delRdf($serial_id, 0);
         }
     }
     $serial = new serial($serial_id);
     $update_result = $serial->update($table);
 } else {
     error_message_history($msg["notice_champs_perso"], $p_perso->error_message, 1);
     exit;
 }
 // vignette de la notice uploadé dans un répertoire
 if ($_FILES['f_img_load']['name'] && $pmb_notice_img_folder_id) {
     $poids_fichier_max = 1024 * 1024;
     //Limite la taille de l'image à 1 Mo
     $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'";
     $res = mysql_query($req, $dbh);
     if (mysql_num_rows($res)) {
         $rep = mysql_fetch_object($res);
         $filename_output = $rep->repertoire_path . "img_" . $update_result;
     }
Example #8
0
function import_new_notice_suite()
{
    global $dbh;
    global $notice_id;
    global $info_464, $info_676;
    global $info_606_a, $info_606_x;
    global $info_900, $info_901, $info_902, $info_200, $info_903, $info_904, $info_910;
    global $rs, $bl, $dt;
    global $bulletin_ex;
    global $m_thess;
    //si on est en multi-thesaurus
    if (!$m_thess) {
        $rqt = "SELECT count(1) FROM thesaurus WHERE active=1";
        $m_thess = mysql_result(mysql_query($rqt), 0, 0);
    }
    //Cas des périodiques
    if (is_array($info_464)) {
        $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_464[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);
            //Mise à jour du champ commentaire de gestion si nécessaire
            if ($info_903[0]) {
                $requete = "UPDATE notices SET commentaire_gestion=concat(commentaire_gestion,' ','" . addslashes($info_903[0]) . "') WHERE notice_id={$chapeau_id}";
                mysql_query($requete);
            }
            //Bulletin existe-t-il ?
            $requete = "SELECT bulletin_id FROM bulletins WHERE bulletin_numero='" . addslashes($info_464[0]['v']) . "' AND mention_date='" . addslashes($info_464[0]['d']) . "' 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);
                if ($info_464[0]['u']) {
                    $info['bul_titre'] = addslashes($info_464[0]['u']);
                } else {
                    $info['bul_titre'] = addslashes("Bulletin " . $info_464[0]['v']);
                }
                $info['bul_no'] = addslashes($info_464[0]['v']);
                $info['bul_date'] = addslashes($info_464[0]['d']);
                if (!$info_464[0]['e']) {
                    if ($info_902[0]) {
                        $info['date_date'] = $info_902[0];
                    }
                } else {
                    $info['date_date'] = $info_464[0]['e'];
                }
                $bulletin_id = $bulletin->update($info);
            }
        } else {
            //Si non, création notice chapeau et bulletin
            $chapeau = new serial();
            $info = array();
            $info['tit1'] = addslashes($info_464[0]['t']);
            $info['niveau_biblio'] = 's';
            $info['niveau_hierar'] = '1';
            $info['typdoc'] = $r->typdoc;
            $chapeau->update($info);
            $chapeau_id = $chapeau->serial_id;
            //Mise à jour du champ commentaire de gestion si nécessaire
            if ($info_903[0]) {
                $requete = "UPDATE notices SET commentaire_gestion=concat(commentaire_gestion,' ','" . addslashes($info_903[0]) . "') WHERE notice_id={$chapeau_id}";
                mysql_query($requete);
            }
            $bulletin = new bulletinage("", $chapeau_id);
            $info = array();
            if ($info_464[0]['u']) {
                $info['bul_titre'] = addslashes($info_464[0]['u']);
            } else {
                $info['bul_titre'] = addslashes("Bulletin " . $info_464[0]['v']);
            }
            $info['bul_no'] = addslashes($info_464[0]['v']);
            $info['bul_date'] = addslashes($info_464[0]['d']);
            if (!$info_464[0]['e']) {
                if ($info_902[0]) {
                    $info['date_date'] = $info_902[0];
                }
            } else {
                $info['date_date'] = $info_464[0]['e'];
            }
            $bulletin_id = $bulletin->update($info);
        }
        //Passage de la notice en article
        $requete = "UPDATE notices SET niveau_biblio='a', niveau_hierar='2', npages='" . addslashes($info_464[0]['p']) . "' WHERE notice_id={$notice_id}";
        mysql_query($requete);
        $requete = "INSERT INTO analysis (analysis_bulletin,analysis_notice) VALUES({$bulletin_id},{$notice_id})";
        mysql_query($requete);
        $bulletin_ex = $bulletin_id;
    } else {
        $bulletin_ex = 0;
    }
    //Traitement du thésaurus
    if ($m_thess > 1) {
        //on est en multi-thesaurus
        for ($i = 0; $i < count($info_606_a); $i++) {
            for ($j = 0; $j < count($info_606_a[$i]); $j++) {
                $descripteur_tete = $info_606_a[$i][$j];
                $descripteur_fils = $info_606_x[$i][$j];
                //Recherche du thésaurus
                $thes_id = trouve_thesaurus($descripteur_tete);
                //Recherche du terme fils
                if ($thes_id > 0) {
                    $categ_id_fils = categories::searchLibelle(addslashes(trim($descripteur_fils)), $thes_id, "fr_FR");
                    if (!$categ_id_fils) {
                        //Création
                        $new_thes = $thes_id == 1 ? 4 : $thes_id;
                        //Choix du thesaurus Candidats descripteurs si descripteur inexistant
                        $categ_id_fils = categories::searchLibelle(addslashes(trim($descripteur_fils)), $new_thes, "fr_FR");
                        if (!$categ_id_fils) {
                            $noeud = new noeuds();
                            $noeud->num_thesaurus = $new_thes;
                            $thesau = new thesaurus($new_thes);
                            $noeud->num_parent = $thesau->num_noeud_racine;
                            $noeud->save();
                            $categ_id_fils = $noeud->id_noeud;
                            //Création du libellé
                            $categ = new categories($noeud->id_noeud, 'fr_FR');
                            $categ->libelle_categorie = $descripteur_fils;
                            $categ->index_categorie = " " . strip_empty_words($descripteur_fils) . " ";
                            $categ->save();
                        }
                    }
                    $requete = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ({$notice_id},{$categ_id_fils}, " . ($i + 1) . ")";
                    mysql_query($requete);
                }
            }
        }
        //for($i
    } else {
        //Traitement du thésaurus unique
        for ($i = 0; $i < count($info_606_a); $i++) {
            for ($j = 0; $j < count($info_606_a[$i]); $j++) {
                $descripteur_tete = $info_606_a[$i][$j];
                $descripteur_fils = $info_606_x[$i][$j];
                //Recherche du terme de tête
                //$requete="SELECT num_noeud FROM categories WHERE libelle_categorie='".addslashes($descripteur_tete)."' AND langue='fr_FR'";
                $requete = "SELECT id_noeud FROM noeuds WHERE autorite='" . addslashes($descripteur_tete) . "'";
                $resultat = mysql_query($requete);
                if (@mysql_num_rows($resultat)) {
                    //la tête existe !
                    $categ_id_tete = mysql_result($resultat, 0, 0);
                } else {
                    //Création de la tête
                    //Nouveau Noeud !
                    $th = new thesaurus(1);
                    $noeud = new noeuds();
                    $noeud->num_thesaurus = $th->id_thesaurus;
                    $noeud->num_parent = $th->num_noeud_racine;
                    $noeud->autorite = $descripteur_tete;
                    $noeud->save();
                    $categ_id_tete = $noeud->id_noeud;
                    //Création du libellé
                    $categ = new categories($noeud->id_noeud, 'fr_FR');
                    $categ->libelle_categorie = $descripteur_tete;
                    $categ->index_categorie = " " . strip_empty_words($descripteur_tete) . " ";
                    $categ->save();
                }
                //Recherche du terme fils
                $categ_id_fils = categories::searchLibelle(addslashes($descripteur_fils), 1, "fr_FR");
                if (!$categ_id_fils) {
                    //Création
                    $noeud = new noeuds();
                    $noeud->num_thesaurus = 1;
                    $noeud->num_parent = $categ_id_tete;
                    $noeud->save();
                    $categ_id_fils = $noeud->id_noeud;
                    //Création du libellé
                    $categ = new categories($noeud->id_noeud, 'fr_FR');
                    $categ->libelle_categorie = $descripteur_fils;
                    $categ->index_categorie = " " . strip_empty_words($descripteur_fils) . " ";
                    $categ->save();
                }
                $requete = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ({$notice_id}, {$categ_id_fils}, " . ($i + 1) . ")";
                mysql_query($requete);
            }
        }
    }
    //Indexation décimale
    if ($info_676[0]) {
        $requete = "select indexint_id from indexint where indexint_name='" . addslashes($info_676[0]) . "'";
        $resultat = mysql_query($requete);
        if (mysql_num_rows($resultat)) {
            $indexint = mysql_result($resultat, 0, 0);
        } else {
            $requete = "insert into indexint (indexint_name) values('" . addslashes($info_676[0]) . "')";
            mysql_query($requete);
            $indexint = mysql_insert_id();
        }
        $requete = "update notices set indexint=" . $indexint . " where notice_id=" . $notice_id;
        mysql_query($requete);
    }
    //Organisme
    if ($info_900[0]) {
        $no_champ = trouve_champ_perso("op");
        if ($no_champ > 0) {
            $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ;
            $resultat = mysql_query($requete);
            $max = @mysql_result($resultat, 0, 0);
            $n = $max + 1;
            $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_900[0]) . "' AND notices_custom_champ=" . $no_champ;
            $resultat = mysql_query($requete);
            if (mysql_num_rows($resultat)) {
                $value = mysql_result($resultat, 0, 0);
            } else {
                $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_900[0]) . "')";
                mysql_query($requete);
                $value = $n;
                $n++;
            }
            $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})";
            mysql_query($requete);
        }
    }
    //Genre
    if ($info_901[0]) {
        $no_champ = trouve_champ_perso("gen");
        if ($no_champ > 0) {
            $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ;
            $resultat = mysql_query($requete);
            $max = @mysql_result($resultat, 0, 0);
            $n = $max + 1;
            $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_901[0]) . "' AND notices_custom_champ=" . $no_champ;
            $resultat = mysql_query($requete);
            if (mysql_num_rows($resultat)) {
                $value = mysql_result($resultat, 0, 0);
            } else {
                $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_901[0]) . "')";
                mysql_query($requete);
                $value = $n;
                $n++;
            }
            $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})";
            mysql_query($requete);
        }
    }
    //Type de texte
    if (count($info_904)) {
        $no_champ = trouve_champ_perso("typtext");
        if ($no_champ > 0) {
            for ($i = 0; $i < count($info_904); $i++) {
                for ($j = 0; $j < count($info_904[$i]); $j++) {
                    $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ;
                    $resultat = mysql_query($requete);
                    $max = @mysql_result($resultat, 0, 0);
                    $n = $max + 1;
                    $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_904[$i][$j]) . "' AND notices_custom_champ=" . $no_champ;
                    $resultat = mysql_query($requete);
                    if (mysql_num_rows($resultat)) {
                        $value = mysql_result($resultat, 0, 0);
                    } else {
                        $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_904[$i][$j]) . "')";
                        mysql_query($requete);
                        $value = $n;
                        $n++;
                    }
                    $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})";
                    mysql_query($requete);
                }
            }
        }
    }
    //Date de saisie
    if ($info_902[0]) {
        $no_champ = trouve_champ_perso("ds");
        if ($no_champ > 0) {
            $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) VALUES({$no_champ},{$notice_id},'" . str_replace(".", "-", $info_902[0]) . "')";
            mysql_query($requete);
        }
    }
    //N° de lot
    if ($info_903[0]) {
        $requete = "UPDATE notices SET commentaire_gestion='" . addslashes($info_903[0]) . "' WHERE notice_id={$notice_id}";
        mysql_query($requete);
    }
    //Cas de la mise à jour des périodiques ou du champ bord (notices chapeau)
    if ($bl == "s") {
        //Si c'est un périodique
        if ($dt == "a") {
            //Passage de la notice en notice chapeau
            $requete = "UPDATE notices SET niveau_biblio='s', niveau_hierar='1' WHERE notice_id={$notice_id}";
            mysql_query($requete);
            //Recherche si la notice existe déjà par rapport au titre
            $requete = "select notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND niveau_biblio='s' AND niveau_hierar='1' AND notice_id!={$notice_id}";
            $resultat = mysql_query($requete);
            $update = false;
            if (mysql_num_rows($resultat)) {
                $update = true;
                $n_update = mysql_result($resultat, 0, 0);
                //Mise à jour de tous les bulletins
                $requete = "UPDATE bulletins SET bulletin_notice=" . $notice_id . " WHERE bulletin_notice=" . $n_update;
                mysql_query($requete);
                //Suppression de l'ancienne notice
                $requete = "DELETE FROM notices WHERE notice_id={$n_update}";
                mysql_query($requete);
                $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $n_update;
                mysql_query($requete);
                $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $n_update;
                mysql_query($requete);
                $requete = "DELETE FROM responsability WHERE responsability_author=" . $n_update;
                mysql_query($requete);
            }
            if (!$update && $rs != "n") {
                //Si il n'y a pas de création, on supprime la notice
                $requete = "DELETE FROM notices WHERE notice_id={$notice_id}";
                mysql_query($requete);
                $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $notice_id;
                mysql_query($requete);
                $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $notice_id;
                mysql_query($requete);
                $requete = "DELETE FROM responsability WHERE responsability_author=" . $notice_id;
                mysql_query($requete);
            }
        } else {
            if ($dt == "l") {
                //Recherche si la notice existe déjà par rapport au titre
                $requete = "select notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND typdoc='l' AND notice_id!={$notice_id}";
                $resultat = mysql_query($requete);
                $update = false;
                if (mysql_num_rows($resultat)) {
                    $update = true;
                    $n_update = mysql_result($resultat, 0, 0);
                    //Suppression de l'ancienne notice
                    $requete = "DELETE FROM notices WHERE notice_id={$n_update}";
                    mysql_query($requete);
                    $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $n_update;
                    mysql_query($requete);
                    $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $n_update;
                    mysql_query($requete);
                    $requete = "DELETE FROM responsability WHERE responsability_author=" . $n_update;
                    mysql_query($requete);
                }
            } else {
                if ($dt == "r") {
                    //Mise à jour du champ bord
                    if ($info_910[0]) {
                        $no_champ = trouve_champ_perso("bord");
                        if ($no_champ > 0) {
                            //Recherche si la notice existe déjà par rapport au titre
                            $requete = "SELECT notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND niveau_biblio='s' AND niveau_hierar='1' AND notice_id!={$notice_id}";
                            $resultat = mysql_query($requete);
                            if (mysql_num_rows($resultat)) {
                                $notice_update = mysql_result($resultat, 0, 0);
                                $requete = "UPDATE notices_custom_values SET notices_custom_text='" . addslashes(str_replace("##", "\n", $info_910[0])) . "' WHERE notices_custom_champ={$no_champ} AND notices_custom_origine=" . $notice_update;
                                mysql_query($requete);
                                if (!mysql_affected_rows()) {
                                    $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_text) VALUES({$no_champ},{$notice_update},'" . addslashes(str_replace("##", "\n", $info_910[0])) . "')";
                                    mysql_query($requete);
                                }
                            }
                        }
                    }
                    //Suppression de la nouvelle notice
                    $requete = "DELETE FROM notices WHERE notice_id=" . $notice_id;
                    mysql_query($requete);
                }
            }
        }
    }
}
Example #9
0
function creer_bulletinage_et_articles($bull = array(), $art = array())
{
    global $notice_id, $dbh, $notices_a_creer, $bulletins_crees, $notices_crees, $tit_200a, $isbn_OK, $id_unimarc, $msg;
    global $force_creation_notice_perio;
    //On regarde si la notice n'existe pas déjà dans la base
    $requete = "select notice_id from notices where tit1 LIKE '" . addslashes(clean_string(implode(" ; ", $tit_200a))) . "' and niveau_biblio='s' and niveau_hierar='1' and notice_id !='" . addslashes($notice_id) . "' ";
    if ($isbn_OK) {
        $requete .= "and code = '" . addslashes($isbn_OK) . "'";
    }
    $res = mysql_query($requete, $dbh);
    if ((!isset($force_creation_notice_perio) || !$force_creation_notice_perio) && mysql_num_rows($res)) {
        $id_perio_garde = 0;
        while (($r = mysql_fetch_object($res)) && !$id_perio_garde) {
            if (!array_search($r->notice_id, $notices_crees)) {
                //Si le periodique ne fait pas parti des notices créées (il était déja dans la base)
                $id_perio_garde = $r->notice_id;
            }
        }
        if ($id_perio_garde) {
            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);
            //Si j'ai déja une notice dans la base avec ce titre et ce code je supprime celle que je suis en train d'importer
            $perio_traite = new serial($notice_id);
            $perio_traite->replace($id_perio_garde);
            $perio_traite->serial_delete();
            //Je travail avec le periodique qui était dans la base
            $notice_id = $id_perio_garde;
            $notices_crees[$id_unimarc] = $id_perio_garde;
        }
    }
    if ($bull) {
        for ($i = 0; $i < sizeof($bull); $i++) {
            $bulletin = array();
            $bulletin = array("titre" => $bull[$i]['t'][0], "date" => $bull[$i]['d'][0], "mention" => $bull[$i]['e'][0], "num" => $bull[$i]['v'][0]);
            creer_bulletin($notice_id, $bulletin, "", "");
        }
    }
    if ($art) {
        for ($i = 0; $i < sizeof($art); $i++) {
            if (!$notices_crees[get_valeur_champ9($art[$i]['9'], 'id')] && !$art[$i]['0'][0]) {
                $bulletin = array();
                $bulletin = array("titre" => $art[$i]['t'][1], "date" => $art[$i]['d'][0], "mention" => $art[$i]['e'][0], "num" => $art[$i]['v'][0]);
                creer_notice_article(get_valeur_champ9($art[$i]['9'], 'id'), $art[$i]['t'][0], get_valeur_champ9($art[$i]['9'], 'page'), 0, $bulletin, "", "", $notice_id);
            } elseif ($art[$i]['0'][0]) {
                $id = get_valeur_champ9($art[$i]['9'], 'id');
                $type_lien = get_valeur_champ9($art[$i]['9'], 'type_lnk');
                $lien = get_valeur_champ9($art[$i]['9'], 'lnk');
                $rank = get_valeur_champ9($art[$i]['9'], 'rank') * 1;
                $page = get_valeur_champ9($art[$i]['9'], 'page');
                //On enregistre les informations pour créer l'article plus tard
                $notices_a_creer[$id][] = array("type_lnk" => $type_lien, "lnk" => $lien, "rank" => $rank, "titre_art" => $art[$i]['t'][0], "titre" => $art[$i]['t'][1], "num" => $art[$i]['v'][0], "mention" => $art[$i]['e'][0], "date" => $art[$i]['d'][0], "id_asso" => $notice_id, "page" => $page);
            }
        }
    }
}
         $req_notice_date_is_new = ", notice_date_is_new =now() ";
     }
 }
 $table['notice_is_new'] = $f_notice_is_new + 0;
 $p_perso = new parametres_perso("notices");
 $nberrors = $p_perso->check_submited_fields();
 if (!$nberrors) {
     //Pour la synchro rdf
     if ($pmb_synchro_rdf) {
         require_once $class_path . "/synchro_rdf.class.php";
         $synchro_rdf = new synchro_rdf();
         if ($serial_id) {
             $synchro_rdf->delRdf($serial_id, 0);
         }
     }
     $serial = new serial($serial_id);
     $update_result = $serial->update($table, $req_notice_date_is_new);
 } else {
     error_message_history($msg["notice_champs_perso"], $p_perso->error_message, 1);
     exit;
 }
 // autorité personnalisées
 $authperso = new authperso_notice($serial_id);
 $authperso->save_form();
 // vignette de la notice uploadé dans un répertoire
 if ($_FILES['f_img_load']['name'] && $pmb_notice_img_folder_id) {
     $poids_fichier_max = 1024 * 1024;
     //Limite la taille de l'image à 1 Mo
     $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)) {
Example #11
0
 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;
     $new_notice = 0;
     $notice_retour = 0;
     $long_maxi = mysql_field_len(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 = mysql_query($sql_rech) or die("Couldn't select notice ! = " . $sql_rech);
         if (mysql_num_rows($sql_result_rech) == 0) {
             $new_notice = 1;
         } else {
             $new_notice = 0;
             $lu = 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 = mysql_query($sql_ins) or die("Couldn't insert into table notices : " . $sql_ins);
     $notice_retour = 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 = 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 = 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 = 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 = @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 = @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 = @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 = @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 = "";
     }
     // 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);
     mysql_query("update notices set signature='{$val}' where notice_id=" . $notice_retour, $dbh);
     //Documents numériques
     foreach ($this->doc_nums as $doc_num) {
         if (!$doc_num['a']) {
             continue;
         }
         if ($doc_num['__nodownload__']) {
             explnum_add_url($notice_retour, $doc_num['b'], $doc_num['a']);
         } else {
             explnum_add_from_url($notice_retour, $doc_num['b'], $doc_num['a'], true, $this->source_id, $doc_num['f'], $doc_num['p']);
         }
     }
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         $synchro_rdf = new synchro_rdf();
     }
     //Si on catalogue un article on recrée l'arborescence
     global $biblio_notice;
     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 . "'";
             mysql_query($req_art, $dbh);
             $req = "update bulletins set bulletin_notice='" . $this->perio_id . "' where bulletin_id='" . $this->bull_id . "'";
             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 . "'";
             mysql_query($req_art, $dbh);
             //synchro_rdf
             if ($pmb_synchro_rdf) {
                 $synchro_rdf->addRdf(0, $this->bull_id);
             }
         }
     }
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         $synchro_rdf->addRdf($notice_retour, 0);
     }
     $retour = array($new_notice, $notice_retour);
     return $retour;
 }
Example #12
0
<?php

// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: serial_form.inc.php,v 1.8 2009-03-13 16:36:15 dbellamy Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
//verification des droits de modification notice
$acces_m = 1;
if ($id != 0 && $gestion_acces_active == 1 && $gestion_acces_user_notice == 1) {
    require_once "{$class_path}/acces.class.php";
    $ac = new acces();
    $dom_1 = $ac->setDomain(1);
    $acces_m = $dom_1->getRights($PMBuserid, $id, 8);
}
if ($acces_m == 0) {
    error_message('', htmlentities($dom_1->getComment('mod_seri_error'), ENT_QUOTES, $charset), 1, '');
} else {
    // affichage d'un form pour création, modification d'un périodique
    if (!$id) {
        // pas d'id, c'est une création
        echo str_replace('!!page_title!!', $msg[4000] . $msg[1003] . $msg[4003], $serial_header);
    } else {
        echo str_replace('!!page_title!!', $msg[4000] . $msg[1003] . $msg[4004], $serial_header);
    }
    $mySerial = new serial($id);
    echo $mySerial->do_form();
}
Example #13
0
 $nberrors = $p_perso->check_submited_fields();
 //Pour la synchro rdf
 if ($pmb_synchro_rdf) {
     require_once $class_path . "/synchro_rdf.class.php";
     $synchro_rdf = new synchro_rdf();
     if ($analysis_id) {
         $synchro_rdf->delRdf($analysis_id, 0);
     }
 }
 //Traitement des périos et bulletins
 global $perio_type, $bull_type;
 global $f_perio_new, $f_perio_new_issn;
 global $f_bull_new_num, $f_bull_new_date, $f_bull_new_mention, $f_bull_new_titre;
 //Perios
 if ($perio_type == 'insert_new' && !$serial_id) {
     $new_serial = new serial();
     $values = array();
     $values['tit1'] = $f_perio_new;
     $values['code'] = $f_perio_new_issn;
     $values['niveau_biblio'] = "s";
     $values['niveau_hierar'] = "1";
     $serial_id = $new_serial->update($values);
     if ($pmb_synchro_rdf) {
         $synchro_rdf->addRdf($serial_id, 0);
     }
 }
 //Bulletin
 if ($bull_type == 'insert_new' && !$bul_id) {
     $req = "insert into bulletins set bulletin_numero='" . $f_bull_new_num . "',\n\t\t\t  mention_date='" . $f_bull_new_mention . "',\n\t\t\t  date_date='" . $f_bull_new_date . "',\n\t\t\t  bulletin_titre='" . $f_bull_new_titre . "',\n\t\t\t  bulletin_notice='" . $serial_id . "'";
     pmb_mysql_query($req, $dbh);
     $bul_id = pmb_mysql_insert_id();
Example #14
0
function import_new_notice_suite()
{
    global $dbh;
    global $notice_id;
    global $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;
    global $bulletin_ex;
    //Cas des périodiques
    if (is_array($info_464)) {
        $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_464[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_464[0]['v']) . "' and  mention_date='" . addslashes($info_464[0]['d']) . "' 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 bulltin
                $info = array();
                $bulletin = new bulletinage("", $chapeau_id);
                $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']);
                $info['bul_no'] = addslashes($info_464[0]['v']);
                $info['bul_date'] = addslashes($info_464[0]['d']);
                if (!$info_464[0]['e']) {
                    if ($info_904[0]) {
                        $info['date_date'] = $info_904[0];
                    }
                } else {
                    $info['date_date'] = $info_464[0]['e'];
                }
                $bulletin_id = $bulletin->update($info);
            }
        } else {
            //Si non, création notice chapeau et bulletin
            $chapeau = new serial();
            $info = array();
            $info['tit1'] = addslashes($info_464[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'] = addslashes("Bulletin N°" . $info_464[0]['v']);
            $info['bul_no'] = addslashes($info_464[0]['v']);
            $info['bul_date'] = addslashes($info_464[0]['d']);
            if (!$info_464[0]['e']) {
                if ($info_904[0]) {
                    $info['date_date'] = $info_904[0];
                }
            } else {
                $info['date_date'] = $info_464[0]['e'];
            }
            $bulletin_id = $bulletin->update($info);
        }
        //Notice objet ?
        if ($info_464[0]['z'] == 'objet') {
            //Supression de la notice
            $requete = "delete from notices where notice_id={$notice_id}";
            mysql_query($requete);
            $bulletin_ex = $bulletin_id;
        } else {
            //Passage de la notice en article
            $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($info_464[0]['d']) . "', npages='" . addslashes($info_464[0]['p']) . "', 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);
            $bulletin_ex = $bulletin_id;
        }
    } else {
        $bulletin_ex = 0;
    }
    //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 = trim($info_606_a[$i][$j]);
            //Recherche du terme
            $requete = "SELECT id_noeud,num_renvoi_voir from noeuds JOIN categories ON (noeuds.id_noeud = categories.num_noeud) where categories.libelle_categorie = '" . addslashes($descripteur) . "' ";
            $resultat = mysql_query($requete);
            if (mysql_num_rows($resultat) == 1) {
                $categ_id = mysql_result($resultat, 0, 0);
                if (mysql_result($resultat, 0, 1)) {
                    $categ_id = mysql_result($resultat, 0, 1);
                }
                $requete = "INSERT IGNORE INTO notices_categories (notcateg_notice,num_noeud,ordre_categorie) VALUES({$notice_id},{$categ_id},{$ordre_categ})";
                mysql_query($requete);
                $ordre_categ++;
            } else {
                $unknown_desc[] = $descripteur;
            }
        }
    }
    if (count($unknown_desc)) {
        $mots_cles = implode($pmb_keyword_sep, $unknown_desc);
        $requete = "UPDATE notices SET index_l=IF(index_l != '',CONCAT(index_l,'" . $pmb_keyword_sep . "','" . addslashes($mots_cles) . "'),'" . addslashes($mots_cles) . "'), index_matieres=IF(index_matieres != '',CONCAT(index_matieres,' ','" . addslashes(strip_empty_words($mots_cles)) . "'),'" . addslashes(strip_empty_words($mots_cles)) . "') WHERE notice_id='" . $notice_id . "'";
        mysql_query($requete);
    }
    //Thème
    if (count($info_900)) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=1";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") {
            $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=1";
            $resultat = mysql_query($requete);
            $max = @mysql_result($resultat, 0, 0);
            $n = $max + 1;
            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=1";
                    $resultat = mysql_query($requete);
                    if (mysql_num_rows($resultat)) {
                        $value = mysql_result($resultat, 0, 0);
                    } else {
                        $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(1,{$n},'" . addslashes($info_900[$i][$j]) . "')";
                        mysql_query($requete);
                        $value = $n;
                        $n++;
                    }
                    $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(1,{$notice_id},{$value})";
                    mysql_query($requete);
                }
            }
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=1 ou il n\\'est pas de type liste entier : le 900 n\\'est donc pas repris (Thème)') ");
        }
    }
    //Genres
    if (count($info_901)) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=2";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") {
            $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=2";
            $resultat = mysql_query($requete);
            $max = @mysql_result($resultat, 0, 0);
            $n = $max + 1;
            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=2";
                    $resultat = mysql_query($requete);
                    if (mysql_num_rows($resultat)) {
                        $value = mysql_result($resultat, 0, 0);
                    } else {
                        $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(2,{$n},'" . addslashes($info_901[$i][$j]) . "')";
                        mysql_query($requete);
                        $value = $n;
                        $n++;
                    }
                    $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(2,{$notice_id},{$value})";
                    mysql_query($requete);
                }
            }
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=2 ou il n\\'est pas de type liste entier : le 901 n\\'est donc pas repris (Genres)') ");
        }
    }
    //Discipline
    if (count($info_902)) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=3";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") {
            $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=3";
            $resultat = mysql_query($requete);
            $max = @mysql_result($resultat, 0, 0);
            $n = $max + 1;
            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=3";
                    $resultat = mysql_query($requete);
                    if (mysql_num_rows($resultat)) {
                        $value = mysql_result($resultat, 0, 0);
                    } else {
                        $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(3,{$n},'" . addslashes($info_902[$i][$j]) . "')";
                        mysql_query($requete);
                        $value = $n;
                        $n++;
                    }
                    $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(3,{$notice_id},{$value})";
                    mysql_query($requete);
                }
            }
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=3 ou il n\\'est pas de type liste entier : le 902 n\\'est donc pas repris (Discipline)') ");
        }
    }
    //Type de nature
    if ($info_905[0]) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=6";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") {
            $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=6";
            $resultat = mysql_query($requete);
            $max = @mysql_result($resultat, 0, 0);
            $n = $max + 1;
            $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[0]) . "' and notices_custom_champ=6";
            $resultat = mysql_query($requete);
            if (mysql_num_rows($resultat)) {
                $value = mysql_result($resultat, 0, 0);
            } else {
                $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(6,{$n},'" . addslashes($info_905[0]) . "')";
                mysql_query($requete);
                $value = $n;
                $n++;
            }
            $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(6,{$notice_id},{$value})";
            mysql_query($requete);
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=6 ou il n\\'est pas de type liste entier : le 905 n\\'est donc pas repris (Type de nature)') ");
        }
    }
    //Niveau
    if (count($info_906)) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=7";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") {
            for ($i = 0; $i < count($info_906); $i++) {
                for ($j = 0; $j < count($info_906[$i]); $j++) {
                    $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=7";
                    $resultat = mysql_query($requete);
                    $max = @mysql_result($resultat, 0, 0);
                    $n = $max + 1;
                    $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_906[$i][$j]) . "' and notices_custom_champ=7";
                    $resultat = mysql_query($requete);
                    if (mysql_num_rows($resultat)) {
                        $value = mysql_result($resultat, 0, 0);
                    } else {
                        $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(7,{$n},'" . addslashes($info_906[$i][$j]) . "')";
                        mysql_query($requete);
                        $value = $n;
                        $n++;
                    }
                    $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(7,{$notice_id},{$value})";
                    mysql_query($requete);
                }
            }
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=7 ou il n\\'est pas de type liste entier : le 906 n\\'est donc pas repris (Niveau)') ");
        }
    }
    //Année de péremption
    if ($info_903[0]) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=4";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 2) == "integer") {
            $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(4,{$notice_id},'" . addslashes($info_903[0]) . "')";
            mysql_query($requete);
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=4 ou il n\\'est pas de type entier : le 903 n\\'est donc pas repris (Année de péremption)') ");
        }
    }
    //Date de saisie
    if ($info_904[0]) {
        $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=5";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && mysql_result($res, 0, 2) == "date") {
            $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) values(5,{$notice_id},'" . $info_904[0] . "')";
            mysql_query($requete);
        } else {
            mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=5 ou il n\\'est pas de type date : le 904 n\\'est donc pas repris (Date de saisie)') ");
        }
    }
}
Example #15
0
 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;
 }
Example #16
0
}
echo str_replace('!!page_title!!', $msg[4000] . $msg[1003] . $msg['catalog_serie_suppression'], $serial_header);
//verification des droits de modification notice
$acces_m = 1;
if ($serial_id != 0 && $gestion_acces_active == 1 && $gestion_acces_user_notice == 1) {
    require_once "{$class_path}/acces.class.php";
    $ac = new acces();
    $dom_1 = $ac->setDomain(1);
    $acces_m = $dom_1->getRights($PMBuserid, $serial_id, 8);
}
if ($acces_m == 0) {
    error_message('', htmlentities($dom_1->getComment('mod_seri_error'), ENT_QUOTES, $charset), 1, '');
} else {
    print "<div class=\"row\"><div class=\"msg-perio\">" . $msg['catalog_notices_suppression'] . "</div></div>";
    $requete = "select 1 from pret, exemplaires, bulletins, notices where notice_id='{$serial_id}' and expl_notice=0 ";
    $requete .= "and pret_idexpl=expl_id and expl_bulletin=bulletin_id and bulletin_notice=notice_id";
    $result = @mysql_query($requete);
    if (mysql_num_rows($result)) {
        // gestion erreur pret en cours
        error_message($msg[416], $msg['impossible_perio_del_pret'], 1, "./catalog.php?categ=serials&sub=view&serial_id={$serial_id}");
    } else {
        //suppression du périodique
        $serial = new serial($serial_id);
        if ($pmb_archive_warehouse) {
            serial::save_to_agnostic_warehouse(array(0 => $serial_id), $pmb_archive_warehouse);
        }
        $serial->serial_delete();
        $retour = "./catalog.php?categ=serials";
        print "\n\t\t\t<form class='form-{$current_module}' name=\"dummy\" method=\"post\" action=\"{$retour}\" style=\"display:none\">\n\t\t\t\t<input type=\"hidden\" name=\"id_form\" value=\"{$id_form}\">\n\t\t\t</form>\n\t\t\t<script type=\"text/javascript\">document.dummy.submit();</script>\n\t\t\t";
    }
}
Example #17
0
 function serial_delete()
 {
     global $dbh;
     global $pmb_synchro_rdf, $pmb_notice_img_folder_id;
     $requete = "SELECT bulletin_id,num_notice from bulletins WHERE bulletin_notice='" . $this->serial_id . "' ";
     $myQuery1 = pmb_mysql_query($requete, $dbh);
     if ($myQuery1 && pmb_mysql_num_rows($myQuery1)) {
         while ($bul = pmb_mysql_fetch_object($myQuery1)) {
             $bulletin = new bulletinage($bul->bulletin_id);
             $bulletin->delete();
         }
     }
     //Suppression de la vignette de la notice si il y en a une d'uploadée
     if ($pmb_notice_img_folder_id) {
         $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);
             $img = $rep->repertoire_path . "img_" . $this->serial_id;
             @unlink($img);
         }
     }
     if ($pmb_synchro_rdf) {
         $synchro_rdf = new synchro_rdf();
         $synchro_rdf->delRdf($this->serial_id, 0);
     }
     // élimination des docs numériques
     $req_explNum = "select explnum_id from explnum where explnum_notice='" . $this->serial_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();
     }
     // suppression des vedettes
     serial::delete_vedette_links($this->serial_id);
     $requete = "DELETE FROM responsability WHERE responsability_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($requete, $dbh);
     // suppression des entrées dans les caddies
     $requete = "delete from caddie_content using caddie, caddie_content where caddie_id=idcaddie and type='NOTI' and object_id='" . $this->serial_id . "' ";
     @pmb_mysql_query($requete, $dbh);
     //élimination des champs persos
     $p_perso = new parametres_perso("notices");
     $p_perso->delete_values($this->serial_id);
     // suppression des audits
     audit::delete_audit(AUDIT_NOTICE, $this->serial_id);
     // suppression des categories
     $rqt_del = "delete from notices_categories where notcateg_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($rqt_del, $dbh);
     // suppression des bannettes
     $rqt_del = "delete from bannette_contenu where num_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($rqt_del, $dbh);
     // suppression des tags
     $rqt_del = "delete from tags where num_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($rqt_del, $dbh);
     // suppression des avis
     $rqt_del = "delete from avis where num_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($rqt_del, $dbh);
     //suppression des langues
     $query = "delete from notices_langues where num_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($query, $dbh);
     // suppression index global
     $query = "delete from notices_global_index where num_notice='" . $this->serial_id . "' ";
     @pmb_mysql_query($query, $dbh);
     // Effacement des occurences de la notice ds la table notices_mots_global_index :
     $requete = "DELETE FROM notices_mots_global_index WHERE id_notice=" . $this->serial_id;
     @pmb_mysql_query($requete, $dbh);
     // Effacement des occurences de la notice ds la table notices_fields_global_index :
     $requete = "DELETE FROM notices_fields_global_index WHERE id_notice=" . $this->serial_id;
     @pmb_mysql_query($requete, $dbh);
     //Suppression de la reference a la notice dans la table suggestions
     $query = "UPDATE suggestions set num_notice = 0 where num_notice=" . $this->serial_id;
     @pmb_mysql_query($query, $dbh);
     //Suppression de la reference a la notice dans la table lignes_actes
     $requete = "UPDATE lignes_actes set num_produit=0, type_ligne=0 where num_produit='" . $this->serial_id . "' and type_ligne in ('1','5') ";
     @pmb_mysql_query($requete, $dbh);
     // liens entre notices
     $requete = "DELETE FROM notices_relations WHERE linked_notice='" . $this->serial_id . "' OR num_notice='" . $this->serial_id . "' ";
     pmb_mysql_query($requete, $dbh);
     //suppression des droits d'acces user_notice
     $requete = "delete from acces_res_1 where res_num=" . $this->serial_id;
     @pmb_mysql_query($requete, $dbh);
     //suppression des droits d'acces empr_notice
     $requete = "delete from acces_res_2 where res_num=" . $this->serial_id;
     @pmb_mysql_query($requete, $dbh);
     // suppression des modeles
     $requete = "SELECT modele_id from abts_modeles WHERE num_notice='" . $this->serial_id . "' ";
     $result_modele = pmb_mysql_query($requete, $dbh);
     while ($modele = pmb_mysql_fetch_object($result_modele)) {
         $mon_modele = new abts_modele($modele->modele_id);
         $mon_modele->delete();
     }
     // Suppression des etats de collections
     $collstate = new collstate(0, $this->serial_id);
     $collstate->delete();
     //si intégré depuis une source externe, on suprrime aussi la référence
     $query = "delete from notices_externes where num_notice=" . $this->serial_id;
     @pmb_mysql_query($query, $dbh);
     // on supprime la notice
     $requete = "DELETE FROM notices WHERE notice_id='" . $this->serial_id . "' ";
     pmb_mysql_query($requete, $dbh);
     $result = pmb_mysql_affected_rows($dbh);
     //Suppression dans les listes de lecture partagées
     $requete = "SELECT id_liste, notices_associees from opac_liste_lecture";
     $res = pmb_mysql_query($requete, $dbh);
     $id_tab = array();
     while ($notices = pmb_mysql_fetch_object($res)) {
         $id_tab = explode(',', $notices->notices_associees);
         for ($i = 0; $i < sizeof($id_tab); $i++) {
             if ($id_tab[$i] == $this->serial_id) {
                 unset($id_tab[$i]);
             }
         }
         $requete = "UPDATE opac_liste_lecture set notices_associees='" . addslashes(implode(',', $id_tab)) . "' where id_liste='" . $notices->id_liste . "'";
         pmb_mysql_query($requete, $dbh);
     }
     $req = "delete from notices_authperso where notice_authperso_notice_num=" . $this->serial_id;
     pmb_mysql_query($req, $dbh);
     return $result;
 }
function import_new_notice_suite()
{
    global $dbh;
    global $notice_id;
    global $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;
    global $bulletin_ex;
    //Cas des périodiques
    if (is_array($info_464)) {
        $requete = "select * from notices where notice_id={$notice_id}";
        $resultat = pmb_mysql_query($requete);
        $r = pmb_mysql_fetch_object($resultat);
        //Notice chapeau existe-t-elle ?
        $requete = "select notice_id from notices where tit1='" . addslashes($info_464[0]['t']) . "' and niveau_hierar='1' and niveau_biblio='s'";
        $resultat = pmb_mysql_query($requete);
        if (@pmb_mysql_num_rows($resultat)) {
            //Si oui, récupération id
            $chapeau_id = pmb_mysql_result($resultat, 0, 0);
            //Bulletin existe-t-il ?
            $requete = "select bulletin_id from bulletins where bulletin_numero='" . addslashes($info_464[0]['v']) . "' and  mention_date='" . addslashes($info_464[0]['d']) . "' and bulletin_notice={$chapeau_id}";
            //$requete="select bulletin_id from bulletins where bulletin_numero='".addslashes($info_464[0]['v'])."' and bulletin_notice=$chapeau_id";
            $resultat = pmb_mysql_query($requete);
            if (@pmb_mysql_num_rows($resultat)) {
                //Si oui, récupération id bulletin
                $bulletin_id = pmb_mysql_result($resultat, 0, 0);
            } else {
                //Si non, création bulltin
                $info = array();
                $bulletin = new bulletinage("", $chapeau_id);
                $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']);
                $info['bul_no'] = addslashes($info_464[0]['v']);
                $info['bul_date'] = addslashes($info_464[0]['d']);
                if (!$info_464[0]['e']) {
                    $date_date = explode("/", $info_464[0]['d']);
                    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];
                        }
                    }
                } else {
                    $info['date_date'] = $info_464[0]['e'];
                }
                $bulletin_id = $bulletin->update($info);
            }
        } else {
            //Si non, création notice chapeau et bulletin
            $chapeau = new serial();
            $info = array();
            $info['tit1'] = addslashes($info_464[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'] = addslashes("Bulletin N°" . $info_464[0]['v']);
            $info['bul_no'] = addslashes($info_464[0]['v']);
            $info['bul_date'] = addslashes($info_464[0]['d']);
            if (!$info_464[0]['e']) {
                $date_date = explode("/", $info_464[0]['d']);
                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];
                    }
                }
            } else {
                $info['date_date'] = $info_464[0]['e'];
            }
            $bulletin_id = $bulletin->update($info);
        }
        //Notice objet ?
        if ($info_464[0]['z'] == 'objet') {
            //Supression de la notice
            $requete = "delete from notices where notice_id={$notice_id}";
            pmb_mysql_query($requete);
            $bulletin_ex = $bulletin_id;
        } else {
            //Passage de la notice en article
            $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($info_464[0]['d']) . "', npages='" . addslashes($info_464[0]['p']) . "', date_parution='" . $info['date_date'] . "' where notice_id={$notice_id}";
            pmb_mysql_query($requete);
            $requete = "insert into analysis (analysis_bulletin,analysis_notice) values({$bulletin_id},{$notice_id})";
            pmb_mysql_query($requete);
            $bulletin_ex = $bulletin_id;
        }
    } else {
        $bulletin_ex = 0;
    }
    //Traitement du thésaurus
    $unknown_desc = array();
    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) values({$notice_id},{$categ_id})";
                pmb_mysql_query($requete);
            } else {
                $unknown_desc[] = $descripteur;
            }
        }
        if ($unknown_desc) {
            $mots_cles = implode($pmb_keyword_sep, $unknown_desc);
            $requete = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes(strip_empty_words($mots_cles)) . " ' where notice_id={$notice_id}";
            pmb_mysql_query($requete);
        }
    }
}
function genere_perio($perio_info)
{
    $search = "select notice_id from notices where tit1 LIKE '" . addslashes($perio_info['titre']) . "' and niveau_biblio = 's' and niveau_hierar = '1'";
    $res = pmb_mysql_query($search);
    if (pmb_mysql_num_rows($res) == 0) {
        //il existe pas, faut le créer
        $chapeau = new serial();
        $info = array();
        $info['tit1'] = addslashes($perio_info['titre']);
        $info['niveau_biblio'] = 's';
        $info['niveau_hierar'] = '1';
        $info['typdoc'] = 'p';
        $chapeau->update($info);
        $perio_id = $chapeau->serial_id;
    } else {
        $perio_id = pmb_mysql_result($res, 0, 0);
    }
    return $perio_id;
}
Example #20
0
$can_write = utility::havePrivilege('serial_control', 'w');
if (!$can_read) {
    die('<div class="errorBox">' . __('You are not authorized to view this section') . '</div>');
}
// page title
$page_title = 'Kardex List';
$serialID = 0;
if (isset($_GET['serialID'])) {
    $serialID = (int) $_GET['serialID'];
}
if (isset($_POST['serialID'])) {
    $serialID = (int) $_POST['serialID'];
}
// start content buffering
ob_start();
$serial = new serial($dbs, $serialID);
if (isset($_POST['saveKardexes'])) {
    // save kardexes
    $serial->saveKardexes();
    utility::jsAlert(__('Kardex data updated!'));
} else {
    if (isset($_POST['remove'])) {
        // remove kardex
        $removeID = (int) $_POST['remove'];
        $removed = $serial->deleteKardex($removeID);
        if ($removed) {
            utility::jsAlert(__('Kardex data deleted!'));
        }
    }
}
// view kardexes list
// +-------------------------------------------------+
// $Id: serial_replace.inc.php,v 1.2 2009-03-13 16:36:16 dbellamy Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
//verification des droits de modification notice
$acces_m = 1;
if ($gestion_acces_active == 1 && $gestion_acces_user_notice == 1) {
    require_once "{$class_path}/acces.class.php";
    $ac = new acces();
    $dom_1 = $ac->setDomain(1);
    $acces_m = $dom_1->getRights($PMBuserid, $serial_id, 8);
}
if ($acces_m == 0) {
    error_message('', htmlentities($dom_1->getComment('mod_seri_error'), ENT_QUOTES, $charset), 1, '');
} else {
    print pmb_bidi("<h1>{$msg['catal_rep_per_h1']}</h1>");
    if (!$by) {
        $perio = new serial($serial_id);
        $perio->replace_form();
    } else {
        // routine de remplacement
        $perio = new serial($serial_id);
        $rep_result = $perio->replace($by);
        if (!$rep_result) {
            print pmb_bidi("<div class='row'><div class='msg-perio'>" . $msg["maj_encours"] . "</div></div>\n\t\t\t\t\t\t<script type=\"text/javascript\">document.location='./catalog.php?categ=serials&sub=view&serial_id={$by}'</script>");
        } else {
            error_message($msg[132], $rep_result, 1, "./catalog.php?categ=serials&sub=view&serial_id={$id}");
        }
    }
}