[open-ils-commits] r8770 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 18 18:47:43 EST 2008
Author: erickson
Date: 2008-02-18 18:17:32 -0500 (Mon, 18 Feb 2008)
New Revision: 8770
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
Log:
added method to return list of accessible objects based on object-specific perms
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-18 23:08:52 UTC (rev 8769)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm 2008-02-18 23:17:32 UTC (rev 8770)
@@ -416,7 +416,9 @@
$self->log(I, "checking perms user=$uid, org=$org, perm=$perm");
if($object) {
- $OBJECT_PERM_QUERY->{select}->{au}->[0]->{params} = [$perm, $object->json_hint, $object->id, $org];
+ my $params = [$perm, $object->json_hint, $object->id];
+ push(@$params, $org) if $org;
+ $OBJECT_PERM_QUERY->{select}->{au}->[0]->{params} = $params;
$OBJECT_PERM_QUERY->{where}->{id} = $uid;
return 1 if $U->is_true($self->json_query($OBJECT_PERM_QUERY)->[0]->{has_perm});
@@ -435,6 +437,33 @@
# -----------------------------------------------------------------------------
+# Returns the list of object IDs this user has object-specific permissions for
+# -----------------------------------------------------------------------------
+sub objects_allowed {
+ my($self, $perm, $obj_type) = @_;
+
+ my $query = {
+ select => {puopm => ['object_id']},
+ from => {
+ puopm => {
+ ppl => {field => 'id',fkey => 'perm'}
+ }
+ },
+ where => {
+ '+puopm' => {usr => $self->requestor->id, object_type => $obj_type},
+ '+ppl' => {code => $perm}
+ }
+ };
+
+ my $list = $self->json_query($query);
+ my @ids;
+ push(@ids, 0+$_->{object_id}) for @$list;
+
+ return \@ids;
+}
+
+
+# -----------------------------------------------------------------------------
# checks the appropriate perm for the operation
# -----------------------------------------------------------------------------
sub _checkperm {
More information about the open-ils-commits
mailing list