[open-ils-commits] r8661 - trunk/Open-ILS/src/perlmods/OpenILS/Utils
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Feb 6 11:58:23 EST 2008
Author: erickson
Date: 2008-02-06 11:29:55 -0500 (Wed, 06 Feb 2008)
New Revision: 8661
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
Log:
gave cstore editor the ability to check an array of permissions
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm 2008-02-06 16:23:45 UTC (rev 8660)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm 2008-02-06 16:29:55 UTC (rev 8661)
@@ -375,20 +375,10 @@
# $e->event is set and undef is returned
# The perm user is $e->requestor->id and perm org defaults to the requestor's
# ws_ou
-# If this perm at the given org has already been verified, true is returned
-# and the perm is not re-checked
+# if perm is an array of perms, method will return true at the first allowed
+# permission. If none of the perms are allowed, the perm_failure event
+# is created with the last perm to fail
# -----------------------------------------------------------------------------
-=head
-sub allowed {
- my( $self, $perm, $org ) = @_;
- my $uid = $self->requestor->id;
- $org ||= $self->requestor->ws_ou;
- $self->log(I, "checking perms user=$uid, org=$org, perm=$perm");
- return 1 if $self->perm_checked($perm, $org);
- return $self->checkperm($uid, $org, $perm);
-}
-=cut
-
my $PERM_QUERY = {
select => {
au => [ {
@@ -406,21 +396,26 @@
my( $self, $perm, $org ) = @_;
my $uid = $self->requestor->id;
$org ||= $self->requestor->ws_ou;
- $self->log(I, "checking perms user=$uid, org=$org, perm=$perm");
- # fill in the search hash
- $PERM_QUERY->{select}->{au}->[0]->{params} = [$perm, $org];
- $PERM_QUERY->{where}->{id} = $uid;
+ my $perms = [$perm] unless ref($perm) eq 'ARRAY';
+ my $perm;
+ for $perm (@$perms) {
+ $self->log(I, "checking perms user=$uid, org=$org, perm=$perm");
+
+ # fill in the search hash
+ $PERM_QUERY->{select}->{au}->[0]->{params} = [$perm, $org];
+ $PERM_QUERY->{where}->{id} = $uid;
+
+ return 1 if $U->is_true($self->json_query($PERM_QUERY)->[0]->{has_perm});
+ }
- return 1 if $U->is_true($self->json_query($PERM_QUERY)->[0]->{has_perm});
-
# set the perm failure event if the permission check returned false
my $e = OpenILS::Event->new('PERM_FAILURE', ilsperm => $perm, ilspermloc => $org);
$self->event($e);
return undef;
-
}
+
=head
sub checkperm {
my($self, $userid, $org, $perm) = @_;
More information about the open-ils-commits
mailing list