From a798c53730fb7b341e6337fee2e2ca64267d7716 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 13 May 2013 11:46:09 +1000 Subject: [PATCH] Bug 10096 [FOLLOW-UP] - Add a z39.50 interface for authority searching This patch adds the "recordtype" column to the "z3950servers" table. The value in this column (biblio or authority) then controls whether the z3950 server shows up in a bibliographic search (through the Acq and Cataloguing modules) or in an authority search (through the Authorities module). I also edited the z3950 management console to show this value and allow users to edit it. The default value is "biblio", since the vast majority of z3950 targets will be bibliographic. However, there is an option to add/edit a z3950 target as a source of authority records. Test Plan: 1) Apply both patches 2) Run updatedatabase.pl (after setting your KOHA_CONF and PERL5 environmental variables) 3) Use the test plan from the 1st patch N.B. Make sure that your Z39.50 client target has a Record Type of Authority, otherwise it won't display when you're doing a Z3950 search for authorities. Signed-off-by: Mason James --- acqui/z3950_search.pl | 2 +- admin/z3950servers.pl | 22 +++++++++++-------- cataloguing/z3950_auth_search.pl | 2 +- cataloguing/z3950_search.pl | 2 +- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 ++++++ .../prog/en/modules/admin/z3950servers.tt | 19 +++++++++++++++- .../en/modules/cataloguing/z3950_auth_search.tt | 2 +- 8 files changed, 42 insertions(+), 15 deletions(-) diff --git a/acqui/z3950_search.pl b/acqui/z3950_search.pl index 647db8c..f9c1ab5 100755 --- a/acqui/z3950_search.pl +++ b/acqui/z3950_search.pl @@ -93,7 +93,7 @@ $template->param( ); if ( $op ne "do_search" ) { - my $sth = $dbh->prepare("select id,host,name,checked from z3950servers order by host"); + my $sth = $dbh->prepare("select id,host,name,checked from z3950servers where recordtype <> 'authority' order by host"); $sth->execute(); my $serverloop = $sth->fetchall_arrayref( {} ); $template->param( diff --git a/admin/z3950servers.pl b/admin/z3950servers.pl index 87711c1..c1e657c 100755 --- a/admin/z3950servers.pl +++ b/admin/z3950servers.pl @@ -40,7 +40,7 @@ sub StringSearch { $searchstring = ''; } - my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout"; + my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype"; $query .= " FROM z3950servers"; if ( $searchstring ne '' ) { $query .= " WHERE (name like ?)" } $query .= " ORDER BY rank,name"; @@ -91,7 +91,7 @@ if ($op eq 'add_form') { my $data; if ($searchfield) { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout from z3950servers where (name = ?) order by rank,name"); + my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name"); $sth->execute($searchfield); $data=$sth->fetchrow_hashref; $sth->finish; @@ -99,7 +99,7 @@ if ($op eq 'add_form') { $template->param( $_ => $data->{$_} ) for ( qw( host port db userid password checked rank timeout encoding ) ); $template->param( $_ . $data->{$_} => 1) - for ( qw( syntax ) ); + for ( qw( syntax recordtype ) ); # END $OP eq ADD_FORM ################## ADD_VALIDATE ################################## # called by add_form, used to insert/modify data in DB @@ -110,7 +110,7 @@ if ($op eq 'add_form') { my $checked = $input->param('checked') ? 1 : 0; if ($sth->rows) { $template->param(confirm_update => 1); - $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=? where name=?"); + $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?"); $sth->execute($input->param('host'), $input->param('port'), $input->param('db'), @@ -122,6 +122,7 @@ if ($op eq 'add_form') { $input->param('syntax'), $input->param('encoding'), $input->param('timeout'), + $input->param('recordtype'), $input->param('searchfield'), ); } @@ -129,8 +130,8 @@ if ($op eq 'add_form') { $template->param(confirm_add => 1); $sth=$dbh->prepare( "INSERT INTO z3950servers " . - "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout) " . - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); + "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " . + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); $sth->execute( $input->param( 'host' ), $input->param( 'port' ), @@ -142,7 +143,8 @@ if ($op eq 'add_form') { $input->param( 'rank' ), $input->param( 'syntax' ), $input->param( 'encoding' ), - $input->param( 'timeout' ) ); + $input->param( 'timeout' ), + $input->param( 'recordtype' ) ); } $sth->finish; # END $OP eq ADD_VALIDATE @@ -152,7 +154,7 @@ if ($op eq 'add_form') { $template->param(delete_confirm => 1); my $dbh = C4::Context->dbh; - my $sth2=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout from z3950servers where (name = ?) order by rank,name"); + my $sth2=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name"); $sth2->execute($searchfield); my $data=$sth2->fetchrow_hashref; $sth2->finish; @@ -166,6 +168,7 @@ if ($op eq 'add_form') { rank => $data->{'rank'}, syntax => $data->{'syntax'}, timeout => $data->{'timeout'}, + recordtype => $data->{'recordtype'}, encoding => $data->{'encoding'} ); # END $OP eq DELETE_CONFIRM @@ -197,7 +200,8 @@ if ($op eq 'add_form') { rank => $results->[$i]{'rank'}, syntax => $results->[$i]{'syntax'}, encoding => $results->[$i]{'encoding'}, - timeout => $results->[$i]{'timeout'}); + timeout => $results->[$i]{'timeout'}, + recordtype => $results->[$i]{'recordtype'}); push @loop, \%row; } diff --git a/cataloguing/z3950_auth_search.pl b/cataloguing/z3950_auth_search.pl index 11a8b10..9fbddbd 100755 --- a/cataloguing/z3950_auth_search.pl +++ b/cataloguing/z3950_auth_search.pl @@ -70,7 +70,7 @@ $template->param( ); if ( $op ne "do_search" ) { - my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers ORDER BY rank, name"); + my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers WHERE recordtype = 'authority' ORDER BY rank, name"); $sth->execute(); my $serverloop = $sth->fetchall_arrayref( {} ); $template->param( diff --git a/cataloguing/z3950_search.pl b/cataloguing/z3950_search.pl index 8534190..a754c45 100755 --- a/cataloguing/z3950_search.pl +++ b/cataloguing/z3950_search.pl @@ -74,7 +74,7 @@ $template->param( ); if ( $op ne "do_search" ) { - my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers ORDER BY rank, name"); + my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers WHERE recordtype <> 'authority' ORDER BY rank, name"); $sth->execute(); my $serverloop = $sth->fetchall_arrayref( {} ); $template->param( diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 8a8b70f..d57c2db 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2280,6 +2280,7 @@ CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets u `type` enum('zed','opensearch') NOT NULL default 'zed', `encoding` text default NULL, -- characters encoding provided by this target `description` text NOT NULL, -- unused in Koha + `recordtype` varchar(45) NOT NULL default 'biblio', -- server contains bibliographic or authority records PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 74aeb3e..9c4a11d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7067,6 +7067,13 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ALTER TABLE `z3950servers` ADD COLUMN `recordtype` VARCHAR(45) NOT NULL DEFAULT 'biblio';}); + print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt index 4bfdecd..81df25d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt @@ -240,6 +240,20 @@
  • seconds
  • +
  • + +
  • @@ -276,6 +290,7 @@
  • Syntax: [% syntax %]
  • Encoding: [% encoding %]
  • Timeout: [% timeout %]
  • +
  • Record type: [% recordtype %]
  • @@ -301,7 +316,7 @@ You searched for [% searchfield %] [% END %] - + [% FOREACH loo IN loop %] [% UNLESS ( loop.odd ) %] @@ -309,7 +324,7 @@ [% ELSE %] [% END %] - + [% END %]
    TargetHostname/PortDatabaseUseridPasswordCheckedRankSyntaxEncodingTimeout  
    TargetHostname/PortDatabaseUseridPasswordCheckedRankSyntaxEncodingTimeoutRecord type  
    [% loo.name %][% loo.host %]:[% loo.port %][% loo.db %][% loo.userid %][% loo.password %][% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %][% loo.rank %] [% loo.syntax %][% loo.encoding %][% loo.timeout %]EditDelete
    [% loo.name %][% loo.host %]:[% loo.port %][% loo.db %][% loo.userid %][% loo.password %][% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %][% loo.rank %] [% loo.syntax %][% loo.encoding %][% loo.timeout %][% loo.recordtype %]EditDelete
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt index ff7c320..42a23f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt @@ -109,7 +109,7 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color :
      -
    1. +
    2. -- 1.7.7.4