X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FDB.pm;h=2d394f69031faa6351cc5be59657c4b23a90983e;hb=f1a6f40168188b4e7e1d55db3c9c4e88749aa68b;hp=5a22c5da52ecaaff388f697b0c3f30b129b96fc8;hpb=61cdba5d566357f3beabe0e7f3f0cb2d7bdccd73;p=kivitendo-erp.git diff --git a/SL/DB.pm b/SL/DB.pm index 5a22c5da5..2d394f690 100644 --- a/SL/DB.pm +++ b/SL/DB.pm @@ -46,45 +46,56 @@ sub _register_db { my $domain = shift; my $type = shift; - my %connect_settings; - my $initial_sql; - - if (!%::myconfig) { - $type = 'LXOFFICE_EMPTY'; - %connect_settings = ( driver => 'Pg' ); - - } elsif ($type eq 'LXOFFICE_AUTH') { - %connect_settings = ( driver => $::myconfig{dbdriver} || 'Pg', - database => $::auth->{DB_config}->{db}, - host => $::auth->{DB_config}->{host} || 'localhost', - port => $::auth->{DB_config}->{port} || 5432, - username => $::auth->{DB_config}->{user}, - password => $::auth->{DB_config}->{password}, - connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8, - }); - } else { - my $european_dates = 0; - if ($::myconfig{dateformat}) { - $european_dates = 1 if $_dateformats{ $::myconfig{dateformat} } - && $_dateformats{ $::myconfig{dateformat} } =~ m/european/i; - } + my %specific_connect_settings; + my %common_connect_settings = ( + driver => 'Pg', + connect_options => { + pg_enable_utf8 => $::locale && $::locale->is_utf8, + }, + ); + + if ($::myconfig{dateformat}) { + $common_connect_settings{european_dates} = 1 if ($_dateformats{ $::myconfig{dateformat} } || '') =~ m/european/i; + } - %connect_settings = ( driver => $::myconfig{dbdriver} || 'Pg', - database => $::myconfig{dbname}, - host => $::myconfig{dbhost} || 'localhost', - port => $::myconfig{dbport} || 5432, - username => $::myconfig{dbuser}, - password => $::myconfig{dbpasswd}, - connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8, - }, - european_dates => $european_dates); + if (($type eq 'KIVITENDO_AUTH') && $::auth && $::auth->{DB_config} && $::auth->session_tables_present) { + %specific_connect_settings = ( + database => $::auth->{DB_config}->{db}, + host => $::auth->{DB_config}->{host} || 'localhost', + port => $::auth->{DB_config}->{port} || 5432, + username => $::auth->{DB_config}->{user}, + password => $::auth->{DB_config}->{password}, + ); + + } elsif ($::auth && $::auth->client) { + my $client = $::auth->client; + %specific_connect_settings = ( + database => $client->{dbname}, + host => $client->{dbhost} || 'localhost', + port => $client->{dbport} || 5432, + username => $client->{dbuser}, + password => $client->{dbpasswd}, + ); + + } elsif (%::myconfig && $::myconfig{dbname}) { + %specific_connect_settings = ( + database => $::myconfig{dbname}, + host => $::myconfig{dbhost} || 'localhost', + port => $::myconfig{dbport} || 5432, + username => $::myconfig{dbuser}, + password => $::myconfig{dbpasswd}, + ); + + } else { + $type = 'KIVITENDO_EMPTY'; } + my %connect_settings = (%common_connect_settings, %specific_connect_settings); my %flattened_settings = _flatten_settings(%connect_settings); - $domain = 'LXOFFICE' if $type =~ m/^LXOFFICE/; - $type .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_} || '') } sort keys %flattened_settings); - my $idx = "${domain}::${type}"; + $domain = 'KIVITENDO' if $type =~ m/^KIVITENDO/; + $type .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_} || '') } sort grep { $_ ne 'dbpasswd' } keys %flattened_settings); + my $idx = "${domain}::${type}"; if (!$_db_registered{$idx}) { $_db_registered{$idx} = 1;