Bug 24834: (QA follow-up) Add missing filter
[koha.git] / about.pl
blobbade1ea0ae736c5d3bd55559917c43ede4e4ea5d
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 DateTime::TimeZone;
27 use File::Spec;
28 use File::Slurp;
29 use List::MoreUtils qw/ any /;
30 use LWP::Simple;
31 use Module::Load::Conditional qw(can_load);
32 use XML::Simple;
33 use Config;
34 use Search::Elasticsearch;
35 use Try::Tiny;
36 use YAML qw/LoadFile/;
38 use C4::Output;
39 use C4::Auth;
40 use C4::Context;
41 use C4::Installer::PerlModules;
43 use Koha;
44 use Koha::DateUtils qw(dt_from_string output_pref);
45 use Koha::Acquisition::Currencies;
46 use Koha::BackgroundJob;
47 use Koha::BiblioFrameworks;
48 use Koha::Email;
49 use Koha::Patron::Categories;
50 use Koha::Patrons;
51 use Koha::Caches;
52 use Koha::Config::SysPrefs;
53 use Koha::Illrequest::Config;
54 use Koha::SearchEngine::Elasticsearch;
55 use Koha::Logger;
56 use Koha::Filter::MARC::ViewPolicy;
58 use C4::Members::Statistics;
61 #use Smart::Comments '####';
63 my $query = CGI->new;
64 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
66 template_name => "about.tt",
67 query => $query,
68 type => "intranet",
69 flagsrequired => { catalogue => 1 },
70 debug => 1,
74 my $config_timezone = C4::Context->config('timezone') // '';
75 my $config_invalid = !DateTime::TimeZone->is_valid_name( $config_timezone );
76 my $env_timezone = $ENV{TZ} // '';
77 my $env_invalid = !DateTime::TimeZone->is_valid_name( $env_timezone );
78 my $actual_bad_tz_fallback = 0;
80 if ( $config_timezone ne '' &&
81 $config_invalid ) {
82 # Bad config
83 $actual_bad_tz_fallback = 1;
85 elsif ( $config_timezone eq '' &&
86 $env_timezone ne '' &&
87 $env_invalid ) {
88 # No config, but bad ENV{TZ}
89 $actual_bad_tz_fallback = 1;
92 my $time_zone = {
93 actual => C4::Context->tz->name,
94 actual_bad_tz_fallback => $actual_bad_tz_fallback,
95 config => $config_timezone,
96 config_invalid => $config_invalid,
97 environment => $env_timezone,
98 environment_invalid => $env_invalid
101 { # Logger checks
102 my $log4perl_config = C4::Context->config("log4perl_conf");
103 my @log4perl_errors;
104 if ( ! $log4perl_config ) {
105 push @log4perl_errors, 'missing_config_entry'
107 else {
108 my @lines = read_file($log4perl_config) or push @log4perl_errors, 'cannot_read_config_file';
109 for my $line ( @lines ) {
110 next unless $line =~ m|log4perl.appender.\w+.filename=(.*)|;
111 push @log4perl_errors, 'logfile_not_writable' unless -w $1;
114 eval {Koha::Logger->get};
115 push @log4perl_errors, 'cannot_init_module' and warn $@ if $@;
116 $template->param( log4perl_errors => @log4perl_errors );
119 $template->param(
120 time_zone => $time_zone,
121 current_date_and_time => output_pref({ dt => dt_from_string(), dateformat => 'iso' })
124 my $perl_path = $^X;
125 if ($^O ne 'VMS') {
126 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
129 my $zebraVersion = `zebraidx -V`;
131 # Check running PSGI env
132 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
133 $template->param(
134 is_psgi => 1,
135 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
136 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
137 'Unknown'
141 # Memcached configuration
142 my $memcached_servers = $ENV{MEMCACHED_SERVERS} || C4::Context->config('memcached_servers');
143 my $memcached_namespace = $ENV{MEMCACHED_NAMESPACE} || C4::Context->config('memcached_namespace') // 'koha';
145 my $cache = Koha::Caches->get_instance;
146 my $effective_caching_method = ref($cache->cache);
147 # Memcached may have been running when plack has been initialized but could have been stopped since
148 # FIXME What are the consequences of that??
149 my $is_memcached_still_active = $cache->set_in_cache('test_for_about_page', "just a simple value");
151 my $where_is_memcached_config = 'nowhere';
152 if ( $ENV{MEMCACHED_SERVERS} and C4::Context->config('memcached_servers') ) {
153 $where_is_memcached_config = 'both';
154 } elsif ( $ENV{MEMCACHED_SERVERS} and not C4::Context->config('memcached_servers') ) {
155 $where_is_memcached_config = 'ENV_only';
156 } elsif ( C4::Context->config('memcached_servers') ) {
157 $where_is_memcached_config = 'config_only';
160 $template->param(
161 effective_caching_method => $effective_caching_method,
162 memcached_servers => $memcached_servers,
163 memcached_namespace => $memcached_namespace,
164 is_memcached_still_active => $is_memcached_still_active,
165 where_is_memcached_config => $where_is_memcached_config,
166 memcached_running => Koha::Caches->get_instance->memcached_cache,
169 # Additional system information for warnings
171 my $warnStatisticsFieldsError;
172 my $prefStatisticsFields = C4::Context->preference('StatisticsFields');
173 if ($prefStatisticsFields) {
174 $warnStatisticsFieldsError = $prefStatisticsFields
175 unless ( $prefStatisticsFields eq C4::Members::Statistics->get_fields() );
178 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
179 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
180 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
182 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
183 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
184 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
186 my $AnonymousPatron = C4::Context->preference('AnonymousPatron');
187 my $warnPrefAnonymousPatronOPACPrivacy = (
188 C4::Context->preference('OPACPrivacy')
189 and not $AnonymousPatron
191 my $warnPrefAnonymousPatronAnonSuggestions = (
192 C4::Context->preference('AnonSuggestions')
193 and not $AnonymousPatron
196 my $anonymous_patron = Koha::Patrons->find( $AnonymousPatron );
197 my $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist = ( $AnonymousPatron && C4::Context->preference('AnonSuggestions') && not $anonymous_patron );
199 my $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
201 my $warnPrefKohaAdminEmailAddress = not Email::Valid->address(C4::Context->preference('KohaAdminEmailAddress'));
203 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
205 my $warnIsRootUser = (! $loggedinuser);
207 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
209 my @xml_config_warnings;
211 my $context = C4::Context->new;
213 if ( C4::Context->config('zebra_bib_index_mode')
214 and C4::Context->config('zebra_bib_index_mode') eq 'grs1' )
216 push @xml_config_warnings, { error => 'zebra_bib_index_mode_is_grs1' };
219 if ( C4::Context->config('zebra_auth_index_mode')
220 and C4::Context->config('zebra_auth_index_mode') eq 'grs1' )
222 push @xml_config_warnings, { error => 'zebra_auth_index_mode_is_grs1' };
225 if( ( C4::Context->config('zebra_auth_index_mode')
226 and C4::Context->config('zebra_auth_index_mode') eq 'dom' )
227 && ( $context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/ ) )
229 push @xml_config_warnings, {
230 error => 'zebra_auth_index_mode_mismatch_warn'
234 if ( ! defined C4::Context->config('log4perl_conf') ) {
235 push @xml_config_warnings, {
236 error => 'log4perl_entry_missing'
240 if ( ! defined C4::Context->config('lockdir') ) {
241 push @xml_config_warnings, {
242 error => 'lockdir_entry_missing'
245 else {
246 unless ( -w C4::Context->config('lockdir') ) {
247 push @xml_config_warnings, {
248 error => 'lockdir_not_writable',
249 lockdir => C4::Context->config('lockdir')
254 if ( ! defined C4::Context->config('upload_path') ) {
255 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
256 # OPACBaseURL seems to be set
257 push @xml_config_warnings, {
258 error => 'uploadpath_entry_missing'
260 } else {
261 push @xml_config_warnings, {
262 error => 'uploadpath_and_opacbaseurl_entry_missing'
267 if ( ! C4::Context->config('tmp_path') ) {
268 my $temporary_directory = C4::Context::temporary_directory;
269 push @xml_config_warnings, {
270 error => 'tmp_path_missing',
271 effective_tmp_dir => $temporary_directory,
275 # Test Zebra facets configuration
276 if ( !defined C4::Context->config('use_zebra_facets') ) {
277 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
280 # ILL module checks
281 if ( C4::Context->preference('ILLModule') ) {
282 my $warnILLConfiguration = 0;
283 my $ill_config_from_file = C4::Context->config("interlibrary_loans");
284 my $ill_config = Koha::Illrequest::Config->new;
286 my $available_ill_backends =
287 ( scalar @{ $ill_config->available_backends } > 0 );
289 # Check backends
290 if ( !$available_ill_backends ) {
291 $template->param( no_ill_backends => 1 );
292 $warnILLConfiguration = 1;
295 # Check partner_code
296 if ( !Koha::Patron::Categories->find($ill_config->partner_code) ) {
297 $template->param( ill_partner_code_doesnt_exist => $ill_config->partner_code );
298 $warnILLConfiguration = 1;
301 if ( !$ill_config_from_file->{partner_code} ) {
302 # partner code not defined
303 $template->param( ill_partner_code_not_defined => 1 );
304 $warnILLConfiguration = 1;
308 if ( !$ill_config_from_file->{branch} ) {
309 # branch not defined
310 $template->param( ill_branch_not_defined => 1 );
311 $warnILLConfiguration = 1;
314 $template->param( warnILLConfiguration => $warnILLConfiguration );
317 if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) {
318 # Check ES configuration health and runtime status
320 my $es_status;
321 my $es_config_error;
322 my $es_running = 1;
324 my $es_conf;
325 try {
326 $es_conf = Koha::SearchEngine::Elasticsearch::_read_configuration();
328 catch {
329 if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) {
330 $template->param( elasticsearch_fatal_config_error => $_->message );
331 $es_config_error = 1;
334 if ( !$es_config_error ) {
336 my $biblios_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::BIBLIOS_INDEX;
337 my $authorities_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::AUTHORITIES_INDEX;
339 my @indexes = ($biblios_index_name, $authorities_index_name);
340 # TODO: When new indexes get added, we could have other ways to
341 # fetch the list of available indexes (e.g. plugins, etc)
342 $es_status->{nodes} = $es_conf->{nodes};
343 my $es = Search::Elasticsearch->new({ nodes => $es_conf->{nodes} });
345 foreach my $index ( @indexes ) {
346 my $count;
347 try {
348 $count = $es->indices->stats( index => $index )
349 ->{_all}{primaries}{docs}{count};
351 catch {
352 if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) {
353 push @{ $es_status->{errors} }, "Index not found ($index)";
354 $count = -1;
356 elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
357 $es_running = 0;
359 else {
360 # TODO: when time comes, we will cover more use cases
361 die $_;
365 push @{ $es_status->{indexes} },
367 index_name => $index,
368 count => $count
371 $es_status->{running} = $es_running;
373 $template->param( elasticsearch_status => $es_status );
377 if ( C4::Context->preference('RESTOAuth2ClientCredentials') ) {
378 # Do we have the required deps?
379 unless ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef }) ) {
380 $template->param( oauth2_missing_deps => 1 );
384 # Sco Patron should not contain any other perms than circulate => self_checkout
385 if ( C4::Context->preference('WebBasedSelfCheck')
386 and C4::Context->preference('AutoSelfCheckAllowed')
388 my $userid = C4::Context->preference('AutoSelfCheckID');
389 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
390 my ( $has_self_checkout_perm, $has_other_permissions );
391 while ( my ( $module, $permissions ) = each %$all_permissions ) {
392 if ( $module eq 'self_check' ) {
393 while ( my ( $permission, $flag ) = each %$permissions ) {
394 if ( $permission eq 'self_checkout_module' ) {
395 $has_self_checkout_perm = 1;
396 } else {
397 $has_other_permissions = 1;
400 } else {
401 $has_other_permissions = 1;
404 $template->param(
405 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
406 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
410 # Test YAML system preferences
411 # FIXME: This is list of current YAML formatted prefs, should by type of preference
412 my @yaml_prefs = (
413 "UpdateNotForLoanStatusOnCheckin",
414 "OpacHiddenItems",
415 "BibtexExportAdditionalFields",
416 "RisExportAdditionalFields",
417 "UpdateItemWhenLostFromHoldList",
418 "MarcFieldsToOrder",
419 "MarcItemFieldsToOrder",
420 "UpdateitemLocationOnCheckin",
421 "ItemsDeniedRenewal"
423 my @bad_yaml_prefs;
424 foreach my $syspref (@yaml_prefs) {
425 my $yaml = C4::Context->preference( $syspref );
426 if ( $yaml ) {
427 eval { YAML::Load( "$yaml\n\n" ); };
428 if ($@) {
429 push @bad_yaml_prefs, $syspref;
433 $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
436 my $dbh = C4::Context->dbh;
437 my $patrons = $dbh->selectall_arrayref(
438 q|select b.borrowernumber from borrowers b join deletedborrowers db on b.borrowernumber=db.borrowernumber|,
439 { Slice => {} }
441 my $biblios = $dbh->selectall_arrayref(
442 q|select b.biblionumber from biblio b join deletedbiblio db on b.biblionumber=db.biblionumber|,
443 { Slice => {} }
445 my $items = $dbh->selectall_arrayref(
446 q|select i.itemnumber from items i join deleteditems di on i.itemnumber=di.itemnumber|,
447 { Slice => {} }
449 my $checkouts = $dbh->selectall_arrayref(
450 q|select i.issue_id from issues i join old_issues oi on i.issue_id=oi.issue_id|,
451 { Slice => {} }
453 my $holds = $dbh->selectall_arrayref(
454 q|select r.reserve_id from reserves r join old_reserves o on r.reserve_id=o.reserve_id|,
455 { Slice => {} }
457 if ( @$patrons or @$biblios or @$items or @$checkouts or @$holds ) {
458 $template->param(
459 has_ai_issues => 1,
460 ai_patrons => $patrons,
461 ai_biblios => $biblios,
462 ai_items => $items,
463 ai_checkouts => $checkouts,
464 ai_holds => $holds,
469 # Circ rule warnings
471 my $dbh = C4::Context->dbh;
472 my $units = Koha::CirculationRules->search({ rule_name => 'lengthunit', rule_value => { -not_in => ['days', 'hours'] } });
474 if ( $units->count ) {
475 $template->param(
476 warnIssuingRules => 1,
477 ir_units => $units,
482 # Guarantor relationships warnings
484 my $dbh = C4::Context->dbh;
485 my ($bad_relationships_count) = $dbh->selectall_arrayref(q{
486 SELECT COUNT(*)
487 FROM (
488 SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data'
489 UNION ALL
490 SELECT relationship FROM borrowers WHERE relationship='_bad_data') a
493 $bad_relationships_count = $bad_relationships_count->[0]->[0];
495 my $existing_relationships = $dbh->selectall_arrayref(q{
496 SELECT DISTINCT(relationship)
497 FROM (
498 SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL
499 UNION ALL
500 SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
503 my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') );
504 $valid_relationships{ _bad_data } = 1; # we handle this case in another way
506 my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
507 if ( @$wrong_relationships or $bad_relationships_count ) {
509 $template->param(
510 warnRelationships => 1,
513 if ( $wrong_relationships ) {
514 $template->param(
515 wrong_relationships => $wrong_relationships
518 if ($bad_relationships_count) {
519 $template->param(
520 bad_relationships_count => $bad_relationships_count,
527 # Test 'bcrypt_settings' config for Pseudonymization
528 $template->param( config_bcrypt_settings_no_set => 1 )
529 if C4::Context->preference('Pseudonymization')
530 and not C4::Context->config('bcrypt_settings');
534 my @frameworkcodes = Koha::BiblioFrameworks->search->get_column('frameworkcode');
535 my @hidden_biblionumbers;
536 push @frameworkcodes, ""; # it's not in the biblio_frameworks table!
537 for my $frameworkcode ( @frameworkcodes ) {
538 my $shouldhidemarc_opac = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
540 frameworkcode => $frameworkcode,
541 interface => "opac"
544 push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'opac' }
545 if $shouldhidemarc_opac->{biblionumber};
547 my $shouldhidemarc_intranet = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
549 frameworkcode => $frameworkcode,
550 interface => "intranet"
553 push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'intranet' }
554 if $shouldhidemarc_intranet->{biblionumber};
556 $template->param( warnHiddenBiblionumbers => \@hidden_biblionumbers );
560 # BackgroundJob - test connection to message broker
561 eval {
562 Koha::BackgroundJob->connect;
564 if ( $@ ) {
565 warn $@;
566 $template->param( warnConnectBroker => $@ );
570 my %versions = C4::Context::get_versions();
572 $template->param(
573 kohaVersion => $versions{'kohaVersion'},
574 osVersion => $versions{'osVersion'},
575 perlPath => $perl_path,
576 perlVersion => $versions{'perlVersion'},
577 perlIncPath => [ map { perlinc => $_ }, @INC ],
578 mysqlVersion => $versions{'mysqlVersion'},
579 apacheVersion => $versions{'apacheVersion'},
580 zebraVersion => $zebraVersion,
581 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
582 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
583 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
584 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
585 warnPrefAnonymousPatronOPACPrivacy => $warnPrefAnonymousPatronOPACPrivacy,
586 warnPrefAnonymousPatronAnonSuggestions => $warnPrefAnonymousPatronAnonSuggestions,
587 warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist => $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist,
588 warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist => $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist,
589 warnPrefKohaAdminEmailAddress => $warnPrefKohaAdminEmailAddress,
590 errZebraConnection => $errZebraConnection,
591 warnIsRootUser => $warnIsRootUser,
592 warnNoActiveCurrency => $warnNoActiveCurrency,
593 warnNoTemplateCaching => ( C4::Context->config('template_cache_dir') ? 0 : 1 ),
594 xml_config_warnings => \@xml_config_warnings,
595 warnStatisticsFieldsError => $warnStatisticsFieldsError,
598 my @components = ();
600 my $perl_modules = C4::Installer::PerlModules->new;
601 $perl_modules->versions_info;
603 my @pm_types = qw(missing_pm upgrade_pm current_pm);
605 foreach my $pm_type(@pm_types) {
606 my $modules = $perl_modules->get_attr($pm_type);
607 foreach (@$modules) {
608 my ($module, $stats) = each %$_;
609 push(
610 @components,
612 name => $module,
613 version => $stats->{'cur_ver'},
614 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
615 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
616 current => ($pm_type eq 'current_pm' ? 1 : 0),
617 require => $stats->{'required'},
618 reqversion => $stats->{'min_ver'},
619 maxversion => $stats->{'max_ver'},
620 excversion => $stats->{'exc_ver'}
626 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
628 my $counter=0;
629 my $row = [];
630 my $table = [];
631 foreach (@components) {
632 push (@$row, $_);
633 unless (++$counter % 4) {
634 push (@$table, {row => $row});
635 $row = [];
638 # Processing the last line (if there are any modules left)
639 if (scalar(@$row) > 0) {
640 # Extending $row to the table size
641 $$row[3] = '';
642 # Pushing the last line
643 push (@$table, {row => $row});
645 ## ## $table
647 $template->param( table => $table );
650 ## ------------------------------------------
651 ## Koha contributions
652 my $docdir;
653 if ( defined C4::Context->config('docdir') ) {
654 $docdir = C4::Context->config('docdir');
655 } else {
656 # if no <docdir> is defined in koha-conf.xml, use the default location
657 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
658 $docdir = C4::Context->config('intranetdir') . '/docs';
661 ## Release teams
662 my $teams =
663 -e "$docdir" . "/teams.yaml"
664 ? LoadFile( "$docdir" . "/teams.yaml" )
665 : {};
666 my $dev_team = (sort {$b <=> $a} (keys %{$teams->{team}}))[0];
667 my $short_version = substr($versions{'kohaVersion'},0,5);
668 my $minor = substr($versions{'kohaVersion'},3,2);
669 my $development_version = ( $minor eq '05' || $minor eq '11' ) ? 0 : 1;
670 $template->param( short_version => $short_version );
671 $template->param( development_version => $development_version );
673 ## Contributors
674 my $contributors =
675 -e "$docdir" . "/contributors.yaml"
676 ? LoadFile( "$docdir" . "/contributors.yaml" )
677 : {};
678 for my $version ( sort { $a <=> $b } keys %{$teams->{team}} ) {
679 for my $role ( keys %{ $teams->{team}->{$version} } ) {
680 my $normalized_role = "$role";
681 $normalized_role =~ s/s$//;
682 if ( ref( $teams->{team}->{$version}->{$role} ) eq 'ARRAY' ) {
683 for my $contributor ( @{ $teams->{team}->{$version}->{$role} } ) {
684 my $name = $contributor->{name};
685 # Add role to contributors
686 push @{ $contributors->{$name}->{roles}->{$normalized_role} },
687 $version;
688 # Add openhub to teams
689 if ( exists( $contributors->{$name}->{openhub} ) ) {
690 $contributor->{openhub} = $contributors->{$name}->{openhub};
694 elsif ( $role ne 'release_date' ) {
695 my $name = $teams->{team}->{$version}->{$role}->{name};
696 # Add role to contributors
697 push @{ $contributors->{$name}->{roles}->{$normalized_role} },
698 $version;
699 # Add openhub to teams
700 if ( exists( $contributors->{$name}->{openhub} ) ) {
701 $teams->{team}->{$version}->{$role}->{openhub} =
702 $contributors->{$name}->{openhub};
705 else {
706 $teams->{team}->{$version}->{$role} = DateTime->from_epoch( epoch => $teams->{team}->{$version}->{$role});
711 ## Create last name ordered array of people from contributors
712 my @people = map {
713 { name => $_, ( $contributors->{$_} ? %{ $contributors->{$_} } : () ) }
714 } sort {
715 my ($alast) = ( split( /\s/, $a ) )[-1];
716 my ($blast) = ( split( /\s/, $b ) )[-1];
717 lc($alast) cmp lc($blast)
718 } keys %{$contributors};
720 $template->param( contributors => \@people );
721 $template->param( maintenance_team => $teams->{team}->{$dev_team} );
722 $template->param( release_team => $teams->{team}->{$short_version} );
724 ## Timeline
725 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
727 my $i = 0;
729 my @rows2 = ();
730 my $row2 = [];
732 my @lines = <$file>;
733 close($file);
735 shift @lines; #remove header row
737 foreach (@lines) {
738 my ( $epoch, $date, $desc, $tag ) = split(/\t/);
739 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
740 ($date, $desc)= ($`, $');
742 push(
743 @rows2,
745 date => $date,
746 desc => $desc,
751 my $table2 = [];
752 #foreach my $row2 (@rows2) {
753 foreach (@rows2) {
754 push (@$row2, $_);
755 push( @$table2, { row2 => $row2 } );
756 $row2 = [];
759 $template->param( table2 => $table2 );
760 } else {
761 $template->param( timeline_read_error => 1 );
764 output_html_with_http_headers $query, $cookie, $template->output;