From: Mike Rylander Date: Mon, 3 Aug 2015 17:27:56 +0000 (-0400) Subject: Teach the TPAC to set the client TZ at login X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fmiker%2Fclient-tz;p=working%2FEvergreen.git Teach the TPAC to set the client TZ at login Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage.pm index ada5da6a06..3b55c626c5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage.pm @@ -77,7 +77,7 @@ sub force_db_tz { my $client = shift; my @args = @_; - my ($current_xact) = $self->method_lookup('open-ils.storage.transaction.current')->run; + my ($current_xact) = $self->method_lookup('no_tz.open-ils.storage.transaction.current')->run; if (!$current_xact && $ENV{TZ}) { try { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index b1527fb87d..18cde50af2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -31,6 +31,7 @@ my $U = 'OpenILS::Application::AppUtils'; use constant COOKIE_SES => 'ses'; use constant COOKIE_LOGGEDIN => 'eg_loggedin'; +use constant COOKIE_TZ => 'client_tz'; use constant COOKIE_PHYSICAL_LOC => 'eg_physical_loc'; use constant COOKIE_SSS_EXPAND => 'eg_sss_expand'; @@ -256,12 +257,15 @@ sub load_common { return $self->redirect_ssl unless $self->cgi->https; } + $ctx->{client_tz} = $self->cgi->cookie(COOKIE_TZ) || $ENV{TZ}; $ctx->{referer} = $self->cgi->referer; $ctx->{path_info} = $self->cgi->path_info; $ctx->{full_path} = $ctx->{base_path} . $self->cgi->path_info; $ctx->{unparsed_uri} = $self->apache->unparsed_uri; $ctx->{opac_root} = $ctx->{base_path} . "/opac"; # absolute base url + local $ENV{TZ} = $ctx->{client_tz}; + my $xul_wrapper = ($self->apache->headers_in->get('OILS-Wrapper') || '') =~ /true/; @@ -401,6 +405,7 @@ sub load_login { my $password = $cgi->param('password'); my $org_unit = $ctx->{physical_loc} || $ctx->{aou_tree}->()->id; my $persist = $cgi->param('persist'); + my $client_tz = $cgi->param('client_tz'); # initial log form only return Apache2::Const::OK unless $username and $password; @@ -461,27 +466,41 @@ sub load_login { # both login-related cookies should expire at the same time my $login_cookie_expires = ($persist) ? CORE::time + $response->{payload}->{authtime} : undef; + my $cookie_list = [ + # contains the actual auth token and should be sent only over https + $cgi->cookie( + -name => COOKIE_SES, + -path => '/', + -secure => 1, + -value => $response->{payload}->{authtoken}, + -expires => $login_cookie_expires + ), + # contains only a hint that we are logged in, and is used to + # trigger a redirect to https + $cgi->cookie( + -name => COOKIE_LOGGEDIN, + -path => '/', + -secure => 0, + -value => '1', + -expires => $login_cookie_expires + ) + ]; + + if ($client_tz) { + # contains the client's tz, as passed by the client + # trigger a redirect to https + push @$cookie_list, $cgi->cookie( + -name => COOKIE_TZ, + -path => '/', + -secure => 0, + -value => $client_tz, + -expires => $login_cookie_expires + ); + } + return $self->generic_redirect( $cgi->param('redirect_to') || $acct, - [ - # contains the actual auth token and should be sent only over https - $cgi->cookie( - -name => COOKIE_SES, - -path => '/', - -secure => 1, - -value => $response->{payload}->{authtoken}, - -expires => $login_cookie_expires - ), - # contains only a hint that we are logged in, and is used to - # trigger a redirect to https - $cgi->cookie( - -name => COOKIE_LOGGEDIN, - -path => '/', - -secure => 0, - -value => '1', - -expires => $login_cookie_expires - ) - ] + $cookie_list ); } diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2 index ed68480402..cb03fab4c7 100644 --- a/Open-ILS/src/templates/opac/parts/js.tt2 +++ b/Open-ILS/src/templates/opac/parts/js.tt2 @@ -108,4 +108,5 @@ var aou_hash = { }; + [%- END; # want_dojo -%] diff --git a/Open-ILS/src/templates/opac/parts/login/form.tt2 b/Open-ILS/src/templates/opac/parts/login/form.tt2 index 9b13f587a2..17e72e0ebd 100644 --- a/Open-ILS/src/templates/opac/parts/login/form.tt2 +++ b/Open-ILS/src/templates/opac/parts/login/form.tt2 @@ -53,6 +53,7 @@ + [% INCLUDE "opac/parts/login/help.tt2" %]