3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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 2 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, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 use C4
::AuthoritiesMarc
;
31 use C4
::Koha
; # XXX subfield_is_koha_internal_p
35 my $op = $query->param('op');
37 my $authtypecode = $query->param('authtypecode');
38 $authtypecode ||= q{};
39 my $dbh = C4
::Context
->dbh;
41 my $authid = $query->param('authid');
42 my ( $template, $loggedinuser, $cookie );
44 my $authtypes = getauthtypes
;
46 foreach my $thisauthtype (
48 $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'}
54 value
=> $thisauthtype,
55 selected
=> $thisauthtype eq $authtypecode,
56 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
58 push @authtypesloop, \
%row;
61 if ( $op eq "delete" ) {
62 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
64 template_name
=> "authorities/authorities-home.tmpl",
68 flagsrequired
=> { catalogue
=> 1 },
72 &DelAuthority
( $authid, 1 );
76 if ( $op eq "do_search" ) {
77 my @marclist = $query->param('marclist');
78 my @and_or = $query->param('and_or');
79 my @excluding = $query->param('excluding');
80 my @operator = $query->param('operator');
81 my $orderby = $query->param('orderby');
82 my @value = $query->param('value');
84 my $startfrom = $query->param('startfrom') || 1;
85 my $resultsperpage = $query->param('resultsperpage') || 20;
87 my ( $results, $total ) =
88 SearchAuthorities
( \
@marclist, \
@and_or, \
@excluding, \
@operator, \
@value,
89 ( $startfrom - 1 ) * $resultsperpage,
90 $resultsperpage, $authtypecode, $orderby );
92 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
94 template_name
=> "authorities/searchresultlist.tmpl",
98 flagsrequired
=> { catalogue
=> 1 },
104 marclist
=> $query->param('marclist'),
105 and_or
=> $query->param('and_or'),
106 excluding
=> $query->param('excluding'),
107 operator
=> $query->param('operator'),
108 orderby
=> $query->param('orderby'),
109 value
=> $query->param('value'),
110 authtypecode
=> $query->param('authtypecode'),
111 startfrom
=> $startfrom,
112 resultsperpage
=> $resultsperpage,
117 # we must get parameters once again. Because if there is a mainentry, it
118 # has been replaced by something else during the search, thus the links
119 # next/previous would not work anymore
120 my @marclist_ini = $query->param('marclist');
121 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
123 push @field_data, { term
=> "marclist", val
=> $marclist_ini[$i] };
124 if ( !defined $and_or[$i] ) {
127 push @field_data, { term
=> "and_or", val
=> $and_or[$i] };
128 if ( !defined $excluding[$i] ) {
129 $excluding[$i] = q{};
131 push @field_data, { term
=> "excluding", val
=> $excluding[$i] };
132 push @field_data, { term
=> "operator", val
=> $operator[$i] };
133 push @field_data, { term
=> "value", val
=> $value[$i] };
137 # construction of the url of each page
139 'authorities-home.pl?'
140 . join( '&', map { $_->{term
} . '=' . $_->{val
} } @field_data )
144 map { $_->{term
} . '=' . $_->{val
} } (
145 { term
=> 'resultsperpage', val
=> $resultsperpage },
146 { term
=> 'type', val
=> 'intranet' },
147 { term
=> 'op', val
=> 'do_search' },
148 { term
=> 'authtypecode', val
=> $authtypecode },
149 { term
=> 'orderby', val
=> $orderby },
153 my $from = ( $startfrom - 1 ) * $resultsperpage + 1;
155 if ( !defined $total ) {
159 if ( $total < $startfrom * $resultsperpage ) {
163 $to = $startfrom * $resultsperpage;
166 $template->param( result
=> $results ) if $results;
169 pagination_bar
=> pagination_bar
(
170 $base_url, int( $total / $resultsperpage ) + 1,
171 $startfrom, 'startfrom'
176 isEDITORS
=> $authtypecode eq 'EDITORS',
181 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
183 template_name
=> "authorities/authorities-home.tmpl",
186 authnotrequired
=> 0,
187 flagsrequired
=> { catalogue
=> 1 },
194 $template->param( authtypesloop
=> \
@authtypesloop, );
196 $template->{VARS
}->{marcflavour
} = C4
::Context
->preference("marcflavour");
199 output_html_with_http_headers
$query, $cookie, $template->output;