Translation for 3.20.11
[koha.git] / about.pl
blob044a1df4cccc65972c4e7d931fe48a5ba392581a
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;
37 use Koha::Borrowers;
39 #use Smart::Comments '####';
41 my $query = new CGI;
42 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
44 template_name => "about.tt",
45 query => $query,
46 type => "intranet",
47 authnotrequired => 0,
48 flagsrequired => { catalogue => 1 },
49 debug => 1,
53 my $perl_path = $^X;
54 if ($^O ne 'VMS') {
55 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
58 my $zebraVersion = `zebraidx -V`;
60 # Additional system information for warnings
61 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
62 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
63 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
65 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
66 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
67 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
68 my $warnPrefAnonymousPatron = (
69 C4::Context->preference('OPACPrivacy')
70 and not C4::Context->preference('AnonymousPatron')
73 my $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
74 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
76 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
78 my $warnIsRootUser = (! $loggedinuser);
80 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
81 my @xml_config_warnings;
83 my $context = new C4::Context;
85 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
86 push @xml_config_warnings, {
87 error => 'zebra_bib_index_mode_warn'
89 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
90 push @xml_config_warnings, {
91 error => 'zebra_bib_mode_seems_grs1'
94 else {
95 push @xml_config_warnings, {
96 error => 'zebra_bib_mode_seems_dom'
99 } else {
100 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
101 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
104 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
105 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
107 push @xml_config_warnings, {
108 error => 'zebra_bib_index_mode_mismatch_warn'
112 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
113 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
115 push @xml_config_warnings, {
116 error => 'zebra_bib_index_mode_mismatch_warn'
120 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
121 push @xml_config_warnings, {
122 error => 'zebra_auth_index_mode_warn'
124 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
125 push @xml_config_warnings, {
126 error => 'zebra_auth_mode_seems_grs1'
129 else {
130 push @xml_config_warnings, {
131 error => 'zebra_auth_mode_seems_dom'
134 } else {
135 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
136 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
139 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
140 push @xml_config_warnings, {
141 error => 'zebra_auth_index_mode_mismatch_warn'
145 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
146 push @xml_config_warnings, {
147 error => 'zebra_auth_index_mode_mismatch_warn'
151 # Test QueryParser configuration sanity
152 if ( C4::Context->preference( 'UseQueryParser' ) ) {
153 # Get the QueryParser configuration file name
154 my $queryparser_file = C4::Context->config( 'queryparser_config' );
155 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
156 # Check QueryParser is functional
157 my $QParser = C4::Context->queryparser();
158 my $queryparser_error = {};
159 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
160 # Error initializing the QueryParser object
161 # Get the used queryparser.yaml file path to report the user
162 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
163 $queryparser_error->{ file } = ( defined $queryparser_file )
164 ? $queryparser_file
165 : $queryparser_fallback_file;
166 # Report error data to the template
167 $template->param( QueryParserError => $queryparser_error );
168 } else {
169 # Check for an absent queryparser_config entry in koha-conf.xml
170 if ( ! defined $queryparser_file ) {
171 # Not an error but a warning for the missing entry in koha-conf-xml
172 push @xml_config_warnings, {
173 error => 'queryparser_entry_missing',
174 file => $queryparser_fallback_file
180 # Test Zebra facets configuration
181 if ( !defined C4::Context->config('use_zebra_facets') ) {
182 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
183 } else {
184 if ( C4::Context->config('use_zebra_facets') &&
185 C4::Context->config('zebra_bib_index_mode') ) {
186 # use_zebra_facets works with DOM
187 push @xml_config_warnings, {
188 error => 'use_zebra_facets_needs_dom'
189 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
193 # Sco Patron should not contain any other perms than circulate => self_checkout
194 if ( C4::Context->preference('WebBasedSelfCheck')
195 and C4::Context->preference('AutoSelfCheckAllowed')
197 my $userid = C4::Context->preference('AutoSelfCheckID');
198 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
199 my ( $has_self_checkout_perm, $has_other_permissions );
200 while ( my ( $module, $permissions ) = each %$all_permissions ) {
201 if ( $module eq 'circulate' ) {
202 while ( my ( $permission, $flag ) = each %$permissions ) {
203 if ( $permission eq 'self_checkout' ) {
204 $has_self_checkout_perm = 1;
205 } else {
206 $has_other_permissions = 1;
209 } else {
210 $has_other_permissions = 1;
213 $template->param(
214 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
215 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
221 my %versions = C4::Context::get_versions();
223 $template->param(
224 kohaVersion => $versions{'kohaVersion'},
225 osVersion => $versions{'osVersion'},
226 perlPath => $perl_path,
227 perlVersion => $versions{'perlVersion'},
228 perlIncPath => [ map { perlinc => $_ }, @INC ],
229 mysqlVersion => $versions{'mysqlVersion'},
230 apacheVersion => $versions{'apacheVersion'},
231 zebraVersion => $zebraVersion,
232 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
233 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
234 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
235 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
236 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
237 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
238 errZebraConnection => $errZebraConnection,
239 warnIsRootUser => $warnIsRootUser,
240 warnNoActiveCurrency => $warnNoActiveCurrency,
241 xml_config_warnings => \@xml_config_warnings,
244 my @components = ();
246 my $perl_modules = C4::Installer::PerlModules->new;
247 $perl_modules->version_info;
249 my @pm_types = qw(missing_pm upgrade_pm current_pm);
251 foreach my $pm_type(@pm_types) {
252 my $modules = $perl_modules->get_attr($pm_type);
253 foreach (@$modules) {
254 my ($module, $stats) = each %$_;
255 push(
256 @components,
258 name => $module,
259 version => $stats->{'cur_ver'},
260 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
261 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
262 current => ($pm_type eq 'current_pm' ? 1 : 0),
263 require => $stats->{'required'},
264 reqversion => $stats->{'min_ver'},
270 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
272 my $counter=0;
273 my $row = [];
274 my $table = [];
275 foreach (@components) {
276 push (@$row, $_);
277 unless (++$counter % 4) {
278 push (@$table, {row => $row});
279 $row = [];
282 # Processing the last line (if there are any modules left)
283 if (scalar(@$row) > 0) {
284 # Extending $row to the table size
285 $$row[3] = '';
286 # Pushing the last line
287 push (@$table, {row => $row});
289 ## ## $table
291 $template->param( table => $table );
294 ## ------------------------------------------
295 ## Koha time line code
297 #get file location
298 my $docdir;
299 if ( defined C4::Context->config('docdir') ) {
300 $docdir = C4::Context->config('docdir');
301 } else {
302 # if no <docdir> is defined in koha-conf.xml, use the default location
303 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
304 $docdir = C4::Context->config('intranetdir') . '/docs';
307 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
309 my $i = 0;
311 my @rows2 = ();
312 my $row2 = [];
314 my @lines = <$file>;
315 close($file);
317 shift @lines; #remove header row
319 foreach (@lines) {
320 my ( $date, $desc, $tag ) = split(/\t/);
321 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
322 ($date, $desc)= ($`, $');
324 push(
325 @rows2,
327 date => $date,
328 desc => $desc,
333 my $table2 = [];
334 #foreach my $row2 (@rows2) {
335 foreach (@rows2) {
336 push (@$row2, $_);
337 push( @$table2, { row2 => $row2 } );
338 $row2 = [];
341 $template->param( table2 => $table2 );
342 } else {
343 $template->param( timeline_read_error => 1 );
346 output_html_with_http_headers $query, $cookie, $template->output;