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=f4cc31e9677c39322c4b9fc24b77862566089456;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 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index f0ecf8a0bc..4ded92d007 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -29,6 +29,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'; @@ -247,6 +248,7 @@ sub load_common { $ctx->{unparsed_uri} = $self->apache->unparsed_uri; $ctx->{opac_root} = $ctx->{base_path} . "/opac"; # absolute base url $ctx->{is_staff} = 0; # Assume false, check for workstation id later. Was: ($self->apache->headers_in->get('User-Agent') =~ /oils_xulrunner/); + $ctx->{physical_dept} = $self->get_physical_dept; $ctx->{physical_loc} = $self->get_physical_loc; # capture some commonly accessed pages @@ -310,6 +312,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. sub get_physical_loc {