Teach the TPAC to set the client TZ at login user/miker/client-tz
authorMike Rylander <mrylander@gmail.com>
Mon, 3 Aug 2015 17:27:56 +0000 (13:27 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 4 Aug 2015 16:07:02 +0000 (12:07 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/templates/opac/parts/js.tt2
Open-ILS/src/templates/opac/parts/login/form.tt2

index ada5da6..3b55c62 100644 (file)
@@ -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 {
index b1527fb..18cde50 100644 (file)
@@ -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
     );
 }
 
index ed68480..cb03fab 100644 (file)
@@ -108,4 +108,5 @@ var aou_hash = {
 };
 </script>
 
+<script type="text/javascript">$('client_tz_id').value = OpenSRF.tz</script>
 [%- END; # want_dojo -%]
index 9b13f58..17e72e0 100644 (file)
@@ -53,6 +53,7 @@
             <input type="checkbox" name="persist" id="login_persist" /><label for="login_persist"> [% l('Stay logged in?') %]</label>
             <input type="submit" value="[% l('Log in') %]" alt="[% l('Log in') %]" class="opac-button" />
         </div>
+        <input id="client_tz_id" name="client_tz" type="hidden" />
     </form>
 </div>
 [% INCLUDE "opac/parts/login/help.tt2" %]