Bug 16194: Do not consider xslt as valid theme dir in LangInstaller.pm
[koha.git] / authorities / authorities-home.pl
blobb0c4570306d2786b5a906eccda8951012415eecc
1 #!/usr/bin/perl
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>.
20 use strict;
21 use warnings;
23 use CGI qw ( -utf8 );
24 use URI::Escape;
25 use C4::Auth;
27 use C4::Context;
28 use C4::Auth;
29 use C4::Output;
30 use C4::AuthoritiesMarc;
31 use C4::Acquisition;
32 use C4::Koha;
33 use C4::Biblio;
34 use C4::Search::History;
36 use Koha::Authority::Types;
38 my $query = new CGI;
39 my $dbh = C4::Context->dbh;
40 my $op = $query->param('op') || '';
41 my $authtypecode = $query->param('authtypecode') || '';
42 my $authid = $query->param('authid') || '';
44 my ( $template, $loggedinuser, $cookie );
46 my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
48 if ( $op eq "delete" ) {
49 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51 template_name => "authorities/authorities-home.tt",
52 query => $query,
53 type => 'intranet',
54 authnotrequired => 0,
55 flagsrequired => { catalogue => 1 },
56 debug => 1,
59 &DelAuthority( $authid, 1 );
61 if ( $query->param('operator') ) {
62 # query contains search params so perform search
63 $op = "do_search";
65 else {
66 $op = '';
69 if ( $op eq "do_search" ) {
70 my $marclist = $query->param('marclist') || '';
71 my $and_or = $query->param('and_or') || '';
72 my $excluding = $query->param('excluding') || '';
73 my $operator = $query->param('operator') || '';
74 my $orderby = $query->param('orderby') || '';
75 my $value = $query->param('value') || '';
77 my $startfrom = $query->param('startfrom') || 1;
78 my $resultsperpage = $query->param('resultsperpage') || 20;
80 my ( $results, $total ) = SearchAuthorities(
81 [$marclist], [$and_or],
82 [$excluding], [$operator],
83 [$value], ( $startfrom - 1 ) * $resultsperpage,
84 $resultsperpage, $authtypecode,
85 $orderby
89 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
91 template_name => "authorities/searchresultlist.tt",
92 query => $query,
93 type => 'intranet',
94 authnotrequired => 0,
95 flagsrequired => { catalogue => 1 },
96 debug => 1,
100 # search history
101 if (C4::Context->preference('EnableSearchHistory')) {
102 if ( $startfrom == 1) {
103 my $path_info = $query->url(-path_info=>1);
104 my $query_cgi_history = $query->url(-query=>1);
105 $query_cgi_history =~ s/^$path_info\?//;
106 $query_cgi_history =~ s/;/&/g;
108 C4::Search::History::add({
109 userid => $loggedinuser,
110 sessionid => $query->cookie("CGISESSID"),
111 query_desc => $value,
112 query_cgi => $query_cgi_history,
113 total => $total,
114 type => "authority",
119 $template->param(
120 marclist => $marclist,
121 and_or => $and_or,
122 excluding => $excluding,
123 operator => $operator,
124 orderby => $orderby,
125 value => $value,
126 authtypecode => $authtypecode,
127 startfrom => $startfrom,
128 resultsperpage => $resultsperpage,
131 # we must get parameters once again. Because if there is a mainentry, it
132 # has been replaced by something else during the search, thus the links
133 # next/previous would not work anymore
135 # construction of the url of each page
136 my $value_url = uri_escape_utf8($value);
137 my $base_url = "authorities-home.pl?"
138 ."marclist=$marclist"
139 ."&amp;and_or=$and_or"
140 ."&amp;excluding=$excluding"
141 ."&amp;operator=$operator"
142 ."&amp;value=$value_url"
143 ."&amp;resultsperpage=$resultsperpage"
144 ."&amp;type=intranet"
145 ."&amp;op=do_search"
146 ."&amp;authtypecode=$authtypecode"
147 ."&amp;orderby=$orderby";
149 my $from = ( $startfrom - 1 ) * $resultsperpage + 1;
150 my $to;
151 if ( !defined $total ) {
152 $total = 0;
155 if ( $total < $startfrom * $resultsperpage ) {
156 $to = $total;
158 else {
159 $to = $startfrom * $resultsperpage;
162 $template->param( result => $results ) if $results;
164 $template->param(
165 pagination_bar => pagination_bar(
166 $base_url, int( $total / $resultsperpage ) + 1,
167 $startfrom, 'startfrom'
169 total => $total,
170 from => $from,
171 to => $to,
172 isEDITORS => $authtypecode eq 'EDITORS',
176 if ( $op eq '' ) {
177 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
179 template_name => "authorities/authorities-home.tt",
180 query => $query,
181 type => 'intranet',
182 authnotrequired => 0,
183 flagsrequired => { catalogue => 1 },
184 debug => 1,
190 $template->param(
191 authority_types => $authority_types,
192 op => $op,
195 $template->{VARS}->{marcflavour} = C4::Context->preference("marcflavour");
197 # Print the page
198 output_html_with_http_headers $query, $cookie, $template->output;