[open-ils-commits] r9349 - trunk/Open-ILS/src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 14 15:07:35 EDT 2008


Author: erickson
Date: 2008-04-14 14:29:35 -0400 (Mon, 14 Apr 2008)
New Revision: 9349

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
org_unit_list and org_id_list now return sub-lists, segregated by branches of the org tree.  the first item in each list is the highest perm or for that branch of the tree

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-04-14 18:29:18 UTC (rev 9348)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-04-14 18:29:35 UTC (rev 9349)
@@ -1330,8 +1330,12 @@
     authoritative => 1,
     signature => q/
         @see open-ils.actor.user.work_perm.highest_org_set
-        Returns a flat list of all of the org_units where the user
-        has the requested permission.
+        Returns a list of list of all of the org_units where the user
+        has the requested permission.  The first item in each list
+        is the highest permission org for that section of the
+        org tree.  The remaining items in each sub-list are the 
+        descendants of that org.
+
     /
 );
 
@@ -1341,8 +1345,11 @@
     authoritative => 1,
     signature => q/
         @see open-ils.actor.user.work_perm.highest_org_set
-        Returns a flat list of all of the org_units where the user
-        has the requested permission.
+        Returns a list of lists of all of the org_unit IDs where the user
+        has the requested permission.  The first item in each list
+        is the highest permission org for that section of the
+        org tree.  The remaining items in each sub-list are the 
+        descendants of that org.
     /
 );
 
@@ -1352,17 +1359,24 @@
     return $e->event unless $e->checkauth;
     my $orglist = $U->find_highest_work_orgs($e, $perm, $options);
 
-    return $orglist if
-        $self->api_name =~ /highest_org_set/;
+    return $orglist if $self->api_name =~ /highest_org_set/;
 
     # build a list of org trees
     return get_org_descendants($self, $conn, $orglist)
         if $self->api_name =~ /org_tree_list/;
 
     my @list;
-    push(@list, @{$U->get_org_descendants($_)}) for @$orglist;
-    return \@list if $self->api_name =~ /org_id_list/;
-    return $e->batch_retrieve_actor_org_unit(\@list);
+    for my $orgid (@$orglist) {
+        my @sublist = grep {$_ ne $orgid} @{$U->get_org_descendants($orgid)};
+        unshift @sublist, $orgid; # make sure it's at the front of the list
+        if($self->api_name =~ /org_id_list/) {
+            push(@list, \@sublist);
+        } else {
+            push(@list, $e->batch_retrieve_actor_org_unit(\@sublist));
+        }
+    }
+
+    return \@list;
 }
 
 



More information about the open-ils-commits mailing list