Bug 14910: Redirect to the circulation module after a renew
[koha.git] / about.pl
blob22d5a96ea35a5ec44a410d2286f911fa4ce48a2f
1 #!/usr/bin/perl
3 # Copyright Pat Eyler 2003
4 # Copyright Biblibre 2006
5 # Parts Copyright Liblime 2008
6 # Parts Copyright Chris Nighswonger 2010
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use strict;
24 use warnings;
26 use CGI;
27 use LWP::Simple;
28 use XML::Simple;
29 use Config;
31 use C4::Output;
32 use C4::Auth;
33 use C4::Context;
34 use C4::Installer;
36 #use Smart::Comments '####';
38 my $query = new CGI;
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41 template_name => "about.tt",
42 query => $query,
43 type => "intranet",
44 authnotrequired => 0,
45 flagsrequired => { catalogue => 1 },
46 debug => 1,
50 my $kohaVersion = C4::Context::KOHAVERSION;
51 my $osVersion = `uname -a`;
52 my $perl_path = $^X;
53 if ($^O ne 'VMS') {
54 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
56 my $perlVersion = $];
57 my $mysqlVersion = `mysql -V`;
58 my $apacheVersion = `httpd -v 2> /dev/null`;
59 $apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
60 $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
61 my $zebraVersion = `zebraidx -V`;
63 # Additional system information for warnings
64 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
65 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
66 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
68 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
69 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
70 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
71 my $warnPrefAnonymousPatron = (
72 C4::Context->preference('OPACPrivacy')
73 and not C4::Context->preference('AnonymousPatron')
76 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
78 my $warnIsRootUser = (! $loggedinuser);
80 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
81 my @xml_config_warnings;
83 my $context = new C4::Context;
85 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
86 push @xml_config_warnings, {
87 error => 'zebra_bib_index_mode_warn'
89 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
90 push @xml_config_warnings, {
91 error => 'zebra_bib_mode_seems_grs1'
94 else {
95 push @xml_config_warnings, {
96 error => 'zebra_bib_mode_seems_dom'
99 } else {
100 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
101 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
104 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
105 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
107 push @xml_config_warnings, {
108 error => 'zebra_bib_index_mode_mismatch_warn'
112 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
113 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
115 push @xml_config_warnings, {
116 error => 'zebra_bib_index_mode_mismatch_warn'
120 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
121 push @xml_config_warnings, {
122 error => 'zebra_auth_index_mode_warn'
124 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
125 push @xml_config_warnings, {
126 error => 'zebra_auth_mode_seems_grs1'
129 else {
130 push @xml_config_warnings, {
131 error => 'zebra_auth_mode_seems_dom'
134 } else {
135 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
136 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
139 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
140 push @xml_config_warnings, {
141 error => 'zebra_auth_index_mode_mismatch_warn'
145 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
146 push @xml_config_warnings, {
147 error => 'zebra_auth_index_mode_mismatch_warn'
151 # Test QueryParser configuration sanity
152 if ( C4::Context->preference( 'UseQueryParser' ) ) {
153 # Get the QueryParser configuration file name
154 my $queryparser_file = C4::Context->config( 'queryparser_config' );
155 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
156 # Check QueryParser is functional
157 my $QParser = C4::Context->queryparser();
158 my $queryparser_error = {};
159 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
160 # Error initializing the QueryParser object
161 # Get the used queryparser.yaml file path to report the user
162 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
163 $queryparser_error->{ file } = ( defined $queryparser_file )
164 ? $queryparser_file
165 : $queryparser_fallback_file;
166 # Report error data to the template
167 $template->param( QueryParserError => $queryparser_error );
168 } else {
169 # Check for an absent queryparser_config entry in koha-conf.xml
170 if ( ! defined $queryparser_file ) {
171 # Not an error but a warning for the missing entry in koha-conf-xml
172 push @xml_config_warnings, {
173 error => 'queryparser_entry_missing',
174 file => $queryparser_fallback_file
180 # Test Zebra facets configuration
181 if ( !defined C4::Context->config('use_zebra_facets') ) {
182 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
183 } else {
184 if ( C4::Context->config('use_zebra_facets') &&
185 C4::Context->config('zebra_bib_index_mode') ) {
186 # use_zebra_facets works with DOM
187 push @xml_config_warnings, {
188 error => 'use_zebra_facets_needs_dom'
189 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
193 # Sco Patron should not contain any other perms than circulate => self_checkout
194 if ( C4::Context->preference('WebBasedSelfCheck')
195 and C4::Context->preference('AutoSelfCheckAllowed')
197 my $userid = C4::Context->preference('AutoSelfCheckID');
198 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
199 my ( $has_self_checkout_perm, $has_other_permissions );
200 while ( my ( $module, $permissions ) = each %$all_permissions ) {
201 if ( $module eq 'circulate' ) {
202 while ( my ( $permission, $flag ) = each %$permissions ) {
203 if ( $permission eq 'self_checkout' ) {
204 $has_self_checkout_perm = 1;
205 } else {
206 $has_other_permissions = 1;
209 } else {
210 $has_other_permissions = 1;
213 $template->param(
214 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
215 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
221 $template->param(
222 kohaVersion => $kohaVersion,
223 osVersion => $osVersion,
224 perlPath => $perl_path,
225 perlVersion => $perlVersion,
226 perlIncPath => [ map { perlinc => $_ }, @INC ],
227 mysqlVersion => $mysqlVersion,
228 apacheVersion => $apacheVersion,
229 zebraVersion => $zebraVersion,
230 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
231 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
232 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
233 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
234 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
235 errZebraConnection => $errZebraConnection,
236 warnIsRootUser => $warnIsRootUser,
237 warnNoActiveCurrency => $warnNoActiveCurrency,
238 xml_config_warnings => \@xml_config_warnings,
241 my @components = ();
243 my $perl_modules = C4::Installer::PerlModules->new;
244 $perl_modules->version_info;
246 my @pm_types = qw(missing_pm upgrade_pm current_pm);
248 foreach my $pm_type(@pm_types) {
249 my $modules = $perl_modules->get_attr($pm_type);
250 foreach (@$modules) {
251 my ($module, $stats) = each %$_;
252 push(
253 @components,
255 name => $module,
256 version => $stats->{'cur_ver'},
257 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
258 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
259 current => ($pm_type eq 'current_pm' ? 1 : 0),
260 require => $stats->{'required'},
261 reqversion => $stats->{'min_ver'},
267 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
269 my $counter=0;
270 my $row = [];
271 my $table = [];
272 foreach (@components) {
273 push (@$row, $_);
274 unless (++$counter % 4) {
275 push (@$table, {row => $row});
276 $row = [];
279 # Processing the last line (if there are any modules left)
280 if (scalar(@$row) > 0) {
281 # Extending $row to the table size
282 $$row[3] = '';
283 # Pushing the last line
284 push (@$table, {row => $row});
286 ## ## $table
288 $template->param( table => $table );
291 ## ------------------------------------------
292 ## Koha time line code
294 #get file location
295 my $docdir;
296 if ( defined C4::Context->config('docdir') ) {
297 $docdir = C4::Context->config('docdir');
298 } else {
299 # if no <docdir> is defined in koha-conf.xml, use the default location
300 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
301 $docdir = C4::Context->config('intranetdir') . '/docs';
304 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
306 my $i = 0;
308 my @rows2 = ();
309 my $row2 = [];
311 my @lines = <$file>;
312 close($file);
314 shift @lines; #remove header row
316 foreach (@lines) {
317 my ( $date, $desc, $tag ) = split(/\t/);
318 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
319 ($date, $desc)= ($`, $');
321 push(
322 @rows2,
324 date => $date,
325 desc => $desc,
330 my $table2 = [];
331 #foreach my $row2 (@rows2) {
332 foreach (@rows2) {
333 push (@$row2, $_);
334 push( @$table2, { row2 => $row2 } );
335 $row2 = [];
338 $template->param( table2 => $table2 );
339 } else {
340 $template->param( timeline_read_error => 1 );
343 output_html_with_http_headers $query, $cookie, $template->output;