From: Moritz Bunkus Date: Thu, 9 Apr 2015 07:21:13 +0000 (+0200) Subject: %::myconfig mit sinnvollen Standardwerten vorbelegen X-Git-Tag: release-3.2.1~5^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=313367d361bdc37ebad9647a82a437eedbf45ef4;p=kivitendo-erp.git %::myconfig mit sinnvollen Standardwerten vorbelegen Das zur-Verfügung-Stellen von %::myconfig in JavaScript und die darauf basierende vereinfachte Initialisierung in 4ec753d erfordert, dass %::myconfig immer numberformat und dateformat enthält. Andernfalls gibt es JavaScript-Fehler, wenn noch kein User angemeldet ist. --- diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 7ce18a476..43d6fa757 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -38,6 +38,7 @@ use SL::Form; use SL::Helper::DateTime; use SL::InstanceConfiguration; use SL::Template::Plugin::HTMLFixes; +use SL::User; # Trailing new line is added so that Perl will not add the line # number 'die' was called in. @@ -157,8 +158,8 @@ sub pre_startup_setup { $::lxdebug = LXDebug->new; $::auth = SL::Auth->new; $::form = undef; - %::myconfig = (); $::request = undef; + %::myconfig = User->get_default_myconfig; } $SIG{__WARN__} = sub { diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index ebb4a4d3f..9ef6ef388 100644 --- a/SL/Dispatcher/AuthHandler/Admin.pm +++ b/SL/Dispatcher/AuthHandler/Admin.pm @@ -8,7 +8,7 @@ use SL::Layout::Dispatcher; sub handle { my ($self, %params) = @_; - %::myconfig = (); + %::myconfig = User->get_default_myconfig; my $ok = $::auth->is_api_token_cookie_valid; $ok ||= $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'}) == $::auth->OK()); diff --git a/SL/Dispatcher/AuthHandler/None.pm b/SL/Dispatcher/AuthHandler/None.pm index 255740d2d..b581b44e2 100644 --- a/SL/Dispatcher/AuthHandler/None.pm +++ b/SL/Dispatcher/AuthHandler/None.pm @@ -5,7 +5,7 @@ use strict; use parent qw(Rose::Object); sub handle { - %::myconfig = (); + %::myconfig = User->get_default_myconfig; return 1; } diff --git a/SL/Dispatcher/AuthHandler/User.pm b/SL/Dispatcher/AuthHandler/User.pm index 7a8fd1d75..a1a5bdc84 100644 --- a/SL/Dispatcher/AuthHandler/User.pm +++ b/SL/Dispatcher/AuthHandler/User.pm @@ -14,7 +14,7 @@ sub handle { my $client_id = $::form->{'{AUTH}client_id'} || $::auth->get_session_value('client_id'); return $self->_error(%param) if !$client_id || !$::auth->set_client($client_id); - %::myconfig = $::auth->read_user(login => $login); + %::myconfig = User->get_default_myconfig($::auth->read_user(login => $login)); return $self->_error(%param) unless $::myconfig{login}; diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm index c470a05b6..a8bf139a7 100644 --- a/SL/Layout/Base.pm +++ b/SL/Layout/Base.pm @@ -115,7 +115,6 @@ sub get_stylesheet_for_user { } else { $css_path = "$css_path/kivitendo"; } - $::myconfig{css_path} = $css_path; # needed for menunew, FIXME: don't do this here return $css_path; } diff --git a/SL/User.pm b/SL/User.pm index f077eefe8..44efe5c58 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -412,4 +412,18 @@ sub data { +{ %{ $_[0] } } } +sub get_default_myconfig { + my ($self_or_class, %user_config) = @_; + + return ( + countrycode => 'de', + css_path => 'css', # Needed for menunew, see SL::Layout::Base::get_stylesheet_for_user + dateformat => 'dd.mm.yy', + numberformat => '1.000,00', + stylesheet => 'kivitendo.css', + timeformat => 'hh:mm', + %user_config, + ); +} + 1;