Globale Variablen für Druckvorlagen nach %::lx_office_conf verschoben
[kivitendo-erp.git] / SL / Dispatcher.pm
index 57e2b54..9ba2b70 100644 (file)
@@ -77,6 +77,7 @@ sub pre_startup_setup {
 
   read_config 'config/lx_office.conf' => %::lx_office_conf;
   _decode_recursively(\%::lx_office_conf);
+  _init_environment();
 
   eval {
     package main;
@@ -88,7 +89,6 @@ sub pre_startup_setup {
   {
     no warnings 'once';
     $::menufile    = "menu.ini";
-    $::sendmail    = "| /usr/sbin/sendmail -t";
     $::lxdebug     = LXDebug->new;
     $::auth        = SL::Auth->new;
     $::form        = undef;
@@ -334,6 +334,27 @@ sub _decode_recursively {
   }
 }
 
+sub _init_environment {
+  my %key_map = ( lib  => { name => 'PERL5LIB', append_path => 1 },
+                  path => { name => 'PATH',     append_path => 1 },
+                );
+  my $cfg     = $::lx_office_conf{environment} || {};
+
+  while (my ($key, $value) = each %{ $cfg }) {
+    next unless $value;
+
+    my $info = $key_map{$key} || {};
+    $key     = $info->{name}  || $key;
+
+    if ($info->{append_path}) {
+      $value = ':' . $value unless $value =~ m/^:/ || !$ENV{$key};
+      $value = $ENV{$key} . $value;
+    }
+
+    $ENV{$key} = $value;
+  }
+}
+
 package main;
 
 use strict;