Example #1
0
 function update($nom, $comment, $id_pclass = 0)
 {
     global $dbh;
     global $msg;
     global $include_path;
     global $thesaurus_classement_mode_pmb, $thesaurus_classement_defaut;
     global $thesaurus_concepts_active;
     if (!$nom) {
         return false;
     }
     // nettoyage de la chaîne en entrée
     $nom = clean_string($nom);
     if ($thesaurus_classement_mode_pmb == 0 || $id_pclass == 0) {
         $id_pclass = $thesaurus_classement_defaut;
     }
     $requete = "SET indexint_name='{$nom}', ";
     $requete .= "indexint_comment='{$comment}', ";
     $requete .= "num_pclass='{$id_pclass}', ";
     $requete .= "index_indexint=' " . strip_empty_words($nom . " " . $comment) . " '";
     if ($this->indexint_id) {
         // update
         $requete = 'UPDATE indexint ' . $requete;
         $requete .= ' WHERE indexint_id=' . $this->indexint_id . ' LIMIT 1;';
         if (pmb_mysql_query($requete, $dbh)) {
             $aut_link = new aut_link(AUT_TABLE_INDEXINT, $this->indexint_id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("indexint", $this->indexint_id);
             $aut_pperso->save_form();
             indexint::update_index($this->indexint_id);
             audit::insert_modif(AUDIT_INDEXINT, $this->indexint_id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[indexint_update], $msg[indexint_unable]);
             return FALSE;
         }
     } else {
         // création : s'assurer que le nom n'existe pas déjà
         $dummy = "SELECT * FROM indexint WHERE indexint_name = '" . $nom . "' and num_pclass='" . $id_pclass . "' LIMIT 1 ";
         $check = pmb_mysql_query($dummy, $dbh);
         if (pmb_mysql_num_rows($check)) {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[indexint_create], $msg[indexint_exists]);
             return FALSE;
         }
         $requete = 'INSERT INTO indexint ' . $requete . ';';
         if (pmb_mysql_query($requete, $dbh)) {
             $this->indexint_id = pmb_mysql_insert_id();
             $aut_link = new aut_link(AUT_TABLE_INDEXINT, $this->indexint_id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("indexint", $this->indexint_id);
             $aut_pperso->save_form();
             audit::insert_creation(AUDIT_INDEXINT, $this->indexint_id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[indexint_create], $msg[indexint_unable_create]);
             return FALSE;
         }
     }
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->indexint_id, TYPE_INDEXINT);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->indexint_id, "indexint");
     return TRUE;
 }
 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, $force_creation = false)
 {
     global $dbh;
     global $msg, $charset;
     global $include_path;
     global $thesaurus_concepts_active;
     // nettoyage des valeurs en entrée
     $value['name'] = clean_string($value['name']);
     $value['issn'] = clean_string($value['issn']);
     if (!$value['parent']) {
         if ($value['publisher']) {
             //on les a, on crée l'éditeur
             $value['publisher'] = stripslashes_array($value['publisher']);
             //La fonction d'import fait les addslashes contrairement à l'update
             $value['parent'] = editeur::import($value['publisher']);
         }
     }
     if (!$value['name'] || !$value['parent']) {
         return false;
     }
     // construction de la requête
     $requete = 'SET collection_name="' . $value['name'] . '", ';
     $requete .= 'collection_parent="' . $value['parent'] . '", ';
     $requete .= 'collection_issn="' . $value['issn'] . '", ';
     $requete .= 'collection_web="' . $value['collection_web'] . '", ';
     $requete .= 'collection_comment="' . $value['comment'] . '", ';
     $requete .= 'index_coll=" ' . strip_empty_words($value['name']) . ' ' . strip_empty_words($value['issn']) . ' "';
     if ($this->id) {
         // update
         $requete = 'UPDATE collections ' . $requete;
         $requete .= ' WHERE collection_id=' . $this->id . ' ;';
         if (pmb_mysql_query($requete, $dbh)) {
             $requete = "update notices set ed1_id='" . $value[parent] . "' WHERE coll_id='" . $this->id . "' ";
             $res = pmb_mysql_query($requete, $dbh);
             // liens entre autorités
             $aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("collection", $this->id);
             $aut_pperso->save_form();
             audit::insert_modif(AUDIT_COLLECTION, $this->id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[167], htmlentities($msg[169] . " -> " . $this->display, ENT_QUOTES, $charset));
             return FALSE;
         }
     } else {
         if (!$force_creation) {
             // création : s'assurer que la collection n'existe pas déjà
             if ($id_collection_exists = collection::check_if_exists($value)) {
                 $collection_exists = new collection($id_collection_exists);
                 require_once "{$include_path}/user_error.inc.php";
                 warning($msg[167], htmlentities($msg[171] . " -> " . $collection_exists->display, ENT_QUOTES, $charset));
                 return FALSE;
             }
         }
         $requete = 'INSERT INTO collections ' . $requete . ';';
         if (pmb_mysql_query($requete, $dbh)) {
             $this->id = pmb_mysql_insert_id();
             // liens entre autorités
             $aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
             $aut_link->save_form();
             audit::insert_creation(AUDIT_COLLECTION, $this->id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[167], htmlentities($msg[170] . " -> " . $requete, ENT_QUOTES, $charset));
             return FALSE;
         }
     }
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->id, TYPE_COLLECTION);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->id, "collection");
     if ($value['subcollections']) {
         for ($i = 0; $i < count($value['subcollections']); $i++) {
             $subcoll = stripslashes_array($value['subcollections'][$i]);
             //La fonction d'import fait les addslashes contrairement à l'update
             $subcoll['coll_parent'] = $this->id;
             subcollection::import($subcoll);
         }
     }
     //update authority informations
     $authority = new authority(0, $this->id, AUT_TABLE_COLLECTIONS);
     $authority->set_num_statut($value['statut']);
     $authority->update();
     collection::update_index($this->id);
     return true;
 }
Example #4
0
 function update($value)
 {
     global $dbh;
     global $msg;
     global $include_path;
     global $pmb_synchro_rdf;
     global $thesaurus_concepts_active;
     if (!$value['name']) {
         return false;
     }
     // nettoyage des valeurs en entree
     $value[name] = clean_string($value[name]);
     $value[adr1] = clean_string($value[adr1]);
     $value[adr2] = clean_string($value[adr2]);
     $value[cp] = clean_string($value[cp]);
     $value[ville] = clean_string($value[ville]);
     $value[pays] = clean_string($value[pays]);
     $value[web] = clean_string($value[web]);
     // construction de la requete
     $requete = "SET ed_name='{$value['name']}', ";
     $requete .= "ed_adr1='{$value['adr1']}', ";
     $requete .= "ed_adr2='{$value['adr2']}', ";
     $requete .= "ed_cp='{$value['cp']}', ";
     $requete .= "ed_ville='{$value['ville']}', ";
     $requete .= "ed_pays='{$value['pays']}', ";
     $requete .= "ed_web='{$value['web']}', ";
     $requete .= "ed_comment='{$value['ed_comment']}', ";
     $requete .= "index_publisher=' " . strip_empty_chars($value[name] . " " . $value[ville] . " " . $value[pays]) . " '";
     if ($this->id) {
         // update
         $requete = 'UPDATE publishers ' . $requete;
         $requete .= ' WHERE ed_id=' . $this->id . ' LIMIT 1;';
         if (pmb_mysql_query($requete, $dbh)) {
             $aut_link = new aut_link(AUT_TABLE_PUBLISHERS, $this->id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("publisher", $this->id);
             $aut_pperso->save_form();
             editeur::update_index($this->id);
             audit::insert_modif(AUDIT_PUBLISHER, $this->id);
             //mise à jour de l'éditeur dans la base rdf
             if ($pmb_synchro_rdf) {
                 $synchro_rdf = new synchro_rdf();
                 $synchro_rdf->updateAuthority($this->id, 'editeur');
             }
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[145], $msg[150]);
             return FALSE;
         }
     } else {
         // s'assurer que l'editeur n'existe pas deja
         // on teste sur le nom et la ville seulement. voir a l'usage si necessaire de tester plus
         if (editeur::check_if_exists($value)) {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[145], $msg[149] . " ({$value['name']}).");
             return FALSE;
         }
         $requete = 'INSERT INTO publishers ' . $requete . ';';
         if (pmb_mysql_query($requete, $dbh)) {
             $this->id = pmb_mysql_insert_id();
             $aut_link = new aut_link(AUT_TABLE_PUBLISHERS, $this->id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("publisher", $this->id);
             $aut_pperso->save_form();
             audit::insert_creation(AUDIT_PUBLISHER, $this->id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[145], $msg[151]);
             return FALSE;
         }
     }
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->id, TYPE_PUBLISHER);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->id, "publisher");
     return TRUE;
 }
Example #5
0
 function update($value)
 {
     global $dbh;
     global $msg;
     global $include_path;
     global $thesaurus_concepts_active;
     global $authority_statut;
     if (!$value) {
         return false;
     }
     // nettoyage de la chaîne en entrée
     $value = clean_string($value);
     $requete = 'SET serie_name="' . $value . '", ';
     $requete .= 'serie_index=" ' . strip_empty_words($value) . '" ';
     if ($this->s_id) {
         // update
         $requete = 'UPDATE series ' . $requete;
         $requete .= ' WHERE serie_id=' . $this->s_id . ' LIMIT 1;';
         if (pmb_mysql_query($requete, $dbh)) {
             $rqt_notice = "select notice_id,tit1,tit2,tit3,tit4 from notices where tparent_id=" . $this->s_id;
             $r_notice = pmb_mysql_query($rqt_notice);
             while ($r = pmb_mysql_fetch_object($r_notice)) {
                 $rq_serie = "update notices, series set notices.index_serie=serie_index, notices.index_wew=concat(serie_name,' ',tit1,' ',tit2,' ',tit3,' ',tit4),notices.index_sew=concat(' ',serie_index,' ','" . addslashes(strip_empty_words($r->tit1 . " " . $r->tit2 . " " . $r->tit3 . " " . $r->tit4)) . "',' ') where notice_id=" . $r->notice_id . " and serie_id=tparent_id";
                 pmb_mysql_query($rq_serie);
             }
             $aut_link = new aut_link(AUT_TABLE_SERIES, $this->s_id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("serie", $this->s_id);
             $aut_pperso->save_form();
             audit::insert_modif(AUDIT_SERIE, $this->s_id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[337], $msg[341]);
             return FALSE;
         }
     } else {
         // création : s'assurer que le titre n'existe pas déjà
         $dummy = "SELECT * FROM series WHERE serie_name REGEXP '^{$value}\$' LIMIT 1 ";
         $check = pmb_mysql_query($dummy, $dbh);
         if (pmb_mysql_num_rows($check)) {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[336], $msg[340]);
             return FALSE;
         }
         $requete = 'INSERT INTO series ' . $requete . ';';
         if (pmb_mysql_query($requete, $dbh)) {
             $this->s_id = pmb_mysql_insert_id();
             $aut_link = new aut_link(AUT_TABLE_SERIES, $this->s_id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("serie", $this->s_id);
             $aut_pperso->save_form();
             audit::insert_creation(AUDIT_SERIE, $this->s_id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[336], $msg[342]);
             return FALSE;
         }
     }
     //update authority informations
     $authority = new authority(0, $this->s_id, AUT_TABLE_SERIES);
     $authority->set_num_statut($authority_statut);
     $authority->update();
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->s_id, TYPE_SERIE);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->s_id, "serie");
     serie::update_index($this->s_id);
     return TRUE;
 }
 function save()
 {
     global $dbh;
     global $msg;
     $no = new noeuds($this->num_noeud);
     $num_thesaurus = $no->num_thesaurus;
     //On teste si la categorie existe à ce niveau
     //$categ_exist = $this->searchLibelle($this->libelle_categorie,$num_thesaurus,$this->langue,$no->num_parent);
     //if ($categ_exist != 0) {
     //require_once("$include_path/user_error.inc.php");
     //warning($msg['create_category'],$msg['create_category_double']);
     //on supprime les relations dans la base
     //$this->delete($this->num_noeud,$this->langue);
     //$no->delete($this->num_noeud);
     //return FALSE;
     //} else {
     $q = "update categories set ";
     $q .= "num_thesaurus = '" . $num_thesaurus . "', ";
     $q .= "libelle_categorie = '" . addslashes($this->libelle_categorie) . "', ";
     $q .= "note_application = '" . addslashes($this->note_application) . "', ";
     $q .= "comment_public = '" . addslashes($this->comment_public) . "', ";
     $q .= "comment_voir = '" . addslashes($this->comment_voir) . "', ";
     $q .= "index_categorie = ' " . addslashes(strip_empty_words($this->libelle_categorie, $this->langue)) . " ' ";
     $q .= "where num_noeud = '" . $this->num_noeud . "' and langue = '" . $this->langue . "' ";
     $r = pmb_mysql_query($q, $dbh);
     categories::update_index($this->num_noeud);
     $this->update_index_path_word();
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->num_noeud, "category");
     //}
 }
Example #7
0
 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;
 }
 protected function proceed_save($list = true)
 {
     $this->item->get_values_from_form();
     $result = $this->handler->save($this->item);
     if ($result !== true) {
         $ui_class_name = self::resolve_ui_class_name($this->params->sub, $this->handler->get_onto_name());
         $ui_class_name::display_errors($this, $result);
     } else {
         vedette_composee::update_vedettes_built_with_element(onto_common_uri::get_id($this->item->get_uri()), "ontology" . $this->params->ontology_id);
         if ($list) {
             $this->proceed_list();
         }
     }
 }
Example #9
0
 protected function proceed_save($list = true)
 {
     global $dbh;
     $this->item->get_values_from_form();
     $result = $this->handler->save($this->item);
     if ($result !== true) {
         $ui_class_name = self::resolve_ui_class_name($this->params->sub, $this->handler->get_onto_name());
         $ui_class_name::display_errors($this, $result);
     } else {
         //TODO: reprendre ce hack un peu crade
         //pour faciliter les requetes SPARQL en gestion, on ajoute une propriété qui sort de nulle part... pmb:showInTop si pas de parent dans le schéma
         $query = "select ?scheme ?broader ?broaderScheme where{\n\t\t\t\t<" . $this->item->get_uri() . "> rdf:type skos:Concept .\t\n\t\t\t\t<" . $this->item->get_uri() . "> skos:inScheme ?scheme .\n\t\t\t\toptional {\n\t\t\t\t\t<" . $this->item->get_uri() . "> skos:broader ?broader .\n\t\t\t\t\t?broader skos:inScheme ?broaderScheme\n\t\t\t\t}\t\t\n\t\t\t} order by ?scheme ?broader";
         $this->handler->data_query($query);
         if ($this->handler->data_num_rows()) {
             $results = $this->handler->data_result();
             $lastScheme = $results[0]->scheme;
             $flag = true;
             foreach ($results as $result) {
                 if ($result->scheme == $result->broaderScheme) {
                     $flag = false;
                 }
                 if ($lastScheme != $result->scheme) {
                     if ($flag) {
                         $query = "insert into <pmb> {<" . $this->item->get_uri() . "> pmb:showInTop <" . $lastScheme . ">}";
                         $this->handler->data_query($query);
                     }
                     $flag = true;
                     $lastScheme = $result->scheme;
                 }
             }
             if ($flag) {
                 $query = "insert into <pmb> {<" . $this->item->get_uri() . "> pmb:showInTop <" . $lastScheme . ">}";
                 $this->handler->data_query($query);
             }
         } else {
             $query = "select * where{\n\t\t\t\t<" . $this->item->get_uri() . "> rdf:type skos:Concept .\t\n\t\t\t\toptional{\t\t\n\t\t\t\t <" . $this->item->get_uri() . "> skos:inScheme ?scheme .\n\t\t\t\t} . filter(!bound(?scheme)) .\n\t\t\t\t optional {\n\t\t\t\t\t<" . $this->item->get_uri() . "> skos:broader ?broader .\n\t\t\t\t\t?broader skos:inScheme ?broaderScheme\n\t\t\t\t} filter (!bound(?broaderScheme))\n\t\t\t} ";
             $this->handler->data_query($query);
             if (!$this->handler->data_num_rows()) {
                 $query = "insert into <pmb> {<" . $this->item->get_uri() . "> pmb:showInTop owl:Nothing}";
                 $this->handler->data_query($query);
             }
         }
         //sauvegarde des autorités liées pour les concepts...
         if (get_class($this->item) == "onto_skos_concept_item") {
             $aut_link = new aut_link(AUT_TABLE_CONCEPT, onto_common_uri::get_id($this->item->get_uri()));
             $aut_link->save_form();
         }
         // Mise à jour des vedettes composées contenant cette autorité
         vedette_composee::update_vedettes_built_with_element(onto_common_uri::get_id($this->item->get_uri()), "concept");
         //réindexation des notices indexés avec le concepts
         $query = "select num_object from index_concept where type_object =1 and num_concept = " . onto_common_uri::get_id($this->item->get_uri());
         $result = pmb_mysql_query($query, $dbh);
         if ($result && pmb_mysql_num_rows($result)) {
             while ($row = pmb_mysql_fetch_object($result)) {
                 notice::majNoticesMotsGlobalIndex($row->num_object, "concept");
             }
         }
     }
     if ($list) {
         $this->proceed_list();
     }
 }
Example #10
0
 function update($value, $force_creation = false)
 {
     global $dbh;
     global $msg, $charset;
     global $include_path;
     global $thesaurus_concepts_active;
     //si on a pas d'id, on peut avoir les infos de la collection
     if (!$value['parent']) {
         if ($value['collection']) {
             //on les a, on crée l'éditeur
             $value['collection'] = stripslashes_array($value['collection']);
             //La fonction d'import fait les addslashes contrairement à l'update
             $value['parent'] = collection::import($value['collection']);
         }
     }
     if (!$value['name'] || !$value['parent']) {
         return false;
     }
     // nettoyage des valeurs en entrée
     $value['name'] = clean_string($value['name']);
     // construction de la requête
     $requete = "SET sub_coll_name='{$value['name']}', ";
     $requete .= "sub_coll_parent='{$value['parent']}', ";
     $requete .= "sub_coll_issn='{$value['issn']}', ";
     $requete .= "subcollection_web='{$value['subcollection_web']}', ";
     $requete .= "subcollection_comment='{$value['comment']}', ";
     $requete .= "index_sub_coll=' " . strip_empty_words($value[name]) . " " . strip_empty_words($value["issn"]) . " '";
     if ($this->id) {
         // update
         $requete = 'UPDATE sub_collections ' . $requete;
         $requete .= ' WHERE sub_coll_id=' . $this->id . ' ';
         if (pmb_mysql_query($requete, $dbh)) {
             $requete = "select collection_parent from collections WHERE collection_id='" . $value[parent] . "' ";
             $res = pmb_mysql_query($requete, $dbh);
             $ed_parent = pmb_mysql_result($res, 0, 0);
             $requete = "update notices set ed1_id='{$ed_parent}', coll_id='" . $value[parent] . "' WHERE subcoll_id='" . $this->id . "' ";
             $res = pmb_mysql_query($requete, $dbh);
             $aut_link = new aut_link(AUT_TABLE_SUB_COLLECTIONS, $this->id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("subcollection", $this->id);
             $aut_pperso->save_form();
             audit::insert_modif(AUDIT_SUB_COLLECTION, $this->id);
             subcollection::update_index($this->id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[178], htmlentities($msg[182] . " -> " . $this->display, ENT_QUOTES, $charset));
             return FALSE;
         }
     } else {
         if (!$force_creation) {
             // création : s'assurer que la sous-collection n'existe pas déjà
             if ($id_subcollection_exists = subcollection::check_if_exists($value)) {
                 $subcollection_exists = new subcollection($id_subcollection_exists);
                 require_once "{$include_path}/user_error.inc.php";
                 warning($msg[177], htmlentities($msg[219] . " -> " . $subcollection_exists->display, ENT_QUOTES, $charset));
                 return FALSE;
             }
         }
         $requete = 'INSERT INTO sub_collections ' . $requete . ';';
         if (pmb_mysql_query($requete, $dbh)) {
             $this->id = pmb_mysql_insert_id();
             $aut_link = new aut_link(AUT_TABLE_SUB_COLLECTIONS, $this->id);
             $aut_link->save_form();
             $aut_pperso = new aut_pperso("subcollection", $this->id);
             $aut_pperso->save_form();
             audit::insert_creation(AUDIT_SUB_COLLECTION, $this->id);
         } else {
             require_once "{$include_path}/user_error.inc.php";
             warning($msg[177], htmlentities($msg[182] . " -> " . $requete, ENT_QUOTES, $charset));
             return FALSE;
         }
     }
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($this->id, TYPE_SUBCOLLECTION);
         $index_concept->save();
     }
     // Mise à jour des vedettes composées contenant cette autorité
     vedette_composee::update_vedettes_built_with_element($this->id, "subcollection");
     return TRUE;
 }