Pasted as Plain Text
Description: No description
URL: https://lumen.esilibrary.com/p/ZI3fRH25.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
index 6a77108378..6cdfbfdb71 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
@@ -1528,8 +1528,14 @@ sub flatten {
     }
     unflesh_parents($ot);
 
-    push @{$vis_filter{'c_attr'}},
-        "search.calculate_visibility_attribute_test('circ_lib','{".join(',', @$dorgs)."}',$negate)";
+    if ($negate eq 'TRUE'                 # negated org lists must be included
+        or $lasso_filter                  # lasso filters must be included
+        or $$dorgs[0] != $ot->id          # we're not searching at the top of the org tree, must include
+        or !$self->find_modifier('staff') # patron searches need to test visibility for other reasons
+    ) {
+        push @{$vis_filter{'c_attr'}},
+            "search.calculate_visibility_attribute_test('circ_lib','{".join(',', @$dorgs)."}',$negate)";
+    }
 
     # NOTE: both lassos and shelving locations preclude Located URI search
     if (!$lasso_filter && !$self->find_filter('locations') && !$self->find_filter('location_groups')) {