Bug 15690: CardnumberLength should not be bigger than 16
[koha.git] / about.pl
blob45372288c66f0472cbfeef006e9dcffcd35f9969
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 Modern::Perl;
25 use CGI qw ( -utf8 );
26 use List::MoreUtils qw/ any /;
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 Koha;
37 use Koha::Borrowers;
38 use Koha::Config::SysPrefs;
39 use C4::Members::Statistics;
41 #use Smart::Comments '####';
43 my $query = new CGI;
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46 template_name => "about.tt",
47 query => $query,
48 type => "intranet",
49 authnotrequired => 0,
50 flagsrequired => { catalogue => 1 },
51 debug => 1,
55 my $perl_path = $^X;
56 if ($^O ne 'VMS') {
57 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
60 my $zebraVersion = `zebraidx -V`;
62 # Check running PSGI env
63 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
64 $template->param(
65 is_psgi => 1,
66 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
67 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
68 'Unknown'
72 # Additional system information for warnings
74 my $warnStatisticsFieldsError;
75 my $prefStatisticsFields = C4::Context->preference('StatisticsFields');
76 if ($prefStatisticsFields) {
77 $warnStatisticsFieldsError = $prefStatisticsFields
78 unless ( $prefStatisticsFields eq C4::Members::Statistics->get_fields() );
81 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
82 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
83 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
85 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
86 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
87 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
88 my $warnPrefAnonymousPatron = (
89 C4::Context->preference('OPACPrivacy')
90 and not C4::Context->preference('AnonymousPatron')
93 my $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
94 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
96 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
98 my $warnIsRootUser = (! $loggedinuser);
100 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
101 my @xml_config_warnings;
103 my $context = new C4::Context;
105 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
106 push @xml_config_warnings, {
107 error => 'zebra_bib_index_mode_warn'
109 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
110 push @xml_config_warnings, {
111 error => 'zebra_bib_mode_seems_grs1'
114 else {
115 push @xml_config_warnings, {
116 error => 'zebra_bib_mode_seems_dom'
119 } else {
120 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
121 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
124 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
125 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
127 push @xml_config_warnings, {
128 error => 'zebra_bib_index_mode_mismatch_warn'
132 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
133 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
135 push @xml_config_warnings, {
136 error => 'zebra_bib_index_mode_mismatch_warn'
140 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
141 push @xml_config_warnings, {
142 error => 'zebra_auth_index_mode_warn'
144 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
145 push @xml_config_warnings, {
146 error => 'zebra_auth_mode_seems_grs1'
149 else {
150 push @xml_config_warnings, {
151 error => 'zebra_auth_mode_seems_dom'
154 } else {
155 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
156 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
159 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
160 push @xml_config_warnings, {
161 error => 'zebra_auth_index_mode_mismatch_warn'
165 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
166 push @xml_config_warnings, {
167 error => 'zebra_auth_index_mode_mismatch_warn'
171 if ( ! defined C4::Context->config('log4perl_conf') ) {
172 push @xml_config_warnings, {
173 error => 'log4perl_entry_missing'
177 if ( ! defined C4::Context->config('upload_path') ) {
178 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
179 # OPACBaseURL seems to be set
180 push @xml_config_warnings, {
181 error => 'uploadpath_entry_missing'
183 } else {
184 push @xml_config_warnings, {
185 error => 'uploadpath_and_opacbaseurl_entry_missing'
190 # Test QueryParser configuration sanity
191 if ( C4::Context->preference( 'UseQueryParser' ) ) {
192 # Get the QueryParser configuration file name
193 my $queryparser_file = C4::Context->config( 'queryparser_config' );
194 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
195 # Check QueryParser is functional
196 my $QParser = C4::Context->queryparser();
197 my $queryparser_error = {};
198 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
199 # Error initializing the QueryParser object
200 # Get the used queryparser.yaml file path to report the user
201 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
202 $queryparser_error->{ file } = ( defined $queryparser_file )
203 ? $queryparser_file
204 : $queryparser_fallback_file;
205 # Report error data to the template
206 $template->param( QueryParserError => $queryparser_error );
207 } else {
208 # Check for an absent queryparser_config entry in koha-conf.xml
209 if ( ! defined $queryparser_file ) {
210 # Not an error but a warning for the missing entry in koha-conf-xml
211 push @xml_config_warnings, {
212 error => 'queryparser_entry_missing',
213 file => $queryparser_fallback_file
219 # Test Zebra facets configuration
220 if ( !defined C4::Context->config('use_zebra_facets') ) {
221 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
222 } else {
223 if ( C4::Context->config('use_zebra_facets') &&
224 C4::Context->config('zebra_bib_index_mode') ) {
225 # use_zebra_facets works with DOM
226 push @xml_config_warnings, {
227 error => 'use_zebra_facets_needs_dom'
228 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
232 # Sco Patron should not contain any other perms than circulate => self_checkout
233 if ( C4::Context->preference('WebBasedSelfCheck')
234 and C4::Context->preference('AutoSelfCheckAllowed')
236 my $userid = C4::Context->preference('AutoSelfCheckID');
237 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
238 my ( $has_self_checkout_perm, $has_other_permissions );
239 while ( my ( $module, $permissions ) = each %$all_permissions ) {
240 if ( $module eq 'circulate' ) {
241 while ( my ( $permission, $flag ) = each %$permissions ) {
242 if ( $permission eq 'self_checkout' ) {
243 $has_self_checkout_perm = 1;
244 } else {
245 $has_other_permissions = 1;
248 } else {
249 $has_other_permissions = 1;
252 $template->param(
253 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
254 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
260 my %versions = C4::Context::get_versions();
262 $template->param(
263 kohaVersion => $versions{'kohaVersion'},
264 osVersion => $versions{'osVersion'},
265 perlPath => $perl_path,
266 perlVersion => $versions{'perlVersion'},
267 perlIncPath => [ map { perlinc => $_ }, @INC ],
268 mysqlVersion => $versions{'mysqlVersion'},
269 apacheVersion => $versions{'apacheVersion'},
270 zebraVersion => $zebraVersion,
271 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
272 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
273 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
274 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
275 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
276 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
277 errZebraConnection => $errZebraConnection,
278 warnIsRootUser => $warnIsRootUser,
279 warnNoActiveCurrency => $warnNoActiveCurrency,
280 xml_config_warnings => \@xml_config_warnings,
281 warnStatisticsFieldsError => $warnStatisticsFieldsError,
284 my @components = ();
286 my $perl_modules = C4::Installer::PerlModules->new;
287 $perl_modules->version_info;
289 my @pm_types = qw(missing_pm upgrade_pm current_pm);
291 foreach my $pm_type(@pm_types) {
292 my $modules = $perl_modules->get_attr($pm_type);
293 foreach (@$modules) {
294 my ($module, $stats) = each %$_;
295 push(
296 @components,
298 name => $module,
299 version => $stats->{'cur_ver'},
300 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
301 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
302 current => ($pm_type eq 'current_pm' ? 1 : 0),
303 require => $stats->{'required'},
304 reqversion => $stats->{'min_ver'},
310 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
312 my $counter=0;
313 my $row = [];
314 my $table = [];
315 foreach (@components) {
316 push (@$row, $_);
317 unless (++$counter % 4) {
318 push (@$table, {row => $row});
319 $row = [];
322 # Processing the last line (if there are any modules left)
323 if (scalar(@$row) > 0) {
324 # Extending $row to the table size
325 $$row[3] = '';
326 # Pushing the last line
327 push (@$table, {row => $row});
329 ## ## $table
331 $template->param( table => $table );
334 ## ------------------------------------------
335 ## Koha time line code
337 #get file location
338 my $docdir;
339 if ( defined C4::Context->config('docdir') ) {
340 $docdir = C4::Context->config('docdir');
341 } else {
342 # if no <docdir> is defined in koha-conf.xml, use the default location
343 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
344 $docdir = C4::Context->config('intranetdir') . '/docs';
347 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
349 my $i = 0;
351 my @rows2 = ();
352 my $row2 = [];
354 my @lines = <$file>;
355 close($file);
357 shift @lines; #remove header row
359 foreach (@lines) {
360 my ( $date, $desc, $tag ) = split(/\t/);
361 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
362 ($date, $desc)= ($`, $');
364 push(
365 @rows2,
367 date => $date,
368 desc => $desc,
373 my $table2 = [];
374 #foreach my $row2 (@rows2) {
375 foreach (@rows2) {
376 push (@$row2, $_);
377 push( @$table2, { row2 => $row2 } );
378 $row2 = [];
381 $template->param( table2 => $table2 );
382 } else {
383 $template->param( timeline_read_error => 1 );
386 output_html_with_http_headers $query, $cookie, $template->output;