Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f9c88c3f

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID f9c88c3fcb856b8c5b676a2953e00f9c909591f8
  • Vorgänger 3e29b95e
  • Nachfolger 549dfe12

Rose::DB: Datenbankinfos aus $::auth->client lesen, sofern gegeben

Unterschiede anzeigen:

SL/DB.pm
46 46
  my $domain = shift;
47 47
  my $type   = shift;
48 48

  
49
  my %connect_settings;
50
  my $initial_sql;
51

  
52
  if (($type eq 'KIVITENDO_AUTH') && $::auth && $::auth->{DB_config} && $::auth->session_tables_present) {
53
    %connect_settings = ( driver          => 'Pg',
54
                          database        => $::auth->{DB_config}->{db},
55
                          host            => $::auth->{DB_config}->{host} || 'localhost',
56
                          port            => $::auth->{DB_config}->{port} || 5432,
57
                          username        => $::auth->{DB_config}->{user},
58
                          password        => $::auth->{DB_config}->{password},
59
                          connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8,
60
                                             });
49
  my %specific_connect_settings;
50
  my %common_connect_settings = (
51
    driver           => 'Pg',
52
    connect_options  => {
53
      pg_enable_utf8 => $::locale && $::locale->is_utf8,
54
    },
55
  );
56

  
57
  if ($::myconfig{dateformat}) {
58
    $common_connect_settings{european_dates} = 1 if ($_dateformats{ $::myconfig{dateformat} } || '') =~ m/european/i;
61 59
  }
62 60

  
63
  if (!%connect_settings && %::myconfig) {
64
    my $european_dates = 0;
65
    if ($::myconfig{dateformat}) {
66
      $european_dates = 1 if $_dateformats{ $::myconfig{dateformat} }
67
                          && $_dateformats{ $::myconfig{dateformat} } =~ m/european/i;
68
    }
69

  
70
    %connect_settings = ( driver          => $::myconfig{dbdriver} || 'Pg',
71
                          database        => $::myconfig{dbname},
72
                          host            => $::myconfig{dbhost} || 'localhost',
73
                          port            => $::myconfig{dbport} || 5432,
74
                          username        => $::myconfig{dbuser},
75
                          password        => $::myconfig{dbpasswd},
76
                          connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8,
77
                                             },
78
                          european_dates  => $european_dates);
79
  }
61
  if (($type eq 'KIVITENDO_AUTH') && $::auth && $::auth->{DB_config} && $::auth->session_tables_present) {
62
    %specific_connect_settings = (
63
      database        => $::auth->{DB_config}->{db},
64
      host            => $::auth->{DB_config}->{host} || 'localhost',
65
      port            => $::auth->{DB_config}->{port} || 5432,
66
      username        => $::auth->{DB_config}->{user},
67
      password        => $::auth->{DB_config}->{password},
68
    );
69

  
70
  } elsif ($::auth && $::auth->client) {
71
    my $client        = $::auth->client;
72
    %specific_connect_settings = (
73
      database        => $client->{dbname},
74
      host            => $client->{dbhost} || 'localhost',
75
      port            => $client->{dbport} || 5432,
76
      username        => $client->{dbuser},
77
      password        => $client->{dbpasswd},
78
    );
79

  
80
  } elsif (%::myconfig && $::myconfig{dbname}) {
81
    %specific_connect_settings = (
82
      database        => $::myconfig{dbname},
83
      host            => $::myconfig{dbhost} || 'localhost',
84
      port            => $::myconfig{dbport} || 5432,
85
      username        => $::myconfig{dbuser},
86
      password        => $::myconfig{dbpasswd},
87
    );
80 88

  
81
  if (!%connect_settings) {
89
  } else {
82 90
    $type = 'KIVITENDO_EMPTY';
83
    %connect_settings = ( driver => 'Pg' );
84 91
  }
85 92

  
93
  my %connect_settings   = (%common_connect_settings, %specific_connect_settings);
86 94
  my %flattened_settings = _flatten_settings(%connect_settings);
87 95

  
88
  $domain = 'KIVITENDO' if $type =~ m/^KIVITENDO/;
89
  $type  .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_} || '') } sort grep { $_ ne 'dbpasswd' } keys %flattened_settings);
90
  my $idx = "${domain}::${type}";
96
  $domain                = 'KIVITENDO' if $type =~ m/^KIVITENDO/;
97
  $type                 .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_} || '') } sort grep { $_ ne 'dbpasswd' } keys %flattened_settings);
98
  my $idx                = "${domain}::${type}";
91 99

  
92 100
  if (!$_db_registered{$idx}) {
93 101
    $_db_registered{$idx} = 1;

Auch abrufbar als: Unified diff