Bug 10572: Add phone to message_transport_types table for new installs
[koha.git] / cataloguing / z3950_auth_search.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Copyright 2013 Prosentient Systems
6 #
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.
11 #
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.
15 #
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>.
18
19 use strict;
20 use warnings;
21 use CGI qw / -utf8 /;
22
23 use C4::Auth;
24 use C4::Output;
25 use C4::Context;
26 use C4::Breeding;
27 use C4::Koha;
28
29 my $input        = new CGI;
30 my $dbh          = C4::Context->dbh;
31 my $error         = $input->param('error');
32 my $nameany     = $input->param('nameany');
33 my $authorany     = $input->param('authorany');
34 my $authorcorp     = $input->param('authorcorp');
35 my $authorpersonal     = $input->param('authorpersonal');
36 my $authormeetingcon     = $input->param('authormeetingcon');
37 my $title         = $input->param('title');
38 my $uniformtitle         = $input->param('uniformtitle');
39 my $subject       = $input->param('subject');
40 my $subjectsubdiv       = $input->param('subjectsubdiv');
41 my $srchany       = $input->param('srchany');
42 my $op            = $input->param('op')||'';
43 my $page            = $input->param('current_page') || 1;
44 $page = $input->param('goto_page') if $input->param('changepage_goto');
45
46 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
47         template_name   => "cataloguing/z3950_auth_search.tmpl",
48         query           => $input,
49         type            => "intranet",
50         authnotrequired => 1,
51         flagsrequired   => { catalogue => 1 },
52 });
53
54 $template->param(
55     nameany    => $nameany,
56     authorany    => $authorany,
57     authorcorp    => $authorcorp,
58     authorpersonal    => $authorpersonal,
59     authormeetingcon    => $authormeetingcon,
60     title        => $title,
61     uniformtitle      => $uniformtitle,
62     subject      => $subject,
63     subjectsubdiv   => $subjectsubdiv,
64     srchany      => $srchany,
65 );
66
67 if ( $op ne "do_search" ) {
68     my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers WHERE recordtype = 'authority' ORDER BY rank, name");
69     $sth->execute();
70     my $serverloop = $sth->fetchall_arrayref( {} );
71     $template->param(
72         serverloop   => $serverloop,
73         opsearch     => "search",
74     );
75     output_html_with_http_headers $input, $cookie, $template->output;
76     exit;
77 }
78
79 my @id = $input->param('id');
80 if ( @id==0 ) {
81         # empty server list -> report and exit
82         $template->param( emptyserverlist => 1 );
83         output_html_with_http_headers $input, $cookie, $template->output;
84         exit;
85 }
86
87 my $pars= {
88         random => $input->param('random') || rand(1000000000),
89         page => $page,
90         id => \@id,
91         nameany => $nameany,
92         authorany => $authorany,
93         authorcorp => $authorcorp,
94         authorpersonal => $authorpersonal,
95         authormeetingcon => $authormeetingcon,
96         title => $title,
97         uniformtitle => $uniformtitle,
98         subject => $subject,
99         subjectsubdiv => $subjectsubdiv,
100         srchany => $srchany,
101 };
102 Z3950SearchAuth($pars, $template);
103 output_html_with_http_headers $input, $cookie, $template->output;