";
if(is_array($authperso_fields['FIELDS'])) {
foreach($authperso_fields['FIELDS'] as $field){
//printr($field);
$field_tpl=$authperso_field_tpl;
$field_tpl = str_replace("!!titre!!", $field['TITRE'], $field_tpl);
$field_tpl = str_replace("!!aff!!", $field['AFF'], $field_tpl);
$field_tpl = str_replace("!!comment!!", $field['COMMENT_DISPLAY'], $field_tpl);
$tpl.=$field_tpl;
}
}
$button_remplace = "";
$button_voir = "";
if ($pmb_type_audit && $id)
$bouton_audit= " id + 1000)."&object_id=".$id."', 'audit_popup', 700, 500, -2, -2, 'scrollbars=yes, toolbar=no, dependent=yes, resizable=yes')\" title=\"".$msg['audit_button']."\" value=\"".$msg['audit_button']."\" /> ";
$aut_link= new aut_link($this->id+1000,$id);
$authperso_form_select = str_replace('', $aut_link->get_form('saisie_authperso') , $authperso_form_select);
// Indexation concept
if($thesaurus_concepts_active == 1){
$index_concept = new index_concept($id, TYPE_AUTHPERSO);
$authperso_form_select = str_replace('', $index_concept->get_form('saisie_authperso'), $authperso_form_select);
}
$authperso_form_select = str_replace("!!libelle!!", $msg['authperso_form_titre_new'], $authperso_form_select);
$authperso_form_select = str_replace("!!list_field!!", $tpl, $authperso_form_select);
$authperso_form_select = str_replace("!!retour!!", "$base_url&action=", $authperso_form_select);
$authperso_form_select = str_replace("!!action!!", "$base_url&action=update", $authperso_form_select);
$authperso_form_select = str_replace("!!id_authperso!!", $this->id, $authperso_form_select);
$authperso_form_select = str_replace("!!id!!", $id, $authperso_form_select);
return $authperso_form_select;
}
public function update_from_form($id=0) {
global $thesaurus_concepts_active;
global $authority_statut;
global $authority_thumbnail_url;
global $msg;
$id+=0;
$p_perso=new custom_parametres_perso("authperso","authperso",$this->id);
if($p_perso->check_submited_fields()){ //Des erreurs de types dans les champs perso postés
$this->cp_error_message = $p_perso->error_message;
return;
}
$error_list = $p_perso->check_mandatory_fields_value();
if(count($error_list)){
$this->cp_error_message=sprintf($msg['parperso_field_is_needed'],$error_list[0]['field']['TITRE']);
return;
}
if(!$id){
$requete="insert into authperso_authorities set authperso_authority_authperso_num=".$this->id;
pmb_mysql_query($requete);
$id = pmb_mysql_insert_id();
audit::insert_creation ($this->id+1000,$id);
}else{
audit::insert_modif ($this->id+1000,$id);
}
if(!$id) return;
//update authority informations
$authority = new authority(0, $id, AUT_TABLE_AUTHPERSO);
$authority->set_num_statut($authority_statut);
$authority->set_thumbnail_url($authority_thumbnail_url);
$authority->update();
$p_perso->rec_fields_perso($id);
$aut_link= new aut_link($this->id+1000,$id);
$aut_link->save_form();
// Indexation concepts
if($thesaurus_concepts_active == 1){
$index_concept = new index_concept($id, TYPE_AUTHPERSO);
$index_concept->save();
}
// Mise à jour des vedettes composées contenant cette autorité
vedette_composee::update_vedettes_built_with_element($id,$this->id+1000);
$this->update_global_index($id);
return $id;
}
public function update_global_index($id){
global $include_path;
$id += 0;
$p_perso=new custom_parametres_perso("authperso","authperso",$this->id);
$mots_perso=$p_perso->get_fields_recherche($id);
if($mots_perso) {
$infos_global = $mots_perso.' ';
$infos_global_index = strip_empty_words($mots_perso).' ';
} else {
$infos_global = '';
$infos_global_index = '';
}
$req = "update authperso_authorities set authperso_infos_global='".addslashes($infos_global)."', authperso_index_infos_global='".addslashes(' '.$infos_global_index)."' where id_authperso_authority=$id";
pmb_mysql_query($req);
$indexation_authority = new indexation_authperso($include_path."/indexation/authorities/authperso/champs_base.xml", "authorities", (1000+$this->id), $this->id);
$indexation_authority->maj($id);
}
public function reindex_all(){
$req = "select id_authperso_authority from authperso_authorities";
$res = pmb_mysql_query($req);
while($fiche = pmb_mysql_fetch_object($res)){
$this->update_global_index($fiche->id_authperso_authority);
}
}
static public function update_all_global_index($id_authperso){
global $dbh, $msg;
$id_authperso+= 0;
$req = "select id_authperso_authority from authperso_authorities where authperso_authority_authperso_num=".$id_authperso ;
$res = pmb_mysql_query($req);
$p_perso=new custom_parametres_perso("authperso","authperso",$id_authperso);
while($fiche = pmb_mysql_fetch_object($res)){
$id = $fiche->id_authperso_authority;
$mots_perso=$p_perso->get_fields_recherche($id);
if($mots_perso) {
$infos_global = $mots_perso.' ';
$infos_global_index = strip_empty_words($mots_perso).' ';
} else {
$infos_global = '';
$infos_global_index = '';
}
$req = "update authperso_authorities set authperso_infos_global='".addslashes($infos_global)."', authperso_index_infos_global='".addslashes(' '.$infos_global_index)."' where id_authperso_authority=$id";
pmb_mysql_query($req);
$indexation_authority = new indexation_authperso($include_path."/indexation/authorities/authperso/champs_base.xml", "authorities", (1000+$id_authperso), $id_authperso);
$indexation_authority->maj($id);
}
return "".$msg['admin_authperso_update_global_index_end']."";
}
public function delete($id) {
global $dbh, $msg;
$id += 0;
if(($usage=aut_pperso::delete_pperso(AUT_TABLE_AUTHPERSO, $id,0) )){
// Cette autorité est utilisée dans des champs perso, impossible de supprimer
return ''.$this->display.' '.$msg['autority_delete_error'].'
'.$usage['display'];
}
$attached_vedettes = vedette_composee::get_vedettes_built_with_element($id, $this->id+1000);
if (count($attached_vedettes)) {
// Cette autorité est utilisée dans des vedettes composées, impossible de la supprimer
return '' .$this->display ." " .$msg["vedette_dont_del_autority"].' '.vedette_composee::get_vedettes_display($attached_vedettes);
}
// vedette_composee::delete_element_and_update_vedettes_built_with_element($id,$this->id+1000);
$p_perso=new custom_parametres_perso("authperso","authperso",$this->id);
$p_perso->delete_values($id);
// nettoyage indexation concepts
$index_concept = new index_concept($id, TYPE_AUTHPERSO);
$index_concept->delete();
indexation_authperso::delete_all_index($id, "authorities", "id_authority", AUT_TABLE_AUTHPERSO);
// effacement de l'identifiant unique d'autorité
$authority = new authority(0, $id, AUT_TABLE_AUTHPERSO);
$authority->delete();
$req="DELETE FROM authperso_authorities where id_authperso_authority=". $id;
$resultat=pmb_mysql_query($req);
audit::delete_audit($this->id+1000,$id);
return false;
}
public function replace_form($id) {
global $authperso_replace;
global $msg;
global $include_path;
if(!$id ) {
require_once("$include_path/user_error.inc.php");
error_message($msg[161], $msg[162], 1, './autorites.php?categ=authperso&sub=&id=');
return;
}
$authperso_replace=str_replace('!!old_authperso_libelle!!', static::get_isbd($id), $authperso_replace);
$authperso_replace=str_replace('!!id!!', $id, $authperso_replace);
$authperso_replace=str_replace('!!id_authperso!!', $this->id, $authperso_replace);
return $authperso_replace;
}
public function replace($id,$by,$link_save=0) {
global $msg;
global $pmb_synchro_rdf;
$id += 0;
$by += 0;
if (($id == $by) || (!$id) || (!$by)) return $msg[223];
$aut_link= new aut_link($this->id+1000,$id);
// "Conserver les liens entre autorités" est demandé
if($link_save) {
// liens entre autorités
$aut_link->add_link_to($this->id +1000,$by);
}
$aut_link->delete();
// remplacement dans les notices
$requete = "UPDATE notices_authperso SET notice_authperso_authority_num='$by' WHERE notice_authperso_authority_num='$id' ";
@pmb_mysql_query($requete);
vedette_composee::replace($this->id +1000, $id, $by);
//Remplacement dans les champs persos sélecteur d'autorité
aut_pperso::replace_pperso(AUT_TABLE_AUTHPERSO, $this->id, $by);
// effacement de
$this->delete($id);
// effacement de l'identifiant unique d'autorité
$authority = new authority(0, $id, AUT_TABLE_AUTHPERSO);
$authority->delete();
$this->update_global_index($by);
}
public static function import($data) {
// to do
}
public function get_ajax_list($user_input){
$values=array();
$search_word = str_replace('*','%',$user_input);
$req = "select * from authperso_authorities where ( authperso_infos_global like ' ".addslashes($search_word)."%' or authperso_index_infos_global like ' ".addslashes($user_input)."%' ) and authperso_authority_authperso_num= ".$this->id;
$req .= " order by authperso_index_infos_global limit 20";
$res = pmb_mysql_query($req);
while(($r=pmb_mysql_fetch_object($res))) {
$values[$r->id_authperso_authority]=static::get_isbd($r->id_authperso_authority);
}
return($values);
}
public static function get_ajax_list_oeuvre_events($user_input){
$values=array();
$search_word = str_replace('*','%',$user_input);
$req = "select * from authperso_authorities join authperso on authperso_authorities.authperso_authority_authperso_num = authperso.id_authperso where ( authperso_infos_global like ' ".addslashes($search_word)."%' or authperso_index_infos_global like ' ".addslashes($user_input)."%' ) and authperso.authperso_oeuvre_event = 1";
$req .= " order by authperso_index_infos_global limit 20";
$res = pmb_mysql_query($req);
while($r=pmb_mysql_fetch_object($res)) {
$values[$r->id_authperso_authority] = static::get_isbd($r->id_authperso_authority);
}
return($values);
}
public function get_cp_error_message(){
return $this->cp_error_message;
}
} //authperso class end
class authpersos {
public $info=array();
protected static $instance;
public function __construct() {
$this->fetch_data();
}
public function fetch_data() {
global $PMBuserid;
$this->info=array();
$i=0;
$req="select * from authperso order by authperso_name";
$resultat=pmb_mysql_query($req);
if (pmb_mysql_num_rows($resultat)) {
while($r=pmb_mysql_fetch_object($resultat)){
// $this->info[$i]= new authperso($r->id_authperso);
$authperso= new authperso($r->id_authperso);
$this->info[$r->id_authperso]=$authperso->get_data();
$i++;
}
}
}
public function get_data(){
return($this->info);
}
public function get_all_index_fields(){
$index_fields=array();
$req="select id_authperso from authperso order by authperso_name";
$resultat=pmb_mysql_query($req);
if (pmb_mysql_num_rows($resultat)) {
while($r=pmb_mysql_fetch_object($resultat)){
$index_fields[]=$r->id_authperso;
}
}
return $index_fields;
}
public function get_onglet_list() {
$onglets=array();
foreach($this->info as $elt){
// if($elt['onglet_num'])
$onglets[$elt['onglet_num']][]=$elt;
}
return $onglets;
}
public function get_menu() {
global $authperso_list_tpl,$authperso_list_line_tpl,$msg;
$line_tpl="