Пример #1
0
 /**
  * @param ProjectEntity $project
  * @param Access        $access
  *
  * @return ResultEntity[]
  */
 public function findResultByProjectAndAccess(ProjectEntity $project, Access $access)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select('r');
     $qb->from("Project\\Entity\\Result\\Result", 'r');
     $qb->join('r.type', 't');
     $qb->join('t.access', 'a');
     $qb->where('r.project = ?1');
     $qb->andWhere($qb->expr()->in('a.id', [$access->getId()]));
     $qb->setParameter(1, $project);
     return $qb->getQuery()->getResult();
 }
Пример #2
0
 /**
  * Function which returns true/false based ont he fact if a user can view the calendar
  *
  * @param Entity\Calendar $calendar
  * @param Contact         $contact
  *
  * @return bool
  */
 public function canViewCalendar(Entity\Calendar $calendar, Contact $contact = null)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select('c');
     $qb->from("Calendar\\Entity\\Calendar", 'c');
     if ($contact->isEmpty()) {
         $contact = new Contact();
         $contact->setId(0);
         $access = new Access();
         $access->setAccess(strtolower(Access::ACCESS_PUBLIC));
         $contact->setAccess([$access]);
     }
     $qb = $this->filterForAccess($qb, $contact);
     $qb->andWhere('c = ?100');
     $qb->setParameter(100, $calendar);
     return !is_null($qb->getQuery()->getOneOrNullResult());
 }
Пример #3
0
 /**
  * New function needed to make the hydrator happy
  *
  * @param Collections\Collection $accessCollection
  */
 public function removeAccess(Collections\Collection $accessCollection)
 {
     foreach ($accessCollection as $single) {
         $this->access->removeElement($single);
     }
 }