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
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>.
23 use C4::Auth qw( get_template_and_user );
24 use C4::Output qw( output_html_with_http_headers );
26 use C4::Breeding qw( Z3950Search Z3950SearchAuth );
28 use Koha::Authorities;
29 use Koha::Authority::Types;
30 use C4::AuthoritiesMarc qw( GetAuthority );
33 my $dbh = C4::Context->dbh;
34 my $error = $input->param('error');
35 my $authid = $input->param('authid') || 0;
37 my $record = GetAuthority($authid);
38 my $marc_flavour = C4::Context->preference('marcflavour');
39 my $authfields_mapping = {
40 'authorpersonal' => $marc_flavour eq 'MARC21' ? '100' : '200',
41 'authorcorp' => $marc_flavour eq 'MARC21' ? '110' : '210',
42 'authormeetingcon' => $marc_flavour eq 'MARC21' ? '111' : '210',
43 'uniformtitle' => $marc_flavour eq 'MARC21' ? '130' : '230',
44 'subject' => $marc_flavour eq 'MARC21' ? '150' : '250',
47 my $nameany = $input->param('nameany');
48 my $authorany = $input->param('authorany');
51 ? $record->subfield( $authfields_mapping->{'authorcorp'}, 'a' )
52 : $input->param('authorcorp');
55 ? $record->subfield( $authfields_mapping->{'authorpersonal'}, 'a' )
56 : $input->param('authorpersonal');
57 my $authormeetingcon =
59 ? $record->subfield( $authfields_mapping->{'authormeetingcon'}, 'a' )
60 : $input->param('authormeetingcon');
62 my $title = $input->param('title');
65 ? $record->subfield( $authfields_mapping->{'uniformtitle'}, 'a' )
66 : $input->param('uniformtitle');
69 ? $record->subfield( $authfields_mapping->{'subject'}, 'a' )
70 : $input->param('subject');
72 my $subjectsubdiv = $input->param('subjectsubdiv');
73 my $srchany = $input->param('srchany');
74 my $op = $input->param('op')||'';
75 my $page = $input->param('current_page') || 1;
76 my $index =$input->param('index');
77 $page = $input->param('goto_page') if $input->param('changepage_goto');
78 my $controlnumber = $input->param('controlnumber');
80 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
81 template_name => "cataloguing/z3950_auth_search.tt",
84 flagsrequired => { catalogue => 1 },
89 authorany => $authorany,
90 authorcorp => $authorcorp,
91 authorpersonal => $authorpersonal,
92 authormeetingcon => $authormeetingcon,
94 uniformtitle => $uniformtitle,
96 subjectsubdiv => $subjectsubdiv,
99 controlnumber => $controlnumber,
103 if ( $op ne "do_search" ) {
104 my $sth = $dbh->prepare("SELECT id,host,servername,checked FROM z3950servers WHERE recordtype = 'authority' ORDER BY `rank`, servername");
106 my $serverloop = $sth->fetchall_arrayref( {} );
108 serverloop => $serverloop,
109 opsearch => "search",
112 output_html_with_http_headers $input, $cookie, $template->output;
116 my @id = $input->multi_param('id');
118 # empty server list -> report and exit
119 $template->param( emptyserverlist => 1 );
120 output_html_with_http_headers $input, $cookie, $template->output;
128 authorany => $authorany,
129 authorcorp => $authorcorp,
130 authorpersonal => $authorpersonal,
131 authormeetingcon => $authormeetingcon,
133 uniformtitle => $uniformtitle,
135 subjectsubdiv => $subjectsubdiv,
138 controlnumber => $controlnumber,
140 Z3950SearchAuth($pars, $template);
141 output_html_with_http_headers $input, $cookie, $template->output;