From feac2f65f15b614233f93159a5b5aebf487332a1 Mon Sep 17 00:00:00 2001 From: Martin Haase <martin.haase@daasi.de> Date: Wed, 8 Oct 2008 09:09:33 +0000 Subject: [PATCH] Added event to fix TgExtra function getRights (Jira ticket TG-83) git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@2064 7c539038-3410-0410-b1ec-0f2a7bf1c452 --- .../rbac/RBACcore.class.php | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/info.textgrid.middleware.tgauth.rbac/rbac/RBACcore.class.php b/info.textgrid.middleware.tgauth.rbac/rbac/RBACcore.class.php index 09e60c4..3a538e0 100755 --- a/info.textgrid.middleware.tgauth.rbac/rbac/RBACcore.class.php +++ b/info.textgrid.middleware.tgauth.rbac/rbac/RBACcore.class.php @@ -1079,25 +1079,59 @@ class RBACcore implements iRBACcore { // ## userOperationsOnObject ######################################## public function userOperationsOnObject( $inUser, $inResource ) { + $context = false; // Possibly a Context-object $arrAuthRole; // The users authorized roles $arrOperation = Array(); // The resulting operations $arrTmpOperation; // Temporary array of operations $i = 0; // Loop - // Get the users authorized roles - $arrAuthRole = $this->authorizedRoles( $inUser, false ); + // If an interceptor is defined, we need to + // provide a context and events + if( $this->interceptor ) { + + $context = new Context(); + + } + + + if( preg_match( "/.+/", $inUser ) ) { + + // Get the users authorized roles + $arrAuthRole = $this->authorizedRoles( $inUser, false ); - for( $i = 0; $i < sizeof( $arrAuthRole ); $i++ ) { + for( $i = 0; $i < sizeof( $arrAuthRole ); $i++ ) { + + // Get the operations the user has because of role i + $arrTmpOperation = $this->roleOperationsOnObjectInternal( $arrAuthRole[$i], $inResource, true ); + + + // Only merge the result of the above call if it really is + // an array. + is_array( $arrTmpOperation ) ? $arrOperation = array_merge( $arrOperation, $arrTmpOperation ) : false; + + } + + } + + + // ----------- + // -- EVENT -- + // The operations are ready to return, but + // maybe someone wants to add or remove one. + // ----------- + if( $this->interceptor ) { - // Get the operations the user has because of role i - $arrTmpOperation = $this->roleOperationsOnObjectInternal( $arrAuthRole[$i], $inResource, true ); + // Create context + $context->setValue( "arrOperation", $arrOperation ); + // Give away the context + $context = $this->interceptor->event( "userOperationsOnObject", "finish", $context ); - // Only merge the result of the above call if it really is - // an array. - is_array( $arrTmpOperation ) ? $arrOperation = array_merge( $arrOperation, $arrTmpOperation ) : false; + // Use the returned context + $arrOperation = $context->getValue( "arrOperation" ); + $continue = $context->getSecurityChain(); } -- GitLab