Пример #1
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());
 }