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); } 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; } } //update authority informations $authority = new authority(0, $this->id, AUT_TABLE_SUB_COLLECTIONS); $authority->set_num_statut($value['statut']); $authority->update(); // 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"); subcollection::update_index($this->id); return TRUE; }
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; } }
public function check_if_exists($data) { switch ($data['type_authority']) { case "collection": $id = collection::check_if_exists($data); break; case "subcollection": $id = subcollection::check_if_exists($data); break; } return $id; }
function update($value, $force_creation = false) { global $dbh; global $msg, $charset; global $include_path; //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 (mysql_query($requete, $dbh)) { $requete = "select collection_parent from collections WHERE collection_id='" . $value[parent] . "' "; $res = mysql_query($requete, $dbh); $ed_parent = mysql_result($res, 0, 0); $requete = "update notices set ed1_id='{$ed_parent}', coll_id='" . $value[parent] . "' WHERE subcoll_id='" . $this->id . "' "; $res = 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); return TRUE; } 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 (mysql_query($requete, $dbh)) { $this->id = 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); return TRUE; } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[177], htmlentities($msg[182] . " -> " . $requete, ENT_QUOTES, $charset)); return FALSE; } } }