Bug 20600: (follow-up) Fix filtering
[koha.git] / cataloguing / z3950_auth_search.pl
blob405656de567b3ad2b5a4d82acbdead6f11c11ce6
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Copyright 2013 Prosentient Systems
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Modern::Perl;
21 use CGI qw / -utf8 /;
23 use C4::Auth;
24 use C4::Output;
25 use C4::Context;
26 use C4::Breeding;
27 use C4::Koha;
29 my $input = new CGI;
30 my $dbh = C4::Context->dbh;
31 my $error = $input->param('error');
32 my $authid = $input->param('authid') || 0;
33 my $nameany = $input->param('nameany');
34 my $authorany = $input->param('authorany');
35 my $authorcorp = $input->param('authorcorp');
36 my $authorpersonal = $input->param('authorpersonal');
37 my $authormeetingcon = $input->param('authormeetingcon');
38 my $title = $input->param('title');
39 my $uniformtitle = $input->param('uniformtitle');
40 my $subject = $input->param('subject');
41 my $subjectsubdiv = $input->param('subjectsubdiv');
42 my $srchany = $input->param('srchany');
43 my $op = $input->param('op')||'';
44 my $page = $input->param('current_page') || 1;
45 $page = $input->param('goto_page') if $input->param('changepage_goto');
46 my $controlnumber = $input->param('controlnumber');
48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
49 template_name => "cataloguing/z3950_auth_search.tt",
50 query => $input,
51 type => "intranet",
52 flagsrequired => { catalogue => 1 },
53 });
55 $template->param(
56 nameany => $nameany,
57 authorany => $authorany,
58 authorcorp => $authorcorp,
59 authorpersonal => $authorpersonal,
60 authormeetingcon => $authormeetingcon,
61 title => $title,
62 uniformtitle => $uniformtitle,
63 subject => $subject,
64 subjectsubdiv => $subjectsubdiv,
65 srchany => $srchany,
66 authid => $authid,
67 controlnumber => $controlnumber,
70 if ( $op ne "do_search" ) {
71 my $sth = $dbh->prepare("SELECT id,host,servername,checked FROM z3950servers WHERE recordtype = 'authority' ORDER BY rank, servername");
72 $sth->execute();
73 my $serverloop = $sth->fetchall_arrayref( {} );
74 $template->param(
75 serverloop => $serverloop,
76 opsearch => "search",
78 output_html_with_http_headers $input, $cookie, $template->output;
79 exit;
82 my @id = $input->multi_param('id');
83 if ( @id==0 ) {
84 # empty server list -> report and exit
85 $template->param( emptyserverlist => 1 );
86 output_html_with_http_headers $input, $cookie, $template->output;
87 exit;
90 my $pars= {
91 random => scalar $input->param('random') || rand(1000000000),
92 page => $page,
93 id => \@id,
94 nameany => $nameany,
95 authorany => $authorany,
96 authorcorp => $authorcorp,
97 authorpersonal => $authorpersonal,
98 authormeetingcon => $authormeetingcon,
99 title => $title,
100 uniformtitle => $uniformtitle,
101 subject => $subject,
102 subjectsubdiv => $subjectsubdiv,
103 srchany => $srchany,
104 authid => $authid,
105 controlnumber => $controlnumber,
107 Z3950SearchAuth($pars, $template);
108 output_html_with_http_headers $input, $cookie, $template->output;