Bug 10041 - Provide a koha-translate script to aid package users on installing transl...
[koha.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 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`;
62
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) );
67
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')
74 );
75
76 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
77
78 my $warnIsRootUser   = (! $loggedinuser);
79
80 $template->param(
81     kohaVersion   => $kohaVersion,
82     osVersion     => $osVersion,
83     perlPath      => $perl_path,
84     perlVersion   => $perlVersion,
85     perlIncPath   => [ map { perlinc => $_ }, @INC ],
86     mysqlVersion  => $mysqlVersion,
87     apacheVersion => $apacheVersion,
88     zebraVersion  => $zebraVersion,
89     prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
90     prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
91     warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
92     warnPrefEasyAnalyticalRecords  => $warnPrefEasyAnalyticalRecords,
93     warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
94     errZebraConnection => $errZebraConnection,
95     warnIsRootUser => $warnIsRootUser,
96 );
97
98 my @components = ();
99
100 my $perl_modules = C4::Installer::PerlModules->new;
101 $perl_modules->version_info;
102
103 my @pm_types = qw(missing_pm upgrade_pm current_pm);
104
105 foreach my $pm_type(@pm_types) {
106     my $modules = $perl_modules->get_attr($pm_type);
107     foreach (@$modules) {
108         my ($module, $stats) = each %$_;
109         push(
110             @components,
111             {
112                 name    => $module,
113                 version => $stats->{'cur_ver'},
114                 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
115                 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
116                 current => ($pm_type eq 'current_pm' ? 1 : 0),
117                 require => $stats->{'required'},
118             }
119         );
120     }
121 }
122
123 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
124
125 my $counter=0;
126 my $row = [];
127 my $table = [];
128 foreach (@components) {
129     push (@$row, $_);
130     unless (++$counter % 4) {
131         push (@$table, {row => $row});
132         $row = [];
133     }
134 }
135 # Processing the last line (if there are any modules left)
136 if (scalar(@$row) > 0) {
137     # Extending $row to the table size
138     $$row[3] = '';
139     # Pushing the last line
140     push (@$table, {row => $row});
141 }
142 ## ## $table
143
144 $template->param( table => $table );
145
146
147 ## ------------------------------------------
148 ## Koha time line code
149
150 #get file location
151 my $dir = C4::Context->config('intranetdir');
152 open( my $file, "<", "$dir" . "/docs/history.txt" );
153 my $i = 0;
154
155 my @rows2 = ();
156 my $row2  = [];
157
158 my @lines = <$file>;
159 close($file);
160
161 shift @lines; #remove header row
162
163 foreach (@lines) {
164     my ( $date, $desc, $tag ) = split(/\t/);
165     if(!$desc && $date=~ /(?<=\d{4})\s+/) {
166         ($date, $desc)= ($`, $');
167     }
168     push(
169         @rows2,
170         {
171             date => $date,
172             desc => $desc,
173         }
174     );
175 }
176
177 my $table2 = [];
178 #foreach my $row2 (@rows2) {
179 foreach  (@rows2) {
180     push (@$row2, $_);
181     push( @$table2, { row2 => $row2 } );
182     $row2 = [];
183 }
184
185 $template->param( table2 => $table2 );
186
187 output_html_with_http_headers $query, $cookie, $template->output;