projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
UTF8-Flags setzen/beachten
[kivitendo-erp.git]
/
SL
/
User.pm
diff --git
a/SL/User.pm
b/SL/User.pm
index
805335a
..
46fe855
100644
(file)
--- a/
SL/User.pm
+++ b/
SL/User.pm
@@
-37,12
+37,14
@@
package User;
use IO::File;
use Fcntl qw(:seek);
use IO::File;
use Fcntl qw(:seek);
-use SL::Auth;
+
#
use SL::Auth;
use SL::DBUpgrade2;
use SL::DBUtils;
use SL::Iconv;
use SL::Inifile;
use SL::DBUpgrade2;
use SL::DBUtils;
use SL::Iconv;
use SL::Inifile;
+use strict;
+
sub new {
$main::lxdebug->enter_sub();
sub new {
$main::lxdebug->enter_sub();
@@
-92,6
+94,7
@@
sub login {
$main::lxdebug->enter_sub();
my ($self, $form) = @_;
$main::lxdebug->enter_sub();
my ($self, $form) = @_;
+ our $sid;
local *FH;
local *FH;
@@
-104,7
+107,7
@@
sub login {
my $dbh =
DBI->connect($myconfig{dbconnect}, $myconfig{dbuser},
$myconfig{dbpasswd})
my $dbh =
DBI->connect($myconfig{dbconnect}, $myconfig{dbuser},
$myconfig{dbpasswd})
- or $self->error(DBI::errstr);
+ or $self->error(
$
DBI::errstr);
# we got a connection, check the version
my $query = qq|SELECT version FROM defaults|;
# we got a connection, check the version
my $query = qq|SELECT version FROM defaults|;
@@
-141,7
+144,7
@@
sub login {
if ($form->{"show_dbupdate_warning"}) {
print $form->parse_html_template("dbupgrade/warning");
if ($form->{"show_dbupdate_warning"}) {
print $form->parse_html_template("dbupgrade/warning");
-
exit(0
);
+
::end_of_request(
);
}
# update the tables
}
# update the tables
@@
-170,6
+173,7
@@
sub login {
my $menufile =
$self->{"menustyle"} eq "v3" ? "menuv3.pl" :
$self->{"menustyle"} eq "neu" ? "menunew.pl" :
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";
$self->{"menustyle"} eq "xml" ? "menuXML.pl" :
"menu.pl";
@@
-408,7
+412,7
@@
sub dbcreate {
# Process a Perl script which updates the database.
# If the script returns 1 then the update was successful.
# Return code "2" means "needs more interaction; remove
# Process a Perl script which updates the database.
# If the script returns 1 then the update was successful.
# Return code "2" means "needs more interaction; remove
-# users/nologin and e
xi
t".
+# users/nologin and e
nd current reques
t".
# All other return codes are fatal errors.
sub process_perl_script {
$main::lxdebug->enter_sub();
# All other return codes are fatal errors.
sub process_perl_script {
$main::lxdebug->enter_sub();
@@
-441,14
+445,12
@@
sub process_perl_script {
$dbh->begin_work();
$dbh->begin_work();
+ # setup dbup_ export vars
my %dbup_myconfig = ();
map({ $dbup_myconfig{$_} = $form->{$_}; }
qw(dbname dbuser dbpasswd dbhost dbport dbconnect));
my %dbup_myconfig = ();
map({ $dbup_myconfig{$_} = $form->{$_}; }
qw(dbname dbuser dbpasswd dbhost dbport dbconnect));
- my $nls_file = $filename;
- $nls_file =~ s|.*/||;
- $nls_file =~ s|.pl$||;
- my $dbup_locale = Locale->new($main::language, $nls_file);
+ my $dbup_locale = $::locale;
my $result = eval($contents);
my $result = eval($contents);
@@
-461,10
+463,10
@@
sub process_perl_script {
print $form->parse_html_template("dbupgrade/error",
{ "file" => $filename,
"error" => $@ });
print $form->parse_html_template("dbupgrade/error",
{ "file" => $filename,
"error" => $@ });
-
exit(0
);
+
::end_of_request(
);
} elsif (1 != $result) {
unlink("users/nologin") if (2 == $result);
} elsif (1 != $result) {
unlink("users/nologin") if (2 == $result);
-
exit(0
);
+
::end_of_request(
);
}
if (ref($version_or_control) eq "HASH") {
}
if (ref($version_or_control) eq "HASH") {
@@
-550,6
+552,12
@@
sub process_query {
$query .= $char;
}
}
$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") {
}
if (ref($version_or_control) eq "HASH") {
@@
-680,8
+688,8
@@
sub cmp_script_version {
$my_a =~ s/.sql$//;
$my_b =~ s/.*-upgrade-//;
$my_b =~ s/.sql$//;
$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);
$res_a = calc_version($my_a_from);
$res_b = calc_version($my_b_from);
@@
-792,7
+800,7
@@
sub dbupdate {
last if ($version < $mindb);
# apply upgrade
last if ($version < $mindb);
# apply upgrade
- $main::lxdebug->message(LXDebug
::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);
if ($file_type eq "sql") {
$self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} .
"-upgrade/$upgradescript", $str_maxdb, $db_charset);
@@
-876,7
+884,7
@@
sub dbupdate2 {
my $file_type = $1;
# apply upgrade
my $file_type = $1;
# apply upgrade
- $main::lxdebug->message(LXDebug
::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") {
print $form->parse_html_template("dbupgrade/upgrade_message2", $control);
if ($file_type eq "sql") {
@@
-934,6
+942,7
@@
sub save_member {
$main::lxdebug->enter_sub();
my ($self) = @_;
$main::lxdebug->enter_sub();
my ($self) = @_;
+ my $form = \%main::form;
# format dbconnect and dboptions string
dbconnect_vars($self, $self->{dbname});
# format dbconnect and dboptions string
dbconnect_vars($self, $self->{dbname});
@@
-944,7
+953,7
@@
sub save_member {
my $dbh = DBI->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
if ($dbh) {
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();
}
$dbh->disconnect();
}
@@
-954,18
+963,28
@@
sub save_member {
sub create_employee_entry {
$main::lxdebug->enter_sub();
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
# 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
) {
- $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|;
+ 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"));
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();
}
$main::lxdebug->leave_sub();
@@
-981,7
+1000,7
@@
sub config_vars {
bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen
taxnumber co_ustid duns menustyle template_format default_media
default_printer_id copies show_form_details favorites
bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen
taxnumber co_ustid duns menustyle template_format default_media
default_printer_id copies show_form_details favorites
- pdonumber sdonumber);
+ pdonumber sdonumber
hide_cvar_search_options mandatory_departments
);
$main::lxdebug->leave_sub();
$main::lxdebug->leave_sub();