[open-ils-commits] r8634 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 5 10:53:30 EST 2008
Author: erickson
Date: 2008-02-05 10:25:11 -0500 (Tue, 05 Feb 2008)
New Revision: 8634
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added a descendants option to the high work org retrieval function
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-02-05 15:16:04 UTC (rev 8633)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2008-02-05 15:25:11 UTC (rev 8634)
@@ -1328,17 +1328,18 @@
check is implied by the authtoken. /,
params => [
{desc => 'authtoken', type => 'string'},
- {desc => 'permission name', type => 'string'}
+ {desc => 'permission name', type => 'string'},
+ {desc => 'options hash, including "descendants", which will include all child orgs of the found perm orgs', type => 'hash'}
],
return => {desc => 'An array of org IDs'}
}
);
sub check_user_work_perms {
- my($self, $conn, $auth, $perm) = @_;
+ my($self, $conn, $auth, $perm, $options) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
- return $U->find_highest_work_orgs($e, $perm);
+ return $U->find_highest_work_orgs($e, $perm, $options);
}
__PACKAGE__->register_method(
@@ -2652,7 +2653,7 @@
method => 'usrname_exists',
api_name => 'open-ils.actor.username.exists',
signature => q/
- Returns the user ID of the requested username if that username exists, returns null otherwise
+ Returns 1 if the requested username exists, returns 0 otherwise
/
);
@@ -2664,14 +2665,14 @@
return $e->event unless $e->checkauth;
my $a = $e->search_actor_user({usrname => $usrname, deleted=>'f'}, {idlist=>1});
return $$a[0] if $a and @$a;
- return undef;
+ return 0;
}
__PACKAGE__->register_method(
method => 'barcode_exists',
api_name => 'open-ils.actor.barcode.exists',
signature => q/
- Returns the user ID for the requested barcode if that barcode exists, returns null otherwise
+ Returns 1 if the requested barcode exists, returns 0 otherwise
/
);
@@ -2680,8 +2681,8 @@
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
my $card = $e->search_actor_card({barcode => $barcode});
- return undef unless @$card;
- return $card->[0]->usr;
+ return 0 unless @$card;
+ return $card->[0]->usr;
}
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-02-05 15:16:04 UTC (rev 8633)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-02-05 15:25:11 UTC (rev 8634)
@@ -1288,7 +1288,7 @@
sub find_highest_work_orgs {
- my($self, $e, $perm) = @_;
+ my($self, $e, $perm, $options) = @_;
my $work_orgs = $self->get_user_work_ou_ids($e, $e->requestor->id);
$logger->debug("found work orgs @$work_orgs");
@@ -1320,14 +1320,20 @@
$logger->debug("work org looking at $org");
my $org_list = $self->get_org_full_path($org, $org_depth);
+ my $found = 0;
for my $sub_org (@$org_list) {
- $logger->debug("work org looking at sub-org $sub_org");
- my $org_unit = $self->find_org($org_tree, $sub_org);
- my ($ou_type) = grep { $_->id == $org_unit->ou_type } @$org_types;
- if($ou_type->depth >= $org_depth) {
- push(@allowed_orgs, $sub_org);
- last;
- }
+ if(not $found) {
+ $logger->debug("work org looking at sub-org $sub_org");
+ my $org_unit = $self->find_org($org_tree, $sub_org);
+ my ($ou_type) = grep { $_->id == $org_unit->ou_type } @$org_types;
+ if($ou_type->depth >= $org_depth) {
+ push(@allowed_orgs, $sub_org);
+ $found = 1;
+ }
+ } else {
+ last unless $$options{descendants};
+ push(@allowed_orgs, $sub_org);
+ }
}
}
More information about the open-ils-commits
mailing list