[open-ils-commits] r8685 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Feb 7 13:06:08 EST 2008
Author: erickson
Date: 2008-02-07 12:37:29 -0500 (Thu, 07 Feb 2008)
New Revision: 8685
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
Log:
allowed() now takes an optional 3rd object param which, if present, requests
usr_has_object_perm instead of usr_has_perm
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm 2008-02-07 16:09:08 UTC (rev 8684)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm 2008-02-07 17:37:29 UTC (rev 8685)
@@ -392,8 +392,21 @@
where => {},
};
+my $OBJECT_PERM_QUERY = {
+ select => {
+ au => [ {
+ transform => 'permission.usr_has_object_perm',
+ alias => 'has_perm',
+ column => 'id',
+ params => []
+ } ]
+ },
+ from => 'au',
+ where => {},
+};
+
sub allowed {
- my( $self, $perm, $org ) = @_;
+ my( $self, $perm, $org, $object ) = @_;
my $uid = $self->requestor->id;
$org ||= $self->requestor->ws_ou;
@@ -402,11 +415,16 @@
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});
+ if($object) {
+ $OBJECT_PERM_QUERY->{select}->{au}->[0]->{params} = [$perm, $object->json_hint, $object->id, $org];
+ $OBJECT_PERM_QUERY->{where}->{id} = $uid;
+ return 1 if $U->is_true($self->json_query($OBJECT_PERM_QUERY)->[0]->{has_perm});
+
+ } else {
+ $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});
+ }
}
# set the perm failure event if the permission check returned false
More information about the open-ils-commits
mailing list