[open-ils-commits] r8635 - branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 5 10:53:34 EST 2008


Author: erickson
Date: 2008-02-05 10:25:14 -0500 (Tue, 05 Feb 2008)
New Revision: 8635

Modified:
   branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
   branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added a descendants option to the high work org retrieval function

Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-02-05 15:25:11 UTC (rev 8634)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-02-05 15:25:14 UTC (rev 8635)
@@ -1328,17 +1328,18 @@
             check is implied by the authtoken. /,
         params => [
 		    {desc => 'authtoken', type => 'string'},
-            {desc => 'permission name', type => 'string'}
+            {desc => 'permission name', type => 'string'},
+            {desc => 'options hash, including "descendants", which will include all child orgs of the found perm orgs', type => 'hash'}
         ],
         return => {desc => 'An array of org IDs'}
     }
 );
 
 sub check_user_work_perms {
-    my($self, $conn, $auth, $perm) = @_;
+    my($self, $conn, $auth, $perm, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
-    return $U->find_highest_work_orgs($e, $perm);
+    return $U->find_highest_work_orgs($e, $perm, $options);
 }
 
 __PACKAGE__->register_method(

Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2008-02-05 15:25:11 UTC (rev 8634)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2008-02-05 15:25:14 UTC (rev 8635)
@@ -1288,7 +1288,7 @@
 
 
 sub find_highest_work_orgs {
-    my($self, $e, $perm) = @_;
+    my($self, $e, $perm, $options) = @_;
     my $work_orgs = $self->get_user_work_ou_ids($e, $e->requestor->id);
     $logger->debug("found work orgs @$work_orgs");
 
@@ -1320,14 +1320,20 @@
         $logger->debug("work org looking at $org");
 		my $org_list = $self->get_org_full_path($org, $org_depth);
 
+		my $found = 0;
         for my $sub_org (@$org_list) {
-            $logger->debug("work org looking at sub-org $sub_org");
-            my $org_unit = $self->find_org($org_tree, $sub_org);
-            my ($ou_type) = grep { $_->id == $org_unit->ou_type } @$org_types;
-            if($ou_type->depth >= $org_depth) {
-                push(@allowed_orgs, $sub_org);
-                last;
-            }
+			if(not $found) {
+				$logger->debug("work org looking at sub-org $sub_org");
+				my $org_unit = $self->find_org($org_tree, $sub_org);
+				my ($ou_type) = grep { $_->id == $org_unit->ou_type } @$org_types;
+				if($ou_type->depth >= $org_depth) {
+					push(@allowed_orgs, $sub_org);
+					$found = 1;
+				}
+			} else {
+				last unless $$options{descendants}; 
+				push(@allowed_orgs, $sub_org);
+			}
         }
     }
 



More information about the open-ils-commits mailing list