Merge remote-tracking branch 'origin/new/bug_7143'
[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 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.
14 #
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.
18 #
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.
22
23 use strict;
24 use warnings;
25
26 use CGI;
27 use LWP::Simple;
28 use XML::Simple;
29 use Config;
30
31 use C4::Output;
32 use C4::Auth;
33 use C4::Context;
34 use C4::Installer;
35
36 #use Smart::Comments '####';
37
38 my $query = new CGI;
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40     {
41         template_name   => "about.tmpl",
42         query           => $query,
43         type            => "intranet",
44         authnotrequired => 0,
45         flagsrequired   => { catalogue => 1 },
46         debug           => 1,
47     }
48 );
49
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;
55 }
56 my $perlVersion   = $];
57 my $mysqlVersion  = `mysql -V`;
58 my $apacheVersion = `httpd -v`;
59 $apacheVersion = `httpd2 -v` unless $apacheVersion;
60 $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
61 my $zebraVersion = `zebraidx -V`;
62
63 $template->param(
64     kohaVersion   => $kohaVersion,
65     osVersion     => $osVersion,
66     perlPath      => $perl_path,
67     perlVersion   => $perlVersion,
68     perlIncPath   => [ map { perlinc => $_ }, @INC ],
69     mysqlVersion  => $mysqlVersion,
70     apacheVersion => $apacheVersion,
71     zebraVersion  => $zebraVersion,
72 );
73
74 my @components = ();
75
76 my $perl_modules = C4::Installer::PerlModules->new;
77 $perl_modules->version_info;
78
79 my @pm_types = qw(missing_pm upgrade_pm current_pm);
80
81 foreach my $pm_type(@pm_types) {
82     my $modules = $perl_modules->get_attr($pm_type);
83     foreach (@$modules) {
84         my ($module, $stats) = each %$_;
85         push(
86             @components,
87             {
88                 name    => $module,
89                 version => $stats->{'cur_ver'},
90                 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
91                 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
92                 current => ($pm_type eq 'current_pm' ? 1 : 0),
93                 require => $stats->{'required'},
94             }
95         );
96     }
97 }
98
99 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
100
101 my $counter=0;
102 my $row = [];
103 my $table = [];
104 foreach (@components) {
105     push (@$row, $_);
106     unless (++$counter % 4) {
107         push (@$table, {row => $row});
108         $row = [];
109     }
110 }
111 # Processing the last line (if there are any modules left)
112 if (scalar(@$row) > 0) {
113     # Extending $row to the table size
114     $$row[3] = '';
115     # Pushing the last line
116     push (@$table, {row => $row});
117 }
118 ## ## $table
119
120 $template->param( table => $table );
121
122
123 ## ------------------------------------------
124 ## Koha time line code
125
126 #get file location
127 my $dir = C4::Context->config('intranetdir');
128 open( my $file, "<", "$dir" . "/docs/history.txt" );
129 my $i = 0;
130
131 my @rows2 = ();
132 my $row2  = [];
133
134 my @lines = <$file>;
135 close($file);
136
137 shift @lines; #remove header row
138
139 foreach (@lines) {
140     my ( $date, $desc, $tag ) = split(/\t/);
141     if(!$desc && $date=~ /(?<=\d{4})\s+/) {
142         ($date, $desc)= ($`, $');
143     }
144     push(
145         @rows2,
146         {
147             date => $date,
148             desc => $desc,
149         }
150     );
151 }
152
153 my $table2 = [];
154 #foreach my $row2 (@rows2) {
155 foreach  (@rows2) {
156     push (@$row2, $_);
157     push( @$table2, { row2 => $row2 } );
158     $row2 = [];
159 }
160
161 $template->param( table2 => $table2 );
162
163 output_html_with_http_headers $query, $cookie, $template->output;