Bug 14204: (QA followup) remove unneeded messages
[koha.git] / about.pl
blob34c98ef8833d3a4f62c42fd5880db82bf6093ec4
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
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.
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.
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>.
23 use strict;
24 use warnings;
26 use CGI qw ( -utf8 );
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 Koha;
38 #use Smart::Comments '####';
40 my $query = new CGI;
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "about.tt",
44 query => $query,
45 type => "intranet",
46 authnotrequired => 0,
47 flagsrequired => { catalogue => 1 },
48 debug => 1,
52 my $kohaVersion = Koha::version();
53 my $osVersion = `uname -a`;
54 my $perl_path = $^X;
55 if ($^O ne 'VMS') {
56 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
58 my $perlVersion = $];
59 my $mysqlVersion = `mysql -V`;
60 my $apacheVersion = `httpd -v 2> /dev/null`;
61 $apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
62 $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
63 my $zebraVersion = `zebraidx -V`;
65 # Additional system information for warnings
66 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
67 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
68 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
70 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
71 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
72 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
73 my $warnPrefAnonymousPatron = (
74 C4::Context->preference('OPACPrivacy')
75 and not C4::Context->preference('AnonymousPatron')
78 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
80 my $warnIsRootUser = (! $loggedinuser);
82 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
83 my @xml_config_warnings;
85 my $context = new C4::Context;
87 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
88 push @xml_config_warnings, {
89 error => 'zebra_bib_index_mode_warn'
91 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
92 push @xml_config_warnings, {
93 error => 'zebra_bib_mode_seems_grs1'
96 else {
97 push @xml_config_warnings, {
98 error => 'zebra_bib_mode_seems_dom'
101 } else {
102 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
103 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
106 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
107 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
109 push @xml_config_warnings, {
110 error => 'zebra_bib_index_mode_mismatch_warn'
114 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
115 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
117 push @xml_config_warnings, {
118 error => 'zebra_bib_index_mode_mismatch_warn'
122 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
123 push @xml_config_warnings, {
124 error => 'zebra_auth_index_mode_warn'
126 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
127 push @xml_config_warnings, {
128 error => 'zebra_auth_mode_seems_grs1'
131 else {
132 push @xml_config_warnings, {
133 error => 'zebra_auth_mode_seems_dom'
136 } else {
137 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
138 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
141 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
142 push @xml_config_warnings, {
143 error => 'zebra_auth_index_mode_mismatch_warn'
147 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
148 push @xml_config_warnings, {
149 error => 'zebra_auth_index_mode_mismatch_warn'
153 # Test QueryParser configuration sanity
154 if ( C4::Context->preference( 'UseQueryParser' ) ) {
155 # Get the QueryParser configuration file name
156 my $queryparser_file = C4::Context->config( 'queryparser_config' );
157 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
158 # Check QueryParser is functional
159 my $QParser = C4::Context->queryparser();
160 my $queryparser_error = {};
161 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
162 # Error initializing the QueryParser object
163 # Get the used queryparser.yaml file path to report the user
164 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
165 $queryparser_error->{ file } = ( defined $queryparser_file )
166 ? $queryparser_file
167 : $queryparser_fallback_file;
168 # Report error data to the template
169 $template->param( QueryParserError => $queryparser_error );
170 } else {
171 # Check for an absent queryparser_config entry in koha-conf.xml
172 if ( ! defined $queryparser_file ) {
173 # Not an error but a warning for the missing entry in koha-conf-xml
174 push @xml_config_warnings, {
175 error => 'queryparser_entry_missing',
176 file => $queryparser_fallback_file
182 # Test Zebra facets configuration
183 if ( !defined C4::Context->config('use_zebra_facets') ) {
184 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
185 } else {
186 if ( C4::Context->config('use_zebra_facets') &&
187 C4::Context->config('zebra_bib_index_mode') ) {
188 # use_zebra_facets works with DOM
189 push @xml_config_warnings, {
190 error => 'use_zebra_facets_needs_dom'
191 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
195 $template->param(
196 kohaVersion => $kohaVersion,
197 osVersion => $osVersion,
198 perlPath => $perl_path,
199 perlVersion => $perlVersion,
200 perlIncPath => [ map { perlinc => $_ }, @INC ],
201 mysqlVersion => $mysqlVersion,
202 apacheVersion => $apacheVersion,
203 zebraVersion => $zebraVersion,
204 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
205 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
206 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
207 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
208 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
209 errZebraConnection => $errZebraConnection,
210 warnIsRootUser => $warnIsRootUser,
211 warnNoActiveCurrency => $warnNoActiveCurrency,
212 xml_config_warnings => \@xml_config_warnings,
215 my @components = ();
217 my $perl_modules = C4::Installer::PerlModules->new;
218 $perl_modules->version_info;
220 my @pm_types = qw(missing_pm upgrade_pm current_pm);
222 foreach my $pm_type(@pm_types) {
223 my $modules = $perl_modules->get_attr($pm_type);
224 foreach (@$modules) {
225 my ($module, $stats) = each %$_;
226 push(
227 @components,
229 name => $module,
230 version => $stats->{'cur_ver'},
231 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
232 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
233 current => ($pm_type eq 'current_pm' ? 1 : 0),
234 require => $stats->{'required'},
235 reqversion => $stats->{'min_ver'},
241 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
243 my $counter=0;
244 my $row = [];
245 my $table = [];
246 foreach (@components) {
247 push (@$row, $_);
248 unless (++$counter % 4) {
249 push (@$table, {row => $row});
250 $row = [];
253 # Processing the last line (if there are any modules left)
254 if (scalar(@$row) > 0) {
255 # Extending $row to the table size
256 $$row[3] = '';
257 # Pushing the last line
258 push (@$table, {row => $row});
260 ## ## $table
262 $template->param( table => $table );
265 ## ------------------------------------------
266 ## Koha time line code
268 #get file location
269 my $docdir;
270 if ( defined C4::Context->config('docdir') ) {
271 $docdir = C4::Context->config('docdir');
272 } else {
273 # if no <docdir> is defined in koha-conf.xml, use the default location
274 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
275 $docdir = C4::Context->config('intranetdir') . '/docs';
278 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
280 my $i = 0;
282 my @rows2 = ();
283 my $row2 = [];
285 my @lines = <$file>;
286 close($file);
288 shift @lines; #remove header row
290 foreach (@lines) {
291 my ( $date, $desc, $tag ) = split(/\t/);
292 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
293 ($date, $desc)= ($`, $');
295 push(
296 @rows2,
298 date => $date,
299 desc => $desc,
304 my $table2 = [];
305 #foreach my $row2 (@rows2) {
306 foreach (@rows2) {
307 push (@$row2, $_);
308 push( @$table2, { row2 => $row2 } );
309 $row2 = [];
312 $template->param( table2 => $table2 );
313 } else {
314 $template->param( timeline_read_error => 1 );
317 output_html_with_http_headers $query, $cookie, $template->output;