From 8f6fe3d4e0c463ce9dc0286f9c1e089d862e5399 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Mon, 11 Mar 2013 16:25:40 -0400 Subject: [PATCH] TPAC: Add physical_dept arg/cookie Add physical_dept variable to TPAC -- set by url argument, backed by a session cookie. This is accessible to TPAC templates as ctx.physical_dept, and can be used by conditionals to show/hide UI components based on the provided location of a catalog terminal within a library. physical_dept is independent from, and can be used in combination with, physical_loc: /eg/opac/home?physical_loc=2&physical_dept=teen Signed-off-by: Jeff Godin Conflicts: Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm --- Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 58df01198a..aaf6c0875d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -32,6 +32,7 @@ my $U = 'OpenILS::Application::AppUtils'; use constant COOKIE_SES => 'ses'; use constant COOKIE_SHARED_SES => 'shared_ses'; use constant COOKIE_LOGGEDIN => 'eg_loggedin'; +use constant COOKIE_PHYSICAL_DEPT => 'eg_physical_dept'; use constant COOKIE_PHYSICAL_LOC => 'eg_physical_loc'; use constant COOKIE_SSS_EXPAND => 'eg_sss_expand'; @@ -273,6 +274,7 @@ sub load_common { $ctx->{hostname} = 'remote'; } + $ctx->{physical_dept} = $self->get_physical_dept; $ctx->{physical_loc} = $self->get_physical_loc; # capture some commonly accessed pages @@ -350,6 +352,24 @@ sub staff_saved_searches_set_expansion_state { $self->ctx->{saved_searches_expanded} = $value; } +sub get_physical_dept { + my $self = shift; + + if(my $physical_dept = $self->cgi->param('physical_dept')) { + $self->apache->headers_out->add( + "Set-Cookie" => $self->cgi->cookie( + -name => COOKIE_PHYSICAL_DEPT, + -path => $self->ctx->{base_path}, + -value => $physical_dept, + -expires => undef + ) + ); + return $physical_dept; + } + + return $self->cgi->cookie(COOKIE_PHYSICAL_DEPT); +} + # physical_loc (i.e. "original location") passed in as a URL # param will replace any existing physical_loc stored as a cookie. # If specified via ENV that rules over all and we don't set cookies. -- 2.11.0