Bug 16317 - Attempt to share private list results in error
[koha.git] / about.pl
blob4bf9779fc4ebd2aa5bcf190d512baa7ce7f8d2f3
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::Borrowers;
38 use Koha::Config::SysPrefs;
40 #use Smart::Comments '####';
42 my $query = new CGI;
43 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45 template_name => "about.tt",
46 query => $query,
47 type => "intranet",
48 authnotrequired => 0,
49 flagsrequired => { catalogue => 1 },
50 debug => 1,
54 my $perl_path = $^X;
55 if ($^O ne 'VMS') {
56 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
59 my $zebraVersion = `zebraidx -V`;
61 # Check running PSGI env
62 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
63 $template->param(
64 is_psgi => 1,
65 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
66 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
67 'Unknown'
71 # Additional system information for warnings
72 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
73 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
74 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
76 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
77 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
78 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
79 my $warnPrefAnonymousPatron = (
80 C4::Context->preference('OPACPrivacy')
81 and not C4::Context->preference('AnonymousPatron')
84 my $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
85 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
87 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
89 my $warnIsRootUser = (! $loggedinuser);
91 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
92 my @xml_config_warnings;
94 my $context = new C4::Context;
96 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
97 push @xml_config_warnings, {
98 error => 'zebra_bib_index_mode_warn'
100 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
101 push @xml_config_warnings, {
102 error => 'zebra_bib_mode_seems_grs1'
105 else {
106 push @xml_config_warnings, {
107 error => 'zebra_bib_mode_seems_dom'
110 } else {
111 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
112 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
115 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
116 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
118 push @xml_config_warnings, {
119 error => 'zebra_bib_index_mode_mismatch_warn'
123 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
124 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
126 push @xml_config_warnings, {
127 error => 'zebra_bib_index_mode_mismatch_warn'
131 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
132 push @xml_config_warnings, {
133 error => 'zebra_auth_index_mode_warn'
135 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
136 push @xml_config_warnings, {
137 error => 'zebra_auth_mode_seems_grs1'
140 else {
141 push @xml_config_warnings, {
142 error => 'zebra_auth_mode_seems_dom'
145 } else {
146 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
147 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
150 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
151 push @xml_config_warnings, {
152 error => 'zebra_auth_index_mode_mismatch_warn'
156 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
157 push @xml_config_warnings, {
158 error => 'zebra_auth_index_mode_mismatch_warn'
162 if ( ! defined C4::Context->config('log4perl_conf') ) {
163 push @xml_config_warnings, {
164 error => 'log4perl_entry_missing'
168 if ( ! defined C4::Context->config('upload_path') ) {
169 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
170 # OPACBaseURL seems to be set
171 push @xml_config_warnings, {
172 error => 'uploadpath_entry_missing'
174 } else {
175 push @xml_config_warnings, {
176 error => 'uploadpath_and_opacbaseurl_entry_missing'
181 # Test QueryParser configuration sanity
182 if ( C4::Context->preference( 'UseQueryParser' ) ) {
183 # Get the QueryParser configuration file name
184 my $queryparser_file = C4::Context->config( 'queryparser_config' );
185 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
186 # Check QueryParser is functional
187 my $QParser = C4::Context->queryparser();
188 my $queryparser_error = {};
189 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
190 # Error initializing the QueryParser object
191 # Get the used queryparser.yaml file path to report the user
192 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
193 $queryparser_error->{ file } = ( defined $queryparser_file )
194 ? $queryparser_file
195 : $queryparser_fallback_file;
196 # Report error data to the template
197 $template->param( QueryParserError => $queryparser_error );
198 } else {
199 # Check for an absent queryparser_config entry in koha-conf.xml
200 if ( ! defined $queryparser_file ) {
201 # Not an error but a warning for the missing entry in koha-conf-xml
202 push @xml_config_warnings, {
203 error => 'queryparser_entry_missing',
204 file => $queryparser_fallback_file
210 # Test Zebra facets configuration
211 if ( !defined C4::Context->config('use_zebra_facets') ) {
212 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
213 } else {
214 if ( C4::Context->config('use_zebra_facets') &&
215 C4::Context->config('zebra_bib_index_mode') ) {
216 # use_zebra_facets works with DOM
217 push @xml_config_warnings, {
218 error => 'use_zebra_facets_needs_dom'
219 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
223 # Sco Patron should not contain any other perms than circulate => self_checkout
224 if ( C4::Context->preference('WebBasedSelfCheck')
225 and C4::Context->preference('AutoSelfCheckAllowed')
227 my $userid = C4::Context->preference('AutoSelfCheckID');
228 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
229 my ( $has_self_checkout_perm, $has_other_permissions );
230 while ( my ( $module, $permissions ) = each %$all_permissions ) {
231 if ( $module eq 'circulate' ) {
232 while ( my ( $permission, $flag ) = each %$permissions ) {
233 if ( $permission eq 'self_checkout' ) {
234 $has_self_checkout_perm = 1;
235 } else {
236 $has_other_permissions = 1;
239 } else {
240 $has_other_permissions = 1;
243 $template->param(
244 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
245 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
251 my %versions = C4::Context::get_versions();
253 $template->param(
254 kohaVersion => $versions{'kohaVersion'},
255 osVersion => $versions{'osVersion'},
256 perlPath => $perl_path,
257 perlVersion => $versions{'perlVersion'},
258 perlIncPath => [ map { perlinc => $_ }, @INC ],
259 mysqlVersion => $versions{'mysqlVersion'},
260 apacheVersion => $versions{'apacheVersion'},
261 zebraVersion => $zebraVersion,
262 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
263 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
264 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
265 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
266 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
267 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
268 errZebraConnection => $errZebraConnection,
269 warnIsRootUser => $warnIsRootUser,
270 warnNoActiveCurrency => $warnNoActiveCurrency,
271 xml_config_warnings => \@xml_config_warnings,
274 my @components = ();
276 my $perl_modules = C4::Installer::PerlModules->new;
277 $perl_modules->version_info;
279 my @pm_types = qw(missing_pm upgrade_pm current_pm);
281 foreach my $pm_type(@pm_types) {
282 my $modules = $perl_modules->get_attr($pm_type);
283 foreach (@$modules) {
284 my ($module, $stats) = each %$_;
285 push(
286 @components,
288 name => $module,
289 version => $stats->{'cur_ver'},
290 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
291 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
292 current => ($pm_type eq 'current_pm' ? 1 : 0),
293 require => $stats->{'required'},
294 reqversion => $stats->{'min_ver'},
300 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
302 my $counter=0;
303 my $row = [];
304 my $table = [];
305 foreach (@components) {
306 push (@$row, $_);
307 unless (++$counter % 4) {
308 push (@$table, {row => $row});
309 $row = [];
312 # Processing the last line (if there are any modules left)
313 if (scalar(@$row) > 0) {
314 # Extending $row to the table size
315 $$row[3] = '';
316 # Pushing the last line
317 push (@$table, {row => $row});
319 ## ## $table
321 $template->param( table => $table );
324 ## ------------------------------------------
325 ## Koha time line code
327 #get file location
328 my $docdir;
329 if ( defined C4::Context->config('docdir') ) {
330 $docdir = C4::Context->config('docdir');
331 } else {
332 # if no <docdir> is defined in koha-conf.xml, use the default location
333 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
334 $docdir = C4::Context->config('intranetdir') . '/docs';
337 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
339 my $i = 0;
341 my @rows2 = ();
342 my $row2 = [];
344 my @lines = <$file>;
345 close($file);
347 shift @lines; #remove header row
349 foreach (@lines) {
350 my ( $date, $desc, $tag ) = split(/\t/);
351 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
352 ($date, $desc)= ($`, $');
354 push(
355 @rows2,
357 date => $date,
358 desc => $desc,
363 my $table2 = [];
364 #foreach my $row2 (@rows2) {
365 foreach (@rows2) {
366 push (@$row2, $_);
367 push( @$table2, { row2 => $row2 } );
368 $row2 = [];
371 $template->param( table2 => $table2 );
372 } else {
373 $template->param( timeline_read_error => 1 );
376 output_html_with_http_headers $query, $cookie, $template->output;