public function findByRoleNamesBySearch(array $roleNames, $search, $orderedToolType = 0)
    {
        $dql = '
            SELECT DISTINCT w
            FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
            JOIN w.orderedTools ot
            JOIN ot.rights otr
            JOIN otr.role r
            WHERE r.name IN (:roleNames)
            AND ot.type = :type
            AND BIT_AND(otr.mask, :openValue) = :openValue
            AND (
                UPPER(w.name) LIKE :search
                OR UPPER(w.code) LIKE :search
            )
            ORDER BY w.name
        ';

        $upperSearch = strtoupper($search);
        $query = $this->_em->createQuery($dql);
        $query->setParameter('roleNames', $roleNames);
        $query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']);
        $query->setParameter('search', "%{$upperSearch}%");
        $query->setParameter('type', $orderedToolType);

        return $query->getResult();
    }