added a batch org setting fetcher. cleaned up one of the high-org perm checkers...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 15 Sep 2008 20:22:22 +0000 (20:22 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 15 Sep 2008 20:22:22 +0000 (20:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10599 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm

index a443b1e..aa07b05 100644 (file)
@@ -176,6 +176,17 @@ sub ou_ancestor_setting {
     return $U->ou_ancestor_setting($orgid, $name);
 }
 
+__PACKAGE__->register_method(
+    api_name => 'open-ils.actor.ou_setting.ancestor_default.batch',
+    method => 'ou_ancestor_setting_batch',
+);
+sub ou_ancestor_setting_batch {
+    my( $self, $client, $orgid, $name_list ) = @_;
+    my %values;
+    $values{$_} = $U->ou_ancestor_setting($orgid, $_) for @$name_list;
+    return \%values;
+}
+
 
 
 
@@ -1278,16 +1289,20 @@ __PACKAGE__->register_method(
        /);
 
 sub check_user_perms3 {
-       my( $self, $client, $authtoken, $userid, $perm ) = @_;
+       my($self, $client, $authtoken, $user_id, $perm) = @_;
+       my $e = new_editor(authtoken=>$authtoken);
+       return $e->event unless $e->checkauth;
 
-       my( $staff, $target, $org, $evt );
+       my $tree = $self->get_org_tree();
 
-       ( $staff, $target, $evt ) = $apputils->checkses_requestor(
-               $authtoken, $userid, 'VIEW_PERMISSION' );
-       return $evt if $evt;
+    unless($e->requestor->id == $user_id) {
+        my $user = $e->retrieve_actor_user($user_id)
+            or return $e->event;
+        return $e->event unless $e->allowed('VIEW_PERMISSION', $user->home_ou);
+           return $U->find_highest_perm_org($perm, $user_id, $user->home_ou, $tree );
+    }
 
-       my $tree = $U->get_org_tree();
-       return $U->find_highest_perm_org( $perm, $userid, $target->ws_ou, $tree );
+    return $U->find_highest_perm_org($perm, $user_id, $e->requestor->ws_ou, $tree);
 }