Tpac: let ws_ou take the place of physical_loc for staff users user/senator/ws-ou-as-phys-loc
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 4 Nov 2011 19:24:09 +0000 (15:24 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 4 Nov 2011 19:24:09 +0000 (15:24 -0400)
Better for staff saved searches, and probably makes sense broadly, too.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm

index e934a39..4f91283 100644 (file)
@@ -221,7 +221,6 @@ 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_loc} = $self->get_physical_loc;
 
     # capture some commonly accessed pages
     $ctx->{home_page} = 'http://' . $self->apache->hostname . $self->ctx->{opac_root} . "/home";
@@ -250,6 +249,7 @@ sub load_common {
         }
     }
 
+    $ctx->{physical_loc} = $self->get_physical_loc;
     $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
 
     return Apache2::Const::OK;
@@ -284,7 +284,9 @@ sub staff_saved_searches_set_expansion_state {
 sub get_physical_loc {
     my $self = shift;
 
-    if(my $physical_loc = $self->cgi->param('physical_loc')) {
+    my $physical_loc;
+
+    if ($physical_loc = $self->cgi->param('physical_loc')) {    # assignment
         $self->apache->headers_out->add(
             "Set-Cookie" => $self->cgi->cookie(
                 -name => COOKIE_PHYSICAL_LOC,
@@ -294,9 +296,13 @@ sub get_physical_loc {
             )
         );
         return $physical_loc;
+    } elsif ($physical_loc = $self->cgi->cookie(COOKIE_PHYSICAL_LOC)) { # assignment
+        return $physical_loc;
+    } elsif ($self->ctx->{is_staff}) {
+        return $self->editor->requestor->ws_ou;
     }
 
-    return $self->cgi->cookie(COOKIE_PHYSICAL_LOC);
+    return;
 }