LP#1501471: check OU setting view_perms only when needed
authorGalen Charlton <gmc@esilibrary.com>
Wed, 30 Sep 2015 20:16:02 +0000 (20:16 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 5 Nov 2015 14:23:31 +0000 (09:23 -0500)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm

index fcc71a5..122b32d 100644 (file)
@@ -313,10 +313,23 @@ __PACKAGE__->register_method(
 );
 sub ou_ancestor_setting_batch {
     my( $self, $client, $orgid, $name_list, $auth ) = @_;
-    # Make sure $auth is set to something if not given.
-    $auth ||= -1;
+
+    my %must_check_perm = ();
+    unless (defined $auth) {
+        # figure out which OU settings *require* view permission
+        # checks
+        my $e = new_editor();
+        my $res = $e->search_config_org_unit_setting_type({
+            name      => $name_list,
+            view_perm => { "!=" => undef },
+        });
+        $must_check_perm{ $_->name() } = -1 for @$res;
+    }
     my %values;
-    $values{$_} = $U->ou_ancestor_setting($orgid, $_, undef, $auth) for @$name_list;
+    $values{$_} = $U->ou_ancestor_setting(
+        $orgid, $_, undef,
+        ($auth ? $auth : $must_check_perm{$_})
+    ) for @$name_list;
     return \%values;
 }