Bug 6874: (QA followup) Attach files to bibliographic records
[koha.git] / about.pl
blob847dc2b073a830a0d3b63cddc86fe7e620907811
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;
38 #use Smart::Comments '####';
40 my $query = new CGI;
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "about.tt",
44 query => $query,
45 type => "intranet",
46 authnotrequired => 0,
47 flagsrequired => { catalogue => 1 },
48 debug => 1,
52 my $kohaVersion = Koha::version();
53 my $osVersion = `uname -a`;
54 my $perl_path = $^X;
55 if ($^O ne 'VMS') {
56 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
58 my $perlVersion = $];
59 my $mysqlVersion = `mysql -V`;
60 # Get Apache version
61 my $apacheVersion = (`apache2ctl -v`)[0];
62 $apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
63 $apacheVersion = `httpd -v 2> /dev/null` unless $apacheVersion;
64 my $zebraVersion = `zebraidx -V`;
66 # Additional system information for warnings
67 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
68 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
69 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
71 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
72 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
73 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
74 my $warnPrefAnonymousPatron = (
75 C4::Context->preference('OPACPrivacy')
76 and not C4::Context->preference('AnonymousPatron')
79 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
81 my $warnIsRootUser = (! $loggedinuser);
83 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
84 my @xml_config_warnings;
86 my $context = new C4::Context;
88 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
89 push @xml_config_warnings, {
90 error => 'zebra_bib_index_mode_warn'
92 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
93 push @xml_config_warnings, {
94 error => 'zebra_bib_mode_seems_grs1'
97 else {
98 push @xml_config_warnings, {
99 error => 'zebra_bib_mode_seems_dom'
102 } else {
103 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
104 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
107 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
108 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
110 push @xml_config_warnings, {
111 error => 'zebra_bib_index_mode_mismatch_warn'
115 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
116 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
118 push @xml_config_warnings, {
119 error => 'zebra_bib_index_mode_mismatch_warn'
123 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
124 push @xml_config_warnings, {
125 error => 'zebra_auth_index_mode_warn'
127 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
128 push @xml_config_warnings, {
129 error => 'zebra_auth_mode_seems_grs1'
132 else {
133 push @xml_config_warnings, {
134 error => 'zebra_auth_mode_seems_dom'
137 } else {
138 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
139 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
142 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
143 push @xml_config_warnings, {
144 error => 'zebra_auth_index_mode_mismatch_warn'
148 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
149 push @xml_config_warnings, {
150 error => 'zebra_auth_index_mode_mismatch_warn'
154 if ( ! defined C4::Context->config('log4perl_conf') ) {
155 push @xml_config_warnings, {
156 error => 'log4perl_entry_missing'
160 # Test QueryParser configuration sanity
161 if ( C4::Context->preference( 'UseQueryParser' ) ) {
162 # Get the QueryParser configuration file name
163 my $queryparser_file = C4::Context->config( 'queryparser_config' );
164 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
165 # Check QueryParser is functional
166 my $QParser = C4::Context->queryparser();
167 my $queryparser_error = {};
168 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
169 # Error initializing the QueryParser object
170 # Get the used queryparser.yaml file path to report the user
171 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
172 $queryparser_error->{ file } = ( defined $queryparser_file )
173 ? $queryparser_file
174 : $queryparser_fallback_file;
175 # Report error data to the template
176 $template->param( QueryParserError => $queryparser_error );
177 } else {
178 # Check for an absent queryparser_config entry in koha-conf.xml
179 if ( ! defined $queryparser_file ) {
180 # Not an error but a warning for the missing entry in koha-conf-xml
181 push @xml_config_warnings, {
182 error => 'queryparser_entry_missing',
183 file => $queryparser_fallback_file
189 # Test Zebra facets configuration
190 if ( !defined C4::Context->config('use_zebra_facets') ) {
191 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
192 } else {
193 if ( C4::Context->config('use_zebra_facets') &&
194 C4::Context->config('zebra_bib_index_mode') ) {
195 # use_zebra_facets works with DOM
196 push @xml_config_warnings, {
197 error => 'use_zebra_facets_needs_dom'
198 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
202 $template->param(
203 kohaVersion => $kohaVersion,
204 osVersion => $osVersion,
205 perlPath => $perl_path,
206 perlVersion => $perlVersion,
207 perlIncPath => [ map { perlinc => $_ }, @INC ],
208 mysqlVersion => $mysqlVersion,
209 apacheVersion => $apacheVersion,
210 zebraVersion => $zebraVersion,
211 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
212 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
213 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
214 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
215 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
216 errZebraConnection => $errZebraConnection,
217 warnIsRootUser => $warnIsRootUser,
218 warnNoActiveCurrency => $warnNoActiveCurrency,
219 xml_config_warnings => \@xml_config_warnings,
222 my @components = ();
224 my $perl_modules = C4::Installer::PerlModules->new;
225 $perl_modules->version_info;
227 my @pm_types = qw(missing_pm upgrade_pm current_pm);
229 foreach my $pm_type(@pm_types) {
230 my $modules = $perl_modules->get_attr($pm_type);
231 foreach (@$modules) {
232 my ($module, $stats) = each %$_;
233 push(
234 @components,
236 name => $module,
237 version => $stats->{'cur_ver'},
238 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
239 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
240 current => ($pm_type eq 'current_pm' ? 1 : 0),
241 require => $stats->{'required'},
242 reqversion => $stats->{'min_ver'},
248 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
250 my $counter=0;
251 my $row = [];
252 my $table = [];
253 foreach (@components) {
254 push (@$row, $_);
255 unless (++$counter % 4) {
256 push (@$table, {row => $row});
257 $row = [];
260 # Processing the last line (if there are any modules left)
261 if (scalar(@$row) > 0) {
262 # Extending $row to the table size
263 $$row[3] = '';
264 # Pushing the last line
265 push (@$table, {row => $row});
267 ## ## $table
269 $template->param( table => $table );
272 ## ------------------------------------------
273 ## Koha time line code
275 #get file location
276 my $docdir;
277 if ( defined C4::Context->config('docdir') ) {
278 $docdir = C4::Context->config('docdir');
279 } else {
280 # if no <docdir> is defined in koha-conf.xml, use the default location
281 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
282 $docdir = C4::Context->config('intranetdir') . '/docs';
285 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
287 my $i = 0;
289 my @rows2 = ();
290 my $row2 = [];
292 my @lines = <$file>;
293 close($file);
295 shift @lines; #remove header row
297 foreach (@lines) {
298 my ( $date, $desc, $tag ) = split(/\t/);
299 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
300 ($date, $desc)= ($`, $');
302 push(
303 @rows2,
305 date => $date,
306 desc => $desc,
311 my $table2 = [];
312 #foreach my $row2 (@rows2) {
313 foreach (@rows2) {
314 push (@$row2, $_);
315 push( @$table2, { row2 => $row2 } );
316 $row2 = [];
319 $template->param( table2 => $table2 );
320 } else {
321 $template->param( timeline_read_error => 1 );
324 output_html_with_http_headers $query, $cookie, $template->output;