";
// affichage du tableau des z_bib
$requete = "SELECT bib_id, bib_nom, base, search_type, count(*) as nb_attr FROM z_bib left outer join z_attr on bib_id=attr_bib_id group by bib_id, bib_nom, base, search_type ORDER BY bib_nom, base, search_type ";
$res = mysql_query($requete, $dbh);
$nbr = mysql_num_rows($res);
$parity=1;
for($i=0;$i<$nbr;$i++) {
$row=mysql_fetch_object($res);
if ($parity % 2) {
$pair_impair = "even";
} else {
$pair_impair = "odd";
}
$parity += 1;
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=z3950&sub=zbib&action=modif&id=$row->bib_id';\" ";
print "
";
print "".$row->bib_nom." | ";
print "".$row->base." | ";
print "".$row->search_type." | ";
print "".$row->nb_attr." | ";
print "
";
}
print "
";
}
function zbib_form($znom="", $zbase="", $zsearch_type="CATALOG", $zurl="", $zport="211", $zformat="UNIMARC", $zuser="", $zpassword="", $zsutrs="",$zid=0, $zfunc='') {
global $msg;
global $admin_zbib_form;
$admin_zbib_form = str_replace('!!id!!', $zid, $admin_zbib_form);
if(!$zid) $admin_zbib_form = str_replace('!!form_title!!', $msg["zbib_ajouter_serveur"], $admin_zbib_form);
else $admin_zbib_form = str_replace('!!form_title!!',$msg["zbib_modifier_serveur"], $admin_zbib_form);
$admin_zbib_form = str_replace('!!nom!!', $znom, $admin_zbib_form);
$admin_zbib_form = str_replace('!!base!!', $zbase, $admin_zbib_form);
$admin_zbib_form = str_replace('!!search_type!!', $zsearch_type, $admin_zbib_form);
$admin_zbib_form = str_replace('!!url!!', $zurl, $admin_zbib_form);
$admin_zbib_form = str_replace('!!port!!', $zport, $admin_zbib_form);
$admin_zbib_form = str_replace('!!format!!', $zformat, $admin_zbib_form);
$admin_zbib_form = str_replace('!!user!!', $zuser, $admin_zbib_form);
$admin_zbib_form = str_replace('!!password!!', $zpassword, $admin_zbib_form);
$admin_zbib_form = str_replace('!!sutrs!!', $zsutrs, $admin_zbib_form);
$admin_zbib_form = str_replace('!!zfunc!!', $zfunc, $admin_zbib_form);
$admin_zbib_form = str_replace('!!nom_script!!', addslashes($znom), $admin_zbib_form);
// added by Marco Vaninetti
print confirmation_delete("./admin.php?categ=z3950&sub=zbib&action=del&id=");
// end
print $admin_zbib_form;
}
switch($action) {
case 'update':
// no duplication
$requete = " SELECT count(1) FROM z_bib WHERE (bib_nom='$form_nom' AND bib_id!='$id' ) LIMIT 1 ";
$res = mysql_query($requete, $dbh);
$nbr = mysql_result($res, 0, 0);
if ($nbr > 0) {
error_form_message($form_nom.$msg["docs_label_already_used"]);
} else {
// O.k., now if the id already exist UPDATE else INSERT
if(!empty($form_nom) && !empty($form_base) && !empty($form_search_type) && !empty($form_url) && !empty($form_port) && !empty($form_format)) {
if($id) {
$requete = "UPDATE z_bib SET bib_nom='$form_nom', base='$form_base',
search_type='$form_search_type', url='$form_url', port='$form_port',
format='$form_format', auth_user='$form_user',
auth_pass='$form_password', sutrs_lang='$form_sutrs', fichier_func='$form_zfunc' WHERE bib_id=$id ";
$res = mysql_query($requete, $dbh);
} else {
$requete = "INSERT INTO z_bib (bib_nom, search_type, url, port, base, format, auth_user, auth_pass, sutrs_lang, fichier_func) VALUES ('$form_nom', '$form_search_type', '$form_url', '$form_port', '$form_base', '$form_format', '$form_user', '$form_password', '$form_sutrs', '$form_zfunc') ";
$res = mysql_query($requete, $dbh);
$id_insert=mysql_insert_id();
$requete = "INSERT INTO z_attr (attr_bib_id, attr_libelle, attr_attr) VALUES ('$id_insert', 'sujet', '21') ";
$res = mysql_query($requete, $dbh);
$requete = "INSERT INTO z_attr (attr_bib_id, attr_libelle, attr_attr) VALUES ('$id_insert', 'auteur', '1003') ";
$res = mysql_query($requete, $dbh);
$requete = "INSERT INTO z_attr (attr_bib_id, attr_libelle, attr_attr) VALUES ('$id_insert', 'isbn', '7') ";
$res = mysql_query($requete, $dbh);
$requete = "INSERT INTO z_attr (attr_bib_id, attr_libelle, attr_attr) VALUES ('$id_insert', 'titre', '4') ";
$res = mysql_query($requete, $dbh);
}
}
}
show_zbib($dbh);
break;
case 'add':
if(empty($form_nom) || empty($form_base) || empty($form_search_type) || empty($form_url) || empty($form_port) || empty($form_format)) {
zbib_form($form_nom, $form_base, $form_search_type, $form_url, $form_port, $form_format, $form_user, $form_password, $form_sutrs, $form_zfunc);
} else {
show_bib($dbh);
}
break;
case 'modif':
if($id){
$requete = "SELECT bib_id, bib_nom, base, search_type, url, port, format, auth_user, auth_pass, sutrs_lang, fichier_func FROM z_bib WHERE bib_id=$id ";
$res = mysql_query($requete, $dbh);
if(mysql_num_rows($res)) {
$row=mysql_fetch_object($res);
zbib_form($row->bib_nom, $row->base, $row->search_type, $row->url, $row->port, $row->format, $row->auth_user, $row->auth_pass, $row->sutrs_lang, $id, $row->fichier_func);
} else {
show_zbib($dbh);
}
} else {
show_zbib($dbh);
}
break;
case 'del':
if($id) {
$requete = "DELETE FROM z_bib WHERE bib_id=$id ";
$res = mysql_query($requete, $dbh);
$requete = "DELETE FROM z_attr WHERE attr_bib_id=$id ";
$res = mysql_query($requete, $dbh);
show_zbib($dbh);
} else show_zbib($dbh);
break;
default:
show_zbib($dbh);
break;
}
print "";