From c208d6713576f885b0ef49d49256f43cc35cd02e Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 11 Mar 2008 15:45:21 +0000 Subject: [PATCH] added ability to pass an object ID and hint to allowed() for object perm checking git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8965 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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; -- 2.11.0