Fix release notes typo
[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 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
81 my @xml_config_warnings;
82
83 my $context = new C4::Context;
84
85 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
86     push @xml_config_warnings, {
87         error => 'zebra_bib_index_mode_warn'
88     };
89     if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
90         push @xml_config_warnings, {
91             error => 'zebra_bib_mode_seems_grs1'
92         };
93     }
94     else {
95         push @xml_config_warnings, {
96             error => 'zebra_bib_mode_seems_dom'
97         };
98     }
99 } else {
100     push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
101         if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
102 }
103
104 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
105      ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
106
107     push @xml_config_warnings, {
108         error => 'zebra_bib_index_mode_mismatch_warn'
109     };
110 }
111
112 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
113      ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
114
115     push @xml_config_warnings, {
116         error => 'zebra_bib_index_mode_mismatch_warn'
117     };
118 }
119
120 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
121     push @xml_config_warnings, {
122         error => 'zebra_auth_index_mode_warn'
123     };
124 }
125
126 $template->param(
127     kohaVersion   => $kohaVersion,
128     osVersion     => $osVersion,
129     perlPath      => $perl_path,
130     perlVersion   => $perlVersion,
131     perlIncPath   => [ map { perlinc => $_ }, @INC ],
132     mysqlVersion  => $mysqlVersion,
133     apacheVersion => $apacheVersion,
134     zebraVersion  => $zebraVersion,
135     prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
136     prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
137     warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
138     warnPrefEasyAnalyticalRecords  => $warnPrefEasyAnalyticalRecords,
139     warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
140     errZebraConnection => $errZebraConnection,
141     warnIsRootUser => $warnIsRootUser,
142     warnNoActiveCurrency => $warnNoActiveCurrency,
143     xml_config_warnings => \@xml_config_warnings,
144 );
145
146 my @components = ();
147
148 my $perl_modules = C4::Installer::PerlModules->new;
149 $perl_modules->version_info;
150
151 my @pm_types = qw(missing_pm upgrade_pm current_pm);
152
153 foreach my $pm_type(@pm_types) {
154     my $modules = $perl_modules->get_attr($pm_type);
155     foreach (@$modules) {
156         my ($module, $stats) = each %$_;
157         push(
158             @components,
159             {
160                 name    => $module,
161                 version => $stats->{'cur_ver'},
162                 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
163                 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
164                 current => ($pm_type eq 'current_pm' ? 1 : 0),
165                 require => $stats->{'required'},
166             }
167         );
168     }
169 }
170
171 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
172
173 my $counter=0;
174 my $row = [];
175 my $table = [];
176 foreach (@components) {
177     push (@$row, $_);
178     unless (++$counter % 4) {
179         push (@$table, {row => $row});
180         $row = [];
181     }
182 }
183 # Processing the last line (if there are any modules left)
184 if (scalar(@$row) > 0) {
185     # Extending $row to the table size
186     $$row[3] = '';
187     # Pushing the last line
188     push (@$table, {row => $row});
189 }
190 ## ## $table
191
192 $template->param( table => $table );
193
194
195 ## ------------------------------------------
196 ## Koha time line code
197
198 #get file location
199 my $docdir;
200 if ( defined C4::Context->config('docdir') ) {
201     $docdir = C4::Context->config('docdir');
202 } else {
203     # if no <docdir> is defined in koha-conf.xml, use the default location
204     # this is a work-around to stop breakage on upgraded Kohas, bug 8911
205     $docdir = C4::Context->config('intranetdir') . '/docs';
206 }
207
208 if ( open( my $file, "<", "$docdir" . "/history.txt" ) ) {
209
210     my $i = 0;
211
212     my @rows2 = ();
213     my $row2  = [];
214
215     my @lines = <$file>;
216     close($file);
217
218     shift @lines; #remove header row
219
220     foreach (@lines) {
221         my ( $date, $desc, $tag ) = split(/\t/);
222         if(!$desc && $date=~ /(?<=\d{4})\s+/) {
223             ($date, $desc)= ($`, $');
224         }
225         push(
226             @rows2,
227             {
228                 date => $date,
229                 desc => $desc,
230             }
231         );
232     }
233
234     my $table2 = [];
235     #foreach my $row2 (@rows2) {
236     foreach  (@rows2) {
237         push (@$row2, $_);
238         push( @$table2, { row2 => $row2 } );
239         $row2 = [];
240     }
241
242     $template->param( table2 => $table2 );
243 } else {
244     $template->param( timeline_read_error => 1 );
245 }
246
247 output_html_with_http_headers $query, $cookie, $template->output;