Bug 14098: FIX Copy a subfield should not update the original field
[koha.git] / about.pl
blob29777cf5cfa46adc004e001a4000147f2c133176
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::Config::SysPrefs;
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 $kohaVersion = Koha::version();
54 my $osVersion = `uname -a`;
55 my $perl_path = $^X;
56 if ($^O ne 'VMS') {
57 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
59 my $perlVersion = $];
60 my $mysqlVersion = `mysql -V`;
61 # Get Apache version
62 my $apacheVersion = (`apache2ctl -v`)[0];
63 $apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
64 $apacheVersion = `httpd -v 2> /dev/null` unless $apacheVersion;
65 my $zebraVersion = `zebraidx -V`;
67 # Additional system information for warnings
68 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
69 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
70 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
72 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
73 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
74 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
75 my $warnPrefAnonymousPatron = (
76 C4::Context->preference('OPACPrivacy')
77 and not C4::Context->preference('AnonymousPatron')
80 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
82 my $warnIsRootUser = (! $loggedinuser);
84 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
85 my @xml_config_warnings;
87 my $context = new C4::Context;
89 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
90 push @xml_config_warnings, {
91 error => 'zebra_bib_index_mode_warn'
93 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
94 push @xml_config_warnings, {
95 error => 'zebra_bib_mode_seems_grs1'
98 else {
99 push @xml_config_warnings, {
100 error => 'zebra_bib_mode_seems_dom'
103 } else {
104 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
105 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
108 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
109 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
111 push @xml_config_warnings, {
112 error => 'zebra_bib_index_mode_mismatch_warn'
116 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
117 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
119 push @xml_config_warnings, {
120 error => 'zebra_bib_index_mode_mismatch_warn'
124 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
125 push @xml_config_warnings, {
126 error => 'zebra_auth_index_mode_warn'
128 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
129 push @xml_config_warnings, {
130 error => 'zebra_auth_mode_seems_grs1'
133 else {
134 push @xml_config_warnings, {
135 error => 'zebra_auth_mode_seems_dom'
138 } else {
139 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
140 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
143 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
144 push @xml_config_warnings, {
145 error => 'zebra_auth_index_mode_mismatch_warn'
149 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
150 push @xml_config_warnings, {
151 error => 'zebra_auth_index_mode_mismatch_warn'
155 if ( ! defined C4::Context->config('log4perl_conf') ) {
156 push @xml_config_warnings, {
157 error => 'log4perl_entry_missing'
161 if ( ! defined C4::Context->config('upload_path') ) {
162 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
163 # OPACBaseURL seems to be set
164 push @xml_config_warnings, {
165 error => 'uploadpath_entry_missing'
167 } else {
168 push @xml_config_warnings, {
169 error => 'uploadpath_and_opacbaseurl_entry_missing'
174 # Test QueryParser configuration sanity
175 if ( C4::Context->preference( 'UseQueryParser' ) ) {
176 # Get the QueryParser configuration file name
177 my $queryparser_file = C4::Context->config( 'queryparser_config' );
178 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
179 # Check QueryParser is functional
180 my $QParser = C4::Context->queryparser();
181 my $queryparser_error = {};
182 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
183 # Error initializing the QueryParser object
184 # Get the used queryparser.yaml file path to report the user
185 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
186 $queryparser_error->{ file } = ( defined $queryparser_file )
187 ? $queryparser_file
188 : $queryparser_fallback_file;
189 # Report error data to the template
190 $template->param( QueryParserError => $queryparser_error );
191 } else {
192 # Check for an absent queryparser_config entry in koha-conf.xml
193 if ( ! defined $queryparser_file ) {
194 # Not an error but a warning for the missing entry in koha-conf-xml
195 push @xml_config_warnings, {
196 error => 'queryparser_entry_missing',
197 file => $queryparser_fallback_file
203 # Test Zebra facets configuration
204 if ( !defined C4::Context->config('use_zebra_facets') ) {
205 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
206 } else {
207 if ( C4::Context->config('use_zebra_facets') &&
208 C4::Context->config('zebra_bib_index_mode') ) {
209 # use_zebra_facets works with DOM
210 push @xml_config_warnings, {
211 error => 'use_zebra_facets_needs_dom'
212 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
216 $template->param(
217 kohaVersion => $kohaVersion,
218 osVersion => $osVersion,
219 perlPath => $perl_path,
220 perlVersion => $perlVersion,
221 perlIncPath => [ map { perlinc => $_ }, @INC ],
222 mysqlVersion => $mysqlVersion,
223 apacheVersion => $apacheVersion,
224 zebraVersion => $zebraVersion,
225 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
226 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
227 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
228 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
229 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
230 errZebraConnection => $errZebraConnection,
231 warnIsRootUser => $warnIsRootUser,
232 warnNoActiveCurrency => $warnNoActiveCurrency,
233 xml_config_warnings => \@xml_config_warnings,
236 my @components = ();
238 my $perl_modules = C4::Installer::PerlModules->new;
239 $perl_modules->version_info;
241 my @pm_types = qw(missing_pm upgrade_pm current_pm);
243 foreach my $pm_type(@pm_types) {
244 my $modules = $perl_modules->get_attr($pm_type);
245 foreach (@$modules) {
246 my ($module, $stats) = each %$_;
247 push(
248 @components,
250 name => $module,
251 version => $stats->{'cur_ver'},
252 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
253 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
254 current => ($pm_type eq 'current_pm' ? 1 : 0),
255 require => $stats->{'required'},
256 reqversion => $stats->{'min_ver'},
262 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
264 my $counter=0;
265 my $row = [];
266 my $table = [];
267 foreach (@components) {
268 push (@$row, $_);
269 unless (++$counter % 4) {
270 push (@$table, {row => $row});
271 $row = [];
274 # Processing the last line (if there are any modules left)
275 if (scalar(@$row) > 0) {
276 # Extending $row to the table size
277 $$row[3] = '';
278 # Pushing the last line
279 push (@$table, {row => $row});
281 ## ## $table
283 $template->param( table => $table );
286 ## ------------------------------------------
287 ## Koha time line code
289 #get file location
290 my $docdir;
291 if ( defined C4::Context->config('docdir') ) {
292 $docdir = C4::Context->config('docdir');
293 } else {
294 # if no <docdir> is defined in koha-conf.xml, use the default location
295 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
296 $docdir = C4::Context->config('intranetdir') . '/docs';
299 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
301 my $i = 0;
303 my @rows2 = ();
304 my $row2 = [];
306 my @lines = <$file>;
307 close($file);
309 shift @lines; #remove header row
311 foreach (@lines) {
312 my ( $date, $desc, $tag ) = split(/\t/);
313 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
314 ($date, $desc)= ($`, $');
316 push(
317 @rows2,
319 date => $date,
320 desc => $desc,
325 my $table2 = [];
326 #foreach my $row2 (@rows2) {
327 foreach (@rows2) {
328 push (@$row2, $_);
329 push( @$table2, { row2 => $row2 } );
330 $row2 = [];
333 $template->param( table2 => $table2 );
334 } else {
335 $template->param( timeline_read_error => 1 );
338 output_html_with_http_headers $query, $cookie, $template->output;