kernel/classes/ezrole.php
static function fetchByUser( $idArray, $recursive = false )
    {
        if ( count( $idArray ) < 1 )
        {
            return array();
        }

        $db = eZDB::instance();

        if ( !$recursive )
        {
            $groupINSQL = $db->generateSQLINStatement( $idArray, 'ezuser_role.contentobject_id', false, false, 'int' );
            $query = "SELECT DISTINCT ezrole.id,
                                      ezrole.name,
                                      ezuser_role.limit_identifier,
                                      ezuser_role.limit_value,
                                      ezuser_role.id as user_role_id
                      FROM ezrole,
                           ezuser_role
                      WHERE $groupINSQL AND
                            ezuser_role.role_id = ezrole.id";
        }
        else
        {
            $userNodeIDArray = array();
            foreach( $idArray as $id )
            {
                $nodeDefinition = eZContentObjectTreeNode::fetchByContentObjectID( $id );
                foreach ( $nodeDefinition as $nodeDefinitionElement )
                {
                    $userNodeIDArray = array_merge( $nodeDefinitionElement->attribute( 'path_array' ), $userNodeIDArray );
                }
            }

            if ( count( $userNodeIDArray ) < 1 )
            {
                return array();
            }

            $roleTreeINSQL = $db->generateSQLINStatement( $userNodeIDArray, 'role_tree.node_id', false, false, 'int' );
            $query = "SELECT DISTINCT ezrole.id,
                                      ezrole.name,
                                      ezuser_role.limit_identifier,
                                      ezuser_role.limit_value,
                                      ezuser_role.id as user_role_id
                      FROM ezrole,
                           ezuser_role,
                           ezcontentobject_tree role_tree
                      WHERE ezuser_role.contentobject_id = role_tree.contentobject_id AND
                            ezuser_role.role_id = ezrole.id AND
                            $roleTreeINSQL";
        }

        $roleArray = $db->arrayQuery( $query );

        $roles = array();
        foreach ( $roleArray as $roleRow )
        {
            $role = new eZRole( $roleRow );
            $roles[] = $role;
        }

        return $roles;
    }
static function fetchByUser( $idArray, $recursive = false )
    {
        if ( count( $idArray ) < 1 )
        {
            return array();
        }

        $db = eZDB::instance();

        if ( !$recursive )
        {
            $groupINSQL = $db->generateSQLINStatement( $idArray, 'ezuser_role.contentobject_id', false, false, 'int' );
            $query = "SELECT DISTINCT ezrole.id,
                                      ezrole.name,
                                      ezuser_role.limit_identifier,
                                      ezuser_role.limit_value,
                                      ezuser_role.id as user_role_id
                      FROM ezrole,
                           ezuser_role
                      WHERE $groupINSQL AND
                            ezuser_role.role_id = ezrole.id";
        }
        else
        {
            $userNodeIDArray = array();
            foreach( $idArray as $id )
            {
                $nodeDefinition = eZContentObjectTreeNode::fetchByContentObjectID( $id );
                foreach ( $nodeDefinition as $nodeDefinitionElement )
                {
                    $userNodeIDArray = array_merge( $nodeDefinitionElement->attribute( 'path_array' ), $userNodeIDArray );
                }
            }

            if ( count( $userNodeIDArray ) < 1 )
            {
                return array();
            }

            $roleTreeINSQL = $db->generateSQLINStatement( $userNodeIDArray, 'role_tree.node_id', false, false, 'int' );
            $query = "SELECT DISTINCT ezrole.id,
                                      ezrole.name,
                                      ezuser_role.limit_identifier,
                                      ezuser_role.limit_value,
                                      ezuser_role.id as user_role_id
                      FROM ezrole,
                           ezuser_role,
                           ezcontentobject_tree role_tree
                      WHERE ezuser_role.contentobject_id = role_tree.contentobject_id AND
                            ezuser_role.role_id = ezrole.id AND
                            $roleTreeINSQL";
        }

        $roleArray = $db->arrayQuery( $query );

        $roles = array();
        foreach ( $roleArray as $roleRow )
        {
            $role = new eZRole( $roleRow );
            $roles[] = $role;
        }

        return $roles;
    }
static function fetchByUser ( $ idArray , $ recursive = false ) { if ( count ( $ idArray ) < 1 ) { return array ( ) ; } $ db = eZDB :: instance ( ) ; if ( ! $ recursive ) { $ groupINSQL = $ db -> generateSQLINStatement ( $ idArray , 'ezuser_role.contentobject_id' , false , false , 'int' ) ; $ query = "SELECT DISTINCT ezrole.id,
                                      ezrole.name,
                                      ezuser_role.limit_identifier,
                                      ezuser_role.limit_value,
                                      ezuser_role.id as user_role_id
                      FROM ezrole,
                           ezuser_role
                      WHERE $groupINSQL AND
                            ezuser_role.role_id = ezrole.id" ; } else { $ userNodeIDArray = array ( ) ; foreach ( $ idArray as $ id ) { $ nodeDefinition = eZContentObjectTreeNode :: fetchByContentObjectID ( $ id ) ; foreach ( $ nodeDefinition as $ nodeDefinitionElement ) { $ userNodeIDArray = array_merge ( $ nodeDefinitionElement -> attribute ( 'path_array' ) , $ userNodeIDArray ) ; } } if ( count ( $ userNodeIDArray ) < 1 ) { return array ( ) ; } $ roleTreeINSQL = $ db -> generateSQLINStatement ( $ userNodeIDArray , 'role_tree.node_id' , false , false , 'int' ) ; $ query = "SELECT DISTINCT ezrole.id,
                                      ezrole.name,
                                      ezuser_role.limit_identifier,
                                      ezuser_role.limit_value,
                                      ezuser_role.id as user_role_id
                      FROM ezrole,
                           ezuser_role,
                           ezcontentobject_tree role_tree
                      WHERE ezuser_role.contentobject_id = role_tree.contentobject_id AND
                            ezuser_role.role_id = ezrole.id AND
                            $roleTreeINSQL" ; } $ roleArray = $ db -> arrayQuery ( $ query ) ; $ roles = array ( ) ; foreach ( $ roleArray as $ roleRow ) { $ role = new eZRole ( $ roleRow ) ; $ roles [ ] = $ role ; } return $ roles ; }
Returns the roles matching the given users' eZContentObject ID array

@param array $idArray Array of eZContentObject IDs, either groups + user id or user id's only
If only user id's, then remember to set $recursive to true
@param bool $recursive
If true, roles will be looked up for all nodes of the id's and it's parents

@return array(eZRole)
Returns the roles matching the given users eZContentObject ID array