# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-use warnings;
+use Modern::Perl;
use diagnostics;
use C4::InstallAuth;
use C4::Templates;
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
use C4::Installer;
+use C4::Installer::PerlModules;
use Koha;
-my $query = new CGI;
+my $query = CGI->new;
my $step = $query->param('step');
my $language = $query->param('language');
template_name => "installer/step" . ( $step ? $step : 1 ) . ".tt",
query => $query,
type => "intranet",
- authnotrequired => 0,
debug => 1,
}
);
#Whenever there is an error, adding a report to the page
my $op = $query->param('op') || 'noop';
$template->param( language => 1 );
+ my $checkmodule = 1;
$template->param( 'checkmodule' => 1 )
; # we start with the assumption that there are no problems and set this to 0 if there are
unless ( $] >= 5.010000 ) { # Bug 7375
$template->param( problems => 1, perlversion => 1, checkmodule => 0 );
+ $checkmodule = 0;
}
my $perl_modules = C4::Installer::PerlModules->new;
$perl_modules->versions_info;
- my $modules = $perl_modules->get_attr('missing_pm');
- if ( scalar(@$modules) ) {
- my @components = ();
- my $checkmodule = 1;
- foreach (@$modules) {
+ my $missing_modules = $perl_modules->get_attr('missing_pm');
+ my $upgrade_modules = $perl_modules->get_attr('upgrade_pm');
+ if ( scalar(@$missing_modules) || scalar(@$upgrade_modules) ) {
+ my @missing = ();
+ my @upgrade = ();
+ foreach (@$missing_modules) {
my ( $module, $stats ) = each %$_;
$checkmodule = 0 if $stats->{'required'};
push(
- @components,
+ @missing,
{
name => $module,
- version => $stats->{'min_ver'},
- require => $stats->{'required'},
- usage => $stats->{'usage'},
+ min_version => $stats->{'min_ver'},
+ max_version => $stats->{'max_ver'},
+ require => $stats->{'required'}
}
);
}
- @components = sort { $a->{'name'} cmp $b->{'name'} } @components;
+ foreach (@$upgrade_modules) {
+ my ( $module, $stats ) = each %$_;
+ $checkmodule = 0 if $stats->{'required'};
+ push(
+ @upgrade,
+ {
+ name => $module,
+ min_version => $stats->{'min_ver'},
+ max_version => $stats->{'max_ver'},
+ require => $stats->{'required'}
+ }
+ );
+ }
+ @missing = sort { $a->{'name'} cmp $b->{'name'} } @missing;
+ @upgrade = sort { $a->{'name'} cmp $b->{'name'} } @upgrade;
$template->param(
- missing_modules => \@components,
+ missing_modules => \@missing,
+ upgrade_modules => \@upgrade,
checkmodule => $checkmodule,
op => $op
);
$template->param( 'checkdatabasecreated' => 1 );
}
- #Check if user have all necessary grants on this database.
- my $rq =
- $dbh->prepare(
- "SHOW GRANTS FOR \'$info{user}\'\@'$info{hostname}'");
+ # Check if user have all necessary grants on this database.
+ # CURRENT_USER is ANSI SQL, and doesn't require mysql table
+ # privileges, making the % check pointless, since they
+ # couldn't even check GRANTS if they couldn't connect.
+ my $rq = $dbh->prepare('SHOW GRANTS FOR CURRENT_USER');
$rq->execute;
my $grantaccess;
while ( my ($line) = $rq->fetchrow ) {
);
}
}
- unless ($grantaccess) {
- $rq =
- $dbh->prepare("SHOW GRANTS FOR \'$info{user}\'\@'\%'");
- $rq->execute;
- while ( my ($line) = $rq->fetchrow ) {
- my $dbname = $info{dbname};
- if ( $line =~ m/$dbname/ || index( $line, '*.*' ) > 0 )
- {
- $grantaccess = 1
- if (
- index( $line, 'ALL PRIVILEGES' ) > 0
- || ( ( index( $line, 'SELECT' ) > 0 )
- && ( index( $line, 'INSERT' ) > 0 )
- && ( index( $line, 'UPDATE' ) > 0 )
- && ( index( $line, 'DELETE' ) > 0 )
- && ( index( $line, 'CREATE' ) > 0 )
- && ( index( $line, 'DROP' ) > 0 ) )
- );
- }
- }
- }
$template->param( "checkgrantaccess" => $grantaccess );
} # End mysql connect check...
my $op = $query->param('op');
if ( $op && $op eq 'finished' ) {
- #
+ # Remove the HandleError set at the beginning of the installer process
+ C4::Context->dbh->disconnect;
+
# we have finished, just redirect to mainpage.
- #
print $query->redirect("/cgi-bin/koha/mainpage.pl");
exit;
}
elsif ( $op && $op eq 'finish' ) {
$installer->set_version_syspref();
+ my $langchoice = $query->param('fwklanguage');
+ $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice);
+ $langchoice =~ s/[^a-zA-Z_-]*//g;
+ $installer->set_languages_syspref($langchoice);
+
# Installation is finished.
# We just deny anybody access to install
# And we redirect people to mainpage.
elsif ( $op && $op eq 'addframeworks' ) {
# 1ST install, 3rd sub-step : insert the SQL files the user has selected
+ my $langchoice = $query->param('fwklanguage');
+ $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice);
+ $langchoice =~ s/[^a-zA-Z_-]*//g;
my ( $fwk_language, $list ) =
- $installer->load_sql_in_order( $all_languages,
- $query->param('framework') );
+ $installer->load_sql_in_order( $langchoice, $all_languages,
+ $query->multi_param('framework') );
$template->param(
"fwklanguage" => $fwk_language,
"list" => $list
# Where <level> is a category of requirement : required, recommended optional
# level should contain :
# SQL File for import With a readable name.
-# txt File taht explains what this SQL File is meant for.
+# txt File that explains what this SQL File is meant for.
# Could be VERY useful to have A Big file for a kind of library.
# But could also be useful to have some Authorised values data set prepared here.
# Marcflavour Selection is achieved through radiobuttons.
system($cmd );
my $fh;
- open( $fh, "<", $logfilepath )
+ open( $fh, "<:encoding(utf-8)", $logfilepath )
or die "Cannot open log file $logfilepath: $!";
my @report = <$fh>;
close $fh;
if (@report) {
$template->param( update_report =>
- [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ]
+ [ map { { line => $_ =~ s/\t/  /gr } } split( /\n/, join( '', @report ) ) ]
);
$template->param( has_update_succeeds => 1 );
}
else {
eval { `rm $logfilepath` };
}
- open( $fh, "<", $logfilepath_errors )
+ open( $fh, "<:encoding(utf-8)", $logfilepath_errors )
or die "Cannot open log file $logfilepath_errors: $!";
@report = <$fh>;
close $fh;