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 DateTime
::TimeZone
;
28 use List
::MoreUtils qw
/ any /;
30 use Module
::Load
::Conditional
qw(can_load);
33 use Search
::Elasticsearch
;
35 use YAML qw
/LoadFile/;
43 use Koha
::DateUtils
qw(dt_from_string output_pref);
44 use Koha
::Acquisition
::Currencies
;
45 use Koha
::Patron
::Categories
;
48 use Koha
::Config
::SysPrefs
;
49 use Koha
::Illrequest
::Config
;
50 use Koha
::SearchEngine
::Elasticsearch
;
52 use C4
::Members
::Statistics
;
55 #use Smart::Comments '####';
58 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
60 template_name
=> "about.tt",
63 flagsrequired
=> { catalogue
=> 1 },
68 my $config_timezone = C4
::Context
->config('timezone') // '';
69 my $config_invalid = !DateTime
::TimeZone
->is_valid_name( $config_timezone );
70 my $env_timezone = $ENV{TZ
} // '';
71 my $env_invalid = !DateTime
::TimeZone
->is_valid_name( $env_timezone );
72 my $actual_bad_tz_fallback = 0;
74 if ( $config_timezone ne '' &&
77 $actual_bad_tz_fallback = 1;
79 elsif ( $config_timezone eq '' &&
80 $env_timezone ne '' &&
82 # No config, but bad ENV{TZ}
83 $actual_bad_tz_fallback = 1;
87 actual
=> C4
::Context
->tz->name,
88 actual_bad_tz_fallback
=> $actual_bad_tz_fallback,
89 config
=> $config_timezone,
90 config_invalid
=> $config_invalid,
91 environment
=> $env_timezone,
92 environment_invalid
=> $env_invalid
96 time_zone
=> $time_zone,
97 current_date_and_time
=> output_pref
({ dt
=> dt_from_string
(), dateformat
=> 'iso' })
102 $perl_path .= $Config{_exe
} unless $perl_path =~ m/$Config{_exe}$/i;
105 my $zebraVersion = `zebraidx -V`;
107 # Check running PSGI env
108 if ( any
{ /(^psgi\.|^plack\.)/i } keys %ENV ) {
111 psgi_server
=> ($ENV{ PLACK_ENV
}) ?
"Plack ($ENV{PLACK_ENV})" :
112 ($ENV{ MOD_PERL
}) ?
"mod_perl ($ENV{MOD_PERL})" :
117 # Memcached configuration
118 my $memcached_servers = $ENV{MEMCACHED_SERVERS
} || C4
::Context
->config('memcached_servers');
119 my $memcached_namespace = $ENV{MEMCACHED_NAMESPACE
} || C4
::Context
->config('memcached_namespace') // 'koha';
121 my $cache = Koha
::Caches
->get_instance;
122 my $effective_caching_method = ref($cache->cache);
123 # Memcached may have been running when plack has been initialized but could have been stopped since
124 # FIXME What are the consequences of that??
125 my $is_memcached_still_active = $cache->set_in_cache('test_for_about_page', "just a simple value");
127 my $where_is_memcached_config = 'nowhere';
128 if ( $ENV{MEMCACHED_SERVERS
} and C4
::Context
->config('memcached_servers') ) {
129 $where_is_memcached_config = 'both';
130 } elsif ( $ENV{MEMCACHED_SERVERS
} and not C4
::Context
->config('memcached_servers') ) {
131 $where_is_memcached_config = 'ENV_only';
132 } elsif ( C4
::Context
->config('memcached_servers') ) {
133 $where_is_memcached_config = 'config_only';
137 effective_caching_method
=> $effective_caching_method,
138 memcached_servers
=> $memcached_servers,
139 memcached_namespace
=> $memcached_namespace,
140 is_memcached_still_active
=> $is_memcached_still_active,
141 where_is_memcached_config
=> $where_is_memcached_config,
142 memcached_running
=> Koha
::Caches
->get_instance->memcached_cache,
145 # Additional system information for warnings
147 my $warnStatisticsFieldsError;
148 my $prefStatisticsFields = C4
::Context
->preference('StatisticsFields');
149 if ($prefStatisticsFields) {
150 $warnStatisticsFieldsError = $prefStatisticsFields
151 unless ( $prefStatisticsFields eq C4
::Members
::Statistics
->get_fields() );
154 my $prefAutoCreateAuthorities = C4
::Context
->preference('AutoCreateAuthorities');
155 my $prefBiblioAddsAuthorities = C4
::Context
->preference('BiblioAddsAuthorities');
156 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
158 my $prefEasyAnalyticalRecords = C4
::Context
->preference('EasyAnalyticalRecords');
159 my $prefUseControlNumber = C4
::Context
->preference('UseControlNumber');
160 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
161 my $warnPrefAnonymousPatron = (
162 C4
::Context
->preference('OPACPrivacy')
163 and not C4
::Context
->preference('AnonymousPatron')
166 my $anonymous_patron = Koha
::Patrons
->find( C4
::Context
->preference('AnonymousPatron') );
167 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha
::Patrons
->search({ privacy
=> 2 })->count );
169 my $errZebraConnection = C4
::Context
->Zconn("biblioserver",0)->errcode();
171 my $warnIsRootUser = (! $loggedinuser);
173 my $warnNoActiveCurrency = (! defined Koha
::Acquisition
::Currencies
->get_active);
175 my @xml_config_warnings;
177 my $context = new C4
::Context
;
179 if ( C4
::Context
->config('zebra_bib_index_mode')
180 and C4
::Context
->config('zebra_bib_index_mode') eq 'grs1' )
182 push @xml_config_warnings, { error
=> 'zebra_bib_index_mode_is_grs1' };
185 if ( C4
::Context
->config('zebra_auth_index_mode')
186 and C4
::Context
->config('zebra_auth_index_mode') eq 'grs1' )
188 push @xml_config_warnings, { error
=> 'zebra_auth_index_mode_is_grs1' };
191 if( ( C4
::Context
->config('zebra_auth_index_mode')
192 and C4
::Context
->config('zebra_auth_index_mode') eq 'dom' )
193 && ( $context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/ ) )
195 push @xml_config_warnings, {
196 error
=> 'zebra_auth_index_mode_mismatch_warn'
200 if ( ! defined C4
::Context
->config('log4perl_conf') ) {
201 push @xml_config_warnings, {
202 error
=> 'log4perl_entry_missing'
206 if ( ! defined C4
::Context
->config('upload_path') ) {
207 if ( Koha
::Config
::SysPrefs
->find('OPACBaseURL')->value ) {
208 # OPACBaseURL seems to be set
209 push @xml_config_warnings, {
210 error
=> 'uploadpath_entry_missing'
213 push @xml_config_warnings, {
214 error
=> 'uploadpath_and_opacbaseurl_entry_missing'
219 if ( ! C4
::Context
->config('tmp_path') ) {
220 my $temporary_directory = C4
::Context
::temporary_directory
;
221 push @xml_config_warnings, {
222 error
=> 'tmp_path_missing',
223 effective_tmp_dir
=> $temporary_directory,
227 # Test QueryParser configuration sanity
228 if ( C4
::Context
->preference( 'UseQueryParser' ) ) {
229 # Get the QueryParser configuration file name
230 my $queryparser_file = C4
::Context
->config( 'queryparser_config' );
231 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
232 # Check QueryParser is functional
233 my $QParser = C4
::Context
->queryparser();
234 my $queryparser_error = {};
235 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
236 # Error initializing the QueryParser object
237 # Get the used queryparser.yaml file path to report the user
238 $queryparser_error->{ fallback
} = ( defined $queryparser_file ) ?
0 : 1;
239 $queryparser_error->{ file
} = ( defined $queryparser_file )
241 : $queryparser_fallback_file;
242 # Report error data to the template
243 $template->param( QueryParserError
=> $queryparser_error );
245 # Check for an absent queryparser_config entry in koha-conf.xml
246 if ( ! defined $queryparser_file ) {
247 # Not an error but a warning for the missing entry in koha-conf-xml
248 push @xml_config_warnings, {
249 error
=> 'queryparser_entry_missing',
250 file
=> $queryparser_fallback_file
256 # Test Zebra facets configuration
257 if ( !defined C4
::Context
->config('use_zebra_facets') ) {
258 push @xml_config_warnings, { error
=> 'use_zebra_facets_entry_missing' };
262 if ( C4
::Context
->preference('ILLModule') ) {
263 my $warnILLConfiguration = 0;
264 my $ill_config_from_file = C4
::Context
->config("interlibrary_loans");
265 my $ill_config = Koha
::Illrequest
::Config
->new;
267 my $available_ill_backends =
268 ( scalar @
{ $ill_config->available_backends } > 0 );
271 if ( !$available_ill_backends ) {
272 $template->param( no_ill_backends
=> 1 );
273 $warnILLConfiguration = 1;
277 if ( !Koha
::Patron
::Categories
->find($ill_config->partner_code) ) {
278 $template->param( ill_partner_code_doesnt_exist
=> $ill_config->partner_code );
279 $warnILLConfiguration = 1;
282 if ( !$ill_config_from_file->{partner_code
} ) {
283 # partner code not defined
284 $template->param( ill_partner_code_not_defined
=> 1 );
285 $warnILLConfiguration = 1;
289 if ( !$ill_config_from_file->{branch
} ) {
291 $template->param( ill_branch_not_defined
=> 1 );
292 $warnILLConfiguration = 1;
295 $template->param( warnILLConfiguration
=> $warnILLConfiguration );
298 if ( C4
::Context
->preference('SearchEngine') eq 'Elasticsearch' ) {
299 # Check ES configuration health and runtime status
307 $es_conf = Koha
::SearchEngine
::Elasticsearch
::_read_configuration
();
310 if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) {
311 $template->param( elasticsearch_fatal_config_error
=> $_->message );
312 $es_config_error = 1;
315 if ( !$es_config_error ) {
317 my $biblios_index_name = $es_conf->{index_name
} . "_" . $Koha::SearchEngine
::BIBLIOS_INDEX
;
318 my $authorities_index_name = $es_conf->{index_name
} . "_" . $Koha::SearchEngine
::AUTHORITIES_INDEX
;
320 my @indexes = ($biblios_index_name, $authorities_index_name);
321 # TODO: When new indexes get added, we could have other ways to
322 # fetch the list of available indexes (e.g. plugins, etc)
323 $es_status->{nodes
} = $es_conf->{nodes
};
324 my $es = Search
::Elasticsearch
->new({ nodes
=> $es_conf->{nodes
} });
326 foreach my $index ( @indexes ) {
329 $count = $es->indices->stats( index => $index )
330 ->{_all
}{primaries
}{docs
}{count
};
333 if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) {
334 push @
{ $es_status->{errors
} }, "Index not found ($index)";
337 elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
341 # TODO: when time comes, we will cover more use cases
346 push @
{ $es_status->{indexes
} },
348 index_name
=> $index,
352 $es_status->{running
} = $es_running;
354 $template->param( elasticsearch_status
=> $es_status );
358 if ( C4
::Context
->preference('RESTOAuth2ClientCredentials') ) {
359 # Do we have the required deps?
360 unless ( can_load
( modules
=> { 'Net::OAuth2::AuthorizationServer' => undef }) ) {
361 $template->param( oauth2_missing_deps
=> 1 );
365 # Sco Patron should not contain any other perms than circulate => self_checkout
366 if ( C4
::Context
->preference('WebBasedSelfCheck')
367 and C4
::Context
->preference('AutoSelfCheckAllowed')
369 my $userid = C4
::Context
->preference('AutoSelfCheckID');
370 my $all_permissions = C4
::Auth
::get_user_subpermissions
( $userid );
371 my ( $has_self_checkout_perm, $has_other_permissions );
372 while ( my ( $module, $permissions ) = each %$all_permissions ) {
373 if ( $module eq 'self_check' ) {
374 while ( my ( $permission, $flag ) = each %$permissions ) {
375 if ( $permission eq 'self_checkout_module' ) {
376 $has_self_checkout_perm = 1;
378 $has_other_permissions = 1;
382 $has_other_permissions = 1;
386 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm
=> not ( $has_self_checkout_perm ),
387 AutoSelfCheckPatronHasTooManyPerm
=> $has_other_permissions,
391 # Test YAML system preferences
392 # FIXME: This is list of current YAML formatted prefs, should by type of preference
394 "UpdateNotForLoanStatusOnCheckin",
396 "BibtexExportAdditionalFields",
397 "RisExportAdditionalFields",
398 "UpdateItemWhenLostFromHoldList",
400 "MarcItemFieldsToOrder",
401 "UpdateitemLocationOnCheckin",
405 foreach my $syspref (@yaml_prefs) {
406 my $yaml = C4
::Context
->preference( $syspref );
408 eval { YAML
::Load
( "$yaml\n\n" ); };
410 push @bad_yaml_prefs, $syspref;
414 $template->param( 'bad_yaml_prefs' => \
@bad_yaml_prefs ) if @bad_yaml_prefs;
417 my $dbh = C4
::Context
->dbh;
418 my $patrons = $dbh->selectall_arrayref(
419 q
|select b
.borrowernumber from borrowers b
join deletedborrowers db on b
.borrowernumber
=db
.borrowernumber
|,
422 my $biblios = $dbh->selectall_arrayref(
423 q
|select b
.biblionumber from biblio b
join deletedbiblio db on b
.biblionumber
=db
.biblionumber
|,
426 my $items = $dbh->selectall_arrayref(
427 q
|select i
.itemnumber from items i
join deleteditems di on i
.itemnumber
=di
.itemnumber
|,
430 my $checkouts = $dbh->selectall_arrayref(
431 q
|select i
.issue_id from issues i
join old_issues oi on i
.issue_id
=oi
.issue_id
|,
434 my $holds = $dbh->selectall_arrayref(
435 q
|select r
.reserve_id from reserves r
join old_reserves o on r
.reserve_id
=o
.reserve_id
|,
438 if ( @
$patrons or @
$biblios or @
$items or @
$checkouts or @
$holds ) {
441 ai_patrons
=> $patrons,
442 ai_biblios
=> $biblios,
444 ai_checkouts
=> $checkouts,
452 my $dbh = C4
::Context
->dbh;
453 my $units = $dbh->selectall_arrayref(
454 q
|SELECT branchcode
, categorycode
, itemtype
, lengthunit FROM issuingrules WHERE lengthunit NOT IN
( 'days', 'hours' ); |,
460 warnIssuingRules
=> 1,
465 my %versions = C4
::Context
::get_versions
();
468 kohaVersion
=> $versions{'kohaVersion'},
469 osVersion
=> $versions{'osVersion'},
470 perlPath
=> $perl_path,
471 perlVersion
=> $versions{'perlVersion'},
472 perlIncPath
=> [ map { perlinc
=> $_ }, @INC ],
473 mysqlVersion
=> $versions{'mysqlVersion'},
474 apacheVersion
=> $versions{'apacheVersion'},
475 zebraVersion
=> $zebraVersion,
476 prefBiblioAddsAuthorities
=> $prefBiblioAddsAuthorities,
477 prefAutoCreateAuthorities
=> $prefAutoCreateAuthorities,
478 warnPrefBiblioAddsAuthorities
=> $warnPrefBiblioAddsAuthorities,
479 warnPrefEasyAnalyticalRecords
=> $warnPrefEasyAnalyticalRecords,
480 warnPrefAnonymousPatron
=> $warnPrefAnonymousPatron,
481 warnPrefAnonymousPatron_PatronDoesNotExist
=> $warnPrefAnonymousPatron_PatronDoesNotExist,
482 errZebraConnection
=> $errZebraConnection,
483 warnIsRootUser
=> $warnIsRootUser,
484 warnNoActiveCurrency
=> $warnNoActiveCurrency,
485 warnNoTemplateCaching
=> ( C4
::Context
->config('template_cache_dir') ?
0 : 1 ),
486 xml_config_warnings
=> \
@xml_config_warnings,
487 warnStatisticsFieldsError
=> $warnStatisticsFieldsError,
492 my $perl_modules = C4
::Installer
::PerlModules
->new;
493 $perl_modules->versions_info;
495 my @pm_types = qw(missing_pm upgrade_pm current_pm);
497 foreach my $pm_type(@pm_types) {
498 my $modules = $perl_modules->get_attr($pm_type);
499 foreach (@
$modules) {
500 my ($module, $stats) = each %$_;
505 version
=> $stats->{'cur_ver'},
506 missing
=> ($pm_type eq 'missing_pm' ?
1 : 0),
507 upgrade
=> ($pm_type eq 'upgrade_pm' ?
1 : 0),
508 current
=> ($pm_type eq 'current_pm' ?
1 : 0),
509 require => $stats->{'required'},
510 reqversion
=> $stats->{'min_ver'},
516 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
521 foreach (@components) {
523 unless (++$counter % 4) {
524 push (@
$table, {row
=> $row});
528 # Processing the last line (if there are any modules left)
529 if (scalar(@
$row) > 0) {
530 # Extending $row to the table size
532 # Pushing the last line
533 push (@
$table, {row
=> $row});
537 $template->param( table
=> $table );
540 ## ------------------------------------------
541 ## Koha contributions
543 if ( defined C4
::Context
->config('docdir') ) {
544 $docdir = C4
::Context
->config('docdir');
546 # if no <docdir> is defined in koha-conf.xml, use the default location
547 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
548 $docdir = C4
::Context
->config('intranetdir') . '/docs';
553 -e
"$docdir" . "/teams.yaml"
554 ? LoadFile
( "$docdir" . "/teams.yaml" )
556 my $dev_team = (sort {$b <=> $a} (keys %{$teams->{team
}}))[0];
557 my $short_version = substr($versions{'kohaVersion'},0,5);
558 my $minor = substr($versions{'kohaVersion'},3,2);
559 my $development_version = ( $minor eq '05' || $minor eq '11' ) ?
0 : 1;
560 $template->param( short_version
=> $short_version );
561 $template->param( development_version
=> $development_version );
565 -e
"$docdir" . "/contributors.yaml"
566 ? LoadFile
( "$docdir" . "/contributors.yaml" )
568 for my $version ( sort { $a <=> $b } keys %{$teams->{team
}} ) {
569 for my $role ( keys %{ $teams->{team
}->{$version} } ) {
570 my $normalized_role = "$role";
571 $normalized_role =~ s/s$//;
572 if ( ref( $teams->{team
}->{$version}->{$role} ) eq 'ARRAY' ) {
573 for my $contributor ( @
{ $teams->{team
}->{$version}->{$role} } ) {
574 my $name = $contributor->{name
};
575 # Add role to contributors
576 push @
{ $contributors->{$name}->{roles
}->{$normalized_role} },
578 # Add openhub to teams
579 if ( exists( $contributors->{$name}->{openhub
} ) ) {
580 $contributor->{openhub
} = $contributors->{$name}->{openhub
};
584 elsif ( $role ne 'release_date' ) {
585 my $name = $teams->{team
}->{$version}->{$role}->{name
};
586 # Add role to contributors
587 push @
{ $contributors->{$name}->{roles
}->{$normalized_role} },
589 # Add openhub to teams
590 if ( exists( $contributors->{$name}->{openhub
} ) ) {
591 $teams->{team
}->{$version}->{$role}->{openhub
} =
592 $contributors->{$name}->{openhub
};
596 $teams->{team
}->{$version}->{$role} = DateTime
->from_epoch( epoch
=> $teams->{team
}->{$version}->{$role});
601 ## Create last name ordered array of people from contributors
603 { name
=> $_, ( $contributors->{$_} ?
%{ $contributors->{$_} } : () ) }
605 my ($alast) = ( split( /\s/, $a ) )[-1];
606 my ($blast) = ( split( /\s/, $b ) )[-1];
607 lc($alast) cmp lc($blast)
608 } keys %{$contributors};
610 $template->param( contributors
=> \
@people );
611 $template->param( maintenance_team
=> $teams->{team
}->{$dev_team} );
612 $template->param( release_team
=> $teams->{team
}->{$short_version} );
615 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
625 shift @lines; #remove header row
628 my ( $epoch, $date, $desc, $tag ) = split(/\t/);
629 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
630 ($date, $desc)= ($`, $');
642 #foreach my $row2 (@rows2) {
645 push( @$table2, { row2 => $row2 } );
649 $template->param( table2 => $table2 );
651 $template->param( timeline_read_error => 1 );
654 output_html_with_http_headers $query, $cookie, $template->output;