X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUser.pm;h=520bf422959e316d965ab4c70b0913fe506bca1e;hb=89c9ff022d3f13e27ba6bda085df15707fcfb0eb;hp=e1ec6ef49654176089b55966784130bcf2a12943;hpb=38a2e7894debd7bc5787e74129f8f6f4e74ed2dc;p=kivitendo-erp.git diff --git a/SL/User.pm b/SL/User.pm index e1ec6ef49..520bf4229 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -145,10 +145,10 @@ sub login { } # update the tables - if (!open(FH, ">$main::userspath/nologin")) { + if (!open(FH, ">" . $::lx_office_conf{paths}->{userspath} . "/nologin")) { $form->show_generic_error($main::locale->text('A temporary file could not be created. ' . 'Please verify that the directory "#1" is writeable by the webserver.', - $main::userspath), + $::lx_office_conf{paths}->{userspath}), 'back_button' => 1); } @@ -161,11 +161,12 @@ sub login { $self->dbupdate($form); $self->dbupdate2($form, $dbupdater); + SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(0); close(FH); # remove lock file - unlink("$main::userspath/nologin"); + unlink($::lx_office_conf{paths}->{userspath} . "/nologin"); my $menufile = $self->{"menustyle"} eq "v3" ? "menuv3.pl" : @@ -177,7 +178,6 @@ sub login { print $form->parse_html_template("dbupgrade/footer", { "menufile" => $menufile }); $rc = -2; - } } @@ -581,7 +581,7 @@ sub dbupdate { closedir(SQLDIR); } - my $db_charset = $main::dbcharset; + my $db_charset = $::lx_office_conf{system}->{dbcharset}; $db_charset ||= Common::DEFAULT_CHARSET; my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver}); @@ -647,59 +647,29 @@ sub dbupdate2 { $form->{sid} = $form->{dbdefault}; - my @upgradescripts = (); - my ($query, $sth, $tag); - my $rc = -2; + my $rc = -2; + my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET; - @upgradescripts = $dbupdater->sort_dbupdate_controls; - - my $db_charset = $main::dbcharset; - $db_charset ||= Common::DEFAULT_CHARSET; + map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $dbupdater->{all_controls} }; foreach my $db (split / /, $form->{dbupdate}) { - next unless $form->{$db}; # strip db from dataset $db =~ s/^db//; &dbconnect_vars($form, $db); - my $dbh = - DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) - or $form->dberror; + my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) or $form->dberror; $dbh->do($form->{dboptions}) if ($form->{dboptions}); - map({ $_->{"applied"} = 0; } @upgradescripts); - $self->create_schema_info_table($form, $dbh); - $query = qq|SELECT tag FROM schema_info|; - $sth = $dbh->prepare($query); - $sth->execute() || $form->dberror($query); - while (($tag) = $sth->fetchrow_array()) { - $dbupdater->{all_controls}->{$tag}->{"applied"} = 1 if (defined($dbupdater->{all_controls}->{$tag})); - } - $sth->finish(); - - my $all_applied = 1; - foreach (@upgradescripts) { - if (!$_->{"applied"}) { - $all_applied = 0; - last; - } - } + my @upgradescripts = $dbupdater->unapplied_upgrade_scripts($dbh); - next if ($all_applied); + $dbh->disconnect and next if !@upgradescripts; foreach my $control (@upgradescripts) { - next if ($control->{"applied"}); - - $control->{description} = SL::Iconv::convert($control->{charset}, $db_charset, $control->{description}); - - $control->{"file"} =~ /\.(sql|pl)$/; - my $file_type = $1; - # apply upgrade $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $form->parse_html_template("dbupgrade/upgrade_message2", $control);