X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher.pm;h=854b863a3f4e8fcc9b1a319ef5afe02040d9eeaf;hb=f7c4665fd435b94e599ea1ac2ba23d8e21a8420f;hp=3eaebf08b1cacc40ebb4e84b23099fcf92cadd6b;hpb=a36f8ac729bac34b3dbb43cb8e50924afd51d5ff;p=kivitendo-erp.git diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 3eaebf08b..854b863a3 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -26,6 +26,7 @@ use File::Basename; use List::MoreUtils qw(all); use List::Util qw(first); use POSIX; +use SL::ArchiveZipFixes; use SL::Auth; use SL::Dispatcher::AuthHandler; use SL::LXDebug; @@ -51,6 +52,8 @@ sub new { $self->{interface} = lc($interface || 'cgi'); $self->{auth_handler} = SL::Dispatcher::AuthHandler->new; + SL::ArchiveZipFixes->apply_fixes; + return $self; } @@ -78,6 +81,38 @@ sub pre_request_checks { } } +sub pre_request_initialization { + my ($self, %params) = @_; + + $self->unrequire_bin_mozilla; + + $::locale = Locale->new($::lx_office_conf{system}->{language}); + $::form = Form->new; + $::instance_conf = SL::InstanceConfiguration->new; + $::request = SL::Request->new( + cgi => CGI->new({}), + layout => SL::Layout::None->new, + ); + + my $session_result = $::auth->restore_session; + $::auth->create_or_refresh_session; + + if ($params{client}) { + $::auth->set_client($params{client}) || die("cannot find client " . $params{client}); + + if ($params{login}) { + die "cannot find user " . $params{login} unless %::myconfig = $::auth->read_user(login => $params{login}); + die "cannot find locale for user " . $params{login} unless $::locale = Locale->new($::myconfig{countrycode}); + + $::form->{login} = $params{login}; # normaly implicit at login + + $::instance_conf->init; + } + } + + return $session_result; +} + sub render_error_ajax { my ($error) = @_; @@ -196,18 +231,7 @@ sub handle_request { my ($script, $path, $suffix, $script_name, $action, $routing_type); - $self->unrequire_bin_mozilla; - - $::locale = Locale->new($::lx_office_conf{system}->{language}); - $::form = Form->new; - $::instance_conf = SL::InstanceConfiguration->new; - $::request = SL::Request->new( - cgi => CGI->new({}), - layout => SL::Layout::None->new, - ); - - my $session_result = $::auth->restore_session; - $::auth->create_or_refresh_session; + my $session_result = $self->pre_request_initialization; $::form->read_cgi_input; @@ -350,7 +374,7 @@ sub _route_dispatcher_request { my ($script_name, $action); eval { - die "Unroutable request -- inavlid module name.\n" if !$::form->{M} || ($::form->{M} !~ m/^${name_re}$/); + die "Unroutable request -- invalid module name.\n" if !$::form->{M} || ($::form->{M} !~ m/^${name_re}$/); $script_name = $::form->{M} . '.pl'; if ($::form->{A}) { @@ -358,7 +382,7 @@ sub _route_dispatcher_request { } else { $action = first { m/^A_${name_re}$/ } keys %{ $::form }; - die "Unroutable request -- inavlid action name.\n" if !$action; + die "Unroutable request -- invalid action name.\n" if !$action; delete $::form->{$action}; $action = substr $action, 2; @@ -379,7 +403,7 @@ sub _route_controller_request { my ($controller, $action, $request_type); eval { - $::form->{action} =~ m|^ ( [A-Z] [A-Za-z0-9_]* ) / ( [a-z] [a-z0-9_]* ) ( \. [a-zA-Z]+ )? $|x || die "Unroutable request -- inavlid controller/action.\n"; + $::form->{action} =~ m|^ ( [A-Z] [A-Za-z0-9_]* ) / ( [a-z] [a-z0-9_]* ) ( \. [a-zA-Z]+ )? $|x || die "Unroutable request -- invalid controller/action.\n"; ($controller, $action) = ($1, $2); delete $::form->{action};