Bug 25109: Add entry in about.pl about the configuration lockdir entry
[koha-equinox.git] / about.pl
1 #!/usr/bin/perl
2
3 # Copyright Pat Eyler 2003
4 # Copyright Biblibre 2006
5 # Parts Copyright Liblime 2008
6 # Parts Copyright Chris Nighswonger 2010
7 #
8 # This file is part of Koha.
9 #
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.
14 #
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.
19 #
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>.
22
23 use Modern::Perl;
24
25 use CGI qw ( -utf8 );
26 use DateTime::TimeZone;
27 use File::Spec;
28 use List::MoreUtils qw/ any /;
29 use LWP::Simple;
30 use Module::Load::Conditional qw(can_load);
31 use XML::Simple;
32 use Config;
33 use Search::Elasticsearch;
34 use Try::Tiny;
35 use YAML qw/LoadFile/;
36
37 use C4::Output;
38 use C4::Auth;
39 use C4::Context;
40 use C4::Installer::PerlModules;
41
42 use Koha;
43 use Koha::DateUtils qw(dt_from_string output_pref);
44 use Koha::Acquisition::Currencies;
45 use Koha::Patron::Categories;
46 use Koha::Patrons;
47 use Koha::Caches;
48 use Koha::Config::SysPrefs;
49 use Koha::Illrequest::Config;
50 use Koha::SearchEngine::Elasticsearch;
51
52 use C4::Members::Statistics;
53
54
55 #use Smart::Comments '####';
56
57 my $query = new CGI;
58 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
59     {
60         template_name   => "about.tt",
61         query           => $query,
62         type            => "intranet",
63         authnotrequired => 0,
64         flagsrequired   => { catalogue => 1 },
65         debug           => 1,
66     }
67 );
68
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;
74
75 if ( $config_timezone ne '' &&
76      $config_invalid ) {
77     # Bad config
78     $actual_bad_tz_fallback = 1;
79 }
80 elsif ( $config_timezone eq '' &&
81         $env_timezone    ne '' &&
82         $env_invalid ) {
83     # No config, but bad ENV{TZ}
84     $actual_bad_tz_fallback = 1;
85 }
86
87 my $time_zone = {
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
94 };
95
96 $template->param(
97     time_zone              => $time_zone,
98     current_date_and_time  => output_pref({ dt => dt_from_string(), dateformat => 'iso' })
99 );
100
101 my $perl_path = $^X;
102 if ($^O ne 'VMS') {
103     $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
104 }
105
106 my $zebraVersion = `zebraidx -V`;
107
108 # Check running PSGI env
109 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
110     $template->param(
111         is_psgi => 1,
112         psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
113                        ($ENV{ MOD_PERL })  ? "mod_perl ($ENV{MOD_PERL})" :
114                                              'Unknown'
115     );
116 }
117
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';
121
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");
127
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';
135 }
136
137 $template->param(
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,
144 );
145
146 # Additional system information for warnings
147
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() );
153 }
154
155 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
156 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
157 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
158
159 my $prefEasyAnalyticalRecords  = C4::Context->preference('EasyAnalyticalRecords');
160 my $prefUseControlNumber  = C4::Context->preference('UseControlNumber');
161 my $warnPrefEasyAnalyticalRecords  = ( $prefEasyAnalyticalRecords  && $prefUseControlNumber );
162
163 my $AnonymousPatron = C4::Context->preference('AnonymousPatron');
164 my $warnPrefAnonymousPatronOPACPrivacy = (
165     C4::Context->preference('OPACPrivacy')
166         and not $AnonymousPatron
167 );
168 my $warnPrefAnonymousPatronAnonSuggestions = (
169     C4::Context->preference('AnonSuggestions')
170         and not $AnonymousPatron
171 );
172
173 my $anonymous_patron = Koha::Patrons->find( $AnonymousPatron );
174 my $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist = ( $AnonymousPatron && C4::Context->preference('AnonSuggestions') && not $anonymous_patron );
175
176 my $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
177
178 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
179
180 my $warnIsRootUser   = (! $loggedinuser);
181
182 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
183
184 my @xml_config_warnings;
185
186 my $context = new C4::Context;
187
188 if (    C4::Context->config('zebra_bib_index_mode')
189     and C4::Context->config('zebra_bib_index_mode') eq 'grs1' )
190 {
191     push @xml_config_warnings, { error => 'zebra_bib_index_mode_is_grs1' };
192 }
193
194 if (    C4::Context->config('zebra_auth_index_mode')
195     and C4::Context->config('zebra_auth_index_mode') eq 'grs1' )
196 {
197     push @xml_config_warnings, { error => 'zebra_auth_index_mode_is_grs1' };
198 }
199
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'
203     };
204 }
205
206 if ( ! defined C4::Context->config('log4perl_conf') ) {
207     push @xml_config_warnings, {
208         error => 'log4perl_entry_missing'
209     }
210 }
211
212 if ( ! defined C4::Context->config('lockdir') ) {
213     push @xml_config_warnings, {
214         error => 'lockdir_entry_missing'
215     }
216 }
217
218 if ( ! defined C4::Context->config('upload_path') ) {
219     if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
220         # OPACBaseURL seems to be set
221         push @xml_config_warnings, {
222             error => 'uploadpath_entry_missing'
223         }
224     } else {
225         push @xml_config_warnings, {
226             error => 'uploadpath_and_opacbaseurl_entry_missing'
227         }
228     }
229 }
230
231 if ( ! C4::Context->config('tmp_path') ) {
232     my $temporary_directory = C4::Context::temporary_directory;
233     push @xml_config_warnings, {
234         error             => 'tmp_path_missing',
235         effective_tmp_dir => $temporary_directory,
236     }
237 }
238
239 # Test Zebra facets configuration
240 if ( !defined C4::Context->config('use_zebra_facets') ) {
241     push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
242 }
243
244 # ILL module checks
245 if ( C4::Context->preference('ILLModule') ) {
246     my $warnILLConfiguration = 0;
247     my $ill_config_from_file = C4::Context->config("interlibrary_loans");
248     my $ill_config = Koha::Illrequest::Config->new;
249
250     my $available_ill_backends =
251       ( scalar @{ $ill_config->available_backends } > 0 );
252
253     # Check backends
254     if ( !$available_ill_backends ) {
255         $template->param( no_ill_backends => 1 );
256         $warnILLConfiguration = 1;
257     }
258
259     # Check partner_code
260     if ( !Koha::Patron::Categories->find($ill_config->partner_code) ) {
261         $template->param( ill_partner_code_doesnt_exist => $ill_config->partner_code );
262         $warnILLConfiguration = 1;
263     }
264
265     if ( !$ill_config_from_file->{partner_code} ) {
266         # partner code not defined
267         $template->param( ill_partner_code_not_defined => 1 );
268         $warnILLConfiguration = 1;
269     }
270
271
272     if ( !$ill_config_from_file->{branch} ) {
273         # branch not defined
274         $template->param( ill_branch_not_defined => 1 );
275         $warnILLConfiguration = 1;
276     }
277
278     $template->param( warnILLConfiguration => $warnILLConfiguration );
279 }
280
281 if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) {
282     # Check ES configuration health and runtime status
283
284     my $es_status;
285     my $es_config_error;
286     my $es_running = 1;
287
288     my $es_conf;
289     try {
290         $es_conf = Koha::SearchEngine::Elasticsearch::_read_configuration();
291     }
292     catch {
293         if ( ref($_) eq 'Koha::Exceptions::Config::MissingEntry' ) {
294             $template->param( elasticsearch_fatal_config_error => $_->message );
295             $es_config_error = 1;
296         }
297     };
298     if ( !$es_config_error ) {
299
300         my $biblios_index_name     = $es_conf->{index_name} . "_" . $Koha::SearchEngine::BIBLIOS_INDEX;
301         my $authorities_index_name = $es_conf->{index_name} . "_" . $Koha::SearchEngine::AUTHORITIES_INDEX;
302
303         my @indexes = ($biblios_index_name, $authorities_index_name);
304         # TODO: When new indexes get added, we could have other ways to
305         #       fetch the list of available indexes (e.g. plugins, etc)
306         $es_status->{nodes} = $es_conf->{nodes};
307         my $es = Search::Elasticsearch->new({ nodes => $es_conf->{nodes} });
308
309         foreach my $index ( @indexes ) {
310             my $count;
311             try {
312                 $count = $es->indices->stats( index => $index )
313                       ->{_all}{primaries}{docs}{count};
314             }
315             catch {
316                 if ( ref($_) eq 'Search::Elasticsearch::Error::Missing' ) {
317                     push @{ $es_status->{errors} }, "Index not found ($index)";
318                     $count = -1;
319                 }
320                 elsif ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
321                     $es_running = 0;
322                 }
323                 else {
324                     # TODO: when time comes, we will cover more use cases
325                     die $_;
326                 }
327             };
328
329             push @{ $es_status->{indexes} },
330               {
331                 index_name => $index,
332                 count      => $count
333               };
334         }
335         $es_status->{running} = $es_running;
336
337         $template->param( elasticsearch_status => $es_status );
338     }
339 }
340
341 if ( C4::Context->preference('RESTOAuth2ClientCredentials') ) {
342     # Do we have the required deps?
343     unless ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef }) ) {
344         $template->param( oauth2_missing_deps => 1 );
345     }
346 }
347
348 # Sco Patron should not contain any other perms than circulate => self_checkout
349 if (  C4::Context->preference('WebBasedSelfCheck')
350       and C4::Context->preference('AutoSelfCheckAllowed')
351 ) {
352     my $userid = C4::Context->preference('AutoSelfCheckID');
353     my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
354     my ( $has_self_checkout_perm, $has_other_permissions );
355     while ( my ( $module, $permissions ) = each %$all_permissions ) {
356         if ( $module eq 'self_check' ) {
357             while ( my ( $permission, $flag ) = each %$permissions ) {
358                 if ( $permission eq 'self_checkout_module' ) {
359                     $has_self_checkout_perm = 1;
360                 } else {
361                     $has_other_permissions = 1;
362                 }
363             }
364         } else {
365             $has_other_permissions = 1;
366         }
367     }
368     $template->param(
369         AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
370         AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
371     );
372 }
373
374 # Test YAML system preferences
375 # FIXME: This is list of current YAML formatted prefs, should by type of preference
376 my @yaml_prefs = (
377     "UpdateNotForLoanStatusOnCheckin",
378     "OpacHiddenItems",
379     "BibtexExportAdditionalFields",
380     "RisExportAdditionalFields",
381     "UpdateItemWhenLostFromHoldList",
382     "MarcFieldsToOrder",
383     "MarcItemFieldsToOrder",
384     "UpdateitemLocationOnCheckin",
385     "ItemsDeniedRenewal"
386 );
387 my @bad_yaml_prefs;
388 foreach my $syspref (@yaml_prefs) {
389     my $yaml = C4::Context->preference( $syspref );
390     if ( $yaml ) {
391         eval { YAML::Load( "$yaml\n\n" ); };
392         if ($@) {
393             push @bad_yaml_prefs, $syspref;
394         }
395     }
396 }
397 $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
398
399 {
400     my $dbh       = C4::Context->dbh;
401     my $patrons = $dbh->selectall_arrayref(
402         q|select b.borrowernumber from borrowers b join deletedborrowers db on b.borrowernumber=db.borrowernumber|,
403         { Slice => {} }
404     );
405     my $biblios = $dbh->selectall_arrayref(
406         q|select b.biblionumber from biblio b join deletedbiblio db on b.biblionumber=db.biblionumber|,
407         { Slice => {} }
408     );
409     my $items = $dbh->selectall_arrayref(
410         q|select i.itemnumber from items i join deleteditems di on i.itemnumber=di.itemnumber|,
411         { Slice => {} }
412     );
413     my $checkouts = $dbh->selectall_arrayref(
414         q|select i.issue_id from issues i join old_issues oi on i.issue_id=oi.issue_id|,
415         { Slice => {} }
416     );
417     my $holds = $dbh->selectall_arrayref(
418         q|select r.reserve_id from reserves r join old_reserves o on r.reserve_id=o.reserve_id|,
419         { Slice => {} }
420     );
421     if ( @$patrons or @$biblios or @$items or @$checkouts or @$holds ) {
422         $template->param(
423             has_ai_issues => 1,
424             ai_patrons    => $patrons,
425             ai_biblios    => $biblios,
426             ai_items      => $items,
427             ai_checkouts  => $checkouts,
428             ai_holds      => $holds,
429         );
430     }
431 }
432
433 # Circ rule warnings
434 {
435     my $dbh   = C4::Context->dbh;
436     my $units = Koha::CirculationRules->search({ rule_name => 'lengthunit', rule_value => { -not_in => ['days', 'hours'] } });
437
438     if ( $units->count ) {
439         $template->param(
440             warnIssuingRules => 1,
441             ir_units         => $units,
442         );
443     }
444 }
445
446 # Guarantor relationships warnings
447 {
448     my $dbh   = C4::Context->dbh;
449     my ($bad_relationships_count) = $dbh->selectall_arrayref(q{
450         SELECT COUNT(*)
451         FROM (
452             SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data'
453             UNION ALL
454             SELECT relationship FROM borrowers WHERE relationship='_bad_data') a
455     });
456
457     $bad_relationships_count = $bad_relationships_count->[0]->[0];
458
459     my $existing_relationships = $dbh->selectall_arrayref(q{
460           SELECT DISTINCT(relationship)
461           FROM (
462               SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL
463               UNION ALL
464               SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
465     });
466
467     my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') );
468     $valid_relationships{ _bad_data } = 1; # we handle this case in another way
469
470     my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
471     if ( @$wrong_relationships or $bad_relationships_count ) {
472
473         $template->param(
474             warnRelationships => 1,
475         );
476
477         if ( $wrong_relationships ) {
478             $template->param(
479                 wrong_relationships => $wrong_relationships
480             );
481         }
482         if ($bad_relationships_count) {
483             $template->param(
484                 bad_relationships_count => $bad_relationships_count,
485             );
486         }
487     }
488 }
489
490 my %versions = C4::Context::get_versions();
491
492 $template->param(
493     kohaVersion   => $versions{'kohaVersion'},
494     osVersion     => $versions{'osVersion'},
495     perlPath      => $perl_path,
496     perlVersion   => $versions{'perlVersion'},
497     perlIncPath   => [ map { perlinc => $_ }, @INC ],
498     mysqlVersion  => $versions{'mysqlVersion'},
499     apacheVersion => $versions{'apacheVersion'},
500     zebraVersion  => $zebraVersion,
501     prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
502     prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
503     warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
504     warnPrefEasyAnalyticalRecords  => $warnPrefEasyAnalyticalRecords,
505     warnPrefAnonymousPatronOPACPrivacy        => $warnPrefAnonymousPatronOPACPrivacy,
506     warnPrefAnonymousPatronAnonSuggestions    => $warnPrefAnonymousPatronAnonSuggestions,
507     warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist     => $warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist,
508     warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist => $warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist,
509     errZebraConnection => $errZebraConnection,
510     warnIsRootUser => $warnIsRootUser,
511     warnNoActiveCurrency => $warnNoActiveCurrency,
512     warnNoTemplateCaching => ( C4::Context->config('template_cache_dir') ? 0 : 1 ),
513     xml_config_warnings => \@xml_config_warnings,
514     warnStatisticsFieldsError => $warnStatisticsFieldsError,
515 );
516
517 my @components = ();
518
519 my $perl_modules = C4::Installer::PerlModules->new;
520 $perl_modules->versions_info;
521
522 my @pm_types = qw(missing_pm upgrade_pm current_pm);
523
524 foreach my $pm_type(@pm_types) {
525     my $modules = $perl_modules->get_attr($pm_type);
526     foreach (@$modules) {
527         my ($module, $stats) = each %$_;
528         push(
529             @components,
530             {
531                 name    => $module,
532                 version => $stats->{'cur_ver'},
533                 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
534                 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
535                 current => ($pm_type eq 'current_pm' ? 1 : 0),
536                 require => $stats->{'required'},
537                 reqversion => $stats->{'min_ver'},
538                 maxversion => $stats->{'max_ver'}
539             }
540         );
541     }
542 }
543
544 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
545
546 my $counter=0;
547 my $row = [];
548 my $table = [];
549 foreach (@components) {
550     push (@$row, $_);
551     unless (++$counter % 4) {
552         push (@$table, {row => $row});
553         $row = [];
554     }
555 }
556 # Processing the last line (if there are any modules left)
557 if (scalar(@$row) > 0) {
558     # Extending $row to the table size
559     $$row[3] = '';
560     # Pushing the last line
561     push (@$table, {row => $row});
562 }
563 ## ## $table
564
565 $template->param( table => $table );
566
567
568 ## ------------------------------------------
569 ## Koha contributions
570 my $docdir;
571 if ( defined C4::Context->config('docdir') ) {
572     $docdir = C4::Context->config('docdir');
573 } else {
574     # if no <docdir> is defined in koha-conf.xml, use the default location
575     # this is a work-around to stop breakage on upgraded Kohas, bug 8911
576     $docdir = C4::Context->config('intranetdir') . '/docs';
577 }
578
579 ## Release teams
580 my $teams =
581   -e "$docdir" . "/teams.yaml"
582   ? LoadFile( "$docdir" . "/teams.yaml" )
583   : {};
584 my $dev_team = (sort {$b <=> $a} (keys %{$teams->{team}}))[0];
585 my $short_version = substr($versions{'kohaVersion'},0,5);
586 my $minor = substr($versions{'kohaVersion'},3,2);
587 my $development_version = ( $minor eq '05' || $minor eq '11' ) ? 0 : 1;
588 $template->param( short_version => $short_version );
589 $template->param( development_version => $development_version );
590
591 ## Contributors
592 my $contributors =
593   -e "$docdir" . "/contributors.yaml"
594   ? LoadFile( "$docdir" . "/contributors.yaml" )
595   : {};
596 for my $version ( sort { $a <=> $b } keys %{$teams->{team}} ) {
597     for my $role ( keys %{ $teams->{team}->{$version} } ) {
598         my $normalized_role = "$role";
599         $normalized_role =~ s/s$//;
600         if ( ref( $teams->{team}->{$version}->{$role} ) eq 'ARRAY' ) {
601             for my $contributor ( @{ $teams->{team}->{$version}->{$role} } ) {
602                 my $name = $contributor->{name};
603                 # Add role to contributors
604                 push @{ $contributors->{$name}->{roles}->{$normalized_role} },
605                   $version;
606                 # Add openhub to teams
607                 if ( exists( $contributors->{$name}->{openhub} ) ) {
608                     $contributor->{openhub} = $contributors->{$name}->{openhub};
609                 }
610             }
611         }
612         elsif ( $role ne 'release_date' ) {
613             my $name = $teams->{team}->{$version}->{$role}->{name};
614             # Add role to contributors
615             push @{ $contributors->{$name}->{roles}->{$normalized_role} },
616               $version;
617             # Add openhub to teams
618             if ( exists( $contributors->{$name}->{openhub} ) ) {
619                 $teams->{team}->{$version}->{$role}->{openhub} =
620                   $contributors->{$name}->{openhub};
621             }
622         }
623         else {
624             $teams->{team}->{$version}->{$role} = DateTime->from_epoch( epoch => $teams->{team}->{$version}->{$role});
625         }
626     }
627 }
628
629 ## Create last name ordered array of people from contributors
630 my @people = map {
631     { name => $_, ( $contributors->{$_} ? %{ $contributors->{$_} } : () ) }
632 } sort {
633     my ($alast) = ( split( /\s/, $a ) )[-1];
634     my ($blast) = ( split( /\s/, $b ) )[-1];
635     lc($alast) cmp lc($blast)
636 } keys %{$contributors};
637
638 $template->param( contributors => \@people );
639 $template->param( maintenance_team => $teams->{team}->{$dev_team} );
640 $template->param( release_team => $teams->{team}->{$short_version} );
641
642 ## Timeline
643 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
644
645     my $i = 0;
646
647     my @rows2 = ();
648     my $row2  = [];
649
650     my @lines = <$file>;
651     close($file);
652
653     shift @lines; #remove header row
654
655     foreach (@lines) {
656         my ( $epoch, $date, $desc, $tag ) = split(/\t/);
657         if(!$desc && $date=~ /(?<=\d{4})\s+/) {
658             ($date, $desc)= ($`, $');
659         }
660         push(
661             @rows2,
662             {
663                 date => $date,
664                 desc => $desc,
665             }
666         );
667     }
668
669     my $table2 = [];
670     #foreach my $row2 (@rows2) {
671     foreach  (@rows2) {
672         push (@$row2, $_);
673         push( @$table2, { row2 => $row2 } );
674         $row2 = [];
675     }
676
677     $template->param( table2 => $table2 );
678 } else {
679     $template->param( timeline_read_error => 1 );
680 }
681
682 output_html_with_http_headers $query, $cookie, $template->output;