Merge branch 'master' of git@vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / SL / Dispatcher.pm
index 0071e81..97a2f45 100644 (file)
@@ -23,6 +23,7 @@ use SL::Locale;
 use SL::Common;
 use SL::Form;
 use SL::Helper::DateTime;
+use SL::InstanceConfiguration;
 use SL::Template::Plugin::HTMLFixes;
 
 # Trailing new line is added so that Perl will not add the line
@@ -80,7 +81,6 @@ sub pre_startup_setup {
   my ($self) = @_;
 
   SL::LxOfficeConf->read;
-  _init_environment();
 
   eval {
     package main;
@@ -168,10 +168,11 @@ sub handle_request {
 
   $self->unrequire_bin_mozilla;
 
-  $::cgi         = CGI->new('');
-  $::locale      = Locale->new($::lx_office_conf{system}->{language});
-  $::form        = Form->new;
-  %::called_subs = ();
+  $::cgi           = CGI->new('');
+  $::locale        = Locale->new($::lx_office_conf{system}->{language});
+  $::form          = Form->new;
+  %::called_subs   = ();
+  $::instance_conf = SL::InstanceConfiguration->new;
 
   my $session_result = $::auth->restore_session;
   $::auth->create_or_refresh_session;
@@ -219,6 +220,8 @@ sub handle_request {
       delete $::form->{password};
 
       if ($action) {
+        $::instance_conf->init;
+
         map { $::form->{$_} = $::myconfig{$_} } qw(stylesheet charset)
           unless $action eq 'save' && $::form->{type} eq 'preferences';
 
@@ -366,27 +369,6 @@ sub get_standard_filehandles {
   return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR);
 }
 
-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;
-  }
-}
-
 sub _check_for_old_config_files {
   my @old_files = grep { -f "config/${_}" } qw(authentication.pl console.conf lx-erp.conf lx-erp-local.conf);
   return unless @old_files;