Bug 13670 - Patron holds table not loading when holds tab anchor is used
[koha.git] / about.pl
blob2db78b27da9b30ef4484a50f47f3e772a85cfc3f
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 under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use strict;
24 use warnings;
26 use CGI;
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 Smart::Comments '####';
38 my $query = new CGI;
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41 template_name => "about.tt",
42 query => $query,
43 type => "intranet",
44 authnotrequired => 0,
45 flagsrequired => { catalogue => 1 },
46 debug => 1,
50 my $kohaVersion = C4::Context::KOHAVERSION;
51 my $osVersion = `uname -a`;
52 my $perl_path = $^X;
53 if ($^O ne 'VMS') {
54 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
56 my $perlVersion = $];
57 my $mysqlVersion = `mysql -V`;
58 my $apacheVersion = `httpd -v 2> /dev/null`;
59 $apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
60 $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
61 my $zebraVersion = `zebraidx -V`;
63 # Additional system information for warnings
64 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
65 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
66 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
68 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
69 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
70 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
71 my $warnPrefAnonymousPatron = (
72 C4::Context->preference('OPACPrivacy')
73 and not C4::Context->preference('AnonymousPatron')
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') && ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
105 push @xml_config_warnings, {
106 error => 'zebra_bib_index_mode_mismatch_warn'
110 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
111 push @xml_config_warnings, {
112 error => 'zebra_bib_index_mode_mismatch_warn'
116 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
117 push @xml_config_warnings, {
118 error => 'zebra_auth_index_mode_warn'
120 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
121 push @xml_config_warnings, {
122 error => 'zebra_auth_mode_seems_grs1'
125 else {
126 push @xml_config_warnings, {
127 error => 'zebra_auth_mode_seems_dom'
130 } else {
131 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
132 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
135 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
136 push @xml_config_warnings, {
137 error => 'zebra_auth_index_mode_mismatch_warn'
141 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
142 push @xml_config_warnings, {
143 error => 'zebra_auth_index_mode_mismatch_warn'
147 # Test QueryParser configuration sanity
148 if ( C4::Context->preference( 'UseQueryParser' ) ) {
149 # Get the QueryParser configuration file name
150 my $queryparser_file = C4::Context->config( 'queryparser_config' );
151 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
152 # Check QueryParser is functional
153 my $QParser = C4::Context->queryparser();
154 my $queryparser_error = {};
155 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
156 # Error initializing the QueryParser object
157 # Get the used queryparser.yaml file path to report the user
158 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
159 $queryparser_error->{ file } = ( defined $queryparser_file )
160 ? $queryparser_file
161 : $queryparser_fallback_file;
162 # Report error data to the template
163 $template->param( QueryParserError => $queryparser_error );
164 } else {
165 # Check for an absent queryparser_config entry in koha-conf.xml
166 if ( ! defined $queryparser_file ) {
167 # Not an error but a warning for the missing entry in koha-conf-xml
168 push @xml_config_warnings, {
169 error => 'queryparser_entry_missing',
170 file => $queryparser_fallback_file
176 # Test Zebra facets configuration
177 if ( !defined C4::Context->config('use_zebra_facets') ) {
178 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
179 } else {
180 if ( C4::Context->config('use_zebra_facets') &&
181 C4::Context->config('zebra_bib_index_mode') ) {
182 # use_zebra_facets works with DOM
183 push @xml_config_warnings, {
184 error => 'use_zebra_facets_needs_dom'
185 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
189 $template->param(
190 kohaVersion => $kohaVersion,
191 osVersion => $osVersion,
192 perlPath => $perl_path,
193 perlVersion => $perlVersion,
194 perlIncPath => [ map { perlinc => $_ }, @INC ],
195 mysqlVersion => $mysqlVersion,
196 apacheVersion => $apacheVersion,
197 zebraVersion => $zebraVersion,
198 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
199 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
200 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
201 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
202 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
203 errZebraConnection => $errZebraConnection,
204 warnIsRootUser => $warnIsRootUser,
205 warnNoActiveCurrency => $warnNoActiveCurrency,
206 xml_config_warnings => \@xml_config_warnings,
209 my @components = ();
211 my $perl_modules = C4::Installer::PerlModules->new;
212 $perl_modules->version_info;
214 my @pm_types = qw(missing_pm upgrade_pm current_pm);
216 foreach my $pm_type(@pm_types) {
217 my $modules = $perl_modules->get_attr($pm_type);
218 foreach (@$modules) {
219 my ($module, $stats) = each %$_;
220 push(
221 @components,
223 name => $module,
224 version => $stats->{'cur_ver'},
225 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
226 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
227 current => ($pm_type eq 'current_pm' ? 1 : 0),
228 require => $stats->{'required'},
229 reqversion => $stats->{'min_ver'},
235 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
237 my $counter=0;
238 my $row = [];
239 my $table = [];
240 foreach (@components) {
241 push (@$row, $_);
242 unless (++$counter % 4) {
243 push (@$table, {row => $row});
244 $row = [];
247 # Processing the last line (if there are any modules left)
248 if (scalar(@$row) > 0) {
249 # Extending $row to the table size
250 $$row[3] = '';
251 # Pushing the last line
252 push (@$table, {row => $row});
254 ## ## $table
256 $template->param( table => $table );
259 ## ------------------------------------------
260 ## Koha time line code
262 #get file location
263 my $docdir;
264 if ( defined C4::Context->config('docdir') ) {
265 $docdir = C4::Context->config('docdir');
266 } else {
267 # if no <docdir> is defined in koha-conf.xml, use the default location
268 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
269 $docdir = C4::Context->config('intranetdir') . '/docs';
272 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
274 my $i = 0;
276 my @rows2 = ();
277 my $row2 = [];
279 my @lines = <$file>;
280 close($file);
282 shift @lines; #remove header row
284 foreach (@lines) {
285 my ( $date, $desc, $tag ) = split(/\t/);
286 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
287 ($date, $desc)= ($`, $');
289 push(
290 @rows2,
292 date => $date,
293 desc => $desc,
298 my $table2 = [];
299 #foreach my $row2 (@rows2) {
300 foreach (@rows2) {
301 push (@$row2, $_);
302 push( @$table2, { row2 => $row2 } );
303 $row2 = [];
306 $template->param( table2 => $table2 );
307 } else {
308 $template->param( timeline_read_error => 1 );
311 output_html_with_http_headers $query, $cookie, $template->output;