function insert_authority_infos($authority_number, $type, $id_origin_authority, $authority_infos = array()) { global $opac_enrichment_bnf_sparql; //on a un numéro d'autorité, on regarde si on l'a déjà rencontré $num_authority = $authority_infos['id']; $query = "select id_authority_source,num_authority from authorities_sources where authority_number = '" . $authority_number . "' and num_origin_authority='" . $id_origin_authority . "' and authority_type = '" . $type . "'"; $result = pmb_mysql_query($query) or die("can't select authorities_sources :" . $query); if (pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_object($result); $num_authority = $row->num_authority; $num_authority_source = $row->id_authority_source; // on cherche la préférence... dès fois que... $query = "select id_authority_source, num_authority from authorities_sources where authority_number = '" . $authority_number . "' and authority_type = '" . $type . "' and authority_favorite = 1"; $result = pmb_mysql_query($query) or die("can't select authorities_sources :" . $query); if (pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_object($result); $num_authority = $row->num_authority; $num_authority_source = $row->id_authority_source; } } else { // on importe l'autorité dans la base si elle n'a pas d'id if ($num_authority == 0) { switch ($type) { case "author": $num_authority = auteur::import($authority_infos); break; case "uniform_title": $num_authority = titre_uniforme::import($authority_infos); break; case "category": $num_authority = category::import($authority_infos); break; case "collection": $num_authority = collection::import($authority_infos); break; case "subcollection": $num_authority = subcollection::import($authority_infos); break; case "serie": break; } } // on intègre la source de l'autorité $query = "insert into authorities_sources set\n\t\t\tnum_authority = '{$num_authority}',\n\t\t\tauthority_number = '" . $authority_number . "',\n\t\t\tauthority_type = '{$type}',\n\t\t\tnum_origin_authority = " . $id_origin_authority . ",\n\t\t\timport_date = now()"; pmb_mysql_query($query) or die("can't insert authorities_sources :" . $query); $num_authority_source = pmb_mysql_insert_id(); //////////////////////////////////////////////////////////////// if ($opac_enrichment_bnf_sparql && $type == 'author') { auteur::author_enrichment($num_authority); } } return $num_authority; }
static function import($value, $from_form = 0) { global $dbh; // Si vide on sort if (trim($value['name']) == '') { return FALSE; } if (!$from_form) { $value['name'] = addslashes($value['name']); $value['num_author'] = addslashes($value['num_author']); $value['form'] = addslashes($value['form']); $value['date'] = addslashes($value['date']); $value['subject'] = addslashes($value['subject']); $value['place'] = addslashes($value['place']); $value['history'] = addslashes($value['history']); $value['characteristic'] = addslashes($value['characteristic']); $value['intended_termination'] = addslashes($value['intended_termination']); $value['intended_audience'] = addslashes($value['intended_audience']); $value['context'] = addslashes($value['context']); $value['equinox'] = addslashes($value['equinox']); $value['coordinates'] = addslashes($value['coordinates']); $value['tonalite'] = addslashes($value['tonalite']); $value['comment'] = addslashes($value['comment']); $value['databnf_uri'] = addslashes($value['databnf_uri']); for ($i = 0; $i < count($value['distrib']); $i++) { $value['distrib'][$i] = addslashes($value['distrib'][$i]); } for ($i = 0; $i < count($value['ref']); $i++) { $value['ref'][$i] = addslashes($value['ref'][$i]); } for ($i = 0; $i < count($value['subdiv']); $i++) { $value['subdiv'][$i] = addslashes($value['subdiv'][$i]); } for ($i = 0; $i < count($value['authors']); $i++) { // les champs auteurs sont addslashes dans import auteur $value['authors'][$i]['type'] = addslashes($value['authors'][$i]['type']); $value['authors'][$i]['fonction'] = addslashes($value['authors'][$i]['fonction']); } } $marc_key = new marc_list("music_key"); $marc_form = new marc_list("music_form"); $flag_form = false; $flag_key = false; foreach ($marc_form->table as $value_form => $libelle_form) { if ($value_form == $value['form']) { $flag_form = true; } } foreach ($marc_key->table as $value_key => $libelle_key) { if ($value_key == $value['tonalite']) { $flag_key = true; } } if (count($value['authors'])) { for ($i = 0; $i < count($value['authors']); $i++) { if ($value['authors'][$i]['id']) { $tu_auteur = new auteur($value['authors'][$i]['id']); if (!$tu_auteur->id) { // id non valide $value['authors'][$i]['id'] = 0; } } if (!$value['authors'][$i]['id']) { // création ou déjà existant. auteur::import addslashes les champs $value['authors'][$i]['id'] = auteur::import($value['authors'][$i]); } } } // $value déjà addslashes plus haut -> 1 $titre = titre_uniforme::import_tu_exist($value, 1); if ($titre) { return $titre; } $requete = "INSERT INTO titres_uniformes SET "; $requete .= "tu_name='" . $value["name"] . "', "; $requete .= "tu_num_author='" . $value["num_author"] . "', "; $requete .= (!$flag_form ? "tu_forme='" : "tu_forme_marclist='") . $value['form'] . "', "; $requete .= "tu_date='" . $value["date"] . "', "; $requete .= "tu_sujet='" . $value["subject"] . "', "; $requete .= "tu_lieu='" . $value["place"] . "', "; $requete .= "tu_histoire='" . $value["history"] . "', "; $requete .= "tu_caracteristique='" . $value["characteristic"] . "', "; $requete .= "tu_completude='" . $value["intended_termination"] . "', "; $requete .= "tu_public='" . $value["intended_audience"] . "', "; $requete .= "tu_contexte='" . $value["context"] . "', "; $requete .= "tu_equinoxe='" . $value["equinox"] . "', "; $requete .= "tu_coordonnees='" . $value["coordinates"] . "', "; $requete .= (!$flag_key ? "tu_tonalite='" : "tu_tonalite_marclist='") . $value['tonalite'] . "', "; $requete .= "tu_comment='" . $value["comment"] . "', "; $requete .= "tu_databnf_uri='" . $value["databnf_uri"] . "' "; // insertion du titre uniforme et mise à jour de l'index tu if (pmb_mysql_query($requete, $dbh)) { $tu_id = pmb_mysql_insert_id(); } else { return FALSE; } if (count($value['authors'])) { $ordre = 0; $rqt_ins = "INSERT INTO responsability_tu (responsability_tu_author_num, responsability_tu_num, responsability_tu_fonction, responsability_tu_type, responsability_tu_ordre) VALUES "; foreach ($value['authors'] as $author) { if ($author['id']) { $rqt = $rqt_ins . " ('" . $author['id'] . "','" . $tu_id . "','" . $author['fonction'] . "','" . $author['type'] . "', {$ordre}) "; $res_ins = @pmb_mysql_query($rqt); $ordre++; } } } // Distribution instrumentale et vocale (pour la musique) for ($i = 0; $i < count($value['distrib']); $i++) { $requete = "INSERT INTO tu_distrib SET\n\t\t\tdistrib_num_tu='{$tu_id}',\n\t\t\tdistrib_name='" . $value['distrib'][$i] . "',\n\t\t\tdistrib_ordre='{$i}' "; pmb_mysql_query($requete, $dbh); } // Référence numérique (pour la musique) for ($i = 0; $i < count($value['ref']); $i++) { $requete = "INSERT INTO tu_ref SET\n\t\t\tref_num_tu='{$tu_id}',\n\t\t\tref_name='" . $value['ref'][$i] . "',\n\t\t\tref_ordre='{$i}' "; pmb_mysql_query($requete, $dbh); } // Subdivision de forme for ($i = 0; $i < count($value['subdiv']); $i++) { $requete = "INSERT INTO tu_subdiv SET\n\t\t\tsubdiv_num_tu='{$tu_id}',\n\t\t\tsubdiv_name='" . $value['subdiv'][$i] . "',\n\t\t\tsubdiv_ordre='{$i}' "; pmb_mysql_query($requete, $dbh); } audit::insert_creation(AUDIT_TITRE_UNIFORME, $tu_id); //update authority informations $authority = new authority(0, $tu_id, AUT_TABLE_TITRES_UNIFORMES); $authority->set_num_statut($value["statut"]); $authority->update(); // mise à jour du champ index du titre uniforme if ($tu_id) { titre_uniforme::update_index_tu($tu_id); titre_uniforme::tu_enrichment($tu_id); } return $tu_id; }
function list_authors($cle, $author_list, $nav_bar, $type_autorite) { global $authors_list_tmpl; global $charset; $authors_list_tmpl = str_replace("!!cle!!", htmlentities(stripslashes($cle), ENT_QUOTES, $charset), $authors_list_tmpl); $authors_list_tmpl = str_replace("!!list!!", $author_list, $authors_list_tmpl); $authors_list_tmpl = str_replace("!!nav_bar!!", $nav_bar, $authors_list_tmpl); auteur::search_form($type_autorite); print pmb_bidi($authors_list_tmpl); }
function update_aut() { global $dbh; global $text, $n, $t_xml; //Reprise des auteurs sans élément rejeté et des titres de notices lorsque tronqués. //Upload du fichier if (!$_FILES['userfile']['tmp_name']) { print "Cliquez sur Précédent et choisissez un fichier"; exit; } elseif (!move_uploaded_file($_FILES['userfile']['tmp_name'], "../../temp/" . basename($_FILES['userfile']['tmp_name']))) { print "Le fichier n'a pas pu être téléchargé. Voici plus d'informations :<br />"; print_r($_FILES) . "<p>"; exit; } $fichier = @fopen("../../temp/" . basename($_FILES['userfile']['tmp_name']), "r"); if ($fichier) { print "<br /><br />"; print "Téléchargement du fichier effectué.<br /><hr />"; print "Traitement du fichier en cours.<br />"; $nb_ok = 0; $tab_err = array(); //definition header et footer $header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><inm:results>"; $footer = "</inm:results>"; $compte = 0; while (!feof($fichier)) { $buffer = ""; $deb = FALSE; $i = 0; while ($i < 200 && !feof($fichier)) { $line = fgets($fichier, 4096); if (strpos($line, "<inm:Recordset") === FALSE && strpos($line, "<inm:Record") !== FALSE) { $deb = TRUE; } if ($deb) { $buffer .= trim($line); } if (strpos($line, "</inm:Record>") !== FALSE) { $deb = FALSE; $i++; } } if ($buffer) { $buffer = $header . $buffer . $footer; //parse buffer $text = ''; $t_xml = array(); $n = 0; $encoding = "UTF-8"; $parser = xml_parser_create($encoding); xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $encoding); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($parser, "debutBalise", "finBalise"); xml_set_character_data_handler($parser, "texte"); if (!xml_parse($parser, $buffer, TRUE)) { die(sprintf("erreur XML %s à la ligne: %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); } xml_parser_free($parser); $tmp_compte = $compte; $tmp_val = array(); //traitement des enregistrements for ($i = 1; $i <= count($t_xml); $i++) { //Il faut un code-barres d'exemplaire et un auteur sans element rejete $t_xml[$i]['INM:CODE-BARRE'][0] = trim($t_xml[$i]['INM:CODE-BARRE'][0]); $q = "select notice_id,tit1 from notices join exemplaires on expl_notice=notice_id where expl_cb='" . $t_xml[$i]['INM:CODE-BARRE'][0] . "' "; $r = mysql_query($q, $dbh); if (mysql_num_rows($r)) { $n = mysql_result($r, 0, 0); $t = mysql_result($r, 0, 1); /* if ($t != $t_xml[$i]['INM:TITRE'][0]) { print "ancien titre = ".$t.'<br/>'; print "nouveau titre=".$t_xml[$i]['INM:TITRE'][0].'<br/>'; } */ foreach ($t_xml[$i]['INM:AUTEUR'] as $k => $v) { $t_xml[$i]['INM:AUTEUR'][$k] = trim($v); if (strpos($v, ',') === FALSE) { $compte++; $tmp_val[$compte]['name'] = clean_string(utf8_decode($v)); $tmp_val[$compte]['type'] = '70'; $aut = auteur::import($tmp_val[$compte]); $q1 = "select count(*) from responsability join authors on author_id=responsability_author where responsability_notice='" . $n . "' and responsability_type='0' "; $r1 = mysql_query($q1, $dbh); $n1 = mysql_result($r1, 0, 0); if ($n1) { $q2 = "select max(ordre)*1+1 from responsability join authors on author_id=responsability_author where responsability_notice_id='" . $n . "' and responsability_type='1' "; $r2 = mysql_query($q2, $dbh); $n2 = mysql_result($r2, 0, 0); $q3 = "insert ignore into responsability (responsability_author,responsability_notice,responsability_fonction,responsability_type,responsability_ordre) "; $q3 .= "values ('" . $aut . "','" . $n . "','','1','" . $n2 . "') "; mysql_query($q3, $dbh); } else { $q3 = "insert ignore into responsability (responsability_author,responsability_notice,responsability_fonction,responsability_type,responsability_ordre) "; $q3 .= "values ('" . $aut . "','" . $n . "','','0','0') "; mysql_query($q3, $dbh); } } } foreach ($t_xml[$i]['INM:AUTEUR-COLLECTIF'] as $k => $v) { $t_xml[$i]['INM:AUTEUR-COLLECTIF'] = trim($v); if (strpos($v, ',') === FALSE) { $compte++; $tmp_val[$compte]['name'] = clean_string(utf8_decode($v)); $tmp_val[$compte]['type'] = '71'; $aut = auteur::import($tmp_val[$compte]); $q1 = "select count(*) from responsability join authors on author_id=responsability_author where responsability_notice='" . $n . "' and responsability_type='0' "; $r1 = mysql_query($q1, $dbh); $n1 = mysql_result($r1, 0, 0); if ($n1) { $q2 = "select max(ordre)*1+1 from responsability join authors on author_id=responsability_author where responsability_notice_id='" . $n . "' and responsability_type='1' "; $r2 = mysql_query($q2, $dbh); $n2 = mysql_result($r2, 0, 0); $q3 = "insert ignore into responsability (responsability_author,responsability_notice,responsability_fonction,responsability_type,responsability_ordre) "; $q3 .= "values ('" . $aut . "','" . $n . "','','1','" . $n2 . "') "; mysql_query($q3, $dbh); } else { $q3 = "insert ignore into responsability (responsability_author,responsability_notice,responsability_fonction,responsability_type,responsability_ordre) "; $q3 .= "values ('" . $aut . "','" . $n . "','','0','0') "; mysql_query($q3, $dbh); } } } foreach ($t_xml[$i]['INM:AUTEUR-SECONDAIRE'] as $k => $v) { $t_xml[$i]['INM:AUTEUR-SECONDAIRE'][$k] = trim($v); if (strpos($v, ',') === FALSE) { $compte++; $tmp_val[$compte]['name'] = clean_string(utf8_decode($v)); $tmp_val[$compte]['type'] = '70'; $aut = auteur::import($tmp_val[$compte]); $q2 = "select max(ordre)*1+1 from responsability join authors on author_id=responsability_author where responsability_notice_id='" . $n . "' and responsability_type='2' "; $r2 = mysql_query($q2, $dbh); $n2 = mysql_result($r2, 0, 0); $q3 = "insert ignore into responsability (responsability_author,responsability_notice,responsability_fonction,responsability_type,responsability_ordre) "; $q3 .= "values ('" . $aut . "','" . $n . "','','2','" . $n2 . "') "; mysql_query($q3, $dbh); } } if ($compte != $tmp_compte) { print 'notice n° ' . $n . ' - ' . $t . '<br />'; foreach ($tmp_val as $v) { print $v['name'] . '<br />'; } print '<br/>'; print '_______________________________<br />'; $tmp_val = array(); $tmp_compte = $compte; } } } } } fclose($fichier); unlink("../../temp/" . basename($_FILES['userfile']['tmp_name'])); print "Traitement du fichier terminé."; print "<br /><hr />"; print "Nb total d'enregistrements modifiés = " . $compte . '<br />'; if (count($tab_err)) { for ($i = 0; $i < count($tab_err); $i++) { print "Erreur à l'enregistrement n° " . $tab_err[$i] . "<br />"; } print "<hr /><br />"; } } else { print "Le fichier n'a pu être lu ."; } }
function keep_authority_infos($authority_number, $type, $origin_authority, $notice_id, $authority_infos = array()) { //on a un numéro d'autorité, on regarde si on l'a déjà rencontré $query = "select id_authority_source,num_authority from authorities_sources where authority_number = '" . $authority_number . "' and num_origin_authority='" . $origin_authority . "' and authority_type = '" . $type . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $row = mysql_fetch_object($result); $num_authority = $row->num_authority; $num_authority_source = $row->id_authority_source; // on cherche la préférence... dès fois que... $query = "select id_authority_source, num_authority from authorities_sources where authority_number = '" . $authority_number . "' and authority_type = '" . $type . "' and authority_favorite = 1"; $result = mysql_query($query); if (mysql_num_rows($result)) { $row = mysql_fetch_object($result); $num_authority = $row->num_authority; $num_authority_source = $row->id_authority_source; } } else { // c'est un petit nouveau switch ($type) { case "author": $num_authority = auteur::import($authority_infos); break; case "uniform_title": $num_authority = titre_uniforme::import($authority_infos); break; case "category": $num_authority = category::import($authority_infos); break; case "collection": $num_authority = collection::import($authority_infos); break; case "subcollection": $num_authority = subcollection::import($authority_infos); break; case "serie": break; } $query = "insert into authorities_sources set \n\t\t\tnum_authority = '{$num_authority}',\n\t\t\tauthority_number = '" . $authority_number . "',\n\t\t\tauthority_type = '{$type}',\n\t\t\tnum_origin_authority = " . $origin_authority . ",\n\t\t\timport_date = now()"; mysql_query($query); $num_authority_source = mysql_insert_id(); } //certaines autorités sont créés avant la notice... if ($notice_id != 0) { $query = "insert into notices_authorities_sources set \n\t\tnum_authority_source = " . $num_authority_source . ",\n\t\tnum_notice = " . $notice_id; mysql_query($query); } return $num_authority; }
function update($value, $force = false) { global $dbh; global $msg, $charset; global $include_path; global $pmb_synchro_rdf; global $thesaurus_concepts_active; global $opac_enrichment_bnf_sparql; if (!$value['name']) { return false; } // nettoyage des chaînes en entrée $value['name'] = clean_string($value['name']); $value['rejete'] = clean_string($value['rejete']); $value['date'] = clean_string($value['date']); $value['lieu'] = clean_string($value['lieu']); $value['ville'] = clean_string($value['ville']); $value['pays'] = clean_string($value['pays']); $value['subdivision'] = clean_string($value['subdivision']); $value['numero'] = clean_string($value['numero']); if (!$force) { if ($this->id) { // s'assurer que l'auteur n'existe pas déjà switch ($value['type']) { case 71: // Collectivité $and_dedoublonnage = " and author_subdivision ='" . $value['subdivision'] . "' and author_lieu='" . $value['lieu'] . "' and author_ville = '" . $value['ville'] . "' and author_pays = '" . $value['pays'] . "' and author_numero ='" . $value['numero'] . "' "; break; case 72: // Congrès $and_dedoublonnage = " and author_subdivision ='" . $value['subdivision'] . "' and author_lieu='" . $value['lieu'] . "' and author_ville = '" . $value['ville'] . "' and author_pays = '" . $value['pays'] . "' and author_numero ='" . $value['numero'] . "' "; break; default: $and_dedoublonnage = ''; break; } $dummy = "SELECT * FROM authors WHERE author_type='" . $value['type'] . "' AND author_name='" . $value['name'] . "'"; $dummy .= " AND author_rejete='" . $value['rejete'] . "' "; $dummy .= "AND author_date='" . $value[date] . "' and author_id!='" . $this->id . "' {$and_dedoublonnage} "; $check = pmb_mysql_query($dummy, $dbh); if (pmb_mysql_num_rows($check)) { $auteur_exists = new auteur(pmb_mysql_result($check, 0, "author_id")); require_once "{$include_path}/user_error.inc.php"; warning($msg[200], htmlentities($msg[220] . " -> " . $auteur_exists->display, ENT_QUOTES, $charset)); return FALSE; } } else { // s'assurer que l'auteur n'existe pas déjà if ($id_auteur_exists = auteur::check_if_exists($value)) { $auteur_exists = new auteur($id_auteur_exists); require_once "{$include_path}/user_error.inc.php"; warning($msg[200], htmlentities($msg[220] . " -> " . $auteur_exists->display, ENT_QUOTES, $charset)); return FALSE; } } // s'assurer que la forme_retenue ne pointe pas dans les deux sens if ($this->id) { $dummy = "SELECT * FROM authors WHERE author_id='" . $value[voir_id] . "' and author_see='" . $this->id . "'"; $check = pmb_mysql_query($dummy, $dbh); if (pmb_mysql_num_rows($check)) { require_once "{$include_path}/user_error.inc.php"; warning($msg[200], htmlentities($msg['author_forme_retenue_error'] . " -> " . $this->display, ENT_QUOTES, $charset)); return FALSE; } } } $requete = "SET author_type='{$value['type']}', "; $requete .= "author_name='{$value['name']}', "; $requete .= "author_rejete='{$value['rejete']}', "; $requete .= "author_date='{$value['date']}', "; $requete .= "author_lieu='" . $value["lieu"] . "', "; $requete .= "author_ville='" . $value["ville"] . "', "; $requete .= "author_pays='" . $value["pays"] . "', "; $requete .= "author_subdivision='" . $value["subdivision"] . "', "; $requete .= "author_numero='" . $value["numero"] . "', "; $requete .= "author_web='{$value['author_web']}', "; $requete .= "author_see='{$value['voir_id']}', "; $requete .= "author_comment='{$value['author_comment']}', "; $word_to_index = $value["name"] . " " . $value["rejete"] . " " . $value["lieu"] . " " . $value["ville"] . " " . $value["pays"] . " " . $value["numero"] . " " . $value["subdivision"]; if ($value['type'] == 72) { $word_to_index .= " " . $value["date"]; } $requete .= "index_author=' " . strip_empty_chars($word_to_index) . " ',"; $requete .= "author_import_denied= " . ($value['import_denied'] ? 1 : 0); if ($this->id) { audit::insert_modif(AUDIT_AUTHOR, $this->id); // update // on checke s'il n'y a pas un renvoi circulaire if ($this->id == $value['voir_id']) { require_once "{$include_path}/user_error.inc.php"; warning($msg[199], htmlentities($msg[222] . " -> " . $this->display, ENT_QUOTES, $charset)); return FALSE; } $requete = 'UPDATE authors ' . $requete; $requete .= ' WHERE author_id=' . $this->id . ' ;'; if (pmb_mysql_query($requete, $dbh)) { // liens entre autorités $aut_link = new aut_link(AUT_TABLE_AUTHORS, $this->id); $aut_link->save_form(); $aut_pperso = new aut_pperso("author", $this->id); $aut_pperso->save_form(); auteur::update_index($this->id); // mise à jour de l'auteur dans la base rdf if ($pmb_synchro_rdf) { $synchro_rdf = new synchro_rdf(); $synchro_rdf->updateAuthority($this->id, 'auteur'); } // ////////////////////////modif de l'update/////////////////////////////// $query = "select 1 from authors where (author_enrichment_last_update < now()-interval '0' day) and author_id={$this->id}"; $result = pmb_mysql_query($query, $dbh); if ($opac_enrichment_bnf_sparql && pmb_mysql_num_rows($result)) { auteur::author_enrichment($this->id); } // //////////////////////////////////////////////////////////////////////// } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[199], htmlentities($msg[208] . " -> " . $this->display, ENT_QUOTES, $charset)); return FALSE; } } else { // creation $requete = 'INSERT INTO authors ' . $requete . ' '; if (pmb_mysql_query($requete, $dbh)) { $this->id = pmb_mysql_insert_id(); // liens entre autorités $aut_link = new aut_link(AUT_TABLE_AUTHORS, $this->id); $aut_link->save_form(); $aut_pperso = new aut_pperso("author", $this->id); $aut_pperso->save_form(); audit::insert_creation(AUDIT_AUTHOR, $this->id); // ajout des enrichissements si activés if ($opac_enrichment_bnf_sparql) { auteur::author_enrichment($this->id); } } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[200], htmlentities($msg[221] . " -> " . $requete, ENT_QUOTES, $charset)); return FALSE; } } // Indexation concepts if ($thesaurus_concepts_active == 1) { $index_concept = new index_concept($this->id, TYPE_AUTHOR); $index_concept->save(); } // Mise à jour des vedettes composées contenant cette autorité vedette_composee::update_vedettes_built_with_element($this->id, "author"); return TRUE; }
public function check_if_exists($data, $id_thesaurus = 0) { switch ($data['type_authority']) { // Forme associée - Nom de Personne case "author": $id = auteur::check_if_exists($data); break; // Forme associée - Titre Uniforme // Forme associée - Titre Uniforme case "uniform_title": $id = titre_uniforme::import_tu_exist($data); break; case "category": $id = category::check_if_exists($data, $id_thesaurus, 0, $this->common_data['lang']); break; default: $id = 0; break; } return $id; }
/** * @param array $entry le tableau $entry généré par la fonction buildEntry() * * Fonction d'import d'une notice formaté par la fonction buildEntry() * Ajoute les informations d'audit * Ajoute les champs personnalisés * Ajoute les tables annexes [responsability], [notices_categories] et [notices_langues] * Met à jours l'indexation de la notice */ static function buildNotice(&$entry) { global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; //la notice existe déjà ? si oui, on renvoi l'id trouvé if ($entry['niveau_biblio'] . $entry['niveau_hierar'] == 'a2') { $query = ' SELECT n1.* FROM notices AS n1 JOIN analysis ON n1.notice_id=analysis_notice JOIN bulletins ON bulletin_id=analysis_bulletin JOIN notices AS n2 ON n2.notice_id=bulletin_notice WHERE n1.tit1="' . addslashes($entry['tit1']) . '" AND n1.niveau_biblio="' . addslashes($entry['niveau_biblio']) . '" AND n1.niveau_hierar="' . addslashes($entry['niveau_hierar']) . '" AND bulletin_numero="' . addslashes($entry['bulletin']['bulletin_numero']) . '" AND mention_date="' . addslashes($entry['bulletin']['mention_date']) . '" AND date_date="' . addslashes($entry['bulletin']['date_date']) . '" AND n2.tit1="' . addslashes($entry['periodique']['tit1']) . '" AND n2.niveau_biblio="' . addslashes($entry['periodique']['niveau_biblio']) . '" AND n2.niveau_hierar="' . addslashes($entry['periodique']['niveau_hierar']) . '" '; $result = mysql_query($query); } else { $query = 'SELECT * FROM notices WHERE tit1="' . addslashes($entry['tit1']) . '" AND niveau_biblio="' . addslashes($entry['niveau_biblio']) . '" AND niveau_hierar="' . addslashes($entry['niveau_hierar']) . '"'; $result = mysql_query($query); } if (mysql_num_rows($result)) { // La notice existe $entry = array_merge(mysql_fetch_array($result, MYSQL_ASSOC), $entry); //TODO : A vérifier $first = true; $query = 'UPDATE notices SET '; foreach (array_keys($entry) as $fieldName) { if (!is_array($entry[$fieldName]) && $entry[$fieldName] != '' && $fieldName != 'ancien_num_name') { if (!$first) { $query .= ','; } $query .= $fieldName . '="' . addslashes($entry[$fieldName]) . '"'; $first = false; } } $query .= ' WHERE notice_id="' . addslashes($entry['notice_id']) . '"'; mysql_query($query) or die('echec de la requete : ' . $query . '<br/>' . mysql_error() . "\n"); } else { //les éditeurs if (sizeof($entry['publishers'])) { foreach ($entry['publishers'] as $id => $publisher) { if ($id < 2) { if ($id === 0) { $entry['ed1_id'] = \editeur::import($publisher); } elseif ($id === 1) { $entry['ed2_id'] = \editeur::import($publisher); } } } } //la collection if (sizeof($entry['collections']) && $entry['ed1_id']) { $entry['collections']['parent'] = $entry['ed1_id']; $entry['coll_id'] = \collection::import($entry['collections']); } $first = true; $query = 'INSERT INTO notices SET '; foreach ($entry as $fieldName => $value) { if (!is_array($value) && $value != '') { if (!$first) { $query .= ','; } $query .= $fieldName . '="' . addslashes(trim($value)) . '"'; $first = false; } } mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error()); $entry['notice_id'] = mysql_insert_id(); if ($pmb_type_audit && ($webdav_current_user_id || $webdav_current_user_name) && $entry['create_date']) { //ajout des informations d'audit $query = 'INSERT INTO audit (type_obj,object_id,user_id,user_name,type_modif,quand) VALUES (1,' . $entry['notice_id'] . ',' . $webdav_current_user_id . ',"' . addslashes($webdav_current_user_name) . '",1,"' . $entry['create_date'] . '")'; mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error()); } } //les champs persos if (sizeof($entry['cp'])) { foreach ($entry['cp'] as $cp) { \parametres_perso::import($entry['notice_id'], $cp['field'], $cp['value'], 'notices'); } } //ajout dans les tables annexes a la notice if (sizeof($entry['annexes'])) { foreach ($entry['annexes'] as $typeAnnexe => $annexes) { foreach ($annexes as $id => $annexe) { switch ($typeAnnexe) { case 'responsability': //Import et récupération des identifiants auteurs $entry['annexes'][$typeAnnexe][$id]['responsability_author'] = \auteur::import($entry['annexes'][$typeAnnexe][$id]['authors']); $entry['annexes'][$typeAnnexe][$id]['responsability_notice'] = $entry['notice_id']; break; case 'notices_categories': //Import et récupération des identifiants catégories $query = 'SELECT num_noeud FROM categories WHERE libelle_categorie="' . addslashes(trim($entry['annexes'][$typeAnnexe][$id]['categories']['libelle_categorie'])) . '" AND num_thesaurus=' . $entry['annexes'][$typeAnnexe][$id]['categories']['num_thesaurus'] . ' AND langue="' . $entry['annexes'][$typeAnnexe][$id]['categories']['langue'] . '"'; $result = mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error()); if (mysql_num_rows($result)) { //le noeud existe déjà $entry['annexes'][$typeAnnexe][$id]['num_noeud'] = mysql_result($result, 0, 0); } else { //le noeud n'existe pas, on cherche le parent non classé $query = 'SELECT id_noeud FROM noeuds WHERE autorite="NONCLASSES" AND num_thesaurus=' . $entry['annexes'][$typeAnnexe][$id]['categories']['num_thesaurus']; $result = mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error()); if (mysql_num_rows($result)) { //on ajoute le noeud $query = 'INSERT INTO noeuds SET num_parent=' . mysql_result($result, 0, 0) . ', visible=1, num_thesaurus=' . $entry['annexes'][$typeAnnexe][$id]['categories']['num_thesaurus']; mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error()); $entry['annexes']['notices_categories'][$id]['num_noeud'] = mysql_insert_id(); //on ajoute la catégorie $categorie = new \categories($entry['annexes'][$typeAnnexe][$id]['num_noeud'], $entry['annexes'][$typeAnnexe][$id]['categories']['langue']); $categorie->libelle_categorie = trim($entry['annexes'][$typeAnnexe][$id]['categories']['libelle_categorie']); $categorie->save(); } } $entry['annexes'][$typeAnnexe][$id]['notcateg_notice'] = $entry['notice_id']; break; case 'notices_langues': $entry['annexes'][$typeAnnexe][$id]['num_notice'] = $entry['notice_id']; break; case 'notices_authorities_sources': $entry['annexes'][$typeAnnexe][$id]['num_notice'] = $entry['notice_id']; break; case 'notices_relations': $entry['annexes'][$typeAnnexe][$id]['num_notice'] = $entry['notice_id']; break; case 'notices_titres_uniformes': $entry['annexes'][$typeAnnexe][$id]['ntu_num_notice'] = $entry['notice_id']; break; } $first = true; $query = 'INSERT IGNORE INTO ' . $typeAnnexe . ' SET '; foreach ($entry['annexes'][$typeAnnexe][$id] as $fieldName => $value) { if (!is_array($value) && $value != '') { if (!$first) { $query .= ','; } $query .= $fieldName . '="' . addslashes(trim($value)) . '"'; $first = false; } } mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error()); } } } \notice::majNoticesTotal($entry['notice_id']); }
break; case 'author_form': // création/modification d'un responsable if (!$id) { $auteur = new auteur(); } else { $auteur = new auteur($id); } // affichage du form pour modification $auteur->show_form($type_autorite); break; case 'author_last': $last_param = 1; $tri_param = "order by author_id desc "; $limit_param = "limit 0, {$pmb_nb_lastautorities} "; $clef = ""; $nbr_lignes = 0; include './autorites/authors/authors_list.inc.php'; break; case 'duplicate': $auteur = new auteur($id); $auteur->id = 0; $auteur->duplicate_from_id = $id; $auteur->type = $type_autorite; $auteur->show_form($type_autorite); break; default: // affichage du début de la liste include './autorites/authors/authors_list.inc.php'; break; }
protected function create_notice() { global $pmb_keyword_sep; global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; if ($this->data['publisher']) { $ed_1 = \editeur::import(array('name' => $this->data['publisher'])); } else { $ed_1 = 0; } $ind_wew = $this->data['tit1'] . " " . $this->data['tit4']; $ind_sew = \strip_empty_words($ind_wew); $query = "insert into notices set\n\t\t\t\ttit1 = '" . addslashes($this->data['tit1']) . "'," . ($this->data['code'] ? "code='" . $this->data['code'] . "'," : "") . "ed1_id = '" . $ed_1 . "'," . ($this->data['tit4'] ? "tit4 = '" . addslashes($this->data['tit4']) . "'," : "") . ($this->data['npages'] ? "npages = '" . addslashes($this->data['npages']) . "'," : "") . ($this->data['index_l'] ? "index_l = '" . addslashes($this->data['index_l']) . "'," : "") . "\n\t\t\t\tyear = '" . $this->data['year'] . "',\n\t\t\t\tniveau_biblio='m',\n\t\t\t\tniveau_hierar='0',\n\t\t\t\tstatut = '" . $this->config['default_statut'] . "',\n\t\t\t\tindex_wew = '" . $ind_wew . "',\n\t\t\t\tindex_sew = '" . $ind_sew . "',\n\t\t\t\tn_resume = '" . addslashes($this->data['n_resume']) . "',\n\t\t\t\tlien = '" . addslashes($url) . "',\n\t\t\t\tindex_n_resume = '" . \strip_empty_words($this->data['n_resume']) . "'," . ($this->data['thumbnail_content'] ? "thumbnail_url = 'data:image/png;base64," . base64_encode($this->data['thumbnail_content']) . "'," : "") . "create_date = sysdate(),\n\t\t\t\tupdate_date = sysdate()"; pmb_mysql_query($query); $notice_id = pmb_mysql_insert_id(); //traitement audit if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='{$notice_id}', "; $query .= "user_id='{$webdav_current_user_id}', "; $query .= "user_name='{$webdav_current_user_name}', "; $query .= "type_modif=1 "; $result = @pmb_mysql_query($query); } if (count($this->data['authors'])) { $i = 0; foreach ($this->data['authors'] as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set\n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0'"; pmb_mysql_query($query); $i++; } } } if (count($this->data['co_authors'])) { foreach ($this->data['co_authors'] as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set\n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0',\n\t\t\t\t\t\t\trepsonsability_ordre = '" . $i . "'"; pmb_mysql_query($query); $i++; } } } return $notice_id; }
public function create_authority() { switch ($this->notice->type) { case "author": $this->authority_id = auteur::import($this->notice->specifics_data); break; case "uniform_title": $this->authority_id = titre_uniforme::import($this->notice->specifics_data); break; case "collection": $this->authority_id = collection::import($this->notice->specifics_data); if ($this->authority_id != 0 && $this->notice->specifics_data['subcollections']) { for ($i = 0; $i < count($this->notice->specifics_data['subcollections']); $i++) { $this->notice->specifics_data['subcollections'][$i]['coll_parent'] = $this->authority_id; $subcoll_id = subcollection::check_if_exists($this->notice->specifics_data['subcollections'][$i]); if ($subcoll_id != 0 && $this->notice->specifics_data['subcollections'][$i]['authority_number']) { $query = "insert into authorities_sources set \n\t\t\t\t\t\t\t\t\tnum_authority = " . $subcoll_id . ",\n\t\t\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['subcollections'][$i]['authority_number'] . "',\t\n\t\t\t\t\t\t\t\t\tauthority_type = 'subcollection',\n\t\t\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\t\t\timport_date = now()"; mysql_query($query); } } } break; case "subcollection": $this->authority_id = subcollection::import($this->notice->specifics_data); if ($this->authority_id != 0 && $this->notice->specifics_data['collection'] && $this->notice->specifics_data['collection']['authority_number']) { $coll_id = collection::check_if_exists($this->notice->specifics_data['collection']); $query = "insert into authorities_sources set \n\t\t\t\t\t\t\tnum_authority = " . $coll_id . ",\n\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['collection']['authority_number'] . "',\t\n\t\t\t\t\t\t\tauthority_type = 'collection',\n\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\timport_date = now()"; mysql_query($query); } break; case "category": $this->authority_id = category::import($this->notice->specifics_data, $this->id_thesaurus, $this->get_parent_category(), $this->notice->common_data['lang']); break; default: // on fait rien... break; } if ($this->authority_id) { $query = "insert into authorities_sources set \n\t\t\t\tnum_authority = " . $this->authority_id . ",\n\t\t\t\tauthority_number = '" . $this->notice->common_data['authority_number'] . "',\t\n\t\t\t\tauthority_type = '" . $this->notice->type . "',\n\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\tauthority_favorite = 1,\n\t\t\t\timport_date = now(),\n\t\t\t\tupdate_date = now()"; mysql_query($query); } else { return false; } }
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) // +-------------------------------------------------+ // $Id: aut_pass1.inc.php,v 1.16 2013-03-20 18:21:23 mbertin Exp $ if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } require_once "{$class_path}/author.class.php"; // la taille d'un paquet de notices $lot = AUTHOR_PAQUET_SIZE; // defini dans ./params.inc.php // taille de la jauge pour affichage $jauge_size = GAUGE_SIZE; // initialisation de la borne de départ if (!isset($start)) { $start = 0; } $v_state = urldecode($v_state); print "<br /><br /><h2 align='center'>" . htmlentities($msg["nettoyage_suppr_auteurs"], ENT_QUOTES, $charset) . "</h2>"; $res = mysql_query("SELECT author_id from authors left join responsability on responsability_author=author_id where responsability_author is null and author_see=0 "); $affected = 0; if ($affected = mysql_num_rows($res)) { while ($ligne = mysql_fetch_object($res)) { $auteur = new auteur($ligne->author_id); $auteur->delete(); } } //Nettoyage des informations d'autorités pour les sous collections auteur::delete_autority_sources(); // mise à jour de l'affichage de la jauge print "<table border='0' align='center' width='{$table_size}' cellpadding='0'><tr><td class='jauge'>\n \t<img src='../../images/jauge.png' width='{$jauge_size}' height='16'></td></tr></table>\n \t\t<div align='center'>100%</div>"; print "\n\t<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"{$v_state}\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t<input type='hidden' name='affected' value=\"{$affected}\">\n\t\t<input type='hidden' name='pass2' value=\"1\">\t\t\t\n\t\t</form>\n\t<script type=\"text/javascript\"><!--\n\t\tdocument.forms['process_state'].submit();\n\t\t-->\n\t\t</script>";
public static function import($data) { // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes : // $data['type'] type de l'autorité (70 , 71 ou 72) // $data['name'] élément d'entrée de l'autorité // $data['rejete'] élément rejeté // $data['date'] dates de l'autorité // $data['lieu'] lieu du congrès 210$e // $data['ville'] ville du congrès // $data['pays'] pays du congrès // $data['subdivision'] 210$b // $data['numero'] numero du congrès 210$d // $data['voir_id'] id de la forme retenue (sans objet pour l'import de notices) // $data['author_comment'] commentaire // $data['authority_number'] Numéro d'autortité // TODO gestion du dédoublonnage ! global $dbh; global $opac_enrichment_bnf_sparql; // check sur le type de la variable passée en paramètre if (!sizeof($data) || !is_array($data)) { // si ce n'est pas un tableau ou un tableau vide, on retourne 0 return 0; } // check sur les éléments du tableau (data['name'] ou data['rejete'] est requis). $long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT author_name FROM authors limit 1"), 0); $long_maxi_rejete = pmb_mysql_field_len(pmb_mysql_query("SELECT author_rejete FROM authors limit 1"), 0); $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name)); $data['rejete'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['rejete']))), 0, $long_maxi_rejete)); if (!$data['name'] && !$data['rejete']) { return 0; } // check sur le type d'autorité if (!$data['type'] == 70 && !$data['type'] == 71 && !$data['type'] == 72) { return 0; } // tentative de récupérer l'id associée dans la base (implique que l'autorité existe) // préparation de la requête $key0 = $data['type']; $key1 = addslashes($data['name']); $key2 = addslashes($data['rejete']); $key3 = addslashes($data['date']); $key4 = addslashes($data['subdivision']); $key5 = addslashes($data['lieu']); $key6 = addslashes($data['ville']); $key7 = addslashes($data['pays']); $key8 = addslashes($data['numero']); $data['lieu'] = addslashes($data['lieu']); $data['ville'] = addslashes($data['ville']); $data['pays'] = addslashes($data['pays']); $data['subdivision'] = addslashes($data['subdivision']); $data['numero'] = addslashes($data['numero']); $data['author_comment'] = addslashes($data['author_comment']); $data['author_web'] = addslashes($data['author_web']); if (!$data['statut']) { $data['statut'] = 1; } else { $data['statut'] += 0; } $query = "SELECT author_id FROM authors WHERE author_type='{$key0}' AND author_name='{$key1}' AND author_rejete='{$key2}' AND author_date='{$key3}'"; if ($data["type"] > 70) { $query .= " and author_subdivision='{$key4}' and author_lieu='{$key5}' and author_ville='{$key6}' and author_pays='{$key7}' and author_numero='{$key8}'"; } $query .= " LIMIT 1"; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT in database"); } // résultat // récupération du résultat de la recherche $aut = pmb_mysql_fetch_object($result); // du résultat et récupération éventuelle de l'id if ($aut->author_id) { return $aut->author_id; } // id non-récupérée, il faut créer l'auteur $query = 'INSERT INTO authors SET author_type="' . $key0 . '", '; $query .= 'author_name="' . $key1 . '", '; $query .= 'author_rejete="' . $key2 . '", '; $query .= 'author_date="' . $key3 . '", '; $query .= 'author_lieu="' . $data['lieu'] . '", '; $query .= 'author_ville="' . $data['ville'] . '", '; $query .= 'author_pays="' . $data['pays'] . '", '; $query .= 'author_subdivision="' . $data['subdivision'] . '", '; $query .= 'author_numero="' . $data['numero'] . '", '; $query .= 'author_web="' . $data['author_web'] . '", '; $query .= 'author_comment="' . $data['author_comment'] . '", '; $word_to_index = $key1 . ' ' . $key2 . ' ' . $data['lieu'] . ' ' . $data['ville'] . ' ' . $data['pays'] . ' ' . $data['numero'] . ' ' . $data["subdivision"]; if ($key0 == "72") { $word_to_index .= " " . $key3; } $query .= 'index_author=" ' . strip_empty_chars($word_to_index) . ' " '; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into table authors :<br /><b>{$query}</b> "); } $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_AUTHOR, $id); //update authority informations $authority = new authority(0, $id, AUT_TABLE_AUTHORS); $authority->set_num_statut($data['statut']); $authority->update(); auteur::update_index($id); return $id; }
$id += 0; $rqt_auteurs = "select author_id as aut from authors where author_see='{$id}' and author_id!=0 "; $rqt_auteurs .= "union select author_see as aut from authors where author_id='{$id}' and author_see!=0 "; $res_auteurs = pmb_mysql_query($rqt_auteurs, $dbh); $clause_auteurs = " in ('{$id}' "; while ($id_aut = pmb_mysql_fetch_object($res_auteurs)) { $clause_auteurs .= ", '" . $id_aut->aut . "' "; $rqt_auteursuite = "select author_id as aut from authors where author_see='{$id_aut->aut}' and author_id!=0 "; $res_auteursuite = pmb_mysql_query($rqt_auteursuite, $dbh); while ($id_autsuite = pmb_mysql_fetch_object($res_auteursuite)) { $clause_auteurs .= ", '" . $id_autsuite->aut . "' "; } } $clause_auteurs .= " ) "; // affichage des informations sur l'auteur $ourAuteur = new auteur($id); if ($ourAuteur->type == 72) { // Congrès print pmb_bidi("<h3><span>" . $msg["congres_see_title"] . " {$renvoi}</span></h3>\n"); } else { if ($ourAuteur->type == 71) { // Collectivités print pmb_bidi("<h3><span>" . $msg["collectivite_see_title"] . " {$renvoi}</span></h3>\n"); } else { print pmb_bidi("<h3><span>" . $msg["author_see_title"] . " {$renvoi}</span></h3>\n"); } } print "<div id='aut_details_container'>\n"; print "\t<div id='aut_see' class='aut_see'>\n\n\t\t\t<img src='./images/home.gif' border='0'></a> >\n"; print pmb_bidi($ourAuteur->print_congres_titre()); $ourAuteur->get_similar_name($ourAuteur->type);
case 'add': $author_form = str_replace("!!deb_saisie!!", htmlentities(stripslashes($f_user_input), ENT_QUOTES, $charset), $author_form); print $author_form; break; case 'update': $value['type'] = $author_type; $value['name'] = $author_name; $value['rejete'] = $author_rejete; $value['date'] = $date; $value['voir_id'] = 0; $value['lieu'] = $lieu; $value['ville'] = $ville; $value['pays'] = $pays; $value['subdivision'] = $subdivision; $value['numero'] = $numero; $auteur = new auteur(); $auteur->update($value); $sel_search_form = str_replace("!!bouton_ajouter!!", $bouton_ajouter, $sel_search_form); $sel_search_form = str_replace("!!deb_rech!!", htmlentities(stripslashes($f_user_input), ENT_QUOTES, $charset), $sel_search_form); print $sel_search_form; print $jscript; show_results($dbh, $author_name, 0, 0, $auteur->id); break; default: $sel_search_form = str_replace("!!bouton_ajouter!!", $bouton_ajouter, $sel_search_form); $sel_search_form = str_replace("!!deb_rech!!", htmlentities(stripslashes($f_user_input), ENT_QUOTES, $charset), $sel_search_form); print $sel_search_form; print $jscript; show_results($dbh, $user_input, $nbr_lignes, $page, 0); break; }
$id += 0; $rqt_auteurs = "select author_id as aut from authors where author_see='{$id}' and author_id!=0 "; $rqt_auteurs .= "union select author_see as aut from authors where author_id='{$id}' and author_see!=0 "; $res_auteurs = mysql_query($rqt_auteurs, $dbh); $clause_auteurs = " in ('{$id}' "; while ($id_aut = mysql_fetch_object($res_auteurs)) { $clause_auteurs .= ", '" . $id_aut->aut . "' "; $rqt_auteursuite = "select author_id as aut from authors where author_see='{$id_aut->aut}' and author_id!=0 "; $res_auteursuite = mysql_query($rqt_auteursuite, $dbh); while ($id_autsuite = mysql_fetch_object($res_auteursuite)) { $clause_auteurs .= ", '" . $id_autsuite->aut . "' "; } } $clause_auteurs .= " ) "; // affichage des informations sur l'auteur $ourAuteur = new auteur($id); if ($ourAuteur->type == 72) { //Congrès print pmb_bidi("<h3><span>" . $msg["congres_see_title"] . " {$renvoi}</span></h3>\n"); } else { print pmb_bidi("<h3><span>" . $msg["author_see_title"] . " {$renvoi}</span></h3>\n"); } print "<div id='aut_details_container'>\n"; print "<div id='aut_see'>\n"; print pmb_bidi($ourAuteur->print_resume()); // récupération des formes rejetées pour affichage $requete = "select distinct author_id as aut from authors where author_id {$clause_auteurs} and author_id!={$id} "; $res = mysql_query($requete, $dbh); while ($obj = mysql_fetch_object($res)) { $objRenvoi = new auteur($obj->aut); pmb_strlen($renvoi) ? $renvoi .= ', (' . $objRenvoi->isbd_entry . ")" : ($renvoi = $objRenvoi->isbd_entry);
function get_notice_by_meta($name, $filename) { global $pmb_keyword_sep; global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; \create_tableau_mimetype(); $mimetype = \trouve_mimetype($filename, extension_fichier($name)); $notice_id = 0; $title = $cplt = $code = $pages = $year = $keywords = $url = $thumbnail_content = ""; //on commence avec la gymnatisque des métas... if ($mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $epub = new \epubData(realpath($filename)); $title = $epub->metas['title'][0]; $authors = $epub->metas['creator']; $co_authors = $epub->metas['contributor']; if ($epub->metas['identifier']['isbn']) { $code = \formatISBN($epub->metas['identifier']['isbn'], 13); } else { if ($epub->metas['identifier']['ean']) { $code = \EANtoISBN($epub->metas['identifier']['ean']); $code = \formatISBN($code, 13); } } if ($epub->metas['identifier']['uri']) { $url = \clean_string($epub->metas['identifier']['uri']); } $publisher = $epub->metas['publisher'][0]; $year = $epub->metas['date'][0]['value']; if (strlen($year) && strlen($year) != 4) { $year = \formatdate(detectFormatDate($year)); } $lang = $epub->metas['language']; $resume = implode("\n", $epub->metas['description']); $keywords = implode($pmb_keyword_sep, $epub->metas['subject']); //jouons à et si on trouvait a vignette... $img = imagecreatefromstring($epub->getCoverContent()); $file = tempnam(sys_get_temp_dir(), "vign"); imagepng($img, $file); $thumbnail_content = file_get_contents($file); unlink($file); } else { $metas = \extract_metas(realpath($filename), $mimetype); if ($metas['Title'] && $metas['Author'] && $metas['Subject']) { $title = $metas['Title']; $author = $metas['Author']; $cplt = $metas['Subject']; } else { // métas non fiable, on regarde avec le titre... $title = $name; } //date de création... if ($metas["CreateDate"]) { $year = substr($metas["CreateDate"], 0, 4); } //pages if ($metas['PageCount']) { $pages = $metas['PageCount']; } //keywords if ($metas['Keywords']) { foreach ($metas['Keywords'] as $keyword) { if ($keywords != "") { $keywords .= $pmb_keyword_sep; } $keywords .= $keyword; } } } $query = "select notice_id from notices where tit1 = '" . addslashes($title) . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $notice_id = mysql_result($result, 0, 0); } if (!$notice_id) { //en cas d'une leture moyenne des infos, on s'assure d'avoir au moins un titre.... if (!$title) { $title = $name; } if ($publisher) { $ed_1 = \editeur::import(array('name' => $publisher)); } else { $ed_1 = 0; } $ind_wew = $title . " " . $cplt; $ind_sew = \strip_empty_words($ind_wew); $query = "insert into notices set \n\t\t\t\ttit1 = '" . addslashes($title) . "'," . ($code ? "code='" . $code . "'," : "") . "ed1_id = '" . $ed_1 . "'," . ($cplt ? "tit4 = '" . addslashes($cplt) . "'," : "") . ($pages ? "npages = '" . addslashes($pages) . "'," : "") . ($keywords ? "index_l = '" . addslashes($keywords) . "'," : "") . "\n\t\t\t\tyear = '" . $year . "',\n\t\t\t\tniveau_biblio='m', \n\t\t\t\tniveau_hierar='0',\n\t\t\t\tstatut = '" . $this->config['default_statut'] . "',\n\t\t\t\tindex_wew = '" . $ind_wew . "',\n\t\t\t\tindex_sew = '" . $ind_sew . "',\n\t\t\t\tn_resume = '" . addslashes($resume) . "',\n\t\t\t\tlien = '" . addslashes($url) . "',\n\t\t\t\tindex_n_resume = '" . \strip_empty_words($resume) . "'," . ($thumbnail_content ? "thumbnail_url = 'data:image/png;base64," . base64_encode($thumbnail_content) . "'," : "") . "create_date = sysdate(), \n\t\t\t\tupdate_date = sysdate()"; mysql_query($query); $notice_id = mysql_insert_id(); $sign = new \notice_doublon(); mysql_query("update notices set signature = '" . $sign->gen_signature($notice_id) . "' where notice_id = " . $notice_id); //traitement audit if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='{$notice_id}', "; $query .= "user_id='{$webdav_current_user_id}', "; $query .= "user_name='{$webdav_current_user_name}', "; $query .= "type_modif=1 "; $result = @mysql_query($query); } if (count($authors)) { $i = 0; foreach ($authors as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set \n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0'"; mysql_query($query); $i++; } } } if (count($co_authors)) { foreach ($co_authors as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set \n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0',\n\t\t\t\t\t\t\trepsonsability_ordre = '" . $i . "'"; mysql_query($query); $i++; } } } } return $notice_id; }