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>.
26 use List::MoreUtils qw/ any /;
37 use Koha::Acquisition::Currencies;
40 use Koha::Config::SysPrefs;
41 use Koha::Illrequest::Config;
42 use C4::Members::Statistics;
44 #use Smart::Comments '####';
47 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
49 template_name => "about.tt",
53 flagsrequired => { catalogue => 1 },
60 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
63 my $zebraVersion = `zebraidx -V`;
65 # Check running PSGI env
66 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
69 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
70 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
75 # Memcached configuration
76 my $memcached_servers = $ENV{MEMCACHED_SERVERS} || C4::Context->config('memcached_servers');
77 my $memcached_namespace = $ENV{MEMCACHED_NAMESPACE} || C4::Context->config('memcached_namespace') // 'koha';
79 my $cache = Koha::Caches->get_instance;
80 my $effective_caching_method = ref($cache->cache);
81 # Memcached may have been running when plack has been initialized but could have been stopped since
82 # FIXME What are the consequences of that??
83 my $is_memcached_still_active = $cache->set_in_cache('test_for_about_page', "just a simple value");
85 my $where_is_memcached_config = 'nowhere';
86 if ( $ENV{MEMCACHED_SERVERS} and C4::Context->config('memcached_servers') ) {
87 $where_is_memcached_config = 'both';
88 } elsif ( $ENV{MEMCACHED_SERVERS} and not C4::Context->config('memcached_servers') ) {
89 $where_is_memcached_config = 'ENV_only';
90 } elsif ( C4::Context->config('memcached_servers') ) {
91 $where_is_memcached_config = 'config_only';
95 effective_caching_method => $effective_caching_method,
96 memcached_servers => $memcached_servers,
97 memcached_namespace => $memcached_namespace,
98 is_memcached_still_active => $is_memcached_still_active,
99 where_is_memcached_config => $where_is_memcached_config,
100 memcached_running => Koha::Caches->get_instance->memcached_cache,
103 # Additional system information for warnings
105 my $warnStatisticsFieldsError;
106 my $prefStatisticsFields = C4::Context->preference('StatisticsFields');
107 if ($prefStatisticsFields) {
108 $warnStatisticsFieldsError = $prefStatisticsFields
109 unless ( $prefStatisticsFields eq C4::Members::Statistics->get_fields() );
112 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
113 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
114 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
116 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
117 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
118 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
119 my $warnPrefAnonymousPatron = (
120 C4::Context->preference('OPACPrivacy')
121 and not C4::Context->preference('AnonymousPatron')
124 my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
125 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
127 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
129 my $warnIsRootUser = (! $loggedinuser);
131 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
133 my @xml_config_warnings;
135 my $context = new C4::Context;
137 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
138 push @xml_config_warnings, {
139 error => 'zebra_bib_index_mode_warn'
141 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
142 push @xml_config_warnings, {
143 error => 'zebra_bib_mode_seems_grs1'
147 push @xml_config_warnings, {
148 error => 'zebra_bib_mode_seems_dom'
152 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
153 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
156 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
157 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
159 push @xml_config_warnings, {
160 error => 'zebra_bib_index_mode_mismatch_warn'
164 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
165 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
167 push @xml_config_warnings, {
168 error => 'zebra_bib_index_mode_mismatch_warn'
172 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
173 push @xml_config_warnings, {
174 error => 'zebra_auth_index_mode_warn'
176 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
177 push @xml_config_warnings, {
178 error => 'zebra_auth_mode_seems_grs1'
182 push @xml_config_warnings, {
183 error => 'zebra_auth_mode_seems_dom'
187 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
188 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
191 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
192 push @xml_config_warnings, {
193 error => 'zebra_auth_index_mode_mismatch_warn'
197 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
198 push @xml_config_warnings, {
199 error => 'zebra_auth_index_mode_mismatch_warn'
203 if ( ! defined C4::Context->config('log4perl_conf') ) {
204 push @xml_config_warnings, {
205 error => 'log4perl_entry_missing'
209 if ( ! defined C4::Context->config('upload_path') ) {
210 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
211 # OPACBaseURL seems to be set
212 push @xml_config_warnings, {
213 error => 'uploadpath_entry_missing'
216 push @xml_config_warnings, {
217 error => 'uploadpath_and_opacbaseurl_entry_missing'
222 # Test QueryParser configuration sanity
223 if ( C4::Context->preference( 'UseQueryParser' ) ) {
224 # Get the QueryParser configuration file name
225 my $queryparser_file = C4::Context->config( 'queryparser_config' );
226 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
227 # Check QueryParser is functional
228 my $QParser = C4::Context->queryparser();
229 my $queryparser_error = {};
230 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
231 # Error initializing the QueryParser object
232 # Get the used queryparser.yaml file path to report the user
233 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
234 $queryparser_error->{ file } = ( defined $queryparser_file )
236 : $queryparser_fallback_file;
237 # Report error data to the template
238 $template->param( QueryParserError => $queryparser_error );
240 # Check for an absent queryparser_config entry in koha-conf.xml
241 if ( ! defined $queryparser_file ) {
242 # Not an error but a warning for the missing entry in koha-conf-xml
243 push @xml_config_warnings, {
244 error => 'queryparser_entry_missing',
245 file => $queryparser_fallback_file
251 # Test Zebra facets configuration
252 if ( !defined C4::Context->config('use_zebra_facets') ) {
253 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
255 if ( C4::Context->config('use_zebra_facets') &&
256 C4::Context->config('zebra_bib_index_mode') ) {
257 # use_zebra_facets works with DOM
258 push @xml_config_warnings, {
259 error => 'use_zebra_facets_needs_dom'
260 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
264 if ( C4::Context->preference('ILLModule') ) {
265 my $warnILLConfiguration = 0;
266 my $available_ill_backends =
267 ( scalar @{ Koha::Illrequest::Config->new->available_backends } > 0 );
269 if ( !$available_ill_backends ) {
270 $template->param( no_ill_backends => 1 );
271 $warnILLConfiguration = 1;
274 $template->param( warnILLConfiguration => $warnILLConfiguration );
277 # Sco Patron should not contain any other perms than circulate => self_checkout
278 if ( C4::Context->preference('WebBasedSelfCheck')
279 and C4::Context->preference('AutoSelfCheckAllowed')
281 my $userid = C4::Context->preference('AutoSelfCheckID');
282 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
283 my ( $has_self_checkout_perm, $has_other_permissions );
284 while ( my ( $module, $permissions ) = each %$all_permissions ) {
285 if ( $module eq 'circulate' ) {
286 while ( my ( $permission, $flag ) = each %$permissions ) {
287 if ( $permission eq 'self_checkout' ) {
288 $has_self_checkout_perm = 1;
290 $has_other_permissions = 1;
294 $has_other_permissions = 1;
298 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
299 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
304 my $dbh = C4::Context->dbh;
305 my $patrons = $dbh->selectall_arrayref(
306 q|select b.borrowernumber from borrowers b join deletedborrowers db on b.borrowernumber=db.borrowernumber|,
309 my $biblios = $dbh->selectall_arrayref(
310 q|select b.biblionumber from biblio b join deletedbiblio db on b.biblionumber=db.biblionumber|,
313 my $items = $dbh->selectall_arrayref(
314 q|select i.itemnumber from items i join deleteditems di on i.itemnumber=di.itemnumber|,
317 my $checkouts = $dbh->selectall_arrayref(
318 q|select i.issue_id from issues i join old_issues oi on i.issue_id=oi.issue_id|,
321 my $holds = $dbh->selectall_arrayref(
322 q|select r.reserve_id from reserves r join old_reserves o on r.reserve_id=o.reserve_id|,
325 if ( @$patrons or @$biblios or @$items or @$checkouts or @$holds ) {
328 ai_patrons => $patrons,
329 ai_biblios => $biblios,
331 ai_checkouts => $checkouts,
336 my %versions = C4::Context::get_versions();
339 kohaVersion => $versions{'kohaVersion'},
340 osVersion => $versions{'osVersion'},
341 perlPath => $perl_path,
342 perlVersion => $versions{'perlVersion'},
343 perlIncPath => [ map { perlinc => $_ }, @INC ],
344 mysqlVersion => $versions{'mysqlVersion'},
345 apacheVersion => $versions{'apacheVersion'},
346 zebraVersion => $zebraVersion,
347 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
348 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
349 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
350 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
351 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
352 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
353 errZebraConnection => $errZebraConnection,
354 warnIsRootUser => $warnIsRootUser,
355 warnNoActiveCurrency => $warnNoActiveCurrency,
356 warnNoTemplateCaching => ( C4::Context->config('template_cache_dir') ? 0 : 1 ),
357 xml_config_warnings => \@xml_config_warnings,
358 warnStatisticsFieldsError => $warnStatisticsFieldsError,
363 my $perl_modules = C4::Installer::PerlModules->new;
364 $perl_modules->versions_info;
366 my @pm_types = qw(missing_pm upgrade_pm current_pm);
368 foreach my $pm_type(@pm_types) {
369 my $modules = $perl_modules->get_attr($pm_type);
370 foreach (@$modules) {
371 my ($module, $stats) = each %$_;
376 version => $stats->{'cur_ver'},
377 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
378 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
379 current => ($pm_type eq 'current_pm' ? 1 : 0),
380 require => $stats->{'required'},
381 reqversion => $stats->{'min_ver'},
387 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
392 foreach (@components) {
394 unless (++$counter % 4) {
395 push (@$table, {row => $row});
399 # Processing the last line (if there are any modules left)
400 if (scalar(@$row) > 0) {
401 # Extending $row to the table size
403 # Pushing the last line
404 push (@$table, {row => $row});
408 $template->param( table => $table );
411 ## ------------------------------------------
412 ## Koha time line code
416 if ( defined C4::Context->config('docdir') ) {
417 $docdir = C4::Context->config('docdir');
419 # if no <docdir> is defined in koha-conf.xml, use the default location
420 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
421 $docdir = C4::Context->config('intranetdir') . '/docs';
424 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
434 shift @lines; #remove header row
437 my ( $epoch, $date, $desc, $tag ) = split(/\t/);
438 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
439 ($date, $desc)= ($`, $');
451 #foreach my $row2 (@rows2) {
454 push( @$table2, { row2 => $row2 } );
458 $template->param( table2 => $table2 );
460 $template->param( timeline_read_error => 1 );
463 output_html_with_http_headers $query, $cookie, $template->output;