main/core/Repository/ResourceRightsRepository.php
public function findCreationRights(array $roles, ResourceNode $node)
    {
        if (0 === count($roles)) {
            throw new \RuntimeException('Roles cannot be empty');
        }

        $dql = '
            SELECT DISTINCT rType.name
            FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType
            JOIN rType.rights right
            JOIN right.role role
            JOIN right.resourceNode resource
            WHERE ';

        $index = 0;

        foreach ($roles as $key => $role) {
            $dql .= 0 !== $index ? ' OR ' : '';
            $dql .= "resource.id = :nodeId AND role.name = :role_{$key}";
            ++$index;
        }

        $query = $this->_em->createQuery($dql);
        $query->setParameter('nodeId', $node->getId());

        foreach ($roles as $key => $role) {
            $query->setParameter('role_'.$key, $role);
        }

        return $query->getArrayResult();
    }
public function findCreationRights(array $roles, ResourceNode $node)
    {
        if (0 === count($roles)) {
            throw new \RuntimeException('Roles cannot be empty');
        }

        $dql = '
            SELECT DISTINCT rType.name
            FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType
            JOIN rType.rights right
            JOIN right.role role
            JOIN right.resourceNode resource
            WHERE ';

        $index = 0;

        foreach ($roles as $key => $role) {
            $dql .= 0 !== $index ? ' OR ' : '';
            $dql .= "resource.id = :nodeId AND role.name = :role_{$key}";
            ++$index;
        }

        $query = $this->_em->createQuery($dql);
        $query->setParameter('nodeId', $node->getId());

        foreach ($roles as $key => $role) {
            $query->setParameter('role_'.$key, $role);
        }

        return $query->getArrayResult();
    }
public function findCreationRights ( array $ roles , ResourceNode $ node ) { if ( 0 === count ( $ roles ) ) { throw new \ RuntimeException ( 'Roles cannot be empty' ) ; } $ dql = '
            SELECT DISTINCT rType.name
            FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType
            JOIN rType.rights right
            JOIN right.role role
            JOIN right.resourceNode resource
            WHERE ' ; $ index = 0 ; foreach ( $ roles as $ key => $ role ) { $ dql .= 0 !== $ index ? ' OR ' : '' ; $ dql .= "resource.id = :nodeId AND role.name = :role_{$key}" ; ++ $ index ; } $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'nodeId' , $ node -> getId ( ) ) ; foreach ( $ roles as $ key => $ role ) { $ query -> setParameter ( 'role_' . $ key , $ role ) ; } return $ query -> getArrayResult ( ) ; }
Returns the resource types a set of roles is allowed to create in a given
directory.

@param array        $roles
@param ResourceNode $node

@return array
Returns the resource types a set of roles is allowed to create in a given directory .