Bug 17744: Remove the oai_dc:dcCollection wrapper in OAI responses
[koha.git] / about.pl
blobfc16079872957c1616d16e9a14c58d6d1a95cf88
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 Modern::Perl;
25 use CGI qw ( -utf8 );
26 use List::MoreUtils qw/ any /;
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::Acquisition::Currencies;
38 use Koha::Patrons;
39 use Koha::Caches;
40 use Koha::Config::SysPrefs;
41 use C4::Members::Statistics;
43 #use Smart::Comments '####';
45 my $query = new CGI;
46 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
48 template_name => "about.tt",
49 query => $query,
50 type => "intranet",
51 authnotrequired => 0,
52 flagsrequired => { catalogue => 1 },
53 debug => 1,
57 my $perl_path = $^X;
58 if ($^O ne 'VMS') {
59 $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
62 my $zebraVersion = `zebraidx -V`;
64 # Check running PSGI env
65 if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
66 $template->param(
67 is_psgi => 1,
68 psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
69 ($ENV{ MOD_PERL }) ? "mod_perl ($ENV{MOD_PERL})" :
70 'Unknown'
74 # Memcached configuration
75 my $memcached_servers = $ENV{MEMCACHED_SERVERS} || C4::Context->config('memcached_servers');
76 my $memcached_namespace = $ENV{MEMCACHED_NAMESPACE} || C4::Context->config('memcached_namespace') // 'koha';
78 my $cache = Koha::Caches->get_instance;
79 my $effective_caching_method = ref($cache->cache);
80 # Memcached may have been running when plack has been initialized but could have been stopped since
81 # FIXME What are the consequences of that??
82 my $is_memcached_still_active = $cache->set_in_cache('test_for_about_page', "just a simple value");
84 my $where_is_memcached_config = 'nowhere';
85 if ( $ENV{MEMCACHED_SERVERS} and C4::Context->config('memcached_servers') ) {
86 $where_is_memcached_config = 'both';
87 } elsif ( $ENV{MEMCACHED_SERVERS} and not C4::Context->config('memcached_servers') ) {
88 $where_is_memcached_config = 'ENV_only';
89 } elsif ( C4::Context->config('memcached_servers') ) {
90 $where_is_memcached_config = 'config_only';
93 $template->param(
94 effective_caching_method => $effective_caching_method,
95 memcached_servers => $memcached_servers,
96 memcached_namespace => $memcached_namespace,
97 is_memcached_still_active => $is_memcached_still_active,
98 where_is_memcached_config => $where_is_memcached_config,
99 memcached_running => Koha::Caches->get_instance->memcached_cache,
102 # Additional system information for warnings
104 my $warnStatisticsFieldsError;
105 my $prefStatisticsFields = C4::Context->preference('StatisticsFields');
106 if ($prefStatisticsFields) {
107 $warnStatisticsFieldsError = $prefStatisticsFields
108 unless ( $prefStatisticsFields eq C4::Members::Statistics->get_fields() );
111 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
112 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
113 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
115 my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
116 my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
117 my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
118 my $warnPrefAnonymousPatron = (
119 C4::Context->preference('OPACPrivacy')
120 and not C4::Context->preference('AnonymousPatron')
123 my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
124 my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
126 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
128 my $warnIsRootUser = (! $loggedinuser);
130 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
131 my @xml_config_warnings;
133 my $context = new C4::Context;
135 if ( ! defined C4::Context->config('zebra_bib_index_mode') ) {
136 push @xml_config_warnings, {
137 error => 'zebra_bib_index_mode_warn'
139 if ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) {
140 push @xml_config_warnings, {
141 error => 'zebra_bib_mode_seems_grs1'
144 else {
145 push @xml_config_warnings, {
146 error => 'zebra_bib_mode_seems_dom'
149 } else {
150 push @xml_config_warnings, { error => 'zebra_bib_grs_warn' }
151 if C4::Context->config('zebra_bib_index_mode') eq 'grs1';
154 if ( (C4::Context->config('zebra_bib_index_mode') eq 'dom') &&
155 ($context->{'server'}->{'biblioserver'}->{'config'} !~ /zebra-biblios-dom.cfg/) ) {
157 push @xml_config_warnings, {
158 error => 'zebra_bib_index_mode_mismatch_warn'
162 if ( (C4::Context->config('zebra_bib_index_mode') eq 'grs1') &&
163 ($context->{'server'}->{'biblioserver'}->{'config'} =~ /zebra-biblios-dom.cfg/) ) {
165 push @xml_config_warnings, {
166 error => 'zebra_bib_index_mode_mismatch_warn'
170 if ( ! defined C4::Context->config('zebra_auth_index_mode') ) {
171 push @xml_config_warnings, {
172 error => 'zebra_auth_index_mode_warn'
174 if ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) {
175 push @xml_config_warnings, {
176 error => 'zebra_auth_mode_seems_grs1'
179 else {
180 push @xml_config_warnings, {
181 error => 'zebra_auth_mode_seems_dom'
184 } else {
185 push @xml_config_warnings, { error => 'zebra_auth_grs_warn' }
186 if C4::Context->config('zebra_auth_index_mode') eq 'grs1';
189 if ( (C4::Context->config('zebra_auth_index_mode') eq 'dom') && ($context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/) ) {
190 push @xml_config_warnings, {
191 error => 'zebra_auth_index_mode_mismatch_warn'
195 if ( (C4::Context->config('zebra_auth_index_mode') eq 'grs1') && ($context->{'server'}->{'authorityserver'}->{'config'} =~ /zebra-authorities-dom.cfg/) ) {
196 push @xml_config_warnings, {
197 error => 'zebra_auth_index_mode_mismatch_warn'
201 if ( ! defined C4::Context->config('log4perl_conf') ) {
202 push @xml_config_warnings, {
203 error => 'log4perl_entry_missing'
207 if ( ! defined C4::Context->config('upload_path') ) {
208 if ( Koha::Config::SysPrefs->find('OPACBaseURL')->value ) {
209 # OPACBaseURL seems to be set
210 push @xml_config_warnings, {
211 error => 'uploadpath_entry_missing'
213 } else {
214 push @xml_config_warnings, {
215 error => 'uploadpath_and_opacbaseurl_entry_missing'
220 # Test QueryParser configuration sanity
221 if ( C4::Context->preference( 'UseQueryParser' ) ) {
222 # Get the QueryParser configuration file name
223 my $queryparser_file = C4::Context->config( 'queryparser_config' );
224 my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml';
225 # Check QueryParser is functional
226 my $QParser = C4::Context->queryparser();
227 my $queryparser_error = {};
228 if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) {
229 # Error initializing the QueryParser object
230 # Get the used queryparser.yaml file path to report the user
231 $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1;
232 $queryparser_error->{ file } = ( defined $queryparser_file )
233 ? $queryparser_file
234 : $queryparser_fallback_file;
235 # Report error data to the template
236 $template->param( QueryParserError => $queryparser_error );
237 } else {
238 # Check for an absent queryparser_config entry in koha-conf.xml
239 if ( ! defined $queryparser_file ) {
240 # Not an error but a warning for the missing entry in koha-conf-xml
241 push @xml_config_warnings, {
242 error => 'queryparser_entry_missing',
243 file => $queryparser_fallback_file
249 # Test Zebra facets configuration
250 if ( !defined C4::Context->config('use_zebra_facets') ) {
251 push @xml_config_warnings, { error => 'use_zebra_facets_entry_missing' };
252 } else {
253 if ( C4::Context->config('use_zebra_facets') &&
254 C4::Context->config('zebra_bib_index_mode') ) {
255 # use_zebra_facets works with DOM
256 push @xml_config_warnings, {
257 error => 'use_zebra_facets_needs_dom'
258 } if C4::Context->config('zebra_bib_index_mode') ne 'dom' ;
262 # Sco Patron should not contain any other perms than circulate => self_checkout
263 if ( C4::Context->preference('WebBasedSelfCheck')
264 and C4::Context->preference('AutoSelfCheckAllowed')
266 my $userid = C4::Context->preference('AutoSelfCheckID');
267 my $all_permissions = C4::Auth::get_user_subpermissions( $userid );
268 my ( $has_self_checkout_perm, $has_other_permissions );
269 while ( my ( $module, $permissions ) = each %$all_permissions ) {
270 if ( $module eq 'circulate' ) {
271 while ( my ( $permission, $flag ) = each %$permissions ) {
272 if ( $permission eq 'self_checkout' ) {
273 $has_self_checkout_perm = 1;
274 } else {
275 $has_other_permissions = 1;
278 } else {
279 $has_other_permissions = 1;
282 $template->param(
283 AutoSelfCheckPatronDoesNotHaveSelfCheckPerm => not ( $has_self_checkout_perm ),
284 AutoSelfCheckPatronHasTooManyPerm => $has_other_permissions,
290 my %versions = C4::Context::get_versions();
292 $template->param(
293 kohaVersion => $versions{'kohaVersion'},
294 osVersion => $versions{'osVersion'},
295 perlPath => $perl_path,
296 perlVersion => $versions{'perlVersion'},
297 perlIncPath => [ map { perlinc => $_ }, @INC ],
298 mysqlVersion => $versions{'mysqlVersion'},
299 apacheVersion => $versions{'apacheVersion'},
300 zebraVersion => $zebraVersion,
301 prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
302 prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
303 warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
304 warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
305 warnPrefAnonymousPatron => $warnPrefAnonymousPatron,
306 warnPrefAnonymousPatron_PatronDoesNotExist => $warnPrefAnonymousPatron_PatronDoesNotExist,
307 errZebraConnection => $errZebraConnection,
308 warnIsRootUser => $warnIsRootUser,
309 warnNoActiveCurrency => $warnNoActiveCurrency,
310 xml_config_warnings => \@xml_config_warnings,
311 warnStatisticsFieldsError => $warnStatisticsFieldsError,
314 my @components = ();
316 my $perl_modules = C4::Installer::PerlModules->new;
317 $perl_modules->version_info;
319 my @pm_types = qw(missing_pm upgrade_pm current_pm);
321 foreach my $pm_type(@pm_types) {
322 my $modules = $perl_modules->get_attr($pm_type);
323 foreach (@$modules) {
324 my ($module, $stats) = each %$_;
325 push(
326 @components,
328 name => $module,
329 version => $stats->{'cur_ver'},
330 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
331 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
332 current => ($pm_type eq 'current_pm' ? 1 : 0),
333 require => $stats->{'required'},
334 reqversion => $stats->{'min_ver'},
340 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
342 my $counter=0;
343 my $row = [];
344 my $table = [];
345 foreach (@components) {
346 push (@$row, $_);
347 unless (++$counter % 4) {
348 push (@$table, {row => $row});
349 $row = [];
352 # Processing the last line (if there are any modules left)
353 if (scalar(@$row) > 0) {
354 # Extending $row to the table size
355 $$row[3] = '';
356 # Pushing the last line
357 push (@$table, {row => $row});
359 ## ## $table
361 $template->param( table => $table );
364 ## ------------------------------------------
365 ## Koha time line code
367 #get file location
368 my $docdir;
369 if ( defined C4::Context->config('docdir') ) {
370 $docdir = C4::Context->config('docdir');
371 } else {
372 # if no <docdir> is defined in koha-conf.xml, use the default location
373 # this is a work-around to stop breakage on upgraded Kohas, bug 8911
374 $docdir = C4::Context->config('intranetdir') . '/docs';
377 if ( open( my $file, "<:encoding(UTF-8)", "$docdir" . "/history.txt" ) ) {
379 my $i = 0;
381 my @rows2 = ();
382 my $row2 = [];
384 my @lines = <$file>;
385 close($file);
387 shift @lines; #remove header row
389 foreach (@lines) {
390 my ( $date, $desc, $tag ) = split(/\t/);
391 if(!$desc && $date=~ /(?<=\d{4})\s+/) {
392 ($date, $desc)= ($`, $');
394 push(
395 @rows2,
397 date => $date,
398 desc => $desc,
403 my $table2 = [];
404 #foreach my $row2 (@rows2) {
405 foreach (@rows2) {
406 push (@$row2, $_);
407 push( @$table2, { row2 => $row2 } );
408 $row2 = [];
411 $template->param( table2 => $table2 );
412 } else {
413 $template->param( timeline_read_error => 1 );
416 output_html_with_http_headers $query, $cookie, $template->output;