public function findDisplayedByRolesAndWorkspace(
        array $roles,
        Workspace $workspace,
        $orderedToolType = 0
    ) {
        if (count($roles) === 0) {
            return array();
        } else {
            $isAdmin = false;

            foreach ($roles as $role) {
                if ($role === 'ROLE_ADMIN' || $role === 'ROLE_WS_MANAGER_'.$workspace->getGuid()) {
                    $isAdmin = true;
                }
            }

            if (!$isAdmin) {
                $dql = '
                    SELECT t
                    FROM Claroline\CoreBundle\Entity\Tool\Tool t
                    JOIN t.orderedTools ot
                    JOIN ot.rights r
                    JOIN r.role rr
                    LEFT JOIN t.plugin p
                    WHERE ot.workspace = :workspace
                    AND ot.type = :type
                    AND rr.name IN (:roleNames)
                    AND BIT_AND(r.mask, 1) = 1
                    AND (
                        CONCAT(p.vendorName, p.bundleName) IN (:bundles)
                        OR p.id is NULL
                    )
                    ORDER BY ot.order
                ';
                $query = $this->_em->createQuery($dql);
                $query->setParameter('workspace', $workspace);
                $query->setParameter('roleNames', $roles);
                $query->setParameter('type', $orderedToolType);
                $query->setParameter('bundles', $this->bundles);
            } else {
                $dql = '
                    SELECT tool
                    FROM Claroline\CoreBundle\Entity\Tool\Tool tool
                    JOIN tool.orderedTools ot
                    LEFT JOIN tool.plugin p
                    WHERE ot.workspace = :workspace
                    AND tool.isDisplayableInWorkspace = true
                    AND (
                        CONCAT(p.vendorName, p.bundleName) IN (:bundles)
                        OR tool.plugin is NULL
                    )
                    ORDER BY ot.order
                ';

                $query = $this->_em->createQuery($dql);
                $query->setParameter('workspace', $workspace);
                $query->setParameter('bundles', $this->bundles);
            }

            return $query->getResult();
        }
    }