LP#1849161 - Add back in pref_lib located uri feature user/stompro/lp1849161_pref_ou_luri_search
authorJosh Stompro <stompro@stompro.org>
Wed, 23 Oct 2019 14:30:02 +0000 (09:30 -0500)
committerJosh Stompro <stompro@stompro.org>
Wed, 23 Oct 2019 14:30:02 +0000 (09:30 -0500)
Originally added in LP#975577

Allow the pref_lib feature to effect located uri visibility

Signed-off-by: Josh Stompro <stompro@stompro.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index 950a081..0025faa 100644 (file)
@@ -1477,6 +1477,18 @@ sub flatten {
         my $luri_as_copy_gf = $U->get_global_flag('opac.located_uri.act_as_copy');
         push @$lorgs, @$dorgs if ($luri_as_copy_gf and $U->is_true($luri_as_copy_gf->enabled));
 
+        #### Pref Lib Logic
+        #### Add in pref_ou to luri visibility test
+        if ($self->find_filter('pref_ou')) {
+          my $pref_ou = $self->find_filter('pref_ou');
+          my $pref_org = $U->find_org_by_shortname($ot, $pref_ou->args->[0]);
+          $logger->debug('pref_ou is set to: '.$pref_org->id);
+          if ($pref_org->id != $site_org->id){ #if search scope = pref_lib then no need to add in
+            my $porgs = $U->get_org_ancestors($pref_org->id);
+            push @$lorgs, @$porgs;
+          }
+        }
+
         $uses_bre = 1;
         push @{$vis_filter{'b_attr'}},
             "search.calculate_visibility_attribute_test('luri_org','{".join(',', @$lorgs)."}',$negate)";