Bug 16019: Add a warning in the update DB process if intranetcolorstylesheet=blue.css
[koha.git] / about.pl
blob6b776771babfa619344915c2fb381bf1a0f633b5
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 Modern::Perl;
25 use CGI qw ( -utf8 );
26 use List::MoreUtils qw/ any /;
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;
37 use Koha::Acquisition::Currencies;
38 use Koha::Patrons;
39 use Koha::Config::SysPrefs;
41 #use Smart::Comments '####';
43 my $query = new CGI;
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46 template_name => "about.tt",
47 query => $query,
48 type => "intranet",
49 authnotrequired => 0,
50 flagsrequired => { catalogue => 1 },
51 debug => 1,
55 my $perl_path = $^X;
56 if ($^O ne 'VMS') {
57 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
60 my $zebraVersion = `zebraidx -V`;
62 # Check running PSGI env
63 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
64 $template->param(
65 is_psgi => 1,
66 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
67 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
68 'Unknown'
72 # Additional system information for warnings
73 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
74 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
75 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
77 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
78 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
79 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
80 my $warnPrefAnonymousPatron = (
81 C4::Context->preference('OPACPrivacy')
82 and not C4::Context->preference('AnonymousPatron')
85 my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
86 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
88 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
90 my $warnIsRootUser = (! $loggedinuser);
92 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
93 my @xml_config_warnings;
95 my $context = new C4::Context;
97 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
98 push @xml_config_warnings, {
99 error => 'zebra_bib_index_mode_warn'
101 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
102 push @xml_config_warnings, {
103 error => 'zebra_bib_mode_seems_grs1'
106 else {
107 push @xml_config_warnings, {
108 error => 'zebra_bib_mode_seems_dom'
111 } else {
112 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
113 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
116 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
117 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
119 push @xml_config_warnings, {
120 error => 'zebra_bib_index_mode_mismatch_warn'
124 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
125 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
127 push @xml_config_warnings, {
128 error => 'zebra_bib_index_mode_mismatch_warn'
132 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
133 push @xml_config_warnings, {
134 error => 'zebra_auth_index_mode_warn'
136 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
137 push @xml_config_warnings, {
138 error => 'zebra_auth_mode_seems_grs1'
141 else {
142 push @xml_config_warnings, {
143 error => 'zebra_auth_mode_seems_dom'
146 } else {
147 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
148 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
151 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
152 push @xml_config_warnings, {
153 error => 'zebra_auth_index_mode_mismatch_warn'
157 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
158 push @xml_config_warnings, {
159 error => 'zebra_auth_index_mode_mismatch_warn'
163 if ( ! defined C4::Context->config('log4perl_conf') ) {
164 push @xml_config_warnings, {
165 error => 'log4perl_entry_missing'
169 if ( ! defined C4::Context->config('upload_path') ) {
170 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
171 # OPACBaseURL seems to be set
172 push @xml_config_warnings, {
173 error => 'uploadpath_entry_missing'
175 } else {
176 push @xml_config_warnings, {
177 error => 'uploadpath_and_opacbaseurl_entry_missing'
182 # Test QueryParser configuration sanity
183 if ( C4::Context->preference( 'UseQueryParser' ) ) {
184 # Get the QueryParser configuration file name
185 my $queryparser_file = C4::Context->config( 'queryparser_config' );
186 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
187 # Check QueryParser is functional
188 my $QParser = C4::Context->queryparser();
189 my $queryparser_error = {};
190 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
191 # Error initializing the QueryParser object
192 # Get the used queryparser.yaml file path to report the user
193 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
194 $queryparser_error->{ file } = ( defined $queryparser_file )
195 ? $queryparser_file
196 : $queryparser_fallback_file;
197 # Report error data to the template
198 $template->param( QueryParserError => $queryparser_error );
199 } else {
200 # Check for an absent queryparser_config entry in koha-conf.xml
201 if ( ! defined $queryparser_file ) {
202 # Not an error but a warning for the missing entry in koha-conf-xml
203 push @xml_config_warnings, {
204 error => 'queryparser_entry_missing',
205 file => $queryparser_fallback_file
211 # Test Zebra facets configuration
212 if ( !defined C4::Context->config('use_zebra_facets') ) {
213 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
214 } else {
215 if ( C4::Context->config('use_zebra_facets') &&
216 C4::Context->config('zebra_bib_index_mode') ) {
217 # use_zebra_facets works with DOM
218 push @xml_config_warnings, {
219 error => 'use_zebra_facets_needs_dom'
220 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
224 # Sco Patron should not contain any other perms than circulate => self_checkout
225 if ( C4::Context->preference('WebBasedSelfCheck')
226 and C4::Context->preference('AutoSelfCheckAllowed')
228 my $userid = C4::Context->preference('AutoSelfCheckID');
229 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
230 my ( $has_self_checkout_perm, $has_other_permissions );
231 while ( my ( $module, $permissions ) = each %$all_permissions ) {
232 if ( $module eq 'circulate' ) {
233 while ( my ( $permission, $flag ) = each %$permissions ) {
234 if ( $permission eq 'self_checkout' ) {
235 $has_self_checkout_perm = 1;
236 } else {
237 $has_other_permissions = 1;
240 } else {
241 $has_other_permissions = 1;
244 $template->param(
245 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
246 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
252 my %versions = C4::Context::get_versions();
254 $template->param(
255 kohaVersion => $versions{'kohaVersion'},
256 osVersion => $versions{'osVersion'},
257 perlPath => $perl_path,
258 perlVersion => $versions{'perlVersion'},
259 perlIncPath => [ map { perlinc => $_ }, @INC ],
260 mysqlVersion => $versions{'mysqlVersion'},
261 apacheVersion => $versions{'apacheVersion'},
262 zebraVersion => $zebraVersion,
263 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
264 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
265 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
266 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
267 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
268 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
269 errZebraConnection => $errZebraConnection,
270 warnIsRootUser => $warnIsRootUser,
271 warnNoActiveCurrency => $warnNoActiveCurrency,
272 xml_config_warnings => \@xml_config_warnings,
275 my @components = ();
277 my $perl_modules = C4::Installer::PerlModules->new;
278 $perl_modules->version_info;
280 my @pm_types = qw(missing_pm upgrade_pm current_pm);
282 foreach my $pm_type(@pm_types) {
283 my $modules = $perl_modules->get_attr($pm_type);
284 foreach (@$modules) {
285 my ($module, $stats) = each %$_;
286 push(
287 @components,
289 name => $module,
290 version => $stats->{'cur_ver'},
291 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
292 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
293 current => ($pm_type eq 'current_pm' ? 1 : 0),
294 require => $stats->{'required'},
295 reqversion => $stats->{'min_ver'},
301 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
303 my $counter=0;
304 my $row = [];
305 my $table = [];
306 foreach (@components) {
307 push (@$row, $_);
308 unless (++$counter % 4) {
309 push (@$table, {row => $row});
310 $row = [];
313 # Processing the last line (if there are any modules left)
314 if (scalar(@$row) > 0) {
315 # Extending $row to the table size
316 $$row[3] = '';
317 # Pushing the last line
318 push (@$table, {row => $row});
320 ## ## $table
322 $template->param( table => $table );
325 ## ------------------------------------------
326 ## Koha time line code
328 #get file location
329 my $docdir;
330 if ( defined C4::Context->config('docdir') ) {
331 $docdir = C4::Context->config('docdir');
332 } else {
333 # if no <docdir> is defined in koha-conf.xml, use the default location
334 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
335 $docdir = C4::Context->config('intranetdir') . '/docs';
338 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
340 my $i = 0;
342 my @rows2 = ();
343 my $row2 = [];
345 my @lines = <$file>;
346 close($file);
348 shift @lines; #remove header row
350 foreach (@lines) {
351 my ( $date, $desc, $tag ) = split(/\t/);
352 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
353 ($date, $desc)= ($`, $');
355 push(
356 @rows2,
358 date => $date,
359 desc => $desc,
364 my $table2 = [];
365 #foreach my $row2 (@rows2) {
366 foreach (@rows2) {
367 push (@$row2, $_);
368 push( @$table2, { row2 => $row2 } );
369 $row2 = [];
372 $template->param( table2 => $table2 );
373 } else {
374 $template->param( timeline_read_error => 1 );
377 output_html_with_http_headers $query, $cookie, $template->output;