From: erickson Date: Tue, 11 Mar 2008 15:46:47 +0000 (+0000) Subject: added ability to pass an object ID and hint to allowed() for object perm checking X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3986c31cfedcbe76b5b8b8267a83542fff747c67;p=Evergreen.git added ability to pass an object ID and hint to allowed() for object perm checking git-svn-id: svn://svn.open-ils.org/ILS/trunk@8966 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm index a27196765e..4e28ebc36f 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm @@ -406,7 +406,7 @@ my $OBJECT_PERM_QUERY = { }; sub allowed { - my( $self, $perm, $org, $object ) = @_; + my( $self, $perm, $org, $object, $hint ) = @_; my $uid = $self->requestor->id; $org ||= $self->requestor->ws_ou; @@ -416,8 +416,15 @@ sub allowed { $self->log(I, "checking perms user=$uid, org=$org, perm=$perm"); if($object) { - my $id_field = $object->Identity; - my $params = [$perm, $object->json_hint, $object->$id_field]; + my $params; + if(ref $object) { + # determine the ID field and json_hint from the object + my $id_field = $object->Identity; + $params = [$perm, $object->json_hint, $object->$id_field]; + } else { + # we were passed an object-id and json_hint + $params = [$perm, $hint, $object]; + } push(@$params, $org) if $org; $OBJECT_PERM_QUERY->{select}->{au}->[0]->{params} = $params; $OBJECT_PERM_QUERY->{where}->{id} = $uid;