From 9e6d1fe268342e02f203fa4220ed39b4aa056cc0 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 13 May 2013 11:46:09 +1000 Subject: [PATCH 2/2] 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. --- 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 0ae843f..55affee 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 92cc3e5..86c1e9d 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') { $sth->execute($input->param('searchfield')); my $checked = $input->param('checked') ? 1 : 0; if ($sth->rows) { - $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,14 +122,15 @@ if ($op eq 'add_form') { $input->param('syntax'), $input->param('encoding'), $input->param('timeout'), + $input->param('recordtype'), $input->param('searchfield'), ); } else { $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' ), @@ -141,7 +142,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 @@ -151,7 +153,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; @@ -165,6 +167,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 @@ -196,7 +199,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 a801209..b02adb4 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 eddfc3e..2eac18c 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2179,6 +2179,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 35f575a..2de74e5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6834,6 +6834,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.11.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 18f92fc..1bf8c4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt @@ -237,6 +237,20 @@
  • seconds
  • +
  • + +
  • @@ -266,6 +280,7 @@
  • Syntax: [% syntax %]
  • Encoding: [% encoding %]
  • Timeout: [% timeout %]
  • +
  • Record type: [% recordtype %]
  • @@ -291,7 +306,7 @@ You searched for [% searchfield %] [% END %] - + [% FOREACH loo IN loop %] [% UNLESS ( loop.odd ) %] @@ -299,7 +314,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