/**
  * @dataProvider dataForTestSet
  */
 function testSet3($slug, $text, $result)
 {
     $venue = new VenueModel();
     $venue->setSlug($slug);
     $venue->setTitle($text);
     $this->assertEquals($result, $venue->getSlugForUrl());
 }
예제 #2
0
 public function save(\Models\VenueModel $venue)
 {
     $query = 'INSERT INTO venues (name, address) VALUES (?, ?)';
     $param = [$venue->getName(), $venue->getAddress()];
     $this->db->query($query, $param);
     return $this->db->row();
 }
예제 #3
0
 public function createConference(CreateConference $conference)
 {
     $this->headerData();
     $this->view->showView();
     $venueName = $conference->getName();
     $venueAddress = $conference->getAddress();
     $confName = $conference->getConfName();
     $startDate = $conference->getStartDate();
     $endDate = $conference->getEndDate();
     $userId = $_SESSION['id'];
     /**
      * this part added venue's data
      */
     $venue = new VenueModel($venueName, $venueAddress);
     $venue->save();
     $venueId = \Repository\Venue::createInstance()->selectId();
     $conference = new ConferenceModel($confName, $startDate, $endDate, $venueId, $userId);
     $conference->save();
     $conf = Conference::createInstance()->selectAllConferencesDetails();
     $confId = array_pop($conf);
     $confId = $confId->getId();
     //        $confId = array_pop($conf['id']);
     if ($conference->getConfName() != null) {
         //            var_dump($venueId);
         $_SESSION['venue_id'] = $venueId;
         $_SESSION['conferenceId'] = $confId;
         $user = \Repository\User::createInstance()->editUserId($userId);
         $this->redirectControllers('hall', 'createHall');
     }
     $this->view->part('footer');
     exit;
 }
 public function addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array())
 {
     global $CONFIG;
     $siteurlbase = $CONFIG->getWebSiteDomainSecure($this->site ? $this->site->getSlug() : $event->getSiteSlug());
     $siteurl = $siteurlbase . '/event/' . $event->getSlugForUrl();
     $url = $event->getUrl() && filter_var($event->getUrl(), FILTER_VALIDATE_URL) ? $event->getUrl() : $siteurl;
     $ticket_url = $event->getTicketUrl() && filter_var($event->getTicketUrl(), FILTER_VALIDATE_URL) ? $event->getTicketUrl() : null;
     $this->events[] = $this->getCell($event->getSlug()) . $this->delimiter . $this->getCell($event->getSlugForUrl()) . $this->delimiter . $this->getCell($event->getSummary()) . $this->delimiter . $this->getCell($event->getSummaryDisplay()) . $this->delimiter . $this->getCell($event->getDescription()) . $this->delimiter . $this->getCellBoolean($event->getIsDeleted()) . $this->delimiter . $this->getCellBoolean($event->getIsCancelled()) . $this->delimiter . $this->getCellBoolean($event->getIsPhysical()) . $this->delimiter . $this->getCellBoolean($event->getIsVirtual()) . $this->delimiter . $this->getCell($siteurl) . $this->delimiter . $this->getCell($url) . $this->delimiter . $this->getCell($ticket_url) . $this->delimiter . $this->getCell($event->getTimezone()) . $this->delimiter . $this->getCell($event->getStartAtInUTC()->format("r")) . $this->delimiter . $this->getCell($event->getEndAtInUTC()->format("r")) . $this->delimiter . $this->getCell($event->getStartAtInTimezone()->format("r")) . $this->delimiter . $this->getCell($event->getEndAtInTimezone()->format("r")) . $this->delimiter . ($venue ? $this->getCell($venue->getSlug()) . $this->delimiter . $this->getCell($venue->getSlugForUrl()) . $this->delimiter . $this->getCell($venue->getTitle()) . $this->delimiter . $this->getCell($venue->getDescription()) . $this->delimiter . $this->getCell($venue->getAddress()) . $this->delimiter . $this->getCell($venue->getAddressCode()) . $this->delimiter . $this->getCell($venue->getLat()) . $this->delimiter . $this->getCell($venue->getLng()) . $this->delimiter . $this->getCell($siteurlbase . '/venue/' . $venue->getSlugForUrl()) . $this->delimiter : $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter) . ($area ? $this->getCell($area->getSlug()) . $this->delimiter . $this->getCell($area->getSlugForUrl()) . $this->delimiter . $this->getCell($area->getTitle()) . $this->delimiter . $this->getCell($area->getDescription()) . $this->delimiter . $this->getCell($siteurlbase . '/area/' . $area->getSlugForUrl()) . $this->delimiter : $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter . $this->delimiter) . ($country ? $this->getCell($country->getTwoCharCode()) . $this->delimiter . $this->getCell($country->getTitle()) . $this->delimiter . $this->getCell($siteurlbase . '/country/' . $country->getTwoCharCode()) . $this->delimiter : $this->delimiter . $this->delimiter . $this->delimiter);
 }
 public function addDetailsToVenue(VenueModel $venue)
 {
     if ($venue->getAddressCode() && !$venue->getAreaId()) {
         $area = $this->getAreaForPostCode(new PostcodeParser($venue->getAddressCode()));
         if ($area) {
             $venue->setAreaId($area->getId());
         }
     }
 }
 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());
 }
 function test1()
 {
     \TimeSource::mock(2014, 1, 1, 0, 0, 0);
     $this->addCountriesToTestDB();
     $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');
     $venue1 = new VenueModel();
     $venue1->setTitle("test");
     $venue1->setDescription("test test");
     $venue1->setCountryId($gb->getId());
     $venue2 = new VenueModel();
     $venue2->setTitle("test this looks similar");
     $venue2->setDescription("test test");
     $venue2->setCountryId($gb->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue1, $site, $user);
     $venueRepo->create($venue2, $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->setVenueId($venue2->getId());
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     // Test before
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($venue2->getId(), $event->getVenueId());
     $venue2 = $venueRepo->loadById($venue2->getId());
     $this->assertFalse($venue2->getIsDeleted());
     $this->assertNull($venue2->getIsDuplicateOfId());
     // Mark
     \TimeSource::mock(2014, 1, 1, 2, 0, 0);
     $venueRepo->markDuplicate($venue2, $venue1, $user);
     // Test Duplicate
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($venue1->getId(), $event->getVenueId());
     $venue2 = $venueRepo->loadById($venue2->getId());
     $this->assertTrue($venue2->getIsDeleted());
     $this->assertEquals($venue1->getId(), $venue2->getIsDuplicateOfId());
 }
 public function addDetailsToVenue(VenueModel $venue)
 {
     if ($venue->getAddressCode() && (!$venue->getLat() || !$venue->getLng())) {
         $cr = new CountryRepository();
         $gb = $cr->loadByTwoCharCode("GB");
         if ($venue->getCountryId() == $gb->getId()) {
             list($lat, $lng) = AddressCodeGBOpenCodePointGet::get($venue->getAddressCode());
             if ($lat && $lng) {
                 $venue->setLat($lat);
                 $venue->setLng($lng);
             }
         }
     }
 }
 public function createConference(CreateConference $conference)
 {
     $this->headerData();
     $this->view->showView();
     if ($this->getSession()->getSessionParams('user') == null) {
         $this->redirectControllers('user', 'index');
     }
     /**
      * get object property value
      * $this->getRequest()->getPost()->getPostParams()->name;
      */
     $venueName = $conference->getName();
     $venueAddress = $conference->getAddress();
     $confName = $conference->getConfName();
     $startDate = $conference->getStartDate();
     $endDate = $conference->getEndDate();
     $userId = $this->getSession()->getSessionParams('id');
     /**
      * this part added venue's data
      */
     $venue = new VenueModel($venueName, $venueAddress);
     $venue->save();
     $venueId = \Repository\Venue::createInstance()->selectId();
     $conference = new ConferenceModel($confName, $startDate, $endDate, $venueId, $userId);
     $conference->save();
     $conf = Conference::createInstance()->selectAllConferencesDetails();
     $confId = array_pop($conf);
     $confId = $confId->getId();
     if ($conference->getConfName() != null) {
         $this->getSession()->setSessionParams(['venue_id' => $venueId, 'conferenceId' => $confId]);
         //            $user = \Repository\User::createInstance()
         //                ->editUserId($userId);
         $this->redirectControllers('hall', 'createHall');
     }
     $this->view->part('footer');
     exit;
 }
 protected function build()
 {
     if ($this->site) {
         $this->where[] = " media_information.site_id = :site_id ";
         $this->params['site_id'] = $this->site->getId();
     }
     if ($this->group) {
         $this->joins[] = " JOIN media_in_group AS media_in_group ON media_in_group.media_id = media_information.id " . "AND media_in_group.removed_at IS NULL AND media_in_group.group_id = :group_id ";
         $this->params['group_id'] = $this->group->getId();
     } else {
         if ($this->groupNotIn) {
             $this->joins[] = " LEFT JOIN media_in_group AS media_in_group ON media_in_group.media_id = media_information.id " . "AND media_in_group.removed_at IS NULL AND media_in_group.group_id = :group_id ";
             $this->where[] = " media_in_group.added_at IS NULL ";
             $this->params['group_id'] = $this->groupNotIn->getId();
         }
     }
     if ($this->venue) {
         $this->joins[] = " JOIN media_in_venue AS media_in_venue ON media_in_venue.media_id = media_information.id " . "AND media_in_venue.removed_at IS NULL AND media_in_venue.venue_id = :venue_id ";
         $this->params['venue_id'] = $this->venue->getId();
     } else {
         if ($this->venueNotIn) {
             $this->joins[] = " LEFT JOIN media_in_venue AS media_in_venue ON media_in_venue.media_id = media_information.id " . "AND media_in_venue.removed_at IS NULL AND media_in_venue.venue_id = :venue_id ";
             $this->where[] = " media_in_venue.added_at IS NULL ";
             $this->params['venue_id'] = $this->venueNotIn->getId();
         }
     }
     if ($this->event) {
         $this->joins[] = " JOIN media_in_event AS media_in_event ON media_in_event.media_id = media_information.id " . "AND media_in_event.removed_at IS NULL AND media_in_event.event_id = :event_id ";
         $this->params['event_id'] = $this->event->getId();
     } else {
         if ($this->eventNotIn) {
             $this->joins[] = " LEFT JOIN media_in_event AS media_in_event ON media_in_event.media_id = media_information.id " . "AND media_in_event.removed_at IS NULL AND media_in_event.event_id = :event_id ";
             $this->where[] = " media_in_event.added_at IS NULL ";
             $this->params['event_id'] = $this->eventNotIn->getId();
         }
     }
     if (!$this->include_deleted) {
         $this->where[] = " media_information.deleted_at IS NULL ";
     }
 }
 public function postInfoJson($slug, Request $request, Application $app)
 {
     if (!$this->build($slug, $request, $app)) {
         $app->abort(404, "Does not exist.");
     }
     $ourRequest = new \Request($request);
     $edits = false;
     if ($ourRequest->hasGetOrPost('title') && $this->venue->setTitleIfDifferent($ourRequest->getGetOrPostString('title', ''))) {
         $edits = true;
     }
     if ($ourRequest->hasGetOrPost('description') && $this->venue->setDescriptionIfDifferent($ourRequest->getGetOrPostString('description', ''))) {
         $edits = true;
     }
     if ($ourRequest->hasGetOrPost('address') && $this->venue->setAddressIfDifferent($ourRequest->getGetOrPostString('address', ''))) {
         $edits = true;
     }
     if ($ourRequest->hasGetOrPost('address_code') && $this->venue->setAddressCodeIfdifferent($ourRequest->getGetOrPostString('address_code', ''))) {
         $edits = true;
     }
     if ($ourRequest->hasGetOrPost('lat') && $ourRequest->hasGetOrPost('lng')) {
         if ($this->venue->setLatIfDifferent($ourRequest->getGetOrPostString('lat', ''))) {
             $edits = true;
         }
         if ($this->venue->setLngIfDifferent($ourRequest->getGetOrPostString('lng', ''))) {
             $edits = true;
         }
     }
     if ($edits) {
         $repo = new VenueRepository();
         $repo->edit($this->venue, $app['apiUser']);
         $out = array('edited' => true);
     } else {
         $out = array('edited' => false);
     }
     return json_encode($out);
 }
 public function fetchAll()
 {
     $this->buildStart();
     $this->build();
     $this->buildStat();
     $results = array();
     while ($data = $this->stat->fetch()) {
         $venue = new VenueModel();
         $venue->setFromDataBaseRow($data);
         $results[] = $venue;
     }
     return $results;
 }
 protected function build()
 {
     global $DB;
     $this->select[] = 'event_information.*';
     $this->select[] = " group_information.title AS group_title ";
     $this->select[] = " group_information.id AS group_id ";
     $this->joins[] = " LEFT JOIN event_in_group ON event_in_group.event_id = event_information.id AND event_in_group.removed_at IS NULL AND event_in_group.is_main_group = '1' ";
     $this->joins[] = " LEFT JOIN group_information ON group_information.id = event_in_group.group_id ";
     $joinsVenueInfoSQL = " LEFT JOIN venue_information ON venue_information.id = event_information.venue_id ";
     if ($this->site) {
         $this->where[] = " event_information.site_id = :site_id ";
         $this->params['site_id'] = $this->site->getId();
     }
     if ($this->group) {
         // We use a seperate table here so if event is in 2 groups and we select events in 1 group that isn't the main group only,
         // the normal event_in_group table still shows the main group.
         $this->joins[] = " JOIN event_in_group AS event_in_group_select ON event_in_group_select.event_id = event_information.id " . "AND event_in_group_select.removed_at IS NULL AND event_in_group_select.group_id = :group_id ";
         $this->params['group_id'] = $this->group->getId();
     }
     if ($this->country) {
         $this->where[] = " event_information.country_id = :country_id ";
         $this->params['country_id'] = $this->country->getId();
     }
     if ($this->area) {
         // We were doing
         // $this->joins[] = " LEFT JOIN cached_area_has_parent ON cached_area_has_parent.area_id = venue_information.area_id";
         // $this->where[] =  " (venue_information.area_id = :area_id OR  cached_area_has_parent.has_parent_area_id = :area_id )";
         // but then we got duplicates
         $areaids = array($this->area->getId());
         $this->statAreas = $DB->prepare("SELECT area_id FROM cached_area_has_parent WHERE has_parent_area_id=:id");
         $this->statAreas->execute(array('id' => $this->area->getId()));
         while ($d = $this->statAreas->fetch()) {
             $areaids[] = $d['area_id'];
         }
         $this->joins[] = $joinsVenueInfoSQL;
         $this->where[] = " (venue_information.area_id IN (" . implode(",", $areaids) . ") " . "OR event_information.area_id IN (" . implode(",", $areaids) . ")) ";
     }
     if ($this->venue) {
         $this->where[] = " event_information.venue_id = :venue_id ";
         $this->params['venue_id'] = $this->venue->getId();
     }
     if ($this->importURL) {
         $this->joins[] = " LEFT JOIN imported_event_is_event ON imported_event_is_event.event_id = event_information.id ";
         $this->joins[] = " LEFT JOIN imported_event ON imported_event.id = imported_event_is_event.imported_event_id ";
         $this->where[] = " (imported_event.import_url_id = :import_url_id OR event_information.import_url_id = :import_url_id )";
         $this->params['import_url_id'] = $this->importURL->getId();
     }
     if ($this->importedEvent) {
         $this->joins[] = " JOIN imported_event_is_event ON imported_event_is_event.event_id = event_information.id AND imported_event_is_event.imported_event_id = :imported_event_id ";
         $this->params['imported_event_id'] = $this->importedEvent->getId();
     }
     if (!$this->site && !$this->group) {
         $this->joins[] = " JOIN site_information ON event_information.site_id = site_information.id ";
         $this->select[] = " site_information.slug AS site_slug ";
         if (!$this->includeEventsFromClosedSites) {
             $this->where[] = " site_information.is_closed_by_sys_admin = '0' ";
         }
     }
     if ($this->curatedList) {
         $this->joins[] = " LEFT JOIN event_in_curated_list ON event_in_curated_list.event_id = event_information.id " . " AND event_in_curated_list.removed_at IS NULL AND event_in_curated_list.curated_list_id = :curated_list";
         $this->joins[] = " LEFT JOIN  ( SELECT event_in_group.event_id, MAX(event_in_group.group_id) AS group_id" . " FROM event_in_group " . " JOIN group_in_curated_list ON group_in_curated_list.group_id = event_in_group.group_id " . " WHERE group_in_curated_list.curated_list_id = :curated_list AND group_in_curated_list.removed_at IS NULL AND event_in_group.removed_at IS NULL " . " GROUP BY event_in_group.event_id " . ") AS event_in_group_in_curated_list ON event_in_group_in_curated_list.event_id = event_information.id ";
         $this->where[] = " ( event_in_curated_list.curated_list_id IS NOT NULL OR event_in_group_in_curated_list.event_id IS NOT NULL )";
         $this->params['curated_list'] = $this->curatedList->getId();
         if ($this->curatedListInformation) {
             $this->joins[] = " LEFT JOIN group_information AS group_information_cl ON group_information_cl.id = event_in_group_in_curated_list.group_id ";
             $this->select[] = " (CASE WHEN event_in_curated_list.event_id IS NULL THEN 0 ELSE 1 END) AS is_event_in_curated_list ";
             $this->select[] = " group_information_cl.id AS in_curated_list_group_id ";
             $this->select[] = " group_information_cl.slug AS in_curated_list_group_slug ";
             $this->select[] = " group_information_cl.title AS in_curated_list_group_title ";
         }
     }
     if ($this->end) {
         $this->where[] = ' event_information.end_at = :end';
         $this->params['end'] = $this->end->format("Y-m-d H:i:s");
     } else {
         if ($this->after) {
             $this->where[] = ' event_information.end_at > :after';
             $this->params['after'] = $this->after->format("Y-m-d H:i:s");
         } else {
             if ($this->endBefore) {
                 $this->where[] = ' event_information.end_at < :before';
                 $this->params['before'] = $this->endBefore->format("Y-m-d H:i:s");
             }
         }
     }
     if ($this->start) {
         $this->where[] = ' event_information.start_at = :start';
         $this->params['start'] = $this->start->format("Y-m-d H:i:s");
     } else {
         if ($this->before) {
             $this->where[] = ' event_information.start_at < :before';
             $this->params['before'] = $this->before->format("Y-m-d H:i:s");
         } else {
             if ($this->startAfter) {
                 $this->where[] = ' event_information.start_at > :startAfter';
                 $this->params['startAfter'] = $this->startAfter->format("Y-m-d H:i:s");
             }
         }
     }
     if (!$this->include_deleted) {
         $this->where[] = " event_information.is_deleted = '0' ";
     }
     if (!$this->include_cancelled) {
         $this->where[] = " event_information.is_cancelled = '0' ";
     }
     if (!$this->include_imported) {
         $this->where[] = " event_information.import_url_id is null ";
     }
     if ($this->userAccount) {
         // user at event. we want info on this always for the extra selects, so outside if statement
         $this->joins[] = "  LEFT JOIN user_at_event_information ON user_at_event_information.event_id = event_information.id " . "AND user_at_event_information.user_account_id = :user_account_id ";
         $this->select[] = " user_at_event_information.is_plan_attending AS user_is_plan_attending ";
         $this->select[] = " user_at_event_information.is_plan_maybe_attending AS user_is_plan_maybe_attending ";
         if (!$this->userAccountIncludeAll) {
             $w = array();
             if ($this->userAccountIncludeWatching) {
                 $w[] = "  event_information.id IN (SELECT event_information.id FROM event_information " . " LEFT JOIN user_watches_site_information ON  user_watches_site_information.site_id = event_information.site_id " . "AND user_watches_site_information.user_account_id = :user_account_id AND user_watches_site_information.is_watching='1' " . "  LEFT JOIN event_in_group ON event_in_group.event_id = event_information.id AND event_in_group.removed_at IS NULL " . " LEFT JOIN user_watches_group_information ON user_watches_group_information.group_id = event_in_group.group_id " . "AND user_watches_group_information.user_account_id = :user_account_id AND user_watches_group_information.is_watching='1' " . " LEFT JOIN venue_information ON venue_information.id = event_information.venue_id " . " LEFT JOIN cached_area_has_parent ON ( venue_information.area_id = cached_area_has_parent.area_id OR event_information.area_id = cached_area_has_parent.area_id) " . " LEFT JOIN user_watches_area_information ON ( " . "user_watches_area_information.area_id = event_information.area_id OR user_watches_area_information.area_id = venue_information.area_id " . " OR user_watches_area_information.area_id = cached_area_has_parent.has_parent_area_id " . ") " . "AND user_watches_area_information.user_account_id = :user_account_id AND user_watches_area_information.is_watching='1' " . " WHERE user_watches_site_information.is_watching='1' OR user_watches_group_information.is_watching='1'  OR user_watches_area_information.is_watching='1'" . " )  ";
             }
             if ($this->userAccountIncludeAttending) {
                 if ($this->userAccountIncludePrivate) {
                     $w[] = " user_at_event_information.is_plan_attending = '1' ";
                     $w[] = " user_at_event_information.is_plan_maybe_attending = '1' ";
                 } else {
                     $w[] = " (user_at_event_information.is_plan_attending = '1' AND user_at_event_information.is_plan_public  = '1' )";
                     $w[] = " (user_at_event_information.is_plan_maybe_attending = '1' AND user_at_event_information.is_plan_public  = '1' )";
                 }
             }
             $this->where[] = "  (  " . implode(" OR ", $w) . ") ";
         }
         $this->params['user_account_id'] = $this->userAccount->getId();
     }
     if ($this->include_venue_information || $this->include_area_information || $this->must_have_lat_lng) {
         if (!in_array($joinsVenueInfoSQL, $this->joins)) {
             $this->joins[] = $joinsVenueInfoSQL;
         }
         if ($this->include_venue_information) {
             $this->select[] = "  venue_information.lng AS venue_lng";
             $this->select[] = "  venue_information.lat AS venue_lat";
             $this->select[] = "  venue_information.title AS venue_title";
             $this->select[] = "  venue_information.slug AS venue_slug";
             $this->select[] = "  venue_information.description AS venue_description";
             $this->select[] = "  venue_information.address AS venue_address";
             $this->select[] = "  venue_information.address_code AS venue_address_code";
         }
         if ($this->include_area_information) {
             $this->joins[] = " LEFT JOIN area_information ON area_information.id = event_information.area_id OR area_information.id = venue_information.area_id";
             $this->select[] = "  area_information.title AS area_title";
             $this->select[] = "  area_information.slug AS area_slug";
             $this->select[] = "  area_information.id AS area_information_id";
             // we already have a area_id so called something different
         }
         if ($this->must_have_lat_lng) {
             $this->where[] = " venue_information.lat IS NOT NULL ";
             $this->where[] = " venue_information.lng IS NOT NULL ";
         }
     }
     if ($this->include_country_information) {
         $this->joins[] = " LEFT JOIN country ON country.id = event_information.country_id  ";
         $this->select[] = "  country.two_char_code AS country_two_char_code";
         $this->select[] = "  country.title AS country_title";
     }
     if ($this->venueVirtualOnly) {
         $this->where[] = " event_information.is_virtual = '1' ";
     }
     if ($this->event_recur_set_id) {
         $this->where[] = " event_information.event_recur_set_id = :event_recur_set_id ";
         $this->params['event_recur_set_id'] = $this->event_recur_set_id;
     }
     if ($this->tag) {
         $this->joins[] = "  JOIN event_has_tag ON event_has_tag.event_id = event_information.id AND  event_has_tag.tag_id = :tag_id AND event_has_tag.removed_at IS NULL";
         $this->params['tag_id'] = $this->tag->getId();
     }
     if ($this->freeTextSearch) {
         $this->where[] = '(CASE WHEN event_information.summary IS NULL THEN \'\' ELSE event_information.summary END)   || ' . '\' \' || ' . '(CASE WHEN event_information.description IS NULL THEN \'\' ELSE event_information.description END) || ' . '\' \' || ' . '(CASE WHEN group_information.title IS NULL THEN \'\' ELSE group_information.title END)' . ' ILIKE :free_text_search ';
         $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%";
     }
     if ($this->includeMediasSlugs) {
         $this->select[] = "  (SELECT  array_to_string(array_agg(media_information.slug), ',') FROM media_information " . " JOIN media_in_event ON media_information.id = media_in_event.media_id " . " WHERE media_information.deleted_at IS NULL AND media_information.is_file_lost='0' " . " AND media_in_event.removal_approved_at IS NULL AND media_in_event.event_id = event_information.id " . " GROUP BY event_information.id ) AS media_event_slugs ";
         $this->select[] = "  (SELECT  array_to_string(array_agg(media_information.slug), ',') FROM media_information " . " JOIN media_in_group ON media_information.id = media_in_group.media_id " . " JOIN event_in_group ON event_in_group.group_id = media_in_group.group_id " . " WHERE media_information.deleted_at IS NULL AND media_information.is_file_lost='0' " . " AND media_in_group.removal_approved_at IS NULL " . " AND event_in_group.removal_approved_at IS NULL AND event_in_group.event_id = event_information.id " . " GROUP BY event_information.id ) AS media_group_slugs ";
         $this->select[] = "  (SELECT  array_to_string(array_agg(media_information.slug), ',') FROM media_information " . " JOIN media_in_venue ON media_information.id = media_in_venue.media_id " . " WHERE media_information.deleted_at IS NULL AND media_information.is_file_lost='0' " . " AND media_in_venue.removal_approved_at IS NULL AND media_in_venue.venue_id = event_information.venue_id " . " GROUP BY event_information.venue_id ) AS media_venue_slugs ";
     }
     if ($this->editedByUser) {
         $this->where[] = " event_information.id IN (SELECT event_id FROM event_history WHERE user_account_id = :editedByUser) ";
         $this->params['editedByUser'] = $this->editedByUser->getId();
     }
 }
 function testIntegration2()
 {
     $this->addCountriesToTestDB();
     \TimeSource::mock(2014, 1, 1, 12, 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());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     ## Create venue
     \TimeSource::mock(2014, 1, 1, 13, 0, 0);
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     ## Edit venue
     \TimeSource::mock(2014, 1, 1, 14, 0, 0);
     $venue = $venueRepo->loadById($venue->getId());
     $venue->setDescription("testy");
     $venue->setLat(3.6);
     $venue->setLng(3.7);
     $venueRepo->edit($venue, $user);
     ## Delete venue
     \TimeSource::mock(2014, 1, 1, 15, 0, 0);
     $venueRepo->delete($venue, $user);
     ## Now save changed flags on these .....
     $venueHistoryRepo = new VenueHistoryRepository();
     $stat = $this->app['db']->prepare("SELECT * FROM venue_history");
     $stat->execute();
     while ($data = $stat->fetch()) {
         $venueHistory = new VenueHistoryModel();
         $venueHistory->setFromDataBaseRow($data);
         $venueHistoryRepo->ensureChangedFlagsAreSet($venueHistory);
     }
     ## Now load and check
     $historyRepo = new HistoryRepositoryBuilder();
     $historyRepo->setVenue($venue);
     $historyRepo->setIncludeEventHistory(false);
     $historyRepo->setIncludeGroupHistory(false);
     $historyRepo->setIncludeVenueHistory(true);
     $histories = $historyRepo->fetchAll();
     $this->assertEquals(3, count($histories));
     #the delete
     $this->assertEquals(FALSE, $histories[0]->getTitleChanged());
     $this->assertEquals(false, $histories[0]->getDescriptionChanged());
     $this->assertEquals(false, $histories[0]->getCountryIdChanged());
     $this->assertEquals(true, $histories[0]->getIsDeletedChanged());
     $this->assertEquals(false, $histories[0]->getLatChanged());
     $this->assertEquals(false, $histories[0]->getLngChanged());
     #the edit
     $this->assertEquals(FALSE, $histories[1]->getTitleChanged());
     $this->assertEquals(true, $histories[1]->getDescriptionChanged());
     $this->assertEquals(false, $histories[1]->getCountryIdChanged());
     $this->assertEquals(false, $histories[1]->getIsDeletedChanged());
     $this->assertEquals(true, $histories[1]->getLatChanged());
     $this->assertEquals(true, $histories[1]->getLngChanged());
     #the create
     $this->assertEquals(true, $histories[2]->getTitleChanged());
     $this->assertEquals(true, $histories[2]->getDescriptionChanged());
     $this->assertEquals(true, $histories[2]->getCountryIdChanged());
     $this->assertEquals(false, $histories[2]->getIsDeletedChanged());
     $this->assertEquals(false, $histories[2]->getLatChanged());
     $this->assertEquals(false, $histories[2]->getLngChanged());
 }
 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());
     }
 }
 function newVenueJSON(Request $request, Application $app)
 {
     $venue = new VenueModel();
     $data = array();
     if ('POST' == $request->getMethod()) {
         if ($request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) {
             $venue->setTitle($request->request->get('title'));
             $venue->setDescription($request->request->get('description'));
             if (intval($request->request->get('country'))) {
                 $venue->setCountryId(intval($request->request->get('country')));
             }
             $venueRepository = new VenueRepository();
             $venueRepository->create($venue, $app['currentSite'], $app['currentUser']);
             $data['venue'] = array('id' => $venue->getId(), 'slug' => $venue->getSlug(), 'title' => $venue->getTitle());
         }
     }
     $response = new Response(json_encode($data));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 public function addOtherDataVenue(VenueModel $venue)
 {
     $this->otherData['venue'] = array('slug' => $venue->getId(), 'title' => $venue->getTitle(), 'lat' => $venue->getLat(), 'lng' => $venue->getLng());
 }
 public function moveAllFutureEventsAtVenueToNoSetVenueWithMetaData(VenueModel $venue, EventEditMetaDataModel $eventEditMetaDataModel)
 {
     global $DB;
     $statFetch = $DB->prepare("SELECT event_information.* FROM event_information WHERE venue_id = :venue_id AND start_at > :start_at AND is_deleted='0'");
     $statFetch->execute(array('venue_id' => $venue->getId(), 'start_at' => \TimeSource::getFormattedForDataBase()));
     while ($data = $statFetch->fetch()) {
         $event = new EventModel();
         $event->setFromDataBaseRow($data);
         $event->setVenueId(null);
         $event->setAreaId($venue->getAreaId());
         $this->eventDBAccess->update($event, array('venue_id', 'area_id'), $eventEditMetaDataModel);
     }
 }
 /**
  *
  * @TODO This could be improved, At the moment it sets any events with this venue to no venue & no area but it could set them to area of venue.
  * Have to be careful of rewriting history if we do that. Create Event - Create Area - Create Venue  and set event to it - now purge venue.
  * If we just did "update event set area=X, venue=null where venue=Y" on the history table it will look as if the venue was set on the event BEFORE the venue was created.
  *
  * @param VenueModel $venue
  * @throws \Exception
  * @throws Exception
  */
 public function purge(VenueModel $venue)
 {
     global $DB;
     try {
         $DB->beginTransaction();
         $stat = $DB->prepare("UPDATE event_history SET venue_id = NULL, venue_id_changed=0 WHERE venue_id=:id");
         $stat->execute(array('id' => $venue->getId()));
         $stat = $DB->prepare("UPDATE event_information SET venue_id = NULL WHERE venue_id=:id");
         $stat->execute(array('id' => $venue->getId()));
         $stat = $DB->prepare("UPDATE venue_history SET is_duplicate_of_id = NULL, is_duplicate_of_id_changed = 0 WHERE is_duplicate_of_id=:id");
         $stat->execute(array('id' => $venue->getId()));
         $stat = $DB->prepare("UPDATE venue_information SET is_duplicate_of_id = NULL WHERE is_duplicate_of_id=:id");
         $stat->execute(array('id' => $venue->getId()));
         $stat = $DB->prepare("DELETE FROM venue_history WHERE venue_id=:id");
         $stat->execute(array('id' => $venue->getId()));
         $stat = $DB->prepare("DELETE FROM venue_information WHERE id=:id");
         $stat->execute(array('id' => $venue->getId()));
         $DB->commit();
     } catch (Exception $e) {
         $DB->rollBack();
         throw $e;
     }
 }
 function testVenue()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     TimeSource::mock(2013, 7, 1, 7, 0, 0);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     $this->assertTrue($userRepo->hasMadeAnyEdits($user));
 }
 public function remove(MediaModel $media, VenueModel $venue, UserAccountModel $user)
 {
     global $DB;
     $stat = $DB->prepare("UPDATE media_in_venue SET removed_by_user_account_id=:removed_by_user_account_id," . " removed_at=:removed_at, removal_approved_at=:removal_approved_at WHERE " . " venue_id=:venue_id AND media_id=:media_id AND removed_at IS NULL ");
     $stat->execute(array('venue_id' => $venue->getId(), 'media_id' => $media->getId(), 'removed_at' => \TimeSource::getFormattedForDataBase(), 'removal_approved_at' => \TimeSource::getFormattedForDataBase(), 'removed_by_user_account_id' => $user->getId()));
 }
 protected function checkVenueInTest1(VenueModel $venue)
 {
     $this->assertEquals("test test", $venue->getDescription());
     $this->assertEquals("test", $venue->getTitle());
     $this->assertNotNull($venue->getCountryId());
 }
 function testMoveAllFutureEventsAtVenueToNoSetVenueWithNoArea()
 {
     $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());
     $countryRepo = new CountryRepository();
     $venue = new VenueModel();
     $venue->setCountryId($countryRepo->loadByTwoCharCode('GB')->getId());
     $venue->setTitle("edinburgh hall");
     $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->assertNull($event->getAreaId());
 }
 public function update(VenueModel $venue, $fields, VenueEditMetaDataModel $venueEditMetaDataModel)
 {
     $alreadyInTransaction = $this->db->inTransaction();
     // Make Information Data
     $fieldsSQL1 = array();
     $fieldsParams1 = array('id' => $venue->getId());
     foreach ($fields as $field) {
         $fieldsSQL1[] = " " . $field . "=:" . $field . " ";
         if ($field == 'title') {
             $fieldsParams1['title'] = substr($venue->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED);
         } else {
             if ($field == 'lat') {
                 $fieldsParams1['lat'] = $venue->getLat();
             } else {
                 if ($field == 'lng') {
                     $fieldsParams1['lng'] = $venue->getLng();
                 } else {
                     if ($field == 'description') {
                         $fieldsParams1['description'] = $venue->getDescription();
                     } else {
                         if ($field == 'address') {
                             $fieldsParams1['address'] = $venue->getAddress();
                         } else {
                             if ($field == 'address_code') {
                                 $fieldsParams1['address_code'] = substr($venue->getAddressCode(), 0, VARCHAR_COLUMN_LENGTH_USED);
                             } else {
                                 if ($field == 'country_id') {
                                     $fieldsParams1['country_id'] = $venue->getCountryId();
                                 } else {
                                     if ($field == 'area_id') {
                                         $fieldsParams1['area_id'] = $venue->getAreaId();
                                     } else {
                                         if ($field == 'is_duplicate_of_id') {
                                             $fieldsParams1['is_duplicate_of_id'] = $venue->getIsDuplicateOfId();
                                         } else {
                                             if ($field == 'is_deleted') {
                                                 $fieldsParams1['is_deleted'] = $venue->getIsDeleted() ? 1 : 0;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Make History Data
     $fieldsSQL2 = array('venue_id', 'user_account_id', 'created_at', 'approved_at');
     $fieldsSQLParams2 = array(':venue_id', ':user_account_id', ':created_at', ':approved_at');
     $fieldsParams2 = array('venue_id' => $venue->getId(), 'user_account_id' => $venueEditMetaDataModel->getUserAccount() ? $venueEditMetaDataModel->getUserAccount()->getId() : null, 'created_at' => $this->timesource->getFormattedForDataBase(), 'approved_at' => $this->timesource->getFormattedForDataBase());
     if ($venueEditMetaDataModel->getEditComment()) {
         $fieldsSQL2[] = ' edit_comment ';
         $fieldsSQLParams2[] = ' :edit_comment ';
         $fieldsParams2['edit_comment'] = $venueEditMetaDataModel->getEditComment();
     }
     foreach ($this->possibleFields as $field) {
         if (in_array($field, $fields) || $field == 'title') {
             $fieldsSQL2[] = " " . $field . " ";
             $fieldsSQLParams2[] = " :" . $field . " ";
             if ($field == 'title') {
                 $fieldsParams2['title'] = substr($venue->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED);
             } else {
                 if ($field == 'lat') {
                     $fieldsParams2['lat'] = $venue->getLat();
                 } else {
                     if ($field == 'lng') {
                         $fieldsParams2['lng'] = $venue->getLng();
                     } else {
                         if ($field == 'description') {
                             $fieldsParams2['description'] = $venue->getDescription();
                         } else {
                             if ($field == 'address') {
                                 $fieldsParams2['address'] = $venue->getAddress();
                             } else {
                                 if ($field == 'address_code') {
                                     $fieldsParams2['address_code'] = substr($venue->getAddressCode(), 0, VARCHAR_COLUMN_LENGTH_USED);
                                 } else {
                                     if ($field == 'country_id') {
                                         $fieldsParams2['country_id'] = $venue->getCountryId();
                                     } else {
                                         if ($field == 'area_id') {
                                             $fieldsParams2['area_id'] = $venue->getAreaId();
                                         } else {
                                             if ($field == 'is_duplicate_of_id') {
                                                 $fieldsParams2['is_duplicate_of_id'] = $venue->getIsDuplicateOfId();
                                             } else {
                                                 if ($field == 'is_deleted') {
                                                     $fieldsParams2['is_deleted'] = $venue->getIsDeleted() ? 1 : 0;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $fieldsSQL2[] = " " . $field . "_changed ";
             $fieldsSQLParams2[] = " 0 ";
         } else {
             $fieldsSQL2[] = " " . $field . "_changed ";
             $fieldsSQLParams2[] = " -2 ";
         }
     }
     try {
         if (!$alreadyInTransaction) {
             $this->db->beginTransaction();
         }
         // Information SQL
         $stat = $this->db->prepare("UPDATE venue_information  SET " . implode(",", $fieldsSQL1) . " WHERE id=:id");
         $stat->execute($fieldsParams1);
         // History SQL
         $stat = $this->db->prepare("INSERT INTO venue_history (" . implode(",", $fieldsSQL2) . ") VALUES (" . implode(",", $fieldsSQLParams2) . ")");
         $stat->execute($fieldsParams2);
         if (!$alreadyInTransaction) {
             $this->db->commit();
         }
     } catch (Exception $e) {
         if (!$alreadyInTransaction) {
             $this->db->rollBack();
         }
         throw $e;
     }
 }
 public function addEvent(EventModel $event, VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null)
 {
     global $CONFIG;
     $out = array('slug' => $event->getSlug(), 'slugforurl' => $event->getSlugForUrl(), 'summary' => $event->getSummary(), 'summaryDisplay' => $event->getSummaryDisplay(), 'description' => $event->getDescription() ? $event->getDescription() : '', 'deleted' => (bool) $event->getIsDeleted(), 'cancelled' => (bool) $event->getIsCancelled(), 'is_physical' => (bool) $event->getIsPhysical(), 'is_virtual' => (bool) $event->getIsVirtual());
     $out['siteurl'] = $CONFIG->isSingleSiteMode ? 'http://' . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl() : 'http://' . ($this->site ? $this->site->getSlug() : $event->getSiteSlug()) . "." . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl();
     $out['url'] = $event->getUrl() && filter_var($event->getUrl(), FILTER_VALIDATE_URL) ? $event->getUrl() : $out['siteurl'];
     $out['ticket_url'] = $event->getTicketUrl() && filter_var($event->getTicketUrl(), FILTER_VALIDATE_URL) ? $event->getTicketUrl() : null;
     $out['timezone'] = $event->getTimezone();
     $startLocal = clone $event->getStartAt();
     $startLocal->setTimeZone($this->localTimeZone);
     $startTimeZone = clone $event->getStartAt();
     $startTimeZone->setTimeZone(new \DateTimeZone($event->getTimezone()));
     $out['start'] = array('timestamp' => $event->getStartAt()->getTimestamp(), 'rfc2882utc' => $event->getStartAt()->format('r'), 'rfc2882local' => $startLocal->format('r'), 'displaylocal' => $startLocal->format('D j M Y h:ia'), 'yearlocal' => $startLocal->format('Y'), 'monthlocal' => $startLocal->format('n'), 'daylocal' => $startLocal->format('j'), 'hourlocal' => $startLocal->format('G'), 'minutelocal' => $startLocal->format('i'), 'rfc2882timezone' => $startTimeZone->format('r'), 'displaytimezone' => $startTimeZone->format('D j M Y h:ia'), 'yeartimezone' => $startTimeZone->format('Y'), 'monthtimezone' => $startTimeZone->format('n'), 'daytimezone' => $startTimeZone->format('j'), 'hourtimezone' => $startTimeZone->format('G'), 'minutetimezone' => $startTimeZone->format('i'));
     $endLocal = clone $event->getEndAt();
     $endLocal->setTimeZone($this->localTimeZone);
     $endTimeZone = clone $event->getEndAt();
     $endTimeZone->setTimeZone(new \DateTimeZone($event->getTimezone()));
     $out['end'] = array('timestamp' => $event->getEndAt()->getTimestamp(), 'rfc2882utc' => $event->getEndAt()->format('r'), 'rfc2882local' => $endLocal->format('r'), 'displaylocal' => $endLocal->format('D j M Y h:ia'), 'yearlocal' => $endLocal->format('Y'), 'monthlocal' => $endLocal->format('n'), 'daylocal' => $endLocal->format('j'), 'hourlocal' => $endLocal->format('G'), 'minutelocal' => $endLocal->format('i'), 'rfc2882timezone' => $endTimeZone->format('r'), 'displaytimezone' => $endTimeZone->format('D j M Y h:ia'), 'yeartimezone' => $endTimeZone->format('Y'), 'monthtimezone' => $endTimeZone->format('n'), 'daytimezone' => $endTimeZone->format('j'), 'hourtimezone' => $endTimeZone->format('G'), 'minutetimezone' => $endTimeZone->format('i'));
     if ($venue) {
         $out['venue'] = array('slug' => $venue->getSlug(), 'title' => $venue->getTitle(), 'description' => $venue->getDescription(), 'address' => $venue->getAddress(), 'addresscode' => $venue->getAddressCode(), 'lat' => $venue->getLat(), 'lng' => $venue->getLng());
     }
     if ($area) {
         $out['areas'] = array(array('slug' => $area->getSlug(), 'title' => $area->getTitle()));
     }
     if ($country) {
         $out['country'] = array('title' => $country->getTitle());
     }
     return $out;
 }