LP#1879790: Give carousels their own context org
authorMike Rylander <mrylander@gmail.com>
Thu, 22 Oct 2020 20:32:54 +0000 (16:32 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 27 Oct 2020 20:35:31 +0000 (16:35 -0400)
Before this commit, the context org unit for carousels was the same as
the physical_loc environment variable, or the client-passed physcial
location, or the search location, whichever was set in that order.  This
commit provides the ability to specify a carousel_loc environment
variable in the apache vhost configuration, as an override to
physical_loc.  This, in turn, allows hostname-segregated branches of the
org hierarchy in a resource sharing group to specify their own carousels
even when they want the top of the group to be the default search
location.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>

Open-ILS/examples/apache_24/eg.conf.in
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm

index b872a3e..0733794 100644 (file)
@@ -113,6 +113,11 @@ ExpiresByType text/css "access plus 1 year"
        SSLHonorCipherOrder On
        SSLCipherSuite ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM
 
+    # Uncomment and set this variable to the id of the context org unit
+    # you want to provide visible carousels for this vhost.
+    #
+    # SetEnv carousel_loc 1
+
     # If you don't have an SSL cert, you can create self-signed 
     # certificate and key with:
     # openssl req -new -x509 -nodes -out server.crt -keyout server.key
index 907ae8b..663cde6 100644 (file)
@@ -349,6 +349,7 @@ sub load_common {
         $ctx->{hostname} = 'remote';
     }
 
+    $ctx->{carousel_loc} = $self->get_carousel_loc;
     $ctx->{physical_loc} = $self->get_physical_loc;
 
     # capture some commonly accessed pages
@@ -403,7 +404,7 @@ sub load_common {
 
     # FIXME - move carousel helpers to a separate file
     $ctx->{get_visible_carousels} = sub {
-        my $org_unit = $self->ctx->{physical_loc} || $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
+        my $org_unit = $self->ctx->{carousel_loc} || $self->ctx->{physical_loc} || $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
         return $U->simplereq(
             'open-ils.actor',
             'open-ils.actor.carousel.retrieve_by_org',
@@ -527,6 +528,11 @@ sub get_physical_loc {
     return $self->cgi->cookie(COOKIE_PHYSICAL_LOC);
 }
 
+sub get_carousel_loc {
+    my $self = shift;
+    return $self->cgi->param('carousel_loc') || $ENV{carousel_loc};
+}
+
 # -----------------------------------------------------------------------------
 # Log in and redirect to the redirect_to URL (or home)
 # -----------------------------------------------------------------------------