[open-ils-commits] r9344 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Apr 14 14:16:34 EDT 2008
Author: erickson
Date: 2008-04-14 13:38:34 -0400 (Mon, 14 Apr 2008)
New Revision: 9344
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 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: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-04-14 15:22:58 UTC (rev 9343)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-04-14 17:38:34 UTC (rev 9344)
@@ -1311,7 +1311,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
@@ -1321,13 +1321,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: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-04-14 15:22:58 UTC (rev 9343)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-04-14 17:38:34 UTC (rev 9344)
@@ -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