repaired descendant logic for initial high perm org
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 5 Feb 2008 15:52:52 +0000 (15:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 5 Feb 2008 15:52:52 +0000 (15:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8637 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index be346a7..b7aacf7 100644 (file)
@@ -1304,16 +1304,18 @@ sub find_highest_work_orgs {
 
     
     return [] if $high_org_id == -1; # not allowed anywhere
-    push(@allowed_orgs, $high_org_id);
-    my $high_org = $self->find_org($org_tree, $high_org_id);
 
+    my $high_org = $self->find_org($org_tree, $high_org_id);
     my ($high_org_type) = grep { $_->id == $high_org->ou_type } @$org_types;
-    return [$high_org_id] if $high_org_type->depth == 0;
+    my $org_depth = $high_org_type->depth;
+
+       if($$options{descendants}) {
+               push(@allowed_orgs, @{$self->get_org_descendants($high_org_id, $org_depth)});
+       } else {
+               push(@allowed_orgs, $high_org_id);
+       }
 
-    # now that we have the highest depth, find the org in the tree relative to 
-    # each work org at that depth. 
-    my ($org_type) = grep { $_->id == $high_org->ou_type } @$org_types;
-    my $org_depth = $org_type->depth;
+       return \@allowed_orgs if $org_depth == 0;
 
     for my $org (@$work_orgs) {