X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/1c7afd9ee2b5d6233302774c6a69a154a3de29fa..722fee3c7224fa0b1222b9f5134e2c19dc021c64:/SL/User.pm diff --git a/SL/User.pm b/SL/User.pm index f5afb553f..d51b1edd1 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -92,95 +92,79 @@ sub country_codes { } sub login { - $main::lxdebug->enter_sub(); - my ($self, $form) = @_; our $sid; - local *FH; - - my $rc = -3; + return -3 if !$self->{login} || !$::auth->client; - if ($self->{login}) { - my %myconfig = $main::auth->read_user(login => $self->{login}); + my %myconfig = $main::auth->read_user(login => $self->{login}); - # check if database is down - my $dbh = SL::DBConnect->connect($myconfig{dbconnect}, $myconfig{dbuser}, $myconfig{dbpasswd}, SL::DBConnect->get_options) - or $self->error($DBI::errstr); - - # we got a connection, check the version - my $query = qq|SELECT version FROM defaults|; - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + # check if database is down + my $dbh = $form->dbconnect_noauto; - my ($dbversion) = $sth->fetchrow_array; - $sth->finish; + # we got a connection, check the version + my $query = qq|SELECT version FROM defaults|; + my $sth = $dbh->prepare($query); + $sth->execute || $form->dberror($query); - $self->create_employee_entry($form, $dbh, \%myconfig); + my ($dbversion) = $sth->fetchrow_array; + $sth->finish; - $self->create_schema_info_table($form, $dbh); + $self->create_employee_entry($form, $dbh, \%myconfig); - my $dbupdater_auth = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg', auth => 1)->parse_dbupdate_controls; - if ($dbupdater_auth->unapplied_upgrade_scripts($::auth->dbconnect)) { - $::lxdebug->leave_sub; - return -3; - } + $self->create_schema_info_table($form, $dbh); - $rc = 0; + # Auth DB upgrades available? + my $dbupdater_auth = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg', auth => 1)->parse_dbupdate_controls; + return -3 if $dbupdater_auth->unapplied_upgrade_scripts($::auth->dbconnect); - my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $myconfig{dbdriver})->parse_dbupdate_controls; + my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $myconfig{dbdriver})->parse_dbupdate_controls; - map({ $form->{$_} = $myconfig{$_} } qw(dbname dbhost dbport dbdriver dbuser dbpasswd dbconnect dateformat)); - dbconnect_vars($form, $form->{dbname}); - my $update_available = $dbupdater->update_available($dbversion) || $dbupdater->update2_available($dbh); - $dbh->disconnect; + $form->{$_} = $::auth->client->{$_} for qw(dbname dbhost dbport dbuser dbpasswd); + $form->{$_} = $myconfig{$_} for qw(dateformat); - if ($update_available) { - $form->{"title"} = $main::locale->text("Dataset upgrade"); - $form->header(no_layout => $form->{no_layout}); - print $form->parse_html_template("dbupgrade/header"); + dbconnect_vars($form, $form->{dbname}); - $form->{dbupdate} = "db$myconfig{dbname}"; - $form->{ $form->{dbupdate} } = 1; + my $update_available = $dbupdater->update_available($dbversion) || $dbupdater->update2_available($dbh); + $dbh->disconnect; - if ($form->{"show_dbupdate_warning"}) { - print $form->parse_html_template("dbupgrade/warning"); - ::end_of_request(); - } + return 0 if !$update_available; + $form->{"title"} = $main::locale->text("Dataset upgrade"); + $form->header(no_layout => $form->{no_layout}); + print $form->parse_html_template("dbupgrade/header"); - # update the tables - if (!$::lx_office_conf{debug}->{keep_installation_unlocked} && !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.', - $::lx_office_conf{paths}->{userspath}), - 'back_button' => 1); - } + $form->{dbupdate} = "db" . $form->{dbname}; - # required for Oracle - $form->{dbdefault} = $sid; + if ($form->{"show_dbupdate_warning"}) { + print $form->parse_html_template("dbupgrade/warning"); + ::end_of_request(); + } - # ignore HUP, QUIT in case the webserver times out - $SIG{HUP} = 'IGNORE'; - $SIG{QUIT} = 'IGNORE'; + # update the tables + my $fh; + if (!$::lx_office_conf{debug}->{keep_installation_unlocked} && !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.', + $::lx_office_conf{paths}->{userspath}), + 'back_button' => 1); + } - $self->dbupdate($form); - $self->dbupdate2($form, $dbupdater); - SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(0); + # ignore HUP, QUIT in case the webserver times out + $SIG{HUP} = 'IGNORE'; + $SIG{QUIT} = 'IGNORE'; - close(FH); + $self->dbupdate($form); + $self->dbupdate2($form, $dbupdater); + SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(0); - # remove lock file - unlink($::lx_office_conf{paths}->{userspath} . "/nologin"); + close($fh); - print $form->parse_html_template("dbupgrade/footer"); + # remove lock file + unlink($::lx_office_conf{paths}->{userspath} . "/nologin"); - $rc = -2; - } - } + print $form->parse_html_template("dbupgrade/footer"); - $main::lxdebug->leave_sub(); - - return $rc; + return -2; } sub dbconnect_vars { @@ -749,30 +733,6 @@ sub config_vars { return @conf; } -sub error { - $main::lxdebug->enter_sub(); - - my ($self, $msg) = @_; - - $main::lxdebug->show_backtrace(); - - if ($ENV{HTTP_USER_AGENT}) { - print qq|Content-Type: text/html - - - -
- -$msg|; - - } - - die "Error: $msg\n"; - - $main::lxdebug->leave_sub(); -} - sub data { +{ %{ $_[0] } } }