Bug 10742: improve converting simple search to Z39.50 search
[koha.git] / about.pl
1 #!/usr/bin/perl
2
3 # Copyright Pat Eyler 2003
4 # Copyright Biblibre 2006
5 # Parts Copyright Liblime 2008
6 # Parts Copyright Chris Nighswonger 2010
7 #
8 # This file is part of Koha.
9 #
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.
14 #
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.
18 #
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.
22
23 use strict;
24 use warnings;
25
26 use CGI;
27 use LWP::Simple;
28 use XML::Simple;
29 use Config;
30
31 use C4::Output;
32 use C4::Auth;
33 use C4::Context;
34 use C4::Installer;
35
36 #use Smart::Comments '####';
37
38 my $query = new CGI;
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40     {
41         template_name   => "about.tmpl",
42         query           => $query,
43         type            => "intranet",
44         authnotrequired => 0,
45         flagsrequired   => { catalogue => 1 },
46         debug           => 1,
47     }
48 );
49
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;
55 }
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`;
62
63 # Additional system information for warnings
64 my $prefNoZebra = C4::Context->preference('nozebra');
65 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
66 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
67 my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
68
69 my $prefEasyAnalyticalRecords  = C4::Context->preference('EasyAnalyticalRecords');
70 my $prefUseControlNumber  = C4::Context->preference('UseControlNumber');
71 my $warnPrefEasyAnalyticalRecords  = ( $prefEasyAnalyticalRecords  && $prefUseControlNumber );
72
73 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
74
75 my $warnIsRootUser   = (! $loggedinuser);
76
77 $template->param(
78     kohaVersion   => $kohaVersion,
79     osVersion     => $osVersion,
80     perlPath      => $perl_path,
81     perlVersion   => $perlVersion,
82     perlIncPath   => [ map { perlinc => $_ }, @INC ],
83     mysqlVersion  => $mysqlVersion,
84     apacheVersion => $apacheVersion,
85     zebraVersion  => $zebraVersion,
86     prefNoZebra   => $prefNoZebra,
87     prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
88     prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
89     warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
90     warnPrefEasyAnalyticalRecords  => $warnPrefEasyAnalyticalRecords,
91     errZebraConnection => $errZebraConnection,
92     warnIsRootUser => $warnIsRootUser,
93 );
94
95 my @components = ();
96
97 my $perl_modules = C4::Installer::PerlModules->new;
98 $perl_modules->version_info;
99
100 my @pm_types = qw(missing_pm upgrade_pm current_pm);
101
102 foreach my $pm_type(@pm_types) {
103     my $modules = $perl_modules->get_attr($pm_type);
104     foreach (@$modules) {
105         my ($module, $stats) = each %$_;
106         push(
107             @components,
108             {
109                 name    => $module,
110                 version => $stats->{'cur_ver'},
111                 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
112                 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
113                 current => ($pm_type eq 'current_pm' ? 1 : 0),
114                 require => $stats->{'required'},
115             }
116         );
117     }
118 }
119
120 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
121
122 my $counter=0;
123 my $row = [];
124 my $table = [];
125 foreach (@components) {
126     push (@$row, $_);
127     unless (++$counter % 4) {
128         push (@$table, {row => $row});
129         $row = [];
130     }
131 }
132 # Processing the last line (if there are any modules left)
133 if (scalar(@$row) > 0) {
134     # Extending $row to the table size
135     $$row[3] = '';
136     # Pushing the last line
137     push (@$table, {row => $row});
138 }
139 ## ## $table
140
141 $template->param( table => $table );
142
143
144 ## ------------------------------------------
145 ## Koha time line code
146
147 #get file location
148 my $docdir;
149 if ( defined C4::Context->config('docdir') ) {
150     $docdir = C4::Context->config('docdir');
151 } else {
152     # if no <docdir> is defined in koha-conf.xml, use the default location
153     # this is a work-around to stop breakage on upgraded Kohas, bug 8911
154     $docdir = C4::Context->config('intranetdir') . '/docs';
155 }
156
157 if ( open( my $file, "<", "$docdir" . "/history.txt" ) ) {
158
159     my $i = 0;
160
161     my @rows2 = ();
162     my $row2  = [];
163
164     my @lines = <$file>;
165     close($file);
166
167     shift @lines; #remove header row
168
169     foreach (@lines) {
170         my ( $date, $desc, $tag ) = split(/\t/);
171         if(!$desc && $date=~ /(?<=\d{4})\s+/) {
172             ($date, $desc)= ($`, $');
173         }
174         push(
175             @rows2,
176             {
177                 date => $date,
178                 desc => $desc,
179             }
180         );
181     }
182
183     my $table2 = [];
184     #foreach my $row2 (@rows2) {
185     foreach  (@rows2) {
186         push (@$row2, $_);
187         push( @$table2, { row2 => $row2 } );
188         $row2 = [];
189     }
190
191     $template->param( table2 => $table2 );
192 } else {
193     $template->param( timeline_read_error => 1 );
194 }
195
196 output_html_with_http_headers $query, $cookie, $template->output;