コード例 #1
0
 public function addDetailsToVenue(VenueModel $venue)
 {
     if ($venue->getAddressCode() && !$venue->getAreaId()) {
         $area = $this->getAreaForPostCode(new PostcodeParser($venue->getAddressCode()));
         if ($area) {
             $venue->setAreaId($area->getId());
         }
     }
 }
コード例 #2
0
 function test1()
 {
     $this->addCountriesToTestDB();
     \TimeSource::mock(2014, 10, 1, 1, 1, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     $area = new AreaModel();
     $area->setTitle("test");
     $area->setDescription("test test");
     $areaRepo = new \repositories\AreaRepository();
     $areaRepo->create($area, null, $site, $gb, $user);
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     $venue->setAreaId($area->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     $venueDuplicate = new VenueModel();
     $venueDuplicate->setTitle("test Duplicate");
     $venueRepo->create($venueDuplicate, $site, $user);
     \TimeSource::mock(2014, 10, 1, 1, 2, 0);
     $venueRepo->markDuplicate($venueDuplicate, $venue, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0, 'Europe/London'));
     $event->setVenueId($venue->getId());
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     ## Test
     $this->assertNotNull($venueRepo->loadBySlug($site, $venue->getSlug()));
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($venue->getId(), $event->getVenueId());
     ## Now Purge!
     $venueRepo->purge($venue);
     ## Test
     $this->assertNull($venueRepo->loadBySlug($site, $venue->getSlug()));
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertNull($event->getVenueId());
 }
コード例 #3
0
 function test1()
 {
     \TimeSource::mock(2014, 1, 1, 0, 0, 0);
     $this->addCountriesToTestDB();
     $countryRepo = new CountryRepository();
     $areaRepo = new AreaRepository();
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array($countryRepo->loadByTwoCharCode('GB')), $this->getSiteQuotaUsedForTesting());
     $area1 = new AreaModel();
     $area1->setTitle("test");
     $area1->setDescription("test test");
     $area2 = new AreaModel();
     $area2->setTitle("test this looks similar");
     $area2->setDescription("test test");
     $areaRepo->create($area1, null, $site, $countryRepo->loadByTwoCharCode('GB'), $user);
     $areaRepo->create($area2, null, $site, $countryRepo->loadByTwoCharCode('GB'), $user);
     $areaChild = new AreaModel();
     $areaChild->setTitle("child");
     $areaChild->setDescription("child");
     $areaRepo->create($areaChild, $area2, $site, $countryRepo->loadByTwoCharCode('GB'), $user);
     $area1 = $areaRepo->loadById($area1->getId());
     $area2 = $areaRepo->loadById($area2->getId());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     $venue->setAreaId($area2->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0));
     $event->setAreaId($area2->getId());
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     // Test before
     $venue = $venueRepo->loadById($venue->getId());
     $this->assertEquals($area2->getId(), $venue->getAreaId());
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($area2->getId(), $event->getAreaId());
     $areaChild = $areaRepo->loadById($areaChild->getId());
     $this->assertEquals($area2->getId(), $areaChild->getParentAreaId());
     $area2 = $areaRepo->loadById($area2->getId());
     $this->assertFalse($area2->getIsDeleted());
     $this->assertNull($area2->getIsDuplicateOfId());
     // Mark
     \TimeSource::mock(2014, 1, 1, 2, 0, 0);
     $areaRepo->markDuplicate($area2, $area1, $user);
     // Test Duplicate
     $venue = $venueRepo->loadById($venue->getId());
     $this->assertEquals($area1->getId(), $venue->getAreaId());
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($area1->getId(), $event->getAreaId());
     $areaChild = $areaRepo->loadById($areaChild->getId());
     $this->assertEquals($area1->getId(), $areaChild->getParentAreaId());
     $area2 = $areaRepo->loadById($area2->getId());
     $this->assertTrue($area2->getIsDeleted());
     $this->assertEquals($area1->getId(), $area2->getIsDuplicateOfId());
 }
コード例 #4
0
 function testMoveAllFutureEventsAtVenueToNoSetVenue()
 {
     $this->addCountriesToTestDB();
     TimeSource::mock(2013, 7, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $area = new AreaModel();
     $area->setTitle("scotland");
     $areaRepo = new AreaRepository();
     $countryRepo = new CountryRepository();
     $areaRepo->create($area, null, $site, $countryRepo->loadByTwoCharCode('GB'), $user);
     $venue = new VenueModel();
     $venue->setCountryId($countryRepo->loadByTwoCharCode('GB')->getId());
     $venue->setTitle("edinburgh hall");
     $venue->setAreaId($area->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     #### Event To Change
     $event = new EventModel();
     $event->setCountryId($countryRepo->loadByTwoCharCode('GB')->getId());
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt($this->mktime(2013, 8, 1, 19, 0, 0));
     $event->setEndAt($this->mktime(2013, 8, 1, 21, 0, 0));
     $event->setVenueId($venue->getId());
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     #### Load Event, Check in Venue
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals(false, $event->getIsDeleted());
     $this->assertNull($event->getAreaId());
     $this->assertEquals($venue->getId(), $event->getVenueId());
     #### In preperation for deleting event, call moveAllFutureEventsAtVenueToNoSetVenue()
     TimeSource::mock(2013, 7, 1, 8, 0, 0);
     $eventRepository->moveAllFutureEventsAtVenueToNoSetVenue($venue, $user);
     #### Load event, check in area
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals(false, $event->getIsDeleted());
     $this->assertNull($event->getVenueId());
     $this->assertEquals($area->getId(), $event->getAreaId());
 }
コード例 #5
0
 function addDataToEventBeforeSave(EventModel $eventModel)
 {
     $this->addDataToEventBeforeCheck($eventModel);
     if ($this->draftEvent->getDetailsValue('event.newvenue')) {
         $venueModel = new VenueModel();
         $venueModel->setSiteId($this->site->getId());
         $venueModel->setCountryId($this->draftEvent->getDetailsValue('event.country_id'));
         $venueModel->setTitle($this->draftEvent->getDetailsValue('venue.title'));
         $venueModel->setAddress($this->draftEvent->getDetailsValue('venue.address'));
         $venueModel->setAddressCode($this->draftEvent->getDetailsValue('venue.address_code'));
         $venueModel->setDescription($this->draftEvent->getDetailsValue('venue.description'));
         if ($this->draftEvent->getDetailsValue('venue.lat')) {
             $venueModel->setLat($this->draftEvent->getDetailsValue('venue.lat'));
             $venueModel->setLng($this->draftEvent->getDetailsValue('venue.lng'));
         }
         if ($this->draftEvent->getDetailsValue('area.id')) {
             $venueModel->setAreaId($this->draftEvent->getDetailsValue('area.id'));
         }
         foreach ($this->application['extensions']->getExtensionsIncludingCore() as $extension) {
             $extension->addDetailsToVenue($venueModel);
         }
         $vee = new VenueEditMetaDataModel();
         $vee->setUserAccount($this->application['currentUser']);
         // TODO $vee->setFromRequest();
         $venueRepository = new VenueRepository();
         $venueRepository->createWithMetaData($venueModel, $this->site, $vee);
         $eventModel->setVenueId($venueModel->getId());
     }
 }