Exemple #1
0
 protected function getForm($show = null)
 {
     if (is_null($show)) {
         $show = new Show();
         $show->addPerformance(new Performance());
     }
     return $this->createForm(new ShowType($this->get('security.context')), $show);
 }
Exemple #2
0
 public function createShow($show_name)
 {
     $show = new Show();
     $show->setName($show_name)->setCategory('drama')->setAuthorisedBy($this->getAuthoriseUser());
     $em = $this->getEntityManager();
     $em->persist($show);
     $em->flush();
     return $show;
 }
Exemple #3
0
 public function testNotVenueOwner()
 {
     $show = new Show();
     $venue = new Venue();
     $venue->setName('Test Venue');
     $show->setVenue($venue);
     $this->aclProvider->expects($this->atLeastOnce())->method('isOwner')->with($this->user, $venue)->will($this->returnValue(false));
     $this->assertEquals(ShowVoter::ACCESS_DENIED, $this->voter->vote($this->token, $show, array('EDIT')));
     $this->assertEquals(ShowVoter::ACCESS_DENIED, $this->voter->vote($this->token, $show, array('APPROVE')));
 }
Exemple #4
0
 public function testIsOwner_ExternalUserIsOwner()
 {
     $user = new User();
     $user->setEmail('*****@*****.**');
     $external_user = new ExternalUser();
     $external_user->setUser($user)->setUsername('testuser');
     $show = new Show();
     $show->setName('Test Show');
     $this->repository->expects($this->once())->method('aceExists')->with($user, $show)->will($this->returnValue(false));
     $this->assertFalse($this->aclProvider->isOwner($user, $show));
 }
Exemple #5
0
 public function prePersist(Show $show, LifecycleEventArgs $event)
 {
     if (!$show->getPrimaryRef()) {
         $refname = Sluggable\Urlizer::urlize($show->getName(), '_');
         if ($show->getStartAt()) {
             $year = $show->getStartAt()->format('y');
             $refname = $year . '/' . $refname;
         }
         $ref = new ShowRef();
         $ref->setShow($show);
         $ref->setRef($refname);
         $show->setPrimaryRef($ref);
     }
 }
Exemple #6
0
 /**
  * Get the list of users that have requested admin access to a show.
  */
 public function getRequestedShowAdmins(Show $show)
 {
     $query = $this->createQueryBuilder('u')->innerJoin('u.aces', 'e')->where("e.type = 'request-show'")->andWhere('e.entityId = :id')->andWhere('e.grantedBy IS NULL')->andWhere('e.revokedBy IS NULL')->setParameter('id', $show->getId())->getQuery();
     return $query->getResult();
 }
Exemple #7
0
 public function testCreateEventFromShows()
 {
     $s1 = new Show();
     $s1->setName('Test Show 1');
     $s1->setSlug('test-show-1');
     $p1 = new Performance();
     $p1->setStartDate(new \DateTime('2013-04-01'));
     $p1->setEndDate(new \DateTime('2013-04-02'));
     $p1->setTime(new \DateTime('19:30'));
     $p1->setShow($s1);
     $s1->addPerformance($p1);
     $s2 = new Show();
     $s2->setName('Test Show 2');
     $s2->setSlug('test-show-2');
     $p2 = new Performance();
     $p2->setStartDate(new \DateTime('2013-02-10'));
     $p2->setEndDate(new \DateTime('2013-02-15'));
     $p2->setTime(new \DateTime('19:45'));
     $p2->setShow($s2);
     $s2->addPerformance($p2);
     $p3 = new Performance();
     $p3->setStartDate(new \DateTime('2013-02-15'));
     $p3->setEndDate(new \DateTime('2013-02-15'));
     $p3->setTime(new \DateTime('14:30'));
     $p3->setShow($s2);
     $s2->addPerformance($p3);
     $events = $this->diaryHelper->createEventsFromShows(array($s1, $s2));
     $this->assertEquals(3, count($events));
     $this->assertEquals(new \DateTime('2013-04-01'), $events[0]->getStartDate());
     $this->assertEquals(new \DateTime('2013-02-10'), $events[1]->getStartDate());
     $this->assertEquals(new \DateTime('2013-02-15'), $events[2]->getStartDate());
 }
Exemple #8
0
 private function allocateSociety(Show $show)
 {
     if (mt_rand(0, 3) == 0) {
         $show->setOtherSociety('Random Society ' . mt_rand(1, 100));
     } else {
         $show->setSociety($this->society_repo->findOneById($this->society_ids[mt_rand(0, count($this->society_ids) - 1)]));
     }
 }
Exemple #9
0
 public function sendShowVenueChangedEmail(Show $show, array $owners, array $moderators)
 {
     $toEmails = $this->emailArrayFromUsers($moderators);
     $message = \Swift_Message::newInstance()->setSubject('Venue changed to ' . $show->getVenue()->getName() . ': ' . $show->getName())->setFrom(array($this->from_address => 'camdram.net'))->setTo($toEmails)->setBody($this->twig->render('ActsCamdramBundle:Email:show_venue_changed.txt.twig', array('owners' => $owners, 'show' => $show)));
     $this->mailer->send($message);
 }
Exemple #10
0
 public function updateTimes(Show $show)
 {
     $min = null;
     $max = null;
     foreach ($show->getPerformances() as $performance) {
         if (is_null($min) || $performance->getStartDate() < $min) {
             $min = $performance->getStartDate();
         }
         if (is_null($max) || $performance->getEndDate() > $max) {
             $max = $performance->getEndDate();
         }
     }
     $show->setStartAt($min);
     $show->setEndAt($max);
 }
 public function autoApproveOrEmailModerators(Show $entity)
 {
     if (!$entity->isAuthorised()) {
         if ($this->authorizationChecker->isGranted('APPROVE', $entity)) {
             //The current user is able to approve the show, so approve it straight away.
             $this->approveEntity($entity);
         } else {
             //Else Send an email
             $this->emailEntityModerators($entity);
         }
     }
 }
Exemple #12
0
 public function testViewAuthorisedShow()
 {
     $show = new Show();
     $show->setAuthorisedBy(new User());
     $this->assertEquals(ViewVoter::ACCESS_GRANTED, $this->voter->vote($this->token, $show, array('VIEW')));
 }
 /**
  * Get an ACE request request made by a user for the show.
  */
 public function findAceRequest(User $user, Show $show)
 {
     $qb = $this->createQueryBuilder('e');
     $query = $qb->where('e.user = :user')->andWhere('e.entityId = :entityId')->andWhere("e.type = 'request-show'")->setParameter('user', $user)->setParameter('entityId', $show->getId());
     return $query->getQuery()->getOneOrNullResult();
 }