X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/d707f7ac60b9dbe7da50d733db1e73eae84952f7..05fd99ac835a9ffa6b1fefc768b460f207e6f578:/SL/User.pm diff --git a/SL/User.pm b/SL/User.pm index 212175aac..d95a0674f 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -34,6 +34,8 @@ package User; +#use strict; + use IO::File; use Fcntl qw(:seek); @@ -92,6 +94,7 @@ sub login { $main::lxdebug->enter_sub(); my ($self, $form) = @_; + our $sid; local *FH; @@ -145,7 +148,12 @@ sub login { } # update the tables - open(FH, ">$main::userspath/nologin") or die("$!"); + if (!open(FH, ">$main::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), + 'back_button' => 1); + } # required for Oracle $form->{dbdefault} = $sid; @@ -311,6 +319,25 @@ sub dbsources { return @dbsources; } +sub dbclusterencoding { + $main::lxdebug->enter_sub(); + + my ($self, $form) = @_; + + $form->{dbdefault} ||= $form->{dbuser}; + + dbconnect_vars($form, $form->{dbdefault}); + + my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) || $form->dberror(); + my $query = qq|SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'template0'|; + my ($cluster_encoding) = $dbh->selectrow_array($query); + $dbh->disconnect(); + + $main::lxdebug->leave_sub(); + + return $cluster_encoding; +} + sub dbcreate { $main::lxdebug->enter_sub(); @@ -344,7 +371,8 @@ sub dbcreate { my $query = $dbcreate{$form->{dbdriver}}; $query .= " WITH " . join(" ", @{$dboptions{"Pg"}}) if (@{$dboptions{"Pg"}}); - do_query($form, $dbh, $query); + # Ignore errors if the database exists. + $dbh->do($query); if ($form->{dbdriver} eq 'Oracle') { $query = qq|GRANT CONNECT, RESOURCE TO "$form->{db}"|; @@ -655,8 +683,8 @@ sub cmp_script_version { $my_a =~ s/.sql$//; $my_b =~ s/.*-upgrade-//; $my_b =~ s/.sql$//; - ($my_a_from, $my_a_to) = split(/-/, $my_a); - ($my_b_from, $my_b_to) = split(/-/, $my_b); + my ($my_a_from, $my_a_to) = split(/-/, $my_a); + my ($my_b_from, $my_b_to) = split(/-/, $my_b); $res_a = calc_version($my_a_from); $res_b = calc_version($my_b_from); @@ -767,7 +795,7 @@ sub dbupdate { last if ($version < $mindb); # apply upgrade - $main::lxdebug->message(DEBUG2, "Applying Update $upgradescript"); + $main::lxdebug->message(LXDebug::DEBUG2, "Applying Update $upgradescript"); if ($file_type eq "sql") { $self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb, $db_charset); @@ -851,7 +879,7 @@ sub dbupdate2 { my $file_type = $1; # apply upgrade - $main::lxdebug->message(DEBUG2, "Applying Update $control->{file}"); + $main::lxdebug->message(LXDebug::DEBUG2, "Applying Update $control->{file}"); print $form->parse_html_template("dbupgrade/upgrade_message2", $control); if ($file_type eq "sql") { @@ -909,6 +937,7 @@ sub save_member { $main::lxdebug->enter_sub(); my ($self) = @_; + my $form = \%main::form; # format dbconnect and dboptions string dbconnect_vars($self, $self->{dbname}); @@ -939,7 +968,7 @@ sub create_employee_entry { my ($login) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); if (!$login) { - $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|; + my $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|; do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel}, "user")); } @@ -949,7 +978,7 @@ sub create_employee_entry { sub config_vars { $main::lxdebug->enter_sub(); - my @conf = qw(acs address admin businessnumber company countrycode + my @conf = qw(address admin businessnumber company countrycode currency dateformat dbconnect dbdriver dbhost dbport dboptions dbname dbuser dbpasswd email fax name numberformat password printer role sid signature stylesheet tel templates vclimit angebote