コード例 #1
0
ファイル: author.class.php プロジェクト: hogsim/PMB
 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);
     }
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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']);
         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]);
         }
     }
     // s'assurer que ce titre uniforme n'existe pas déjà
     /*$dummy = "SELECT * FROM titres_uniformes WHERE tu_name='".$value['name']."' ";
     		$check = mysql_query($dummy, $dbh);
     		if (mysql_num_rows($check)) {
     			$tu=mysql_fetch_object($check);
     			$tu_id=$tu->tu_id;
     			return $tu->tu_id;
     		}*/
     $tu_auteur = new auteur($value['num_author']);
     if (!$tu_auteur->id) {
         $value['num_author'] = 0;
     } else {
         $value['num_author'] = $tu_auteur->id;
     }
     $titre = titre_uniforme::import_tu_exist($value, $from_form);
     if ($titre) {
         return $titre;
     }
     $requete = "INSERT INTO titres_uniformes 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"] . "'";
     // insertion du titre uniforme	et mise à jour de l'index tu
     if (mysql_query($requete, $dbh)) {
         $tu_id = mysql_insert_id();
     } else {
         return FALSE;
     }
     // 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}' ";
         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}' ";
         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}' ";
         mysql_query($requete, $dbh);
     }
     audit::insert_creation(AUDIT_TITRE_UNIFORME, $tu_id);
     // mise à jour du champ index du titre uniforme
     if ($tu_id) {
         titre_uniforme::update_index_tu($tu_id);
     }
     return $tu_id;
 }