Bug 10096 - Add a Z39.50 interface for authority searching
[koha.git] / cataloguing / z3950_auth_search.pl
1 #!/usr/bin/perl
2
3 # This is a completely new Z3950 clients search using async ZOOM -TG 02/11/06
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This is a new Z3950 authority search using the current Z3950 bibliographic search as a model 07/05/2013
7 # Parts Copyright 2013 Prosentient Systems
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24 use strict;
25 use warnings;
26 use CGI qw / -utf8 /;
27
28 use C4::Auth;
29 use C4::Output;
30 use C4::Context;
31 use C4::Breeding;
32 use C4::Koha;
33
34 my $input        = new CGI;
35 my $dbh          = C4::Context->dbh;
36 my $error         = $input->param('error');
37 my $nameany     = $input->param('nameany');
38 my $authorany     = $input->param('authorany');
39 my $authorcorp     = $input->param('authorcorp');
40 my $authorpersonal     = $input->param('authorpersonal');
41 my $authormeetingcon     = $input->param('authormeetingcon');
42 my $title         = $input->param('title');
43 my $uniformtitle         = $input->param('uniformtitle');
44 my $subject       = $input->param('subject');
45 my $subjectsubdiv       = $input->param('subjectsubdiv');
46 my $srchany       = $input->param('srchany');
47 my $op            = $input->param('op')||'';
48 my $page            = $input->param('current_page') || 1;
49 $page = $input->param('goto_page') if $input->param('changepage_goto');
50
51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
52         template_name   => "cataloguing/z3950_auth_search.tmpl",
53         query           => $input,
54         type            => "intranet",
55         authnotrequired => 1,
56         flagsrequired   => { catalogue => 1 },
57 });
58
59 $template->param(
60     nameany    => $nameany,
61     authorany    => $authorany,
62     authorcorp    => $authorcorp,
63     authorpersonal    => $authorpersonal,
64     authormeetingcon    => $authormeetingcon,
65     title        => $title,
66     uniformtitle      => $uniformtitle,
67     subject      => $subject,
68     subjectsubdiv   => $subjectsubdiv,
69     srchany      => $srchany,
70 );
71
72 if ( $op ne "do_search" ) {
73     my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers WHERE recordtype = 'authority' ORDER BY rank, name");
74     $sth->execute();
75     my $serverloop = $sth->fetchall_arrayref( {} );
76     $template->param(
77         serverloop   => $serverloop,
78         opsearch     => "search",
79     );
80     output_html_with_http_headers $input, $cookie, $template->output;
81     exit;
82 }
83
84 my @id = $input->param('id');
85 if ( @id==0 ) {
86         # empty server list -> report and exit
87         $template->param( emptyserverlist => 1 );
88         output_html_with_http_headers $input, $cookie, $template->output;
89         exit;
90 }
91
92 my $pars= {
93         random => $input->param('random') || rand(1000000000),
94         page => $page,
95         id => \@id,
96         nameany => $nameany,
97         authorany => $authorany,
98         authorcorp => $authorcorp,
99         authorpersonal => $authorpersonal,
100         authormeetingcon => $authormeetingcon,
101         title => $title,
102         uniformtitle => $uniformtitle,
103         subject => $subject,
104         subjectsubdiv => $subjectsubdiv,
105         srchany => $srchany,
106 };
107 Z3950SearchAuth($pars, $template);
108 output_html_with_http_headers $input, $cookie, $template->output;