Bug 11937 - opac link doesn't open in new window
[koha.git] / about.pl
blobb9c19832d9c7737b1437ce0819a7124a2ee72070
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 $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 $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
81 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
83 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
85 my $warnIsRootUser = (! $loggedinuser);
87 my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
88 my @xml_config_warnings;
90 my $context = new C4::Context;
92 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
93 push @xml_config_warnings, {
94 error => 'zebra_bib_index_mode_warn'
96 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
97 push @xml_config_warnings, {
98 error => 'zebra_bib_mode_seems_grs1'
101 else {
102 push @xml_config_warnings, {
103 error => 'zebra_bib_mode_seems_dom'
106 } else {
107 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
108 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
111 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
112 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
114 push @xml_config_warnings, {
115 error => 'zebra_bib_index_mode_mismatch_warn'
119 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
120 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
122 push @xml_config_warnings, {
123 error => 'zebra_bib_index_mode_mismatch_warn'
127 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
128 push @xml_config_warnings, {
129 error => 'zebra_auth_index_mode_warn'
131 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
132 push @xml_config_warnings, {
133 error => 'zebra_auth_mode_seems_grs1'
136 else {
137 push @xml_config_warnings, {
138 error => 'zebra_auth_mode_seems_dom'
141 } else {
142 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
143 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
146 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
147 push @xml_config_warnings, {
148 error => 'zebra_auth_index_mode_mismatch_warn'
152 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
153 push @xml_config_warnings, {
154 error => 'zebra_auth_index_mode_mismatch_warn'
158 # Test QueryParser configuration sanity
159 if ( C4::Context->preference( 'UseQueryParser' ) ) {
160 # Get the QueryParser configuration file name
161 my $queryparser_file = C4::Context->config( 'queryparser_config' );
162 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
163 # Check QueryParser is functional
164 my $QParser = C4::Context->queryparser();
165 my $queryparser_error = {};
166 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
167 # Error initializing the QueryParser object
168 # Get the used queryparser.yaml file path to report the user
169 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
170 $queryparser_error->{ file } = ( defined $queryparser_file )
171 ? $queryparser_file
172 : $queryparser_fallback_file;
173 # Report error data to the template
174 $template->param( QueryParserError => $queryparser_error );
175 } else {
176 # Check for an absent queryparser_config entry in koha-conf.xml
177 if ( ! defined $queryparser_file ) {
178 # Not an error but a warning for the missing entry in koha-conf-xml
179 push @xml_config_warnings, {
180 error => 'queryparser_entry_missing',
181 file => $queryparser_fallback_file
187 # Test Zebra facets configuration
188 if ( !defined C4::Context->config('use_zebra_facets') ) {
189 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
190 } else {
191 if ( C4::Context->config('use_zebra_facets') &&
192 C4::Context->config('zebra_bib_index_mode') ) {
193 # use_zebra_facets works with DOM
194 push @xml_config_warnings, {
195 error => 'use_zebra_facets_needs_dom'
196 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
200 # Sco Patron should not contain any other perms than circulate => self_checkout
201 if ( C4::Context->preference('WebBasedSelfCheck')
202 and C4::Context->preference('AutoSelfCheckAllowed')
204 my $userid = C4::Context->preference('AutoSelfCheckID');
205 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
206 my ( $has_self_checkout_perm, $has_other_permissions );
207 while ( my ( $module, $permissions ) = each %$all_permissions ) {
208 if ( $module eq 'circulate' ) {
209 while ( my ( $permission, $flag ) = each %$permissions ) {
210 if ( $permission eq 'self_checkout' ) {
211 $has_self_checkout_perm = 1;
212 } else {
213 $has_other_permissions = 1;
216 } else {
217 $has_other_permissions = 1;
220 $template->param(
221 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
222 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
228 $template->param(
229 kohaVersion => $kohaVersion,
230 osVersion => $osVersion,
231 perlPath => $perl_path,
232 perlVersion => $perlVersion,
233 perlIncPath => [ map { perlinc => $_ }, @INC ],
234 mysqlVersion => $mysqlVersion,
235 apacheVersion => $apacheVersion,
236 zebraVersion => $zebraVersion,
237 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
238 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
239 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
240 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
241 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
242 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
243 errZebraConnection => $errZebraConnection,
244 warnIsRootUser => $warnIsRootUser,
245 warnNoActiveCurrency => $warnNoActiveCurrency,
246 xml_config_warnings => \@xml_config_warnings,
249 my @components = ();
251 my $perl_modules = C4::Installer::PerlModules->new;
252 $perl_modules->version_info;
254 my @pm_types = qw(missing_pm upgrade_pm current_pm);
256 foreach my $pm_type(@pm_types) {
257 my $modules = $perl_modules->get_attr($pm_type);
258 foreach (@$modules) {
259 my ($module, $stats) = each %$_;
260 push(
261 @components,
263 name => $module,
264 version => $stats->{'cur_ver'},
265 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
266 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
267 current => ($pm_type eq 'current_pm' ? 1 : 0),
268 require => $stats->{'required'},
269 reqversion => $stats->{'min_ver'},
275 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
277 my $counter=0;
278 my $row = [];
279 my $table = [];
280 foreach (@components) {
281 push (@$row, $_);
282 unless (++$counter % 4) {
283 push (@$table, {row => $row});
284 $row = [];
287 # Processing the last line (if there are any modules left)
288 if (scalar(@$row) > 0) {
289 # Extending $row to the table size
290 $$row[3] = '';
291 # Pushing the last line
292 push (@$table, {row => $row});
294 ## ## $table
296 $template->param( table => $table );
299 ## ------------------------------------------
300 ## Koha time line code
302 #get file location
303 my $docdir;
304 if ( defined C4::Context->config('docdir') ) {
305 $docdir = C4::Context->config('docdir');
306 } else {
307 # if no <docdir> is defined in koha-conf.xml, use the default location
308 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
309 $docdir = C4::Context->config('intranetdir') . '/docs';
312 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
314 my $i = 0;
316 my @rows2 = ();
317 my $row2 = [];
319 my @lines = <$file>;
320 close($file);
322 shift @lines; #remove header row
324 foreach (@lines) {
325 my ( $date, $desc, $tag ) = split(/\t/);
326 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
327 ($date, $desc)= ($`, $');
329 push(
330 @rows2,
332 date => $date,
333 desc => $desc,
338 my $table2 = [];
339 #foreach my $row2 (@rows2) {
340 foreach (@rows2) {
341 push (@$row2, $_);
342 push( @$table2, { row2 => $row2 } );
343 $row2 = [];
346 $template->param( table2 => $table2 );
347 } else {
348 $template->param( timeline_read_error => 1 );
351 output_html_with_http_headers $query, $cookie, $template->output;