[open-ils-commits] r14227 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 30 14:23:08 EDT 2009
Author: erickson
Date: 2009-09-30 14:23:04 -0400 (Wed, 30 Sep 2009)
New Revision: 14227
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added support for checking work_ou perms for a given user that is not the logged in user in open-ils.actor.user.has_work_perm_at[.batch]
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-09-30 17:56:22 UTC (rev 14226)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-09-30 18:23:04 UTC (rev 14227)
@@ -1322,16 +1322,22 @@
params => [
{desc => 'authtoken', type => 'string'},
{desc => 'permission name', type => 'string'},
+ {desc => q/user id, optional. If present, check perms for
+ this user instead of the logged in user/, type => 'number'},
],
return => {desc => 'An array of org IDs'}
}
);
sub user_has_work_perm_at {
- my($self, $conn, $auth, $perm) = @_;
+ my($self, $conn, $auth, $perm, $user_id) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
- return $U->user_has_work_perm_at($e, $perm);
+ if(defined $user_id) {
+ my $user = $e->retrieve_actor_user($user_id) or return $e->event;
+ return $e->event unless $e->allowed('VIEW_PERMISSION', $user->home_ou);
+ }
+ return $U->user_has_work_perm_at($e, $perm, undef, $user_id);
}
__PACKAGE__->register_method(
@@ -1341,9 +1347,13 @@
);
sub user_has_work_perm_at_batch {
- my($self, $conn, $auth, $perms) = @_;
+ my($self, $conn, $auth, $perms, $user_id) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
+ if(defined $user_id) {
+ my $user = $e->retrieve_actor_user($user_id) or return $e->event;
+ return $e->event unless $e->allowed('VIEW_PERMISSION', $user->home_ou);
+ }
my $map = {};
$map->{$_} = $U->user_has_work_perm_at($e, $_) for @$perms;
return $map;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-09-30 17:56:22 UTC (rev 14226)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-09-30 18:23:04 UTC (rev 14227)
@@ -1205,13 +1205,14 @@
# returns the org_unit ID's
sub user_has_work_perm_at {
- my($self, $e, $perm, $options) = @_;
+ my($self, $e, $perm, $options, $user_id) = @_;
$options ||= {};
+ $user_id = (defined $user_id) ? $user_id : $e->requestor->id;
my $func = 'permission.usr_has_perm_at';
$func = $func.'_all' if $$options{descendants};
- my $orgs = $e->json_query({from => [$func, $e->requestor->id, $perm]});
+ my $orgs = $e->json_query({from => [$func, $user_id, $perm]});
$orgs = [map { $_->{ (keys %$_)[0] } } @$orgs];
return $orgs unless $$options{objects};
More information about the open-ils-commits
mailing list