Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/inc/Entity/Repository/CurriculumItemRelUserReposi...

37 lines
1014 B

<?php
namespace Entity\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Common\Collections\Criteria;
/**
* CurriculumItemRelUserRepository
*
*/
class CurriculumItemRelUserRepository extends EntityRepository
{
/**
* Get all users that are registered in the course. No matter the status
* @param \Entity\CurriculumItem $item
* @param \Entity\User $user
* @return bool
*/
public function isAllowToInsert(\Entity\CurriculumItem $item, \Entity\User $user)
{
$max = $item->getMaxRepeat();
$count = $this->createQueryBuilder('a')
->select('COUNT(a)')
->where('a.itemId = :itemId')
->andWhere('a.userId = :userId')
->setParameters(
array(
'itemId' => $item->getId(),
'userId' => $user->getUserId()
)
)
->getQuery()
->getSingleScalarResult();
return $count <= $max ? true : false;
}
}