From: Jeff Godin Date: Mon, 11 Mar 2013 20:25:40 +0000 (-0400) Subject: TPAC: Add physical_dept arg/cookie X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=01fe24b7e77fa3a3796f305969375aee8aeef2df;p=evergreen%2Ftadl.git 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 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index fb54f10e47..69ddede2cb 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_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 @@ -362,6 +364,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.