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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
30 use C4
::AuthoritiesMarc
;
32 use C4
::Koha
; # XXX subfield_is_koha_internal_p
34 use C4
::Search
::History
;
37 my $dbh = C4
::Context
->dbh;
38 my $op = $query->param('op') || '';
39 my $authtypecode = $query->param('authtypecode') || '';
40 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.tt",
68 flagsrequired
=> { catalogue
=> 1 },
72 &DelAuthority
( $authid, 1 );
74 if ( $query->param('operator') ) {
75 # query contains search params so perform search
82 if ( $op eq "do_search" ) {
83 my $marclist = $query->param('marclist') || '';
84 my $and_or = $query->param('and_or') || '';
85 my $excluding = $query->param('excluding') || '';
86 my $operator = $query->param('operator') || '';
87 my $orderby = $query->param('orderby') || '';
88 my $value = $query->param('value') || '';
90 my $startfrom = $query->param('startfrom') || 1;
91 my $resultsperpage = $query->param('resultsperpage') || 20;
93 my ( $results, $total ) = SearchAuthorities
(
94 [$marclist], [$and_or],
95 [$excluding], [$operator],
96 [$value], ( $startfrom - 1 ) * $resultsperpage,
97 $resultsperpage, $authtypecode,
102 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
104 template_name
=> "authorities/searchresultlist.tt",
107 authnotrequired
=> 0,
108 flagsrequired
=> { catalogue
=> 1 },
114 if (C4
::Context
->preference('EnableSearchHistory')) {
115 if ( $startfrom == 1) {
116 my $path_info = $query->url(-path_info
=>1);
117 my $query_cgi_history = $query->url(-query
=>1);
118 $query_cgi_history =~ s/^$path_info\?//;
119 $query_cgi_history =~ s/;/&/g;
121 C4
::Search
::History
::add
({
122 userid
=> $loggedinuser,
123 sessionid
=> $query->cookie("CGISESSID"),
124 query_desc
=> $value,
125 query_cgi
=> $query_cgi_history,
133 marclist
=> $marclist,
135 excluding
=> $excluding,
136 operator
=> $operator,
139 authtypecode
=> $authtypecode,
140 startfrom
=> $startfrom,
141 resultsperpage
=> $resultsperpage,
144 # we must get parameters once again. Because if there is a mainentry, it
145 # has been replaced by something else during the search, thus the links
146 # next/previous would not work anymore
148 # construction of the url of each page
149 my $value_url = uri_escape_utf8
($value);
150 my $base_url = "authorities-home.pl?"
151 ."marclist=$marclist"
152 ."&and_or=$and_or"
153 ."&excluding=$excluding"
154 ."&operator=$operator"
155 ."&value=$value_url"
156 ."&resultsperpage=$resultsperpage"
157 ."&type=intranet"
159 ."&authtypecode=$authtypecode"
160 ."&orderby=$orderby";
162 my $from = ( $startfrom - 1 ) * $resultsperpage + 1;
164 if ( !defined $total ) {
168 if ( $total < $startfrom * $resultsperpage ) {
172 $to = $startfrom * $resultsperpage;
175 $template->param( result
=> $results ) if $results;
178 pagination_bar
=> pagination_bar
(
179 $base_url, int( $total / $resultsperpage ) + 1,
180 $startfrom, 'startfrom'
185 isEDITORS
=> $authtypecode eq 'EDITORS',
190 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
192 template_name
=> "authorities/authorities-home.tt",
195 authnotrequired
=> 0,
196 flagsrequired
=> { catalogue
=> 1 },
204 authtypesloop
=> \
@authtypesloop,
208 $template->{VARS
}->{marcflavour
} = C4
::Context
->preference("marcflavour");
211 output_html_with_http_headers
$query, $cookie, $template->output;