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.
30 use C4
::AuthoritiesMarc
;
32 use C4
::Koha
; # XXX subfield_is_koha_internal_p
36 my $dbh = C4
::Context
->dbh;
37 my $op = $query->param('op') || '';
38 my $authtypecode = $query->param('authtypecode') || '';
39 my $authid = $query->param('authid') || '';
41 my ( $template, $loggedinuser, $cookie );
43 my $authtypes = getauthtypes
;
45 foreach my $thisauthtype (
47 $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'}
53 value
=> $thisauthtype,
54 selected
=> $thisauthtype eq $authtypecode,
55 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
57 push @authtypesloop, \
%row;
60 if ( $op eq "delete" ) {
61 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
63 template_name
=> "authorities/authorities-home.tmpl",
67 flagsrequired
=> { catalogue
=> 1 },
71 &DelAuthority
( $authid, 1 );
73 if ( $query->param('operator') ) {
74 # query contains search params so perform search
81 if ( $op eq "do_search" ) {
82 my $marclist = $query->param('marclist') || '';
83 my $and_or = $query->param('and_or') || '';
84 my $excluding = $query->param('excluding') || '';
85 my $operator = $query->param('operator') || '';
86 my $orderby = $query->param('orderby') || '';
87 my $value = $query->param('value') || '';
89 my $startfrom = $query->param('startfrom') || 1;
90 my $resultsperpage = $query->param('resultsperpage') || 20;
92 my ( $results, $total ) = SearchAuthorities
(
93 [$marclist], [$and_or],
94 [$excluding], [$operator],
95 [$value], ( $startfrom - 1 ) * $resultsperpage,
96 $resultsperpage, $authtypecode,
100 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
102 template_name
=> "authorities/searchresultlist.tmpl",
105 authnotrequired
=> 0,
106 flagsrequired
=> { catalogue
=> 1 },
112 marclist
=> $marclist,
114 excluding
=> $excluding,
115 operator
=> $operator,
118 authtypecode
=> $authtypecode,
119 startfrom
=> $startfrom,
120 resultsperpage
=> $resultsperpage,
123 # we must get parameters once again. Because if there is a mainentry, it
124 # has been replaced by something else during the search, thus the links
125 # next/previous would not work anymore
127 # construction of the url of each page
128 my $value_url = uri_escape
($value);
129 my $base_url = "authorities-home.pl?"
130 ."marclist=$marclist"
131 ."&and_or=$and_or"
132 ."&excluding=$excluding"
133 ."&operator=$operator"
134 ."&value=$value_url"
135 ."&resultsperpage=$resultsperpage"
136 ."&type=intranet"
138 ."&authtypecode=$authtypecode"
139 ."&orderby=$orderby";
141 my $from = ( $startfrom - 1 ) * $resultsperpage + 1;
143 if ( !defined $total ) {
147 if ( $total < $startfrom * $resultsperpage ) {
151 $to = $startfrom * $resultsperpage;
154 $template->param( result
=> $results ) if $results;
157 pagination_bar
=> pagination_bar
(
158 $base_url, int( $total / $resultsperpage ) + 1,
159 $startfrom, 'startfrom'
164 isEDITORS
=> $authtypecode eq 'EDITORS',
169 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
171 template_name
=> "authorities/authorities-home.tmpl",
174 authnotrequired
=> 0,
175 flagsrequired
=> { catalogue
=> 1 },
183 authtypesloop
=> \
@authtypesloop,
187 $template->{VARS
}->{marcflavour
} = C4
::Context
->preference("marcflavour");
190 output_html_with_http_headers
$query, $cookie, $template->output;