@@ -, +, @@ --- C4/Auth.pm | 1 + C4/Breeding.pm | 10 +- Koha/Schema/Result/Z3950server.pm | 8 + admin/z3950servers.pl | 2 +- .../data/mysql/atomicupdate/bug11361.perl | 8 + .../en/modules/admin/preferences/opac.pref | 6 + .../prog/en/modules/admin/z3950servers.tt | 11 +- .../bootstrap/en/includes/masthead.inc | 5 + .../bootstrap/en/includes/opac-bottom.inc | 12 + .../bootstrap/en/modules/opac-z3950-search.tt | 304 ++++++++++++++++++ opac/opac-z3950-search.pl | 117 +++++++ 11 files changed, 477 insertions(+), 7 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug11361.perl create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-z3950-search.tt create mode 100755 opac/opac-z3950-search.pl --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -562,6 +562,7 @@ sub get_template_and_user { OPACURLOpenInNewWindow => "" . C4::Context->preference("OPACURLOpenInNewWindow"), OPACUserCSS => "" . C4::Context->preference("OPACUserCSS"), OpacAuthorities => C4::Context->preference("OpacAuthorities"), + OpacZ3950 => C4::Context->preference("OpacZ3950"), opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, opac_search_limit => $opac_search_limit, opac_limit_override => $opac_limit_override, --- a/C4/Breeding.pm +++ a/C4/Breeding.pm @@ -126,7 +126,7 @@ The second parameter $template is a Template object. The routine uses this param =cut sub Z3950Search { - my ($pars, $template)= @_; + my ($pars, $template, $fromopac)= @_; my @id= @{$pars->{id}}; my $page= $pars->{page}; @@ -192,7 +192,7 @@ sub Z3950Search { for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) { if ( $oResult[$k]->record($i) ) { undef $error; - ( $res, $error ) = _handle_one_result( $oResult[$k]->record($i), $servers[$k], ++$imported, $biblionumber, $xslh ); #ignores error in sequence numbering + ( $res, $error ) = _handle_one_result( $oResult[$k]->record($i), $servers[$k], ++$imported, $biblionumber, $xslh, $fromopac ); #ignores error in sequence numbering push @breeding_loop, $res if $res; push @errconn, { server => $servers[$k]->{servername}, error => $error, seq => $i+1 } if $error; } @@ -291,7 +291,7 @@ sub _build_query { } sub _handle_one_result { - my ( $zoomrec, $servhref, $seq, $bib, $xslh )= @_; + my ( $zoomrec, $servhref, $seq, $bib, $xslh, $fromopac )= @_; my $raw= $zoomrec->raw(); my $marcrecord; @@ -304,7 +304,7 @@ sub _handle_one_result { } SetUTF8Flag($marcrecord); my $error; - ( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh); + ( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh) unless $fromopac; my $batch_id = GetZ3950BatchId($servhref->{servername}); my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0); @@ -318,6 +318,7 @@ sub _handle_one_result { { biblionumber => $bib, server => $servhref->{servername}, + host => $servhref->{host}, breedingid => $breedingid, }, $marcrecord) if $breedingid; return ( $row, $error ); @@ -350,6 +351,7 @@ sub _do_xslt_proc { sub _add_rowdata { my ($row, $record)=@_; my %fetch= ( + biblionumber => 'biblio.biblionumber', title => 'biblio.title', author => 'biblio.author', isbn =>'biblioitems.isbn', --- a/Koha/Schema/Result/Z3950server.pm +++ a/Koha/Schema/Result/Z3950server.pm @@ -126,6 +126,12 @@ __PACKAGE__->table("z3950servers"); is_nullable: 1 size: 255 +=head2 opac + + data_type: 'tinyint' + is_nullable: 1 + size: 1 + =cut __PACKAGE__->add_columns( @@ -175,6 +181,8 @@ __PACKAGE__->add_columns( { data_type => "longtext", is_nullable => 1 }, "attributes", { data_type => "varchar", is_nullable => 1, size => 255 }, + "opac", + { data_type => "tinyint", is_nullable => 1, size => 1 }, ); =head1 PRIMARY KEY --- a/admin/z3950servers.pl +++ a/admin/z3950servers.pl @@ -66,7 +66,7 @@ if( $op eq 'delete_confirmed' && $id ) { $id = 0; } elsif ( $op eq 'add_validated' ) { my @fields=qw/host port db userid password rank syntax encoding timeout - recordtype checked servername servertype sru_options sru_fields attributes + recordtype checked servername servertype sru_options sru_fields attributes opac add_xslt/; my $formdata = _form_data_hashref( $input, \@fields ); if( $id ) { --- a/installer/data/mysql/atomicupdate/bug11361.perl +++ a/installer/data/mysql/atomicupdate/bug11361.perl @@ -0,0 +1,8 @@ +$DBversion = "XXX"; +if( CheckVersion( $DBversion ) ) { + $dbh->do("ALTER TABLE z3950servers ADD COLUMN opac TINYINT(1);"); + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACZ3950','0','','Allow patrons to search for bibliographic records in other libraries via Z39.50.','YesNo');"); + print "Add opac column to z3950servers table."; + print "Add OPACZ3950 preference."; + SetVersion($DBversion); +} --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -426,6 +426,12 @@ OPAC: yes: Allow no: "Don't allow" - patrons to search your authority records. + - + - pref: OpacZ3950 + choices: + yes: Allow + no: "Don't allow" + - patrons to search for bibliographic records in other libraries via Z39.50. - - pref: opacbookbag choices: --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt @@ -79,6 +79,13 @@ [% END %] +
Target | Hostname/Port | Database | Userid | Password | Preselected | Rank | Syntax | Encoding | Timeout | Record type | Attributes | Actions | +||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Target | Hostname/Port | Database | Userid | Password | Preselected | Rank | Syntax | Encoding | Timeout | Record type | Attributes | Opac | Options | [% loo.attributes | html %] | +[% IF loo.opac %]X[% END %] |
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
@@ -310,6 +310,11 @@
Authority search
[% END %]
+ [% IF Koha.Preference( 'OpacZ3950' ) %]
+
+
+[% search_fields = [
+ { label => "ISBN", prop => 'isbn' },
+ { label => "ISSN", prop => 'issn' },
+ { label => "Title", prop => 'title' },
+ { label => "Author", prop => 'author' },
+ { label => "Subject Heading", prop => 'subject' },
+ { label => "Keyword (any)", prop => 'srchany' },
+ { label => "LC call number", prop => 'lccall' },
+ { label => "Control no.", prop => 'controlnumber' },
+ { label => "Dewey", prop => 'dewey' },
+ { label => "Standard ID", prop => 'stdid' }
+] %]
+[% IF ( opsearch ) %]
+
+
+[% IF ( numberpending ) %]
+
+Z39.50/SRU search+Still [% numberpending %] servers to search[% END %] + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %][% END %] +[% INCLUDE 'datatables.inc' %] + + + --- a/opac/opac-z3950-search.pl +++ a/opac/opac-z3950-search.pl @@ -0,0 +1,117 @@ +#!/usr/bin/perl + +# This is a completely new Z3950 clients search using async ZOOM -TG 02/11/06 +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; +use CGI; + +use C4::Auth; +use C4::Output; +use C4::Context; +use C4::Breeding; +use C4::Koha; + +my $input = new CGI; +my $error = $input->param('error'); +my $biblionumber = $input->param('biblionumber') || 0; +my $frameworkcode = $input->param('frameworkcode'); +my $title = $input->param('title'); +my $author = $input->param('author'); +my $isbn = $input->param('isbn'); +my $issn = $input->param('issn'); +my $lccn = $input->param('lccn'); +my $lccall = $input->param('lccall'); +my $subject = $input->param('subject'); +my $dewey = $input->param('dewey'); +my $controlnumber = $input->param('controlnumber'); +my $stdid = $input->param('stdid'); +my $srchany = $input->param('srchany'); +my $op = $input->param('op')||''; + +my $page = $input->param('current_page') || 1; +$page = $input->param('goto_page') if $input->param('changepage_goto'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ + template_name => "opac-z3950-search.tt", + query => $input, + type => "opac", + authnotrequired => 1, + debug => 1, +}); + +$template->param( + frameworkcode => $frameworkcode, + isbn => $isbn, + issn => $issn, + lccn => $lccn, + lccall => $lccall, + title => $title, + author => $author, + controlnumber=> $controlnumber, + stdid => $stdid, + srchany => $srchany, + biblionumber => $biblionumber, + dewey => $dewey, + subject => $subject, +); + +if ( $op ne "do_search" ) { + my $schema = Koha::Database->new()->schema(); + my $rs = $schema->resultset('Z3950server')->search( + { + recordtype => 'biblio', + servertype => ['zed', 'sru'], + opac => '1', + }, + { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }, + ); + $template->param( + serverloop => [ $rs->all ], + opsearch => "search", + ); + output_html_with_http_headers $input, $cookie, $template->output; + exit; +} + +my @id = $input->param('id'); +if ( @id==0 ) { + # empty server list -> report and exit + $template->param( emptyserverlist => 1 ); + output_html_with_http_headers $input, $cookie, $template->output; + exit; +} + +my $pars= { + biblionumber => $biblionumber, + page => $page, + id => \@id, + isbn => $isbn, + issn => $issn, + title => $title, + author => $author, + dewey => $dewey, + subject => $subject, + lccall => $lccall, + controlnumber => $controlnumber, + stdid => $stdid, + srchany => $srchany, +}; +Z3950Search($pars, $template, 1); +output_html_with_http_headers $input, $cookie, $template->output; -- |