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

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 14 14:16:59 EDT 2008


Author: erickson
Date: 2008-04-14 13:38:59 -0400 (Mon, 14 Apr 2008)
New Revision: 9345

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added versions of work perm org fetcher to return flat list of all org units or org IDs.  if no depth is provided to get_org_depth, do not default to 0

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-04-14 17:38:34 UTC (rev 9344)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-04-14 17:38:59 UTC (rev 9345)
@@ -1314,7 +1314,7 @@
 
 __PACKAGE__->register_method(
 	method => 'check_user_work_perms',
-	api_name	=> 'open-ils.actor.user.work_perm.highest_org_tree_set',
+	api_name	=> 'open-ils.actor.user.work_perm.org_tree_list',
     authoritative => 1,
     signature => q/
         @see open-ils.actor.user.work_perm.highest_org_set
@@ -1324,13 +1324,45 @@
     /
 );
 
+__PACKAGE__->register_method(
+	method => 'check_user_work_perms',
+	api_name	=> 'open-ils.actor.user.work_perm.org_unit_list',
+    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.
+    /
+);
+
+__PACKAGE__->register_method(
+	method => 'check_user_work_perms',
+	api_name	=> 'open-ils.actor.user.work_perm.org_id_list',
+    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.
+    /
+);
+
 sub check_user_work_perms {
     my($self, $conn, $auth, $perm, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
     my $orglist = $U->find_highest_work_orgs($e, $perm, $options);
-    return $orglist unless $self->api_name =~ /tree/;
-    return get_org_descendants($self, $conn, $orglist);
+
+    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_set/;
+
+    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);
 }
 
 

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2008-04-14 17:38:34 UTC (rev 9344)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2008-04-14 17:38:59 UTC (rev 9345)
@@ -1389,17 +1389,16 @@
 
 sub get_org_descendants {
 	my($self, $org_id, $depth) = @_;
-	$depth ||= 0;
 
+	my $select = {
+		transform => 'actor.org_unit_descendants',
+		column => 'id',
+		result_field => 'id',
+	};
+	$select->{params} = [$depth] if defined $depth;
+
 	my $org_list = OpenILS::Utils::CStoreEditor->new->json_query({
-		select => {
-			aou => [{
-				transform => 'actor.org_unit_descendants',
-				column => 'id',
-				result_field => 'id',
-				params => [$depth]
-			}],
-		},
+		select => {aou => [$select]},
         from => 'aou',
 		where => {id => $org_id}
 	});



More information about the open-ils-commits mailing list