imagedestroy($dest); } else { imagepng($img, $filename_output); } imagedestroy($img); $thumbnail_url = $opac_url_base . "getimage.php?noticecode=&vigurl=¬ice_id=" . $id; $req = "update notices set thumbnail_url='" . $thumbnail_url . "' where notice_id ='" . $id . "'"; $res = pmb_mysql_query($req, $dbh); } } } } // Traitement des titres uniformes if ($pmb_use_uniform_title) { $ntu = new tu_notice($id); $ntu->update($titres_uniformes); } //traitement des droits acces user_notice if ($gestion_acces_active == 1 && $gestion_acces_user_notice == 1) { if ($sav_id) { $dom_1->storeUserRights(1, $id, $res_prf, $chk_rights, $prf_rad, $r_rad); } else { $dom_1->storeUserRights(0, $id, $res_prf, $chk_rights, $prf_rad, $r_rad); } } //traitement des droits acces empr_notice if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) { $dom_2 = $ac->setDomain(2); if ($sav_id) { $dom_2->storeUserRights(1, $id, $res_prf, $chk_rights, $prf_rad, $r_rad); } else {
function update_in_database($id_notice = 0) { global $dbh; global $pmb_synchro_rdf; $new_notice = 2; $notice_retour = $id_notice; if (!$id_notice) { $retour = array(2, 0); return $retour; } //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf = new synchro_rdf(); $synchro_rdf->delRdf($notice_retour, 0); } // traitement des titres uniformes global $pmb_use_uniform_title; if ($pmb_use_uniform_title) { if (count($this->titres_uniformes)) { $ntu = new tu_notice($id_notice); $ntu->update($this->titres_uniformes); } } 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]); } } if ($this->collection["id"]) { $collection_id = $this->collection["id"]; } else { $this->collection['parent'] = $editor_ids[0]; $collection_id = collection::import($this->collection); } if ($this->subcollection["id"]) { $subcollection_id = $this->subcollection["id"]; } else { $this->subcollection['coll_parent'] = $collection_id; $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; } $sql_ins = "update notices set\n\t\t\ttypdoc \t='" . $this->document_type . "',\n\t\t\tcode \t ='" . $this->isbn . "',\t \n\t\t\ttit1 ='" . $this->titles[0] . "', \n\t\t\ttit2 ='" . $this->titles[1] . "', \n\t\t\ttit3 ='" . $this->titles[2] . "', \n\t\t\ttit4 ='" . $this->titles[3] . "', \n\t\t\ttparent_id ='" . $serie_id . "', \n\t\t\ttnvol ='" . $this->nbr_in_serie . "', \n\t\t\ted1_id =" . $editor_ids[0] . " , \n\t\t\ted2_id =" . $editor_ids[1] . " , \n\t\t\tyear ='" . $this->year . "', \n\t\t\tnpages ='" . $this->page_nbr . "', \n\t\t\till ='" . $this->illustration . "', \n\t\t\tsize ='" . $this->size . "', \n\t\t\taccomp ='" . $this->accompagnement . "', \n\t\t\tcoll_id =" . $collection_id . " , \n\t\t\tsubcoll_id =" . $subcollection_id . " , \n\t\t\tnocoll ='" . $this->nbr_in_collection . "', \n\t\t\tmention_edition ='" . $this->mention_edition . "', \n\t\t\tn_gen ='" . $this->general_note . "', \n\t\t\tn_contenu ='" . $this->content_note . "', \n\t\t\tn_resume ='" . $this->abstract_note . "', \n\t\t\tindexint ='" . $this->internal_index . "', \n\t\t\tstatut\t\t\t\t\t='" . $this->statut . "',\n\t\t\tcommentaire_gestion\t\t='" . $this->commentaire_gestion . "',\n\t\t\tindexation_lang\t\t\t='" . $this->indexation_lang . "',\n\t\t\tthumbnail_url\t\t\t='" . $this->thumbnail_url . "',\n\t\t\tindex_l ='" . clean_tags($this->free_index) . "', \n\t\t\tniveau_biblio ='" . $this->bibliographic_level . "', \n\t\t\tniveau_hierar ='" . $this->hierarchic_level . "', \n\t\t\tlien ='" . $this->link_url . "', \n\t\t\teformat ='" . $this->link_format . "', \n\t\t\torigine_catalogage ='" . $this->orinot_id . "', \n\t\t\tprix ='" . $this->prix . "',\n\t\t\tdate_parution \t\t\t='" . $date_parution_z3950 . "' \n\t\t\twhere notice_id='{$id_notice}' "; //echo "<pre>"; //print_r($this->aut_array); //echo "</pre>"; //echo $sql_ins."<br />"; //echo "<pre>"; //print_r($this->categories); //echo "</pre>"; //exit; $sql_result_ins = pmb_mysql_query($sql_ins) or die("Couldn't update notices : " . $sql_ins); $notice_retour = $id_notice; audit::insert_modif(AUDIT_NOTICE, $id_notice); // 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 n'existe pas 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 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 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 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('recup_noticeunimarc_suite')) { //Suppression des champs persos $requete = "delete from notices_custom_values where notices_custom_origine=" . $notice_retour; @pmb_mysql_query($requete); $notice_id = $notice_retour; z_recup_noticeunimarc_suite($notice_org); z_import_new_notice_suite(); } // 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); //Documents numériques foreach ($this->doc_nums as $doc_num) { if (!$doc_num["a"]) { continue; } explnum_add_from_url($notice_retour, $this->bull_id, $doc_num["b"], $doc_num["a"], false, $this->source_id, $doc_num["f"], '', $doc_num["s"]); } //synchro_rdf if ($pmb_synchro_rdf) { $synchro_rdf->addRdf($notice_retour, 0); } $retour = array($new_notice, $notice_retour); return $retour; }
static function getAutomaticTu($notice) { global $dbh, $charset, $opac_enrichment_bnf_sparql; if (!$opac_enrichment_bnf_sparql) { return 0; } $requete = "select code, responsability_author from notices left join responsability on (responsability_notice={$notice} and responsability_type=0)\n\t\t\tleft join notices_titres_uniformes on notice_id=ntu_num_notice where notice_id={$notice} and ntu_num_notice is null"; $resultat = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($resultat, $dbh)) { $code = pmb_mysql_result($resultat, 0, 0, $dbh); $id_author = pmb_mysql_result($resultat, 0, 1, $dbh); } else { $code = ""; } $id_tu = 0; if (isISBN($code)) { $uri = titre_uniforme::get_data_bnf_uri($code); if ($uri) { //Recherche du titre uniforme déjà existant ? $requete = "select tu_id from titres_uniformes where tu_databnf_uri='" . addslashes($uri) . "'"; $resultat = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($resultat, $dbh)) { $id_tu = pmb_mysql_result($resultat, 0, 0, $dbh); } else { //Interrogation de data.bnf pour obtenir les infos ! $configbnf = array('remote_store_endpoint' => 'http://data.bnf.fr/sparql'); $storebnf = ARC2::getRemoteStore($configbnf); $sparql = "\n\t\t\t\t\t\tPREFIX dc: <http://purl.org/dc/terms/>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tSELECT ?title ?date ?description WHERE {\n\t\t\t\t\t\t <" . $uri . "> dc:title ?title.\n\t\t\t\t\t\t OPTIONAL { <" . $uri . "> dc:date ?date. }\n\t\t\t\t\t\t OPTIONAL { <" . $uri . "> dc:description ?description. }\n\t\t\t\t\t\t}"; $rows = $storebnf->query($sparql, 'rows'); // On vérifie qu'il n'y a pas d'erreur sinon on stoppe le programme et on renvoi une chaine vide $err = $storebnf->getErrors(); if (!$err) { $value = array("name" => encoding_normalize::charset_normalize($rows[0]['title'], "utf-8"), "num_author" => $id_author, "date" => encoding_normalize::charset_normalize($rows[0]['date'], "utf-8"), "comment" => encoding_normalize::charset_normalize($rows[0]['description'], "utf-8"), "databnf_uri" => $uri); $id_tu = titre_uniforme::import($value); } } } } if ($id_tu) { $titres_uniformes = array(array("num_tu" => $id_tu)); $ntu = new tu_notice($notice); $ntu->update($titres_uniformes); } return $id_tu; }