Bug 19036: Add ability to auto generate a number for account credits
[koha.git] / about.pl
blob029bd94833f22d709cd1c92641de04fc4ea94f01
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::BiblioFrameworks;
47 use Koha::Patron::Categories;
48 use Koha::Patrons;
49 use Koha::Caches;
50 use Koha::Config::SysPrefs;
51 use Koha::Illrequest::Config;
52 use Koha::SearchEngine::Elasticsearch;
53 use Koha::Logger;
54 use Koha::Filter::MARC::ViewPolicy;
56 use C4::Members::Statistics;
59 #use Smart::Comments '####';
61 my $query = new CGI;
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
64 template_name => "about.tt",
65 query => $query,
66 type => "intranet",
67 authnotrequired => 0,
68 flagsrequired => { catalogue => 1 },
69 debug => 1,
73 my $config_timezone = C4::Context->config('timezone') // '';
74 my $config_invalid = !DateTime::TimeZone->is_valid_name( $config_timezone );
75 my $env_timezone = $ENV{TZ} // '';
76 my $env_invalid = !DateTime::TimeZone->is_valid_name( $env_timezone );
77 my $actual_bad_tz_fallback = 0;
79 if ( $config_timezone ne '' &&
80 $config_invalid ) {
81 # Bad config
82 $actual_bad_tz_fallback = 1;
84 elsif ( $config_timezone eq '' &&
85 $env_timezone ne '' &&
86 $env_invalid ) {
87 # No config, but bad ENV{TZ}
88 $actual_bad_tz_fallback = 1;
91 my $time_zone = {
92 actual => C4::Context->tz->name,
93 actual_bad_tz_fallback => $actual_bad_tz_fallback,
94 config => $config_timezone,
95 config_invalid => $config_invalid,
96 environment => $env_timezone,
97 environment_invalid => $env_invalid
100 { # Logger checks
101 my $log4perl_config = C4::Context->config("log4perl_conf");
102 my @log4perl_errors;
103 if ( ! $log4perl_config ) {
104 push @log4perl_errors, 'missing_config_entry'
106 else {
107 my @lines = read_file($log4perl_config) or push @log4perl_errors, 'cannot_read_config_file';
108 for my $line ( @lines ) {
109 next unless $line =~ m|log4perl.appender.\w+.filename=(.*)|;
110 push @log4perl_errors, 'logfile_not_writable' unless -w $1;
113 eval {Koha::Logger->get};
114 push @log4perl_errors, 'cannot_init_module' and warn $@ if $@;
115 $template->param( log4perl_errors => @log4perl_errors );
118 $template->param(
119 time_zone => $time_zone,
120 current_date_and_time => output_pref({ dt => dt_from_string(), dateformat => 'iso' })
123 my $perl_path = $^X;
124 if ($^O ne 'VMS') {
125 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
128 my $zebraVersion = `zebraidx -V`;
130 # Check running PSGI env
131 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
132 $template->param(
133 is_psgi => 1,
134 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
135 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
136 'Unknown'
140 # Memcached configuration
141 my $memcached_servers = $ENV{MEMCACHED_SERVERS} || C4::Context->config('memcached_servers');
142 my $memcached_namespace = $ENV{MEMCACHED_NAMESPACE} || C4::Context->config('memcached_namespace') // 'koha';
144 my $cache = Koha::Caches->get_instance;
145 my $effective_caching_method = ref($cache->cache);
146 # Memcached may have been running when plack has been initialized but could have been stopped since
147 # FIXME What are the consequences of that??
148 my $is_memcached_still_active = $cache->set_in_cache('test_for_about_page', "just a simple value");
150 my $where_is_memcached_config = 'nowhere';
151 if ( $ENV{MEMCACHED_SERVERS} and C4::Context->config('memcached_servers') ) {
152 $where_is_memcached_config = 'both';
153 } elsif ( $ENV{MEMCACHED_SERVERS} and not C4::Context->config('memcached_servers') ) {
154 $where_is_memcached_config = 'ENV_only';
155 } elsif ( C4::Context->config('memcached_servers') ) {
156 $where_is_memcached_config = 'config_only';
159 $template->param(
160 effective_caching_method => $effective_caching_method,
161 memcached_servers => $memcached_servers,
162 memcached_namespace => $memcached_namespace,
163 is_memcached_still_active => $is_memcached_still_active,
164 where_is_memcached_config => $where_is_memcached_config,
165 memcached_running => Koha::Caches->get_instance->memcached_cache,
168 # Additional system information for warnings
170 my $warnStatisticsFieldsError;
171 my $prefStatisticsFields = C4::Context->preference('StatisticsFields');
172 if ($prefStatisticsFields) {
173 $warnStatisticsFieldsError = $prefStatisticsFields
174 unless ( $prefStatisticsFields eq C4::Members::Statistics->get_fields() );
177 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
178 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
179 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
181 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
182 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
183 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
185 my $AnonymousPatron = C4::Context->preference('AnonymousPatron');
186 my $warnPrefAnonymousPatronOPACPrivacy = (
187 C4::Context->preference('OPACPrivacy')
188 and not $AnonymousPatron
190 my $warnPrefAnonymousPatronAnonSuggestions = (
191 C4::Context->preference('AnonSuggestions')
192 and not $AnonymousPatron
195 my $anonymous_patron = Koha::Patrons->find( $AnonymousPatron );
196 my $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist = ( $AnonymousPatron && C4::Context->preference('AnonSuggestions') && not $anonymous_patron );
198 my $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
200 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
202 my $warnIsRootUser = (! $loggedinuser);
204 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
206 my @xml_config_warnings;
208 my $context = new C4::Context;
210 if ( C4::Context->config('zebra_bib_index_mode')
211 and C4::Context->config('zebra_bib_index_mode') eq 'grs1' )
213 push @xml_config_warnings, { error => 'zebra_bib_index_mode_is_grs1' };
216 if ( C4::Context->config('zebra_auth_index_mode')
217 and C4::Context->config('zebra_auth_index_mode') eq 'grs1' )
219 push @xml_config_warnings, { error => 'zebra_auth_index_mode_is_grs1' };
222 if( ( C4::Context->config('zebra_auth_index_mode')
223 and C4::Context->config('zebra_auth_index_mode') eq 'dom' )
224 && ( $context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/ ) )
226 push @xml_config_warnings, {
227 error => 'zebra_auth_index_mode_mismatch_warn'
231 if ( ! defined C4::Context->config('log4perl_conf') ) {
232 push @xml_config_warnings, {
233 error => 'log4perl_entry_missing'
237 if ( ! defined C4::Context->config('lockdir') ) {
238 push @xml_config_warnings, {
239 error => 'lockdir_entry_missing'
242 else {
243 unless ( -w C4::Context->config('lockdir') ) {
244 push @xml_config_warnings, {
245 error => 'lockdir_not_writable',
246 lockdir => C4::Context->config('lockdir')
251 if ( ! defined C4::Context->config('upload_path') ) {
252 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
253 # OPACBaseURL seems to be set
254 push @xml_config_warnings, {
255 error => 'uploadpath_entry_missing'
257 } else {
258 push @xml_config_warnings, {
259 error => 'uploadpath_and_opacbaseurl_entry_missing'
264 if ( ! C4::Context->config('tmp_path') ) {
265 my $temporary_directory = C4::Context::temporary_directory;
266 push @xml_config_warnings, {
267 error => 'tmp_path_missing',
268 effective_tmp_dir => $temporary_directory,
272 # Test Zebra facets configuration
273 if ( !defined C4::Context->config('use_zebra_facets') ) {
274 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
277 # ILL module checks
278 if ( C4::Context->preference('ILLModule') ) {
279 my $warnILLConfiguration = 0;
280 my $ill_config_from_file = C4::Context->config("interlibrary_loans");
281 my $ill_config = Koha::Illrequest::Config->new;
283 my $available_ill_backends =
284 ( scalar @{ $ill_config->available_backends } > 0 );
286 # Check backends
287 if ( !$available_ill_backends ) {
288 $template->param( no_ill_backends => 1 );
289 $warnILLConfiguration = 1;
292 # Check partner_code
293 if ( !Koha::Patron::Categories->find($ill_config->partner_code) ) {
294 $template->param( ill_partner_code_doesnt_exist => $ill_config->partner_code );
295 $warnILLConfiguration = 1;
298 if ( !$ill_config_from_file->{partner_code} ) {
299 # partner code not defined
300 $template->param( ill_partner_code_not_defined => 1 );
301 $warnILLConfiguration = 1;
305 if ( !$ill_config_from_file->{branch} ) {
306 # branch not defined
307 $template->param( ill_branch_not_defined => 1 );
308 $warnILLConfiguration = 1;
311 $template->param( warnILLConfiguration => $warnILLConfiguration );
314 if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) {
315 # Check ES configuration health and runtime status
317 my $es_status;
318 my $es_config_error;
319 my $es_running = 1;
321 my $es_conf;
322 try {
323 $es_conf = Koha::SearchEngine::Elasticsearch::_read_configuration();
325 catch {
326 if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) {
327 $template->param( elasticsearch_fatal_config_error => $_->message );
328 $es_config_error = 1;
331 if ( !$es_config_error ) {
333 my $biblios_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::BIBLIOS_INDEX;
334 my $authorities_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::AUTHORITIES_INDEX;
336 my @indexes = ($biblios_index_name, $authorities_index_name);
337 # TODO: When new indexes get added, we could have other ways to
338 # fetch the list of available indexes (e.g. plugins, etc)
339 $es_status->{nodes} = $es_conf->{nodes};
340 my $es = Search::Elasticsearch->new({ nodes => $es_conf->{nodes} });
342 foreach my $index ( @indexes ) {
343 my $count;
344 try {
345 $count = $es->indices->stats( index => $index )
346 ->{_all}{primaries}{docs}{count};
348 catch {
349 if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) {
350 push @{ $es_status->{errors} }, "Index not found ($index)";
351 $count = -1;
353 elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
354 $es_running = 0;
356 else {
357 # TODO: when time comes, we will cover more use cases
358 die $_;
362 push @{ $es_status->{indexes} },
364 index_name => $index,
365 count => $count
368 $es_status->{running} = $es_running;
370 $template->param( elasticsearch_status => $es_status );
374 if ( C4::Context->preference('RESTOAuth2ClientCredentials') ) {
375 # Do we have the required deps?
376 unless ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef }) ) {
377 $template->param( oauth2_missing_deps => 1 );
381 # Sco Patron should not contain any other perms than circulate => self_checkout
382 if ( C4::Context->preference('WebBasedSelfCheck')
383 and C4::Context->preference('AutoSelfCheckAllowed')
385 my $userid = C4::Context->preference('AutoSelfCheckID');
386 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
387 my ( $has_self_checkout_perm, $has_other_permissions );
388 while ( my ( $module, $permissions ) = each %$all_permissions ) {
389 if ( $module eq 'self_check' ) {
390 while ( my ( $permission, $flag ) = each %$permissions ) {
391 if ( $permission eq 'self_checkout_module' ) {
392 $has_self_checkout_perm = 1;
393 } else {
394 $has_other_permissions = 1;
397 } else {
398 $has_other_permissions = 1;
401 $template->param(
402 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
403 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
407 # Test YAML system preferences
408 # FIXME: This is list of current YAML formatted prefs, should by type of preference
409 my @yaml_prefs = (
410 "UpdateNotForLoanStatusOnCheckin",
411 "OpacHiddenItems",
412 "BibtexExportAdditionalFields",
413 "RisExportAdditionalFields",
414 "UpdateItemWhenLostFromHoldList",
415 "MarcFieldsToOrder",
416 "MarcItemFieldsToOrder",
417 "UpdateitemLocationOnCheckin",
418 "ItemsDeniedRenewal"
420 my @bad_yaml_prefs;
421 foreach my $syspref (@yaml_prefs) {
422 my $yaml = C4::Context->preference( $syspref );
423 if ( $yaml ) {
424 eval { YAML::Load( "$yaml\n\n" ); };
425 if ($@) {
426 push @bad_yaml_prefs, $syspref;
430 $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
433 my $dbh = C4::Context->dbh;
434 my $patrons = $dbh->selectall_arrayref(
435 q|select b.borrowernumber from borrowers b join deletedborrowers db on b.borrowernumber=db.borrowernumber|,
436 { Slice => {} }
438 my $biblios = $dbh->selectall_arrayref(
439 q|select b.biblionumber from biblio b join deletedbiblio db on b.biblionumber=db.biblionumber|,
440 { Slice => {} }
442 my $items = $dbh->selectall_arrayref(
443 q|select i.itemnumber from items i join deleteditems di on i.itemnumber=di.itemnumber|,
444 { Slice => {} }
446 my $checkouts = $dbh->selectall_arrayref(
447 q|select i.issue_id from issues i join old_issues oi on i.issue_id=oi.issue_id|,
448 { Slice => {} }
450 my $holds = $dbh->selectall_arrayref(
451 q|select r.reserve_id from reserves r join old_reserves o on r.reserve_id=o.reserve_id|,
452 { Slice => {} }
454 if ( @$patrons or @$biblios or @$items or @$checkouts or @$holds ) {
455 $template->param(
456 has_ai_issues => 1,
457 ai_patrons => $patrons,
458 ai_biblios => $biblios,
459 ai_items => $items,
460 ai_checkouts => $checkouts,
461 ai_holds => $holds,
466 # Circ rule warnings
468 my $dbh = C4::Context->dbh;
469 my $units = Koha::CirculationRules->search({ rule_name => 'lengthunit', rule_value => { -not_in => ['days', 'hours'] } });
471 if ( $units->count ) {
472 $template->param(
473 warnIssuingRules => 1,
474 ir_units => $units,
479 # Guarantor relationships warnings
481 my $dbh = C4::Context->dbh;
482 my ($bad_relationships_count) = $dbh->selectall_arrayref(q{
483 SELECT COUNT(*)
484 FROM (
485 SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data'
486 UNION ALL
487 SELECT relationship FROM borrowers WHERE relationship='_bad_data') a
490 $bad_relationships_count = $bad_relationships_count->[0]->[0];
492 my $existing_relationships = $dbh->selectall_arrayref(q{
493 SELECT DISTINCT(relationship)
494 FROM (
495 SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL
496 UNION ALL
497 SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
500 my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') );
501 $valid_relationships{ _bad_data } = 1; # we handle this case in another way
503 my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
504 if ( @$wrong_relationships or $bad_relationships_count ) {
506 $template->param(
507 warnRelationships => 1,
510 if ( $wrong_relationships ) {
511 $template->param(
512 wrong_relationships => $wrong_relationships
515 if ($bad_relationships_count) {
516 $template->param(
517 bad_relationships_count => $bad_relationships_count,
524 # Test 'bcrypt_settings' config for Pseudonymization
525 $template->param( config_bcrypt_settings_no_set => 1 )
526 if C4::Context->preference('Pseudonymization')
527 and not C4::Context->config('bcrypt_settings');
531 my @frameworkcodes = Koha::BiblioFrameworks->search->get_column('frameworkcode');
532 my @hidden_biblionumbers;
533 push @frameworkcodes, ""; # it's not in the biblio_frameworks table!
534 for my $frameworkcode ( @frameworkcodes ) {
535 my $shouldhidemarc_opac = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
537 frameworkcode => $frameworkcode,
538 interface => "opac"
541 push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'opac' }
542 if $shouldhidemarc_opac->{biblionumber};
544 my $shouldhidemarc_intranet = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
546 frameworkcode => $frameworkcode,
547 interface => "intranet"
550 push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'intranet' }
551 if $shouldhidemarc_intranet->{biblionumber};
553 $template->param( warnHiddenBiblionumbers => \@hidden_biblionumbers );
556 my %versions = C4::Context::get_versions();
558 $template->param(
559 kohaVersion => $versions{'kohaVersion'},
560 osVersion => $versions{'osVersion'},
561 perlPath => $perl_path,
562 perlVersion => $versions{'perlVersion'},
563 perlIncPath => [ map { perlinc => $_ }, @INC ],
564 mysqlVersion => $versions{'mysqlVersion'},
565 apacheVersion => $versions{'apacheVersion'},
566 zebraVersion => $zebraVersion,
567 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
568 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
569 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
570 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
571 warnPrefAnonymousPatronOPACPrivacy => $warnPrefAnonymousPatronOPACPrivacy,
572 warnPrefAnonymousPatronAnonSuggestions => $warnPrefAnonymousPatronAnonSuggestions,
573 warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist => $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist,
574 warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist => $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist,
575 errZebraConnection => $errZebraConnection,
576 warnIsRootUser => $warnIsRootUser,
577 warnNoActiveCurrency => $warnNoActiveCurrency,
578 warnNoTemplateCaching => ( C4::Context->config('template_cache_dir') ? 0 : 1 ),
579 xml_config_warnings => \@xml_config_warnings,
580 warnStatisticsFieldsError => $warnStatisticsFieldsError,
583 my @components = ();
585 my $perl_modules = C4::Installer::PerlModules->new;
586 $perl_modules->versions_info;
588 my @pm_types = qw(missing_pm upgrade_pm current_pm);
590 foreach my $pm_type(@pm_types) {
591 my $modules = $perl_modules->get_attr($pm_type);
592 foreach (@$modules) {
593 my ($module, $stats) = each %$_;
594 push(
595 @components,
597 name => $module,
598 version => $stats->{'cur_ver'},
599 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
600 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
601 current => ($pm_type eq 'current_pm' ? 1 : 0),
602 require => $stats->{'required'},
603 reqversion => $stats->{'min_ver'},
604 maxversion => $stats->{'max_ver'},
605 excversion => $stats->{'exc_ver'}
611 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
613 my $counter=0;
614 my $row = [];
615 my $table = [];
616 foreach (@components) {
617 push (@$row, $_);
618 unless (++$counter % 4) {
619 push (@$table, {row => $row});
620 $row = [];
623 # Processing the last line (if there are any modules left)
624 if (scalar(@$row) > 0) {
625 # Extending $row to the table size
626 $$row[3] = '';
627 # Pushing the last line
628 push (@$table, {row => $row});
630 ## ## $table
632 $template->param( table => $table );
635 ## ------------------------------------------
636 ## Koha contributions
637 my $docdir;
638 if ( defined C4::Context->config('docdir') ) {
639 $docdir = C4::Context->config('docdir');
640 } else {
641 # if no <docdir> is defined in koha-conf.xml, use the default location
642 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
643 $docdir = C4::Context->config('intranetdir') . '/docs';
646 ## Release teams
647 my $teams =
648 -e "$docdir" . "/teams.yaml"
649 ? LoadFile( "$docdir" . "/teams.yaml" )
650 : {};
651 my $dev_team = (sort {$b <=> $a} (keys %{$teams->{team}}))[0];
652 my $short_version = substr($versions{'kohaVersion'},0,5);
653 my $minor = substr($versions{'kohaVersion'},3,2);
654 my $development_version = ( $minor eq '05' || $minor eq '11' ) ? 0 : 1;
655 $template->param( short_version => $short_version );
656 $template->param( development_version => $development_version );
658 ## Contributors
659 my $contributors =
660 -e "$docdir" . "/contributors.yaml"
661 ? LoadFile( "$docdir" . "/contributors.yaml" )
662 : {};
663 for my $version ( sort { $a <=> $b } keys %{$teams->{team}} ) {
664 for my $role ( keys %{ $teams->{team}->{$version} } ) {
665 my $normalized_role = "$role";
666 $normalized_role =~ s/s$//;
667 if ( ref( $teams->{team}->{$version}->{$role} ) eq 'ARRAY' ) {
668 for my $contributor ( @{ $teams->{team}->{$version}->{$role} } ) {
669 my $name = $contributor->{name};
670 # Add role to contributors
671 push @{ $contributors->{$name}->{roles}->{$normalized_role} },
672 $version;
673 # Add openhub to teams
674 if ( exists( $contributors->{$name}->{openhub} ) ) {
675 $contributor->{openhub} = $contributors->{$name}->{openhub};
679 elsif ( $role ne 'release_date' ) {
680 my $name = $teams->{team}->{$version}->{$role}->{name};
681 # Add role to contributors
682 push @{ $contributors->{$name}->{roles}->{$normalized_role} },
683 $version;
684 # Add openhub to teams
685 if ( exists( $contributors->{$name}->{openhub} ) ) {
686 $teams->{team}->{$version}->{$role}->{openhub} =
687 $contributors->{$name}->{openhub};
690 else {
691 $teams->{team}->{$version}->{$role} = DateTime->from_epoch( epoch => $teams->{team}->{$version}->{$role});
696 ## Create last name ordered array of people from contributors
697 my @people = map {
698 { name => $_, ( $contributors->{$_} ? %{ $contributors->{$_} } : () ) }
699 } sort {
700 my ($alast) = ( split( /\s/, $a ) )[-1];
701 my ($blast) = ( split( /\s/, $b ) )[-1];
702 lc($alast) cmp lc($blast)
703 } keys %{$contributors};
705 $template->param( contributors => \@people );
706 $template->param( maintenance_team => $teams->{team}->{$dev_team} );
707 $template->param( release_team => $teams->{team}->{$short_version} );
709 ## Timeline
710 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
712 my $i = 0;
714 my @rows2 = ();
715 my $row2 = [];
717 my @lines = <$file>;
718 close($file);
720 shift @lines; #remove header row
722 foreach (@lines) {
723 my ( $epoch, $date, $desc, $tag ) = split(/\t/);
724 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
725 ($date, $desc)= ($`, $');
727 push(
728 @rows2,
730 date => $date,
731 desc => $desc,
736 my $table2 = [];
737 #foreach my $row2 (@rows2) {
738 foreach (@rows2) {
739 push (@$row2, $_);
740 push( @$table2, { row2 => $row2 } );
741 $row2 = [];
744 $template->param( table2 => $table2 );
745 } else {
746 $template->param( timeline_read_error => 1 );
749 output_html_with_http_headers $query, $cookie, $template->output;