From c1603dd0ff6cdec2467ecaed574dea994422969d Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 7 Jan 2008 23:16:02 +0000 Subject: [PATCH] plugged in new permission checking call which uses cstore instead of storage git-svn-id: svn://svn.open-ils.org/ILS/trunk@8347 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Utils/CStoreEditor.pm | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm index d84c82bb1c..b54b5dbc1e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm @@ -357,6 +357,7 @@ sub perm_checked { # If this perm at the given org has already been verified, true is returned # and the perm is not re-checked # ----------------------------------------------------------------------------- +=head sub allowed { my( $self, $perm, $org ) = @_; my $uid = $self->requestor->id; @@ -365,7 +366,41 @@ sub allowed { return 1 if $self->perm_checked($perm, $org); return $self->checkperm($uid, $org, $perm); } +=cut + +my $PERM_QUERY = { + select => { + au => [ { + transform => 'permission.usr_has_perm', + alias => 'has_perm', + column => 'id', + params => [] + } ] + }, + from => 'au', + where => {}, +}; + +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"); + # 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}); + + # 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) = @_; my $s = $U->storagereq( @@ -379,6 +414,7 @@ sub checkperm { return 1; } +=cut -- 2.11.0