X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLxOfficeConf.pm;h=7690eebdabc9af004b4c2d0572af7a2bf022da7c;hb=af56ae02cd83ad4fff35a3ef695a9fcf4c074caf;hp=b0d801024c0056df8e9fd07ff0dffcd6cb2e19c1;hpb=1072cd08c6f5b1905a34dcb3eeab3ddec98d6905;p=kivitendo-erp.git diff --git a/SL/LxOfficeConf.pm b/SL/LxOfficeConf.pm index b0d801024..7690eebda 100644 --- a/SL/LxOfficeConf.pm +++ b/SL/LxOfficeConf.pm @@ -6,9 +6,18 @@ use Config::Std; use Encode; sub read { - my $file = -f 'config/lx_office.conf' ? 'config/lx_office.conf' : 'config/lx_office.conf.default'; - read_config $file => %::lx_office_conf; + my ($class, $file_name) = @_; + + read_config 'config/lx_office.conf.default' => %::lx_office_conf; _decode_recursively(\%::lx_office_conf); + + $file_name ||= 'config/lx_office.conf'; + + if (-f $file_name) { + read_config $file_name => my %local_conf; + _decode_recursively(\%local_conf); + _flat_merge(\%::lx_office_conf, \%local_conf); + } } sub _decode_recursively { @@ -23,4 +32,17 @@ sub _decode_recursively { } } +sub _flat_merge { + my ($dst, $src) = @_; + + while (my ($key, $value) = each %{ $src }) { + if (!exists $dst->{$key}) { + $dst->{$key} = $value; + + } else { + map { $dst->{$key}->{$_} = $value->{$_} } keys %{ $value }; + } + } +} + 1;