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/;
40 use C4
::Installer
::PerlModules
;
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",
64 flagsrequired
=> { catalogue
=> 1 },
69 my $config_timezone = C4
::Context
->config('timezone') // '';
70 my $config_invalid = !DateTime
::TimeZone
->is_valid_name( $config_timezone );
71 my $env_timezone = $ENV{TZ
} // '';
72 my $env_invalid = !DateTime
::TimeZone
->is_valid_name( $env_timezone );
73 my $actual_bad_tz_fallback = 0;
75 if ( $config_timezone ne '' &&
78 $actual_bad_tz_fallback = 1;
80 elsif ( $config_timezone eq '' &&
81 $env_timezone ne '' &&
83 # No config, but bad ENV{TZ}
84 $actual_bad_tz_fallback = 1;
88 actual
=> C4
::Context
->tz->name,
89 actual_bad_tz_fallback
=> $actual_bad_tz_fallback,
90 config
=> $config_timezone,
91 config_invalid
=> $config_invalid,
92 environment
=> $env_timezone,
93 environment_invalid
=> $env_invalid
97 time_zone
=> $time_zone,
98 current_date_and_time
=> output_pref
({ dt
=> dt_from_string
(), dateformat
=> 'iso' })
103 $perl_path .= $Config{_exe
} unless $perl_path =~ m/$Config{_exe}$/i;
106 my $zebraVersion = `zebraidx -V`;
108 # Check running PSGI env
109 if ( any
{ /(^psgi\.|^plack\.)/i } keys %ENV ) {
112 psgi_server
=> ($ENV{ PLACK_ENV
}) ?
"Plack ($ENV{PLACK_ENV})" :
113 ($ENV{ MOD_PERL
}) ?
"mod_perl ($ENV{MOD_PERL})" :
118 # Memcached configuration
119 my $memcached_servers = $ENV{MEMCACHED_SERVERS
} || C4
::Context
->config('memcached_servers');
120 my $memcached_namespace = $ENV{MEMCACHED_NAMESPACE
} || C4
::Context
->config('memcached_namespace') // 'koha';
122 my $cache = Koha
::Caches
->get_instance;
123 my $effective_caching_method = ref($cache->cache);
124 # Memcached may have been running when plack has been initialized but could have been stopped since
125 # FIXME What are the consequences of that??
126 my $is_memcached_still_active = $cache->set_in_cache('test_for_about_page', "just a simple value");
128 my $where_is_memcached_config = 'nowhere';
129 if ( $ENV{MEMCACHED_SERVERS
} and C4
::Context
->config('memcached_servers') ) {
130 $where_is_memcached_config = 'both';
131 } elsif ( $ENV{MEMCACHED_SERVERS
} and not C4
::Context
->config('memcached_servers') ) {
132 $where_is_memcached_config = 'ENV_only';
133 } elsif ( C4
::Context
->config('memcached_servers') ) {
134 $where_is_memcached_config = 'config_only';
138 effective_caching_method
=> $effective_caching_method,
139 memcached_servers
=> $memcached_servers,
140 memcached_namespace
=> $memcached_namespace,
141 is_memcached_still_active
=> $is_memcached_still_active,
142 where_is_memcached_config
=> $where_is_memcached_config,
143 memcached_running
=> Koha
::Caches
->get_instance->memcached_cache,
146 # Additional system information for warnings
148 my $warnStatisticsFieldsError;
149 my $prefStatisticsFields = C4
::Context
->preference('StatisticsFields');
150 if ($prefStatisticsFields) {
151 $warnStatisticsFieldsError = $prefStatisticsFields
152 unless ( $prefStatisticsFields eq C4
::Members
::Statistics
->get_fields() );
155 my $prefAutoCreateAuthorities = C4
::Context
->preference('AutoCreateAuthorities');
156 my $prefBiblioAddsAuthorities = C4
::Context
->preference('BiblioAddsAuthorities');
157 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
159 my $prefEasyAnalyticalRecords = C4
::Context
->preference('EasyAnalyticalRecords');
160 my $prefUseControlNumber = C4
::Context
->preference('UseControlNumber');
161 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
163 my $AnonymousPatron = C4
::Context
->preference('AnonymousPatron');
164 my $warnPrefAnonymousPatronOPACPrivacy = (
165 C4
::Context
->preference('OPACPrivacy')
166 and not $AnonymousPatron
168 my $warnPrefAnonymousPatronAnonSuggestions = (
169 C4
::Context
->preference('AnonSuggestions')
170 and not $AnonymousPatron
173 my $anonymous_patron = Koha
::Patrons
->find( $AnonymousPatron );
174 my $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist = ( $AnonymousPatron && C4
::Context
->preference('AnonSuggestions') && not $anonymous_patron );
176 my $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist = ( not $anonymous_patron and Koha
::Patrons
->search({ privacy
=> 2 })->count );
178 my $errZebraConnection = C4
::Context
->Zconn("biblioserver",0)->errcode();
180 my $warnIsRootUser = (! $loggedinuser);
182 my $warnNoActiveCurrency = (! defined Koha
::Acquisition
::Currencies
->get_active);
184 my @xml_config_warnings;
186 my $context = new C4
::Context
;
188 if ( C4
::Context
->config('zebra_bib_index_mode')
189 and C4
::Context
->config('zebra_bib_index_mode') eq 'grs1' )
191 push @xml_config_warnings, { error
=> 'zebra_bib_index_mode_is_grs1' };
194 if ( C4
::Context
->config('zebra_auth_index_mode')
195 and C4
::Context
->config('zebra_auth_index_mode') eq 'grs1' )
197 push @xml_config_warnings, { error
=> 'zebra_auth_index_mode_is_grs1' };
200 if ( (C4
::Context
->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
201 push @xml_config_warnings, {
202 error
=> 'zebra_auth_index_mode_mismatch_warn'
206 if ( ! defined C4
::Context
->config('log4perl_conf') ) {
207 push @xml_config_warnings, {
208 error
=> 'log4perl_entry_missing'
212 if ( ! defined C4
::Context
->config('lockdir') ) {
213 push @xml_config_warnings, {
214 error
=> 'lockdir_entry_missing'
218 unless ( -w C4
::Context
->config('lockdir') ) {
219 push @xml_config_warnings, {
220 error
=> 'lockdir_not_writable',
221 lockdir
=> C4
::Context
->config('lockdir')
226 if ( ! defined C4
::Context
->config('upload_path') ) {
227 if ( Koha
::Config
::SysPrefs
->find('OPACBaseURL')->value ) {
228 # OPACBaseURL seems to be set
229 push @xml_config_warnings, {
230 error
=> 'uploadpath_entry_missing'
233 push @xml_config_warnings, {
234 error
=> 'uploadpath_and_opacbaseurl_entry_missing'
239 if ( ! C4
::Context
->config('tmp_path') ) {
240 my $temporary_directory = C4
::Context
::temporary_directory
;
241 push @xml_config_warnings, {
242 error
=> 'tmp_path_missing',
243 effective_tmp_dir
=> $temporary_directory,
247 # Test Zebra facets configuration
248 if ( !defined C4
::Context
->config('use_zebra_facets') ) {
249 push @xml_config_warnings, { error
=> 'use_zebra_facets_entry_missing' };
253 if ( C4
::Context
->preference('ILLModule') ) {
254 my $warnILLConfiguration = 0;
255 my $ill_config_from_file = C4
::Context
->config("interlibrary_loans");
256 my $ill_config = Koha
::Illrequest
::Config
->new;
258 my $available_ill_backends =
259 ( scalar @
{ $ill_config->available_backends } > 0 );
262 if ( !$available_ill_backends ) {
263 $template->param( no_ill_backends
=> 1 );
264 $warnILLConfiguration = 1;
268 if ( !Koha
::Patron
::Categories
->find($ill_config->partner_code) ) {
269 $template->param( ill_partner_code_doesnt_exist
=> $ill_config->partner_code );
270 $warnILLConfiguration = 1;
273 if ( !$ill_config_from_file->{partner_code
} ) {
274 # partner code not defined
275 $template->param( ill_partner_code_not_defined
=> 1 );
276 $warnILLConfiguration = 1;
280 if ( !$ill_config_from_file->{branch
} ) {
282 $template->param( ill_branch_not_defined
=> 1 );
283 $warnILLConfiguration = 1;
286 $template->param( warnILLConfiguration
=> $warnILLConfiguration );
289 if ( C4
::Context
->preference('SearchEngine') eq 'Elasticsearch' ) {
290 # Check ES configuration health and runtime status
298 $es_conf = Koha
::SearchEngine
::Elasticsearch
::_read_configuration
();
301 if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) {
302 $template->param( elasticsearch_fatal_config_error
=> $_->message );
303 $es_config_error = 1;
306 if ( !$es_config_error ) {
308 my $biblios_index_name = $es_conf->{index_name
} . "_" . $Koha::SearchEngine
::BIBLIOS_INDEX
;
309 my $authorities_index_name = $es_conf->{index_name
} . "_" . $Koha::SearchEngine
::AUTHORITIES_INDEX
;
311 my @indexes = ($biblios_index_name, $authorities_index_name);
312 # TODO: When new indexes get added, we could have other ways to
313 # fetch the list of available indexes (e.g. plugins, etc)
314 $es_status->{nodes
} = $es_conf->{nodes
};
315 my $es = Search
::Elasticsearch
->new({ nodes
=> $es_conf->{nodes
} });
317 foreach my $index ( @indexes ) {
320 $count = $es->indices->stats( index => $index )
321 ->{_all
}{primaries
}{docs
}{count
};
324 if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) {
325 push @
{ $es_status->{errors
} }, "Index not found ($index)";
328 elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
332 # TODO: when time comes, we will cover more use cases
337 push @
{ $es_status->{indexes
} },
339 index_name
=> $index,
343 $es_status->{running
} = $es_running;
345 $template->param( elasticsearch_status
=> $es_status );
349 if ( C4
::Context
->preference('RESTOAuth2ClientCredentials') ) {
350 # Do we have the required deps?
351 unless ( can_load
( modules
=> { 'Net::OAuth2::AuthorizationServer' => undef }) ) {
352 $template->param( oauth2_missing_deps
=> 1 );
356 # Sco Patron should not contain any other perms than circulate => self_checkout
357 if ( C4
::Context
->preference('WebBasedSelfCheck')
358 and C4
::Context
->preference('AutoSelfCheckAllowed')
360 my $userid = C4
::Context
->preference('AutoSelfCheckID');
361 my $all_permissions = C4
::Auth
::get_user_subpermissions
( $userid );
362 my ( $has_self_checkout_perm, $has_other_permissions );
363 while ( my ( $module, $permissions ) = each %$all_permissions ) {
364 if ( $module eq 'self_check' ) {
365 while ( my ( $permission, $flag ) = each %$permissions ) {
366 if ( $permission eq 'self_checkout_module' ) {
367 $has_self_checkout_perm = 1;
369 $has_other_permissions = 1;
373 $has_other_permissions = 1;
377 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm
=> not ( $has_self_checkout_perm ),
378 AutoSelfCheckPatronHasTooManyPerm
=> $has_other_permissions,
382 # Test YAML system preferences
383 # FIXME: This is list of current YAML formatted prefs, should by type of preference
385 "UpdateNotForLoanStatusOnCheckin",
387 "BibtexExportAdditionalFields",
388 "RisExportAdditionalFields",
389 "UpdateItemWhenLostFromHoldList",
391 "MarcItemFieldsToOrder",
392 "UpdateitemLocationOnCheckin",
396 foreach my $syspref (@yaml_prefs) {
397 my $yaml = C4
::Context
->preference( $syspref );
399 eval { YAML
::Load
( "$yaml\n\n" ); };
401 push @bad_yaml_prefs, $syspref;
405 $template->param( 'bad_yaml_prefs' => \
@bad_yaml_prefs ) if @bad_yaml_prefs;
408 my $dbh = C4
::Context
->dbh;
409 my $patrons = $dbh->selectall_arrayref(
410 q
|select b
.borrowernumber from borrowers b
join deletedborrowers db on b
.borrowernumber
=db
.borrowernumber
|,
413 my $biblios = $dbh->selectall_arrayref(
414 q
|select b
.biblionumber from biblio b
join deletedbiblio db on b
.biblionumber
=db
.biblionumber
|,
417 my $items = $dbh->selectall_arrayref(
418 q
|select i
.itemnumber from items i
join deleteditems di on i
.itemnumber
=di
.itemnumber
|,
421 my $checkouts = $dbh->selectall_arrayref(
422 q
|select i
.issue_id from issues i
join old_issues oi on i
.issue_id
=oi
.issue_id
|,
425 my $holds = $dbh->selectall_arrayref(
426 q
|select r
.reserve_id from reserves r
join old_reserves o on r
.reserve_id
=o
.reserve_id
|,
429 if ( @
$patrons or @
$biblios or @
$items or @
$checkouts or @
$holds ) {
432 ai_patrons
=> $patrons,
433 ai_biblios
=> $biblios,
435 ai_checkouts
=> $checkouts,
443 my $dbh = C4
::Context
->dbh;
444 my $units = Koha
::CirculationRules
->search({ rule_name
=> 'lengthunit', rule_value
=> { -not_in
=> ['days', 'hours'] } });
446 if ( $units->count ) {
448 warnIssuingRules
=> 1,
454 # Guarantor relationships warnings
456 my $dbh = C4
::Context
->dbh;
457 my ($bad_relationships_count) = $dbh->selectall_arrayref(q{
460 SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data'
462 SELECT relationship FROM borrowers WHERE relationship='_bad_data') a
465 $bad_relationships_count = $bad_relationships_count->[0]->[0];
467 my $existing_relationships = $dbh->selectall_arrayref(q{
468 SELECT DISTINCT(relationship)
470 SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL
472 SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
475 my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4
::Context
->preference('borrowerRelationship') );
476 $valid_relationships{ _bad_data
} = 1; # we handle this case in another way
478 my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @
{$existing_relationships} ];
479 if ( @
$wrong_relationships or $bad_relationships_count ) {
482 warnRelationships
=> 1,
485 if ( $wrong_relationships ) {
487 wrong_relationships
=> $wrong_relationships
490 if ($bad_relationships_count) {
492 bad_relationships_count
=> $bad_relationships_count,
498 my %versions = C4
::Context
::get_versions
();
501 kohaVersion
=> $versions{'kohaVersion'},
502 osVersion
=> $versions{'osVersion'},
503 perlPath
=> $perl_path,
504 perlVersion
=> $versions{'perlVersion'},
505 perlIncPath
=> [ map { perlinc
=> $_ }, @INC ],
506 mysqlVersion
=> $versions{'mysqlVersion'},
507 apacheVersion
=> $versions{'apacheVersion'},
508 zebraVersion
=> $zebraVersion,
509 prefBiblioAddsAuthorities
=> $prefBiblioAddsAuthorities,
510 prefAutoCreateAuthorities
=> $prefAutoCreateAuthorities,
511 warnPrefBiblioAddsAuthorities
=> $warnPrefBiblioAddsAuthorities,
512 warnPrefEasyAnalyticalRecords
=> $warnPrefEasyAnalyticalRecords,
513 warnPrefAnonymousPatronOPACPrivacy
=> $warnPrefAnonymousPatronOPACPrivacy,
514 warnPrefAnonymousPatronAnonSuggestions
=> $warnPrefAnonymousPatronAnonSuggestions,
515 warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist
=> $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist,
516 warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist
=> $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist,
517 errZebraConnection
=> $errZebraConnection,
518 warnIsRootUser
=> $warnIsRootUser,
519 warnNoActiveCurrency
=> $warnNoActiveCurrency,
520 warnNoTemplateCaching
=> ( C4
::Context
->config('template_cache_dir') ?
0 : 1 ),
521 xml_config_warnings
=> \
@xml_config_warnings,
522 warnStatisticsFieldsError
=> $warnStatisticsFieldsError,
527 my $perl_modules = C4
::Installer
::PerlModules
->new;
528 $perl_modules->versions_info;
530 my @pm_types = qw(missing_pm upgrade_pm current_pm);
532 foreach my $pm_type(@pm_types) {
533 my $modules = $perl_modules->get_attr($pm_type);
534 foreach (@
$modules) {
535 my ($module, $stats) = each %$_;
540 version
=> $stats->{'cur_ver'},
541 missing
=> ($pm_type eq 'missing_pm' ?
1 : 0),
542 upgrade
=> ($pm_type eq 'upgrade_pm' ?
1 : 0),
543 current
=> ($pm_type eq 'current_pm' ?
1 : 0),
544 require => $stats->{'required'},
545 reqversion
=> $stats->{'min_ver'},
546 maxversion
=> $stats->{'max_ver'}
552 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
557 foreach (@components) {
559 unless (++$counter % 4) {
560 push (@
$table, {row
=> $row});
564 # Processing the last line (if there are any modules left)
565 if (scalar(@
$row) > 0) {
566 # Extending $row to the table size
568 # Pushing the last line
569 push (@
$table, {row
=> $row});
573 $template->param( table
=> $table );
576 ## ------------------------------------------
577 ## Koha contributions
579 if ( defined C4
::Context
->config('docdir') ) {
580 $docdir = C4
::Context
->config('docdir');
582 # if no <docdir> is defined in koha-conf.xml, use the default location
583 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
584 $docdir = C4
::Context
->config('intranetdir') . '/docs';
589 -e
"$docdir" . "/teams.yaml"
590 ? LoadFile
( "$docdir" . "/teams.yaml" )
592 my $dev_team = (sort {$b <=> $a} (keys %{$teams->{team
}}))[0];
593 my $short_version = substr($versions{'kohaVersion'},0,5);
594 my $minor = substr($versions{'kohaVersion'},3,2);
595 my $development_version = ( $minor eq '05' || $minor eq '11' ) ?
0 : 1;
596 $template->param( short_version
=> $short_version );
597 $template->param( development_version
=> $development_version );
601 -e
"$docdir" . "/contributors.yaml"
602 ? LoadFile
( "$docdir" . "/contributors.yaml" )
604 for my $version ( sort { $a <=> $b } keys %{$teams->{team
}} ) {
605 for my $role ( keys %{ $teams->{team
}->{$version} } ) {
606 my $normalized_role = "$role";
607 $normalized_role =~ s/s$//;
608 if ( ref( $teams->{team
}->{$version}->{$role} ) eq 'ARRAY' ) {
609 for my $contributor ( @
{ $teams->{team
}->{$version}->{$role} } ) {
610 my $name = $contributor->{name
};
611 # Add role to contributors
612 push @
{ $contributors->{$name}->{roles
}->{$normalized_role} },
614 # Add openhub to teams
615 if ( exists( $contributors->{$name}->{openhub
} ) ) {
616 $contributor->{openhub
} = $contributors->{$name}->{openhub
};
620 elsif ( $role ne 'release_date' ) {
621 my $name = $teams->{team
}->{$version}->{$role}->{name
};
622 # Add role to contributors
623 push @
{ $contributors->{$name}->{roles
}->{$normalized_role} },
625 # Add openhub to teams
626 if ( exists( $contributors->{$name}->{openhub
} ) ) {
627 $teams->{team
}->{$version}->{$role}->{openhub
} =
628 $contributors->{$name}->{openhub
};
632 $teams->{team
}->{$version}->{$role} = DateTime
->from_epoch( epoch
=> $teams->{team
}->{$version}->{$role});
637 ## Create last name ordered array of people from contributors
639 { name
=> $_, ( $contributors->{$_} ?
%{ $contributors->{$_} } : () ) }
641 my ($alast) = ( split( /\s/, $a ) )[-1];
642 my ($blast) = ( split( /\s/, $b ) )[-1];
643 lc($alast) cmp lc($blast)
644 } keys %{$contributors};
646 $template->param( contributors
=> \
@people );
647 $template->param( maintenance_team
=> $teams->{team
}->{$dev_team} );
648 $template->param( release_team
=> $teams->{team
}->{$short_version} );
651 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
661 shift @lines; #remove header row
664 my ( $epoch, $date, $desc, $tag ) = split(/\t/);
665 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
666 ($date, $desc)= ($`, $');
678 #foreach my $row2 (@rows2) {
681 push( @$table2, { row2 => $row2 } );
685 $template->param( table2 => $table2 );
687 $template->param( timeline_read_error => 1 );
690 output_html_with_http_headers $query, $cookie, $template->output;