EGCatLoader sets is_staff / is_browser_staff
authorBill Erickson <berick@esilibrary.com>
Tue, 15 Jul 2014 19:47:06 +0000 (15:47 -0400)
committerBill Erickson <berick@esilibrary.com>
Tue, 15 Jul 2014 19:47:06 +0000 (15:47 -0400)
When embedded in the browser client, set is_staff and an additional
is_browser_staff flag, which is used to apply different handling in some
cases than the XUL wrapper.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm

index 7fe805b..58c6475 100644 (file)
@@ -260,10 +260,17 @@ sub load_common {
     $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
-    my $oils_wrapper = $self->apache->headers_in->get('OILS-Wrapper') || '';
-    $ctx->{is_staff} = ($oils_wrapper =~ /true/);
-    $ctx->{proto} = 'oils' if $ctx->{is_staff};
-    $ctx->{hostname} = 'remote' if $ctx->{is_staff};
+
+    my $xul_wrapper = 
+        ($self->apache->headers_in->get('OILS-Wrapper') || '') =~ /true/;
+
+    if ($xul_wrapper) {
+        # XUL client
+        $ctx->{is_staff} = 1;
+        $ctx->{proto} = 'oils';
+        $ctx->{hostname} = 'remote';
+    }
+
     $ctx->{physical_loc} = $self->get_physical_loc;
 
     # capture some commonly accessed pages
@@ -279,6 +286,17 @@ sub load_common {
             $ctx->{user} = $e->requestor;
             $ctx->{place_unfillable} = 1 if $e->requestor->wsid && $e->allowed('PLACE_UNFILLABLE_HOLD', $e->requestor->ws_ou);
 
+            # The browser client does not set an OILS-Wrapper header (above).
+            # The presence of a workstation and no header indicates staff mode.
+            # FIXME: this approach leaves un-wrapped TPAC's within the same
+            # browser (and hence same ses cookie) in an unnatural is_staff
+            # state.  Consider alternatives for determining is_staff / 
+            # is_browser_staff when $xul_wrapper is false.
+            if ($e->requestor->wsid) {
+                $ctx->{is_staff} = 1;
+                $ctx->{is_browser_staff} = 1;
+            }
+
             $ctx->{user_stats} = $U->simplereq(
                 'open-ils.actor', 
                 'open-ils.actor.user.opac.vital_stats',