Bug 11934 - Replace given by if-else statements
[koha.git] / about.pl
blobba77ca6d44a665b196ea4156d0082bfded4e7766
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 under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use strict;
24 use warnings;
26 use CGI;
27 use LWP::Simple;
28 use XML::Simple;
29 use Config;
31 use C4::Output;
32 use C4::Auth;
33 use C4::Context;
34 use C4::Installer;
36 #use Smart::Comments '####';
38 my $query = new CGI;
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41 template_name => "about.tmpl",
42 query => $query,
43 type => "intranet",
44 authnotrequired => 0,
45 flagsrequired => { catalogue => 1 },
46 debug => 1,
50 my $kohaVersion = C4::Context::KOHAVERSION;
51 my $osVersion = `uname -a`;
52 my $perl_path = $^X;
53 if ($^O ne 'VMS') {
54 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
56 my $perlVersion = $];
57 my $mysqlVersion = `mysql -V`;
58 my $apacheVersion = `httpd -v 2> /dev/null`;
59 $apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
60 $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
61 my $zebraVersion = `zebraidx -V`;
63 # Additional system information for warnings
64 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
65 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
66 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
68 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
69 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
70 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
71 my $warnPrefAnonymousPatron = (
72 C4::Context->preference('OPACPrivacy')
73 and not C4::Context->preference('AnonymousPatron')
76 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
78 my $warnIsRootUser = (! $loggedinuser);
80 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
82 $template->param(
83 kohaVersion => $kohaVersion,
84 osVersion => $osVersion,
85 perlPath => $perl_path,
86 perlVersion => $perlVersion,
87 perlIncPath => [ map { perlinc => $_ }, @INC ],
88 mysqlVersion => $mysqlVersion,
89 apacheVersion => $apacheVersion,
90 zebraVersion => $zebraVersion,
91 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
92 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
93 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
94 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
95 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
96 errZebraConnection => $errZebraConnection,
97 warnIsRootUser => $warnIsRootUser,
98 warnNoActiveCurrency => $warnNoActiveCurrency,
101 my @components = ();
103 my $perl_modules = C4::Installer::PerlModules->new;
104 $perl_modules->version_info;
106 my @pm_types = qw(missing_pm upgrade_pm current_pm);
108 foreach my $pm_type(@pm_types) {
109 my $modules = $perl_modules->get_attr($pm_type);
110 foreach (@$modules) {
111 my ($module, $stats) = each %$_;
112 push(
113 @components,
115 name => $module,
116 version => $stats->{'cur_ver'},
117 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
118 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
119 current => ($pm_type eq 'current_pm' ? 1 : 0),
120 require => $stats->{'required'},
126 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
128 my $counter=0;
129 my $row = [];
130 my $table = [];
131 foreach (@components) {
132 push (@$row, $_);
133 unless (++$counter % 4) {
134 push (@$table, {row => $row});
135 $row = [];
138 # Processing the last line (if there are any modules left)
139 if (scalar(@$row) > 0) {
140 # Extending $row to the table size
141 $$row[3] = '';
142 # Pushing the last line
143 push (@$table, {row => $row});
145 ## ## $table
147 $template->param( table => $table );
150 ## ------------------------------------------
151 ## Koha time line code
153 #get file location
154 my $docdir;
155 if ( defined C4::Context->config('docdir') ) {
156 $docdir = C4::Context->config('docdir');
157 } else {
158 # if no <docdir> is defined in koha-conf.xml, use the default location
159 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
160 $docdir = C4::Context->config('intranetdir') . '/docs';
163 if ( open( my $file, "<", "$docdir" . "/history.txt" ) ) {
165 my $i = 0;
167 my @rows2 = ();
168 my $row2 = [];
170 my @lines = <$file>;
171 close($file);
173 shift @lines; #remove header row
175 foreach (@lines) {
176 my ( $date, $desc, $tag ) = split(/\t/);
177 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
178 ($date, $desc)= ($`, $');
180 push(
181 @rows2,
183 date => $date,
184 desc => $desc,
189 my $table2 = [];
190 #foreach my $row2 (@rows2) {
191 foreach (@rows2) {
192 push (@$row2, $_);
193 push( @$table2, { row2 => $row2 } );
194 $row2 = [];
197 $template->param( table2 => $table2 );
198 } else {
199 $template->param( timeline_read_error => 1 );
202 output_html_with_http_headers $query, $cookie, $template->output;