public function userHasRoles( core_kernel_classes_Resource $user, $roles)
    {
        $returnValue = (bool) false;

    	if (empty($roles)){
        	throw new InvalidArgumentException('The $roles parameter must not be empty.');	
        }
        
    	$roles = (is_array($roles)) ? $roles : array($roles);
    	$searchRoles = array();
    	foreach ($roles as $r){
    		$searchRoles[] = ($r instanceof core_kernel_classes_Resource) ? $r->getUri() : $r;
    	}
    	unset($roles);
    	
        if (common_session_SessionManager::getSession()->getUserUri() == $user->getUri()){
            foreach (common_session_SessionManager::getSession()->getUserRoles() as $role) {
                if (in_array($role, $searchRoles)) {
                    $returnValue = true;
                    break;
                }
            }
        } else {
    	    // After introducing remote users, we can no longer guarantee that any user and his roles are available
        	common_Logger::w('Roles of non current user ('.$user->getUri().') checked, trying fallback to local ontology');	
        	$userRoles = array_keys($this->getUserRoles($user));
        	$identicalRoles = array_intersect($searchRoles, $userRoles);
        	
        	$returnValue = (count($identicalRoles) === count($searchRoles));
        }
    	
        return (bool) $returnValue;
    }
public function userHasRoles( core_kernel_classes_Resource $user, $roles)
    {
        $returnValue = (bool) false;

    	if (empty($roles)){
        	throw new InvalidArgumentException('The $roles parameter must not be empty.');	
        }
        
    	$roles = (is_array($roles)) ? $roles : array($roles);
    	$searchRoles = array();
    	foreach ($roles as $r){
    		$searchRoles[] = ($r instanceof core_kernel_classes_Resource) ? $r->getUri() : $r;
    	}
    	unset($roles);
    	
        if (common_session_SessionManager::getSession()->getUserUri() == $user->getUri()){
            foreach (common_session_SessionManager::getSession()->getUserRoles() as $role) {
                if (in_array($role, $searchRoles)) {
                    $returnValue = true;
                    break;
                }
            }
        } else {
    	    // After introducing remote users, we can no longer guarantee that any user and his roles are available
        	common_Logger::w('Roles of non current user ('.$user->getUri().') checked, trying fallback to local ontology');	
        	$userRoles = array_keys($this->getUserRoles($user));
        	$identicalRoles = array_intersect($searchRoles, $userRoles);
        	
        	$returnValue = (count($identicalRoles) === count($searchRoles));
        }
    	
        return (bool) $returnValue;
    }
public function userHasRoles ( core_kernel_classes_Resource $ user , $ roles ) { $ returnValue = ( bool ) false ; if ( empty ( $ roles ) ) { throw new InvalidArgumentException ( 'The $roles parameter must not be empty.' ) ; } $ roles = ( is_array ( $ roles ) ) ? $ roles : array ( $ roles ) ; $ searchRoles = array ( ) ; foreach ( $ roles as $ r ) { $ searchRoles [ ] = ( $ r instanceof core_kernel_classes_Resource ) ? $ r -> getUri ( ) : $ r ; } unset ( $ roles ) ; if ( common_session_SessionManager :: getSession ( ) -> getUserUri ( ) == $ user -> getUri ( ) ) { foreach ( common_session_SessionManager :: getSession ( ) -> getUserRoles ( ) as $ role ) { if ( in_array ( $ role , $ searchRoles ) ) { $ returnValue = true ; break ; } } } else { // After introducing remote users, we can no longer guarantee that any user and his roles are available common_Logger :: w ( 'Roles of non current user (' . $ user -> getUri ( ) . ') checked, trying fallback to local ontology' ) ; $ userRoles = array_keys ( $ this -> getUserRoles ( $ user ) ) ; $ identicalRoles = array_intersect ( $ searchRoles , $ userRoles ) ; $ returnValue = ( count ( $ identicalRoles ) === count ( $ searchRoles ) ) ; } return ( bool ) $ returnValue ; }
Indicates if a user is granted with a set of Roles.

@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param  Resource user The User instance you want to check Roles.
@param  roles Can be either a single Resource or an array of Resource depicting Role(s).
@return boolean
Indicates if a user is granted with a set of Roles .