X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUser.pm;h=102b9382e0a2aa8af6de95c6cd6c70fc00dca045;hb=684e84d8b410627473b2187c031f0d9143ea1a60;hp=d95a0674fd58729f40b9066c21d16ae818bbf369;hpb=05fd99ac835a9ffa6b1fefc768b460f207e6f578;p=kivitendo-erp.git diff --git a/SL/User.pm b/SL/User.pm index d95a0674f..102b9382e 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -39,7 +39,7 @@ package User; use IO::File; use Fcntl qw(:seek); -use SL::Auth; +#use SL::Auth; use SL::DBUpgrade2; use SL::DBUtils; use SL::Iconv; @@ -173,6 +173,7 @@ sub login { my $menufile = $self->{"menustyle"} eq "v3" ? "menuv3.pl" : $self->{"menustyle"} eq "neu" ? "menunew.pl" : + $self->{"menustyle"} eq "js" ? "menujs.pl" : $self->{"menustyle"} eq "xml" ? "menuXML.pl" : "menu.pl"; @@ -553,6 +554,12 @@ sub process_query { $query .= $char; } } + + # Insert a space at the end of each line so that queries split + # over multiple lines work properly. + if ($query ne '') { + $query .= @quote_chars ? "\n" : ' '; + } } if (ref($version_or_control) eq "HASH") { @@ -948,7 +955,7 @@ sub save_member { my $dbh = DBI->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd}); if ($dbh) { - $self->create_employee_entry($form, $dbh, $self); + $self->create_employee_entry($form, $dbh, $self, 1); $dbh->disconnect(); } @@ -958,18 +965,28 @@ sub save_member { sub create_employee_entry { $main::lxdebug->enter_sub(); - my $self = shift; - my $form = shift; - my $dbh = shift; - my $myconfig = shift; + my $self = shift; + my $form = shift; + my $dbh = shift; + my $myconfig = shift; + my $update_existing = shift; + + if (!does_table_exist($dbh, 'employee')) { + $main::lxdebug->leave_sub(); + return; + } # add login to employee table if it does not exist # no error check for employee table, ignore if it does not exist - my ($login) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); + my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); - if (!$login) { + if (!$id) { my $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|; do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel}, "user")); + + } elsif ($update_existing) { + my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user' WHERE id = ?|; + do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id); } $main::lxdebug->leave_sub();