Bug 18089 - All XSLT testing singleBranchMode = 0 fails to show even if install has...
[koha.git] / about.pl
blobaf5544c1ca4e4457df7993a1259f14741e968b9a
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;
40 use C4::Members::Statistics;
42 #use Smart::Comments '####';
44 my $query = new CGI;
45 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47 template_name => "about.tt",
48 query => $query,
49 type => "intranet",
50 authnotrequired => 0,
51 flagsrequired => { catalogue => 1 },
52 debug => 1,
56 my $perl_path = $^X;
57 if ($^O ne 'VMS') {
58 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
61 my $zebraVersion = `zebraidx -V`;
63 # Check running PSGI env
64 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
65 $template->param(
66 is_psgi => 1,
67 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
68 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
69 'Unknown'
73 # Additional system information for warnings
75 my $warnStatisticsFieldsError;
76 my $prefStatisticsFields = C4::Context->preference('StatisticsFields');
77 if ($prefStatisticsFields) {
78 $warnStatisticsFieldsError = $prefStatisticsFields
79 unless ( $prefStatisticsFields eq C4::Members::Statistics->get_fields() );
82 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
83 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
84 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
86 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
87 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
88 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
89 my $warnPrefAnonymousPatron = (
90 C4::Context->preference('OPACPrivacy')
91 and not C4::Context->preference('AnonymousPatron')
94 my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
95 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
97 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
99 my $warnIsRootUser = (! $loggedinuser);
101 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
103 my @xml_config_warnings;
105 my $context = new C4::Context;
107 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
108 push @xml_config_warnings, {
109 error => 'zebra_bib_index_mode_warn'
111 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
112 push @xml_config_warnings, {
113 error => 'zebra_bib_mode_seems_grs1'
116 else {
117 push @xml_config_warnings, {
118 error => 'zebra_bib_mode_seems_dom'
121 } else {
122 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
123 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
126 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
127 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
129 push @xml_config_warnings, {
130 error => 'zebra_bib_index_mode_mismatch_warn'
134 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
135 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
137 push @xml_config_warnings, {
138 error => 'zebra_bib_index_mode_mismatch_warn'
142 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
143 push @xml_config_warnings, {
144 error => 'zebra_auth_index_mode_warn'
146 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
147 push @xml_config_warnings, {
148 error => 'zebra_auth_mode_seems_grs1'
151 else {
152 push @xml_config_warnings, {
153 error => 'zebra_auth_mode_seems_dom'
156 } else {
157 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
158 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
161 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
162 push @xml_config_warnings, {
163 error => 'zebra_auth_index_mode_mismatch_warn'
167 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
168 push @xml_config_warnings, {
169 error => 'zebra_auth_index_mode_mismatch_warn'
173 if ( ! defined C4::Context->config('log4perl_conf') ) {
174 push @xml_config_warnings, {
175 error => 'log4perl_entry_missing'
179 if ( ! defined C4::Context->config('upload_path') ) {
180 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
181 # OPACBaseURL seems to be set
182 push @xml_config_warnings, {
183 error => 'uploadpath_entry_missing'
185 } else {
186 push @xml_config_warnings, {
187 error => 'uploadpath_and_opacbaseurl_entry_missing'
192 # Test QueryParser configuration sanity
193 if ( C4::Context->preference( 'UseQueryParser' ) ) {
194 # Get the QueryParser configuration file name
195 my $queryparser_file = C4::Context->config( 'queryparser_config' );
196 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
197 # Check QueryParser is functional
198 my $QParser = C4::Context->queryparser();
199 my $queryparser_error = {};
200 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
201 # Error initializing the QueryParser object
202 # Get the used queryparser.yaml file path to report the user
203 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
204 $queryparser_error->{ file } = ( defined $queryparser_file )
205 ? $queryparser_file
206 : $queryparser_fallback_file;
207 # Report error data to the template
208 $template->param( QueryParserError => $queryparser_error );
209 } else {
210 # Check for an absent queryparser_config entry in koha-conf.xml
211 if ( ! defined $queryparser_file ) {
212 # Not an error but a warning for the missing entry in koha-conf-xml
213 push @xml_config_warnings, {
214 error => 'queryparser_entry_missing',
215 file => $queryparser_fallback_file
221 # Test Zebra facets configuration
222 if ( !defined C4::Context->config('use_zebra_facets') ) {
223 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
224 } else {
225 if ( C4::Context->config('use_zebra_facets') &&
226 C4::Context->config('zebra_bib_index_mode') ) {
227 # use_zebra_facets works with DOM
228 push @xml_config_warnings, {
229 error => 'use_zebra_facets_needs_dom'
230 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
234 # Sco Patron should not contain any other perms than circulate => self_checkout
235 if ( C4::Context->preference('WebBasedSelfCheck')
236 and C4::Context->preference('AutoSelfCheckAllowed')
238 my $userid = C4::Context->preference('AutoSelfCheckID');
239 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
240 my ( $has_self_checkout_perm, $has_other_permissions );
241 while ( my ( $module, $permissions ) = each %$all_permissions ) {
242 if ( $module eq 'circulate' ) {
243 while ( my ( $permission, $flag ) = each %$permissions ) {
244 if ( $permission eq 'self_checkout' ) {
245 $has_self_checkout_perm = 1;
246 } else {
247 $has_other_permissions = 1;
250 } else {
251 $has_other_permissions = 1;
254 $template->param(
255 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
256 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
262 my %versions = C4::Context::get_versions();
264 $template->param(
265 kohaVersion => $versions{'kohaVersion'},
266 osVersion => $versions{'osVersion'},
267 perlPath => $perl_path,
268 perlVersion => $versions{'perlVersion'},
269 perlIncPath => [ map { perlinc => $_ }, @INC ],
270 mysqlVersion => $versions{'mysqlVersion'},
271 apacheVersion => $versions{'apacheVersion'},
272 zebraVersion => $zebraVersion,
273 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
274 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
275 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
276 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
277 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
278 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
279 errZebraConnection => $errZebraConnection,
280 warnIsRootUser => $warnIsRootUser,
281 warnNoActiveCurrency => $warnNoActiveCurrency,
282 warnNoTemplateCaching => ( C4::Context->config('template_cache_dir') ? 0 : 1 ),
283 xml_config_warnings => \@xml_config_warnings,
284 warnStatisticsFieldsError => $warnStatisticsFieldsError,
287 my @components = ();
289 my $perl_modules = C4::Installer::PerlModules->new;
290 $perl_modules->versions_info;
292 my @pm_types = qw(missing_pm upgrade_pm current_pm);
294 foreach my $pm_type(@pm_types) {
295 my $modules = $perl_modules->get_attr($pm_type);
296 foreach (@$modules) {
297 my ($module, $stats) = each %$_;
298 push(
299 @components,
301 name => $module,
302 version => $stats->{'cur_ver'},
303 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
304 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
305 current => ($pm_type eq 'current_pm' ? 1 : 0),
306 require => $stats->{'required'},
307 reqversion => $stats->{'min_ver'},
313 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
315 my $counter=0;
316 my $row = [];
317 my $table = [];
318 foreach (@components) {
319 push (@$row, $_);
320 unless (++$counter % 4) {
321 push (@$table, {row => $row});
322 $row = [];
325 # Processing the last line (if there are any modules left)
326 if (scalar(@$row) > 0) {
327 # Extending $row to the table size
328 $$row[3] = '';
329 # Pushing the last line
330 push (@$table, {row => $row});
332 ## ## $table
334 $template->param( table => $table );
337 ## ------------------------------------------
338 ## Koha time line code
340 #get file location
341 my $docdir;
342 if ( defined C4::Context->config('docdir') ) {
343 $docdir = C4::Context->config('docdir');
344 } else {
345 # if no <docdir> is defined in koha-conf.xml, use the default location
346 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
347 $docdir = C4::Context->config('intranetdir') . '/docs';
350 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
352 my $i = 0;
354 my @rows2 = ();
355 my $row2 = [];
357 my @lines = <$file>;
358 close($file);
360 shift @lines; #remove header row
362 foreach (@lines) {
363 my ( $date, $desc, $tag ) = split(/\t/);
364 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
365 ($date, $desc)= ($`, $');
367 push(
368 @rows2,
370 date => $date,
371 desc => $desc,
376 my $table2 = [];
377 #foreach my $row2 (@rows2) {
378 foreach (@rows2) {
379 push (@$row2, $_);
380 push( @$table2, { row2 => $row2 } );
381 $row2 = [];
384 $template->param( table2 => $table2 );
385 } else {
386 $template->param( timeline_read_error => 1 );
389 output_html_with_http_headers $query, $cookie, $template->output;