Beispiel #1
0
 static function update_index($id)
 {
     global $dbh;
     // On cherche tous les n-uplet de la table notice correspondant à cet auteur.
     $found = pmb_mysql_query("select distinct responsability_notice from responsability where responsability_author='" . $id . "'", $dbh);
     // Pour chaque n-uplet trouvés on met a jour la table notice_global_index avec l'auteur modifié :
     while ($mesNotices = pmb_mysql_fetch_object($found)) {
         $notice_id = $mesNotices->responsability_notice;
         notice::majNoticesGlobalIndex($notice_id);
         notice::majNoticesMotsGlobalIndex($notice_id, 'author');
     }
     // On met à jour les titres uniformes correspondant à cet auteur
     $found = pmb_mysql_query("select distinct responsability_tu_num from responsability_tu where responsability_tu_author_num='" . $id . "'", $dbh);
     // Pour chaque n-uplet trouvés on met a jour l'index du titre uniforme avec l'auteur modifié :
     while ($mesTu = pmb_mysql_fetch_object($found)) {
         titre_uniforme::update_index_tu($mesTu->responsability_tu_num);
         titre_uniforme::update_index($mesTu->responsability_tu_num);
     }
 }
 function update($value)
 {
     global $dbh;
     global $msg;
     global $include_path;
     global $pmb_synchro_rdf;
     global $thesaurus_concepts_active, $max_aut0, $max_aut1;
     global $mc_oeuvre_nature;
     global $pmb_authors_qualification;
     if (!$value['name']) {
         return false;
     }
     // nettoyage des chaînes en entrée
     $value['name'] = clean_string($value['name']);
     $value['num_author'] = clean_string($value['num_author']);
     $value['form'] = clean_string($value['form']);
     $value['form_selector'] = clean_string($value['form_selector']);
     $value['date'] = clean_string($value['date']);
     $value['subject'] = clean_string($value['subject']);
     $value['place'] = clean_string($value['place']);
     $value['history'] = clean_string($value['history']);
     $value['characteristic'] = clean_string($value['characteristic']);
     $value['intended_termination'] = clean_string($value['intended_termination']);
     $value['intended_audience'] = clean_string($value['intended_audience']);
     $value['context'] = clean_string($value['context']);
     $value['equinox'] = clean_string($value['equinox']);
     $value['coordinates'] = clean_string($value['coordinates']);
     $value['tonalite'] = clean_string($value['tonalite']);
     $value['tonalite_selector'] = clean_string($value['tonalite_selector']);
     $value['comment'] = clean_string($value['comment']);
     $value['oeuvre_nature'] = clean_string($value['oeuvre_nature']);
     $value['oeuvre_nature_nature'] = clean_string($mc_oeuvre_nature->attributes[$value['oeuvre_nature']]['NATURE']);
     $value['oeuvre_type'] = clean_string($value['oeuvre_type']);
     $titre = titre_uniforme::import_tu_exist($value, 1, $this->id);
     if ($titre) {
         require_once "{$include_path}/user_error.inc.php";
         warning($msg["aut_titre_uniforme_creation"], $msg["aut_titre_uniforme_doublon_erreur"]);
         return FALSE;
     }
     $tu_auteur = new auteur($value['num_author']);
     if (!$tu_auteur->id) {
         $value['num_author'] = 0;
     } else {
         $value['num_author'] = $tu_auteur->id;
     }
     $flag_index = 0;
     $requete = "SET ";
     $requete .= "tu_name='" . $value["name"] . "', ";
     $requete .= "tu_num_author='" . $value['num_author'] . "', ";
     $requete .= "tu_forme='" . $value["form"] . "', ";
     $requete .= "tu_forme_marclist='" . $value["form_selector"] . "', ";
     $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 .= "tu_tonalite='" . $value["tonalite"] . "', ";
     $requete .= "tu_tonalite_marclist='" . $value["tonalite_selector"] . "', ";
     $requete .= "tu_comment='" . $value["comment"] . "', ";
     $requete .= "tu_import_denied='" . $value["import_denied"] . "', ";
     $requete .= "tu_oeuvre_nature='" . $value["oeuvre_nature"] . "', ";
     $requete .= "tu_oeuvre_nature_nature='" . $value["oeuvre_nature_nature"] . "', ";
     $requete .= "tu_oeuvre_type='" . $value["oeuvre_type"] . "' ";
     if ($this->id) {
         // update
         $requete = 'UPDATE titres_uniformes ' . $requete;
         $requete .= ' WHERE tu_id=' . $this->id . ' ;';
         if (pmb_mysql_query($requete, $dbh)) {
             $flag_index = 1;
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg["aut_titre_uniforme_creation"], $msg["aut_titre_uniforme_modif_erreur"]);
             return FALSE;
         }
         audit::insert_modif(AUDIT_TITRE_UNIFORME, $this->id);
     } else {
         // creation
         $requete = 'INSERT INTO titres_uniformes ' . $requete . ' ';
         $result = pmb_mysql_query($requete, $dbh);
         if ($result) {
             $this->id = pmb_mysql_insert_id();
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg["aut_titre_uniforme_creation"], $msg["aut_titre_uniforme_creation_erreur"]);
             return FALSE;
         }
         audit::insert_creation(AUDIT_TITRE_UNIFORME, $this->id);
     }
     $this->update_oeuvre_expression($value['oeuvre_expression']);
     $this->update_other_link($value['other_link']);
     $this->update_oeuvre_event($value['oeuvre_event']);
     // auteurs
     for ($i = 0; $i < $max_aut0; $i++) {
         eval("global \$f_aut0_id{$i}; \$var_autid=\$f_aut0_id{$i};");
         eval("global \$f_f0_code{$i}; \$var_autfonc=\$f_f0_code{$i};");
         $f_aut[] = array('id' => $var_autid, 'fonction' => $var_autfonc, 'type' => '0', 'ordre' => $i);
     }
     // interpretes
     for ($i = 0; $i < $max_aut1; $i++) {
         eval("global \$f_aut1_id{$i}; \$var_autid=\$f_aut1_id{$i};");
         eval("global \$f_f1_code{$i}; \$var_autfonc=\$f_f1_code{$i};");
         $f_aut[] = array('id' => $var_autid, 'fonction' => $var_autfonc, 'type' => '1', 'ordre' => $i);
     }
     // Clean des vedettes
     titre_uniforme::delete_vedette_links($this->id);
     // traitement des auteurs
     $rqt_del = "delete from responsability_tu where responsability_tu_num='" . $this->id . "' ";
     $res_del = pmb_mysql_query($rqt_del);
     $rqt_ins = "INSERT INTO responsability_tu (responsability_tu_author_num, responsability_tu_num, responsability_tu_fonction, responsability_tu_type, responsability_tu_ordre) VALUES ";
     $i = 0;
     $var_name = 'saisie_titre_uniforme_role_composed';
     global ${$var_name};
     $role_composed = ${$var_name};
     $var_name = 'saisie_titre_uniforme_role_autre_composed';
     global ${$var_name};
     $role_composed_autre = ${$var_name};
     while ($i <= count($f_aut) - 1) {
         $id_aut = $f_aut[$i]['id'];
         if ($id_aut) {
             $fonc_aut = $f_aut[$i]['fonction'];
             $type_aut = $f_aut[$i]['type'];
             $ordre_aut = $f_aut[$i]['ordre'];
             $rqt = $rqt_ins . " ('{$id_aut}','" . $this->id . "','{$fonc_aut}','{$type_aut}', {$ordre_aut}) ";
             $res_ins = @pmb_mysql_query($rqt);
             $id_responsability_tu = pmb_mysql_insert_id();
             if ($pmb_authors_qualification) {
                 switch ($type_aut) {
                     case 0:
                         $this->update_vedette(stripslashes_array($role_composed[$ordre_aut]), $id_responsability_tu, TYPE_TU_RESPONSABILITY);
                         break;
                     case 1:
                         $this->update_vedette(stripslashes_array($role_composed_autre[$ordre_aut]), $id_responsability_tu, TYPE_TU_RESPONSABILITY_INTERPRETER);
                         break;
                 }
             }
         }
         $i++;
     }
     $aut_link = new aut_link(AUT_TABLE_TITRES_UNIFORMES, $this->id);
     $aut_link->save_form();
     $aut_pperso = new aut_pperso("tu", $this->id);
     $aut_pperso->save_form();
     //update authority informations
     $authority = new authority(0, $this->id, AUT_TABLE_TITRES_UNIFORMES);
     $authority->set_num_statut($value['statut']);
     $authority->update();
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->id, TYPE_TITRE_UNIFORME);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->id, "titre_uniforme");
     // Gestion des champ répétables
     $requete = "DELETE FROM tu_distrib WHERE distrib_num_tu='{$this->id}' ";
     pmb_mysql_query($requete, $dbh);
     $requete = "DELETE FROM tu_ref WHERE ref_num_tu='{$this->id}' ";
     pmb_mysql_query($requete, $dbh);
     $requete = "DELETE FROM tu_subdiv WHERE subdiv_num_tu='{$this->id}' ";
     pmb_mysql_query($requete, $dbh);
     // 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='{$this->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='{$this->id}',\n\t\t\tref_name='" . $value['ref'][$i] . "',\n\t\t\tref_ordre='{$i}' ";
         pmb_mysql_query($requete, $dbh);
     }
     // Subdivison de forme
     for ($i = 0; $i < count($value['subdiv']); $i++) {
         $requete = "INSERT INTO tu_subdiv SET\n\t\t\tsubdiv_num_tu='{$this->id}',\n\t\t\tsubdiv_name='" . $value['subdiv'][$i] . "',\n\t\t\tsubdiv_ordre='{$i}' ";
         pmb_mysql_query($requete, $dbh);
     }
     // mise à jour du champ index du titre uniforme
     if ($this->id) {
         titre_uniforme::update_index_tu($this->id);
     }
     // réindexation de la notice
     // 		if ($flag_index)
     titre_uniforme::update_index($this->id);
     //Enrichissement
     if ($this->id && $opac_enrichment_bnf_sparql) {
         titre_uniforme::tu_enrichment($this->id);
     }
     //mise à jour de l'oeuvre rdf
     if ($flag_index && $pmb_synchro_rdf) {
         $synchro_rdf = new synchro_rdf();
         $synchro_rdf->updateAuthority($this->id, 'oeuvre');
     }
     return TRUE;
 }
 function update($value)
 {
     global $dbh;
     global $msg;
     global $include_path;
     global $pmb_synchro_rdf;
     if (!$value['name']) {
         return false;
     }
     // nettoyage des chaînes en entrée
     $value['name'] = clean_string($value['name']);
     $value['num_author'] = clean_string($value['num_author']);
     $value['form'] = clean_string($value['form']);
     $value['date'] = clean_string($value['date']);
     $value['subject'] = clean_string($value['subject']);
     $value['place'] = clean_string($value['place']);
     $value['history'] = clean_string($value['history']);
     $value['characteristic'] = clean_string($value['characteristic']);
     $value['intended_termination'] = clean_string($value['intended_termination']);
     $value['intended_audience'] = clean_string($value['intended_audience']);
     $value['context'] = clean_string($value['context']);
     $value['equinox'] = clean_string($value['equinox']);
     $value['coordinates'] = clean_string($value['coordinates']);
     $value['tonalite'] = clean_string($value['tonalite']);
     $value['comment'] = clean_string($value['comment']);
     $titre = titre_uniforme::import_tu_exist($value, 1, $this->id);
     if ($titre) {
         require_once "{$include_path}/user_error.inc.php";
         warning($msg["aut_titre_uniforme_creation"], $msg["aut_titre_uniforme_doublon_erreur"]);
         return FALSE;
     }
     $tu_auteur = new auteur($value['num_author']);
     if (!$tu_auteur->id) {
         $value['num_author'] = 0;
     } else {
         $value['num_author'] = $tu_auteur->id;
     }
     $flag_index = 0;
     $requete = "SET ";
     $requete .= "tu_name='" . $value["name"] . "', ";
     $requete .= "tu_num_author='" . $value['num_author'] . "', ";
     $requete .= "tu_forme='" . $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 .= "tu_tonalite='" . $value["tonalite"] . "', ";
     $requete .= "tu_comment='" . $value["comment"] . "', ";
     $requete .= "tu_import_denied='" . $value["import_denied"] . "'";
     if ($this->id) {
         // update
         $requete = 'UPDATE titres_uniformes ' . $requete;
         $requete .= ' WHERE tu_id=' . $this->id . ' ;';
         if (mysql_query($requete, $dbh)) {
             $flag_index = 1;
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg["aut_titre_uniforme_creation"], $msg["aut_titre_uniforme_modif_erreur"]);
             return FALSE;
         }
         audit::insert_modif(AUDIT_TITRE_UNIFORME, $this->id);
     } else {
         // creation
         $requete = 'INSERT INTO titres_uniformes ' . $requete . ' ';
         $result = mysql_query($requete, $dbh);
         if ($result) {
             $this->id = mysql_insert_id();
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg["aut_titre_uniforme_creation"], $msg["aut_titre_uniforme_creation_erreur"]);
             return FALSE;
         }
         audit::insert_creation(AUDIT_TITRE_UNIFORME, $this->id);
     }
     $aut_link = new aut_link(AUT_TABLE_TITRES_UNIFORMES, $this->id);
     $aut_link->save_form();
     $aut_pperso = new aut_pperso("tu", $this->id);
     $aut_pperso->save_form();
     // Gestion des champ répétables
     $requete = "DELETE FROM tu_distrib WHERE distrib_num_tu='{$this->id}' ";
     mysql_query($requete, $dbh);
     $requete = "DELETE FROM tu_ref WHERE ref_num_tu='{$this->id}' ";
     mysql_query($requete, $dbh);
     $requete = "DELETE FROM tu_subdiv WHERE subdiv_num_tu='{$this->id}' ";
     mysql_query($requete, $dbh);
     // 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='{$this->id}',\n\t\t\tdistrib_name='" . $value['distrib'][$i] . "',\n\t\t\tdistrib_ordre='{$i}' ";
         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\tref_num_tu='{$this->id}',\n\t\tref_name='" . $value['ref'][$i] . "',\n\t\tref_ordre='{$i}' ";
         mysql_query($requete, $dbh);
     }
     // Subdivison de forme
     for ($i = 0; $i < count($value['subdiv']); $i++) {
         $requete = "INSERT INTO tu_subdiv SET\n\t\tsubdiv_num_tu='{$this->id}',\n\t\tsubdiv_name='" . $value['subdiv'][$i] . "',\n\t\tsubdiv_ordre='{$i}' ";
         mysql_query($requete, $dbh);
     }
     // mise à jour du champ index du titre uniforme
     if ($this->id) {
         titre_uniforme::update_index_tu($this->id);
     }
     // réindexation de la notice
     if ($flag_index) {
         titre_uniforme::update_index($this->id);
     }
     //mise à jour de l'oeuvre rdf
     if ($flag_index && $pmb_synchro_rdf) {
         $synchro_rdf = new synchro_rdf();
         $synchro_rdf->updateAuthority($this->id, 'oeuvre');
     }
     return TRUE;
 }