|
|
@ -55,37 +55,15 @@ final class CourseExtension implements QueryCollectionExtensionInterface |
|
|
|
throw new AccessDeniedException('Access Denied.'); |
|
|
|
throw new AccessDeniedException('Access Denied.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$request = $this->requestStack->getCurrentRequest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rootAlias = $queryBuilder->getRootAliases()[0]; |
|
|
|
$rootAlias = $queryBuilder->getRootAliases()[0]; |
|
|
|
|
|
|
|
|
|
|
|
$queryBuilder |
|
|
|
$queryBuilder |
|
|
|
->innerJoin("$rootAlias.resourceNode", 'node') |
|
|
|
->andWhere(sprintf('%s.visibility <> :visibility_hidden', $rootAlias)) |
|
|
|
->innerJoin('node.resourceLinks', 'links') |
|
|
|
->setParameter('visibility_hidden', Course::HIDDEN) |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Do not show deleted resources. |
|
|
|
|
|
|
|
$queryBuilder |
|
|
|
$queryBuilder |
|
|
|
->andWhere('links.visibility != :visibilityDeleted') |
|
|
|
->andWhere(sprintf('%s.visibility <> :visibility_closed', $rootAlias)) |
|
|
|
->setParameter('visibilityDeleted', ResourceLink::VISIBILITY_DELETED) |
|
|
|
->setParameter('visibility_closed', Course::CLOSED) |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$allowDraft = |
|
|
|
|
|
|
|
$this->security->isGranted('ROLE_ADMIN') || |
|
|
|
|
|
|
|
$this->security->isGranted('ROLE_CURRENT_COURSE_TEACHER') |
|
|
|
|
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
if (!$allowDraft) { |
|
|
|
|
|
|
|
$queryBuilder |
|
|
|
|
|
|
|
->andWhere('links.visibility != :visibilityDraft') |
|
|
|
|
|
|
|
->setParameter('visibilityDraft', ResourceLink::VISIBILITY_DRAFT) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*$queryBuilder-> |
|
|
|
|
|
|
|
andWhere('node.creator = :current_user') |
|
|
|
|
|
|
|
;*/ |
|
|
|
|
|
|
|
//$queryBuilder->andWhere(sprintf('%s.node.creator = :current_user', $rootAlias)); |
|
|
|
|
|
|
|
//$queryBuilder->setParameter('current_user', $user->getId()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|