Internal: Group: Use AccessUrlHelper to filter queries with access_url relation

pull/5217/head
Angel Fernando Quiroz Campos 9 months ago
parent aadedea48b
commit 2ae80c3267
  1. 32
      src/CoreBundle/Repository/Node/UsergroupRepository.php

@ -10,6 +10,7 @@ use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Entity\Usergroup;
use Chamilo\CoreBundle\Entity\UsergroupRelUser;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper;
use Doctrine\Persistence\ManagerRegistry;
use Exception;
@ -17,7 +18,8 @@ class UsergroupRepository extends ResourceRepository
{
public function __construct(
ManagerRegistry $registry,
private readonly IllustrationRepository $illustrationRepository
private readonly IllustrationRepository $illustrationRepository,
private readonly AccessUrlHelper $accessUrlHelper,
) {
parent::__construct($registry, Usergroup::class);
}
@ -47,11 +49,12 @@ class UsergroupRepository extends ResourceRepository
}
}
if ($this->getUseMultipleUrl()) {
$urlId = $this->getCurrentAccessUrlId();
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.urls', 'u')
->andWhere('u.accessUrl = :urlId')
->setParameter('urlId', $urlId)
->setParameter('urlId', $accessUrl->getId())
;
}
@ -85,11 +88,12 @@ class UsergroupRepository extends ResourceRepository
->setMaxResults($limit)
;
if ($this->getUseMultipleUrl()) {
$urlId = $this->getCurrentAccessUrlId();
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.urls', 'u')
->andWhere('u.accessUrl = :urlId')
->setParameter('urlId', $urlId)
->setParameter('urlId', $accessUrl->getId())
;
}
@ -120,11 +124,12 @@ class UsergroupRepository extends ResourceRepository
->setMaxResults($limit)
;
if ($this->getUseMultipleUrl()) {
$urlId = $this->getCurrentAccessUrlId();
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.urls', 'u')
->andWhere('u.accessUrl = :urlId')
->setParameter('urlId', $urlId)
->setParameter('urlId', $accessUrl->getId())
;
}
@ -306,11 +311,12 @@ class UsergroupRepository extends ResourceRepository
$qb->select('g.id, g.title, g.description, g.url, g.picture');
}
if ($this->getUseMultipleUrl()) {
$urlId = $this->getCurrentAccessUrlId();
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.accessUrls', 'a', 'WITH', 'g.id = a.usergroup')
->andWhere('a.accessUrl = :urlId')
->setParameter('urlId', $urlId)
->setParameter('urlId', $accessUrl->getId())
;
}

Loading…
Cancel
Save