From: erickson Date: Mon, 14 Apr 2008 18:29:18 +0000 (+0000) Subject: org_unit_list and org_id_list now return sub-lists, segregated by branches of the... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=324c094eefab1e84f72c520a1a05c35a9637cb7d;p=Evergreen.git 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 git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9348 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index e00553c663..f74edd5ca1 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -1327,8 +1327,12 @@ __PACKAGE__->register_method( 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. + / ); @@ -1338,8 +1342,11 @@ __PACKAGE__->register_method( 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. / ); @@ -1349,17 +1356,24 @@ sub check_user_work_perms { 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; }