protected function build($slug, Request $request, Application $app) { $this->parameters = array('groups' => array(), 'country' => null, 'venue' => null, 'area' => null); if (strpos($slug, "-") > 0) { $slugBits = explode("-", $slug, 2); $slug = $slugBits[0]; } $eventRepository = new EventRepository(); $this->parameters['event'] = $eventRepository->loadBySlug($app['currentSite'], $slug); if (!$this->parameters['event']) { return false; } if ($this->parameters['event']->getGroupId()) { $grb = new GroupRepositoryBuilder(); $grb->setEvent($this->parameters['event']); $this->parameters['groups'] = $grb->fetchAll(); } if ($this->parameters['event']->getVenueID()) { $vr = new VenueRepository(); $this->parameters['venue'] = $vr->loadById($this->parameters['event']->getVenueID()); } if ($this->parameters['event']->getAreaID()) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadById($this->parameters['event']->getAreaID()); } elseif ($this->parameters['venue'] && $this->parameters['venue']->getAreaId()) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadById($this->parameters['venue']->getAreaID()); } if ($this->parameters['event']->getCountryID()) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['event']->getCountryID()); } return true; }
protected function build($siteid, $slug, Request $request, Application $app) { $this->parameters = array('group' => null, 'venue' => null, 'country' => null); $sr = new SiteRepository(); $this->parameters['site'] = $sr->loadById($siteid); if (!$this->parameters['site']) { $app->abort(404); } $er = new EventRepository(); $this->parameters['event'] = $er->loadBySlug($this->parameters['site'], $slug); $this->parameters['eventisduplicateof'] = $this->parameters['event']->getIsDuplicateOfId() ? $er->loadById($this->parameters['event']->getIsDuplicateOfId()) : null; if (!$this->parameters['event']) { $app->abort(404); } if ($this->parameters['event']->getGroupId()) { $gr = new GroupRepository(); $this->parameters['group'] = $gr->loadById($this->parameters['event']->getGroupId()); } if ($this->parameters['event']->getCountryID()) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['event']->getCountryID()); } if ($this->parameters['event']->getVenueID()) { $cr = new VenueRepository(); $this->parameters['venue'] = $cr->loadById($this->parameters['event']->getVenueID()); } }
protected function build($slug, Request $request, Application $app) { $this->parameters = array('country' => null, 'area' => null, 'parentAreas' => array()); $iurlRepository = new ImportURLRepository(); $this->parameters['importurl'] = $iurlRepository->loadBySlug($app['currentSite'], $slug); if (!$this->parameters['importurl']) { return false; } if ($this->parameters['importurl']->getCountryID()) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['importurl']->getCountryID()); } if ($this->parameters['importurl']->getGroupId()) { $gr = new GroupRepository(); $this->parameters['group'] = $gr->loadById($this->parameters['importurl']->getGroupId()); } if ($this->parameters['importurl']->getAreaId()) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadById($this->parameters['importurl']->getAreaId()); if (!$this->parameters['area']) { return false; } $checkArea = $this->parameters['area']->getParentAreaId() ? $ar->loadById($this->parameters['area']->getParentAreaId()) : null; while ($checkArea) { array_unshift($this->parameters['parentAreas'], $checkArea); $checkArea = $checkArea->getParentAreaId() ? $ar->loadById($checkArea->getParentAreaId()) : null; } } $app['currentUserActions']->set("org.openacalendar", "importURLLog", true); $app['currentUserActions']->set("org.openacalendar", "importURLEditDetails", $app['currentUserPermissions']->hasPermission("org.openacalendar", "IMPORTURL_CHANGE") && $app['currentSite']->getIsFeatureImporter()); $app['currentUserActions']->set("org.openacalendar", "importURLDisable", $app['currentUserPermissions']->hasPermission("org.openacalendar", "IMPORTURL_CHANGE") && $app['currentSite']->getIsFeatureImporter() && $this->parameters['importurl']->getIsEnabled()); $app['currentUserActions']->set("org.openacalendar", "importURLEnable", $app['currentUserPermissions']->hasPermission("org.openacalendar", "IMPORTURL_CHANGE") && $app['currentSite']->getIsFeatureImporter() && (!$this->parameters['importurl']->getIsEnabled() || $this->parameters['importurl']->getIsExpired())); return true; }
function onThisStepSetUpPageView() { $out = array(); if ($this->draftEvent->getDetailsValue('event.country_id')) { $countryRepository = new CountryRepository(); $out['country'] = $countryRepository->loadById($this->draftEvent->getDetailsValue('event.country_id')); } return $out; }
protected function build($slug, Request $request, Application $app) { global $CONFIG; $this->parameters = array('country' => null, 'area' => null, 'parentAreas' => array(), 'childAreas' => array(), 'venueIsDuplicateOf' => null); if (strpos($slug, "-")) { $slug = array_shift(explode("-", $slug, 2)); } $vr = new VenueRepository(); $this->parameters['venue'] = $vr->loadBySlug($app['currentSite'], $slug); if (!$this->parameters['venue']) { return false; } if ($this->parameters['venue']->getCountryID()) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['venue']->getCountryID()); } if ($this->parameters['venue']->getAreaId()) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadById($this->parameters['venue']->getAreaId()); if (!$this->parameters['area']) { return false; } $checkArea = $this->parameters['area']->getParentAreaId() ? $ar->loadById($this->parameters['area']->getParentAreaId()) : null; while ($checkArea) { array_unshift($this->parameters['parentAreas'], $checkArea); $checkArea = $checkArea->getParentAreaId() ? $ar->loadById($checkArea->getParentAreaId()) : null; } $areaRepoBuilder = new AreaRepositoryBuilder(); $areaRepoBuilder->setSite($app['currentSite']); $areaRepoBuilder->setCountry($this->parameters['country']); $areaRepoBuilder->setParentArea($this->parameters['area']); $areaRepoBuilder->setIncludeDeleted(false); $this->parameters['childAreas'] = $areaRepoBuilder->fetchAll(); } else { $areaRepoBuilder = new AreaRepositoryBuilder(); $areaRepoBuilder->setSite($app['currentSite']); $areaRepoBuilder->setCountry($this->parameters['country']); $areaRepoBuilder->setNoParentArea(true); $areaRepoBuilder->setIncludeDeleted(false); $this->parameters['childAreas'] = $areaRepoBuilder->fetchAll(); } if ($this->parameters['venue']->getIsDuplicateOfId()) { $this->parameters['venueIsDuplicateOf'] = $vr->loadByID($this->parameters['venue']->getIsDuplicateOfId()); } $app['currentUserActions']->set("org.openacalendar", "venueHistory", true); $app['currentUserActions']->set("org.openacalendar", "venueEditDetails", $app['currentUserPermissions']->hasPermission("org.openacalendar", "VENUES_CHANGE") && $app['currentSite']->getIsFeaturePhysicalEvents() && !$this->parameters['venue']->getIsDeleted()); $app['currentUserActions']->set("org.openacalendar", "venueDelete", $app['currentUserPermissions']->hasPermission("org.openacalendar", "VENUES_CHANGE") && $app['currentSite']->getIsFeaturePhysicalEvents() && !$this->parameters['venue']->getIsDeleted()); $app['currentUserActions']->set("org.openacalendar", "venueEditMedia", $app['currentUserPermissions']->hasPermission("org.openacalendar", "VENUES_CHANGE") && $app['currentSite']->getIsFeaturePhysicalEvents() && !$this->parameters['venue']->getIsDeleted() && $CONFIG->isFileStore()); $app['currentUserActions']->set("org.openacalendar", "venueEditPushToChildAreas", $this->parameters['childAreas'] && $app['currentUserPermissions']->hasPermission("org.openacalendar", "VENUES_CHANGE") && $app['currentSite']->getIsFeaturePhysicalEvents() && !$this->parameters['venue']->getIsDeleted()); return true; }
protected function build($countryslug, Request $request, Application $app) { $this->parameters = array('country' => null, 'parentAreas' => array()); $cr = new CountryRepository(); // we accept both ID and Slug. Slug is proper one to use, but some JS may need to load by ID. $this->parameters['country'] = intval($countryslug) ? $cr->loadById($countryslug) : $cr->loadByTwoCharCode($countryslug); if (!$this->parameters['country']) { return false; } // check this country is or was valid for this site $countryInSiteRepo = new CountryInSiteRepository(); if (!$countryInSiteRepo->isCountryInSite($this->parameters['country'], $app['currentSite'])) { return false; } return true; }
protected function build($siteid, $slug, Request $request, Application $app) { $this->parameters = array('area' => null, 'parentarea' => null); $sr = new SiteRepository(); $this->parameters['site'] = $sr->loadById($siteid); if (!$this->parameters['site']) { $app->abort(404); } $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadBySlug($this->parameters['site'], $slug); if (!$this->parameters['area']) { $app->abort(404); } $this->parameters['areaisduplicateof'] = $this->parameters['area']->getIsDuplicateOfId() ? $ar->loadById($this->parameters['area']->getIsDuplicateOfId()) : null; if ($this->parameters['area']->getParentAreaId()) { $this->parameters['parentarea'] = $ar->loadById($this->parameters['area']->getParentAreaId()); } $cr = new CountryRepository(); $this->parameters['country'] = $this->parameters['area']->getCountryId() ? $cr->loadById($this->parameters['area']->getCountryId()) : null; }
function __construct(ImportURLModel $importURL, SiteModel $site = null) { $this->importURL = $importURL; $this->realurl = $importURL->getUrl(); if ($site) { $this->site = $site; } else { $siteRepo = new SiteRepository(); $this->site = $siteRepo->loadById($importURL->getSiteId()); } if ($importURL->getCountryId()) { $countryRepo = new CountryRepository(); $this->country = $countryRepo->loadById($importURL->getCountryId()); } if ($importURL->getAreaId()) { $areaRepo = new AreaRepository(); $this->area = $areaRepo->loadById($importURL->getAreaId()); } $groupRepository = new GroupRepository(); $this->group = $groupRepository->loadById($importURL->getGroupId()); }
protected function build($slug, Request $request, Application $app) { $this->parameters = array(); $gr = new CountryRepository(); // we must accept both ID and Slug. Slug is proper one to use, but some JS needs to load by ID. $this->parameters['country'] = intval($slug) ? $gr->loadById($slug) : $gr->loadByTwoCharCode($slug); if (!$this->parameters['country']) { return false; } // check this country is or was valid for this site $countryInSiteRepo = new CountryInSiteRepository(); if (!$countryInSiteRepo->isCountryInSite($this->parameters['country'], $app['currentSite'])) { return false; } $areaRepoBuilder = new AreaRepositoryBuilder(); $areaRepoBuilder->setSite($app['currentSite']); $areaRepoBuilder->setCountry($this->parameters['country']); $areaRepoBuilder->setNoParentArea(true); $areaRepoBuilder->setIncludeDeleted(false); $this->parameters['childAreas'] = $areaRepoBuilder->fetchAll(); return true; }
protected function build($countryCode, $areaSlug, $venueSlug, Request $request, Application $app) { $this->parameters = array('country' => null, 'area' => null, 'venue' => null); if ($areaSlug) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadBySlug($app['currentSite'], $areaSlug); } if ($this->parameters['area']) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['area']->getCountryID()); } else { if ($countryCode) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadByTwoCharCode($countryCode); } } if ($venueSlug) { $vr = new VenueRepository(); $this->parameters['venue'] = $vr->loadBySlug($app['currentSite'], $venueSlug); } return true; }
protected function build($slug, Request $request, Application $app) { $this->parameters = array('country' => null, 'parentAreas' => array(), 'areaIsDuplicateOf' => null); if (strpos($slug, "-")) { $slug = array_shift(explode("-", $slug, 2)); } $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadBySlug($app['currentSite'], $slug); if (!$this->parameters['area']) { return false; } $checkArea = $this->parameters['area']->getParentAreaId() ? $ar->loadById($this->parameters['area']->getParentAreaId()) : null; while ($checkArea) { array_unshift($this->parameters['parentAreas'], $checkArea); $checkArea = $checkArea->getParentAreaId() ? $ar->loadById($checkArea->getParentAreaId()) : null; } if ($app['currentUser']) { $uwgr = new UserWatchesAreaRepository(); $uwg = $uwgr->loadByUserAndArea($app['currentUser'], $this->parameters['area']); $this->parameters['currentUserWatchesArea'] = $uwg && $uwg->getIsWatching(); } $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['area']->getCountryID()); $areaRepoBuilder = new AreaRepositoryBuilder(); $areaRepoBuilder->setSite($app['currentSite']); $areaRepoBuilder->setCountry($this->parameters['country']); $areaRepoBuilder->setParentArea($this->parameters['area']); $areaRepoBuilder->setIncludeDeleted(false); $this->parameters['childAreas'] = $areaRepoBuilder->fetchAll(); if ($this->parameters['area']->getIsDuplicateOfId()) { $this->parameters['areaIsDuplicateOf'] = $ar->loadByID($this->parameters['area']->getIsDuplicateOfId()); } $app['currentUserActions']->set("org.openacalendar", "areaHistory", true); $app['currentUserActions']->set("org.openacalendar", "actionAreaEditDetails", $app['currentUserPermissions']->hasPermission("org.openacalendar", "AREAS_CHANGE") && !$this->parameters['area']->getIsDeleted()); $app['currentUserActions']->set("org.openacalendar", "actionAreaNew", $app['currentUserPermissions']->hasPermission("org.openacalendar", "AREAS_CHANGE") && !$this->parameters['area']->getIsDeleted()); return true; }
function newVenue(Request $request, Application $app) { $areaRepository = new AreaRepository(); $countryRepository = new CountryRepository(); $venue = new VenueModel(); $this->parameters = array('country' => null, 'parentAreas' => array(), 'area' => null, 'childAreas' => array(), 'startAreaBrowserFromScratch' => true); if (isset($_GET['area_id'])) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadBySlug($app['currentSite'], $_GET['area_id']); if ($this->parameters['area']) { $checkArea = $this->parameters['area']->getParentAreaId() ? $ar->loadById($this->parameters['area']->getParentAreaId()) : null; while ($checkArea) { array_unshift($this->parameters['parentAreas'], $checkArea); $checkArea = $checkArea->getParentAreaId() ? $ar->loadById($checkArea->getParentAreaId()) : null; } $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['area']->getCountryID()); $venue->setCountryId($this->parameters['country']->getId()); $areaRepoBuilder = new AreaRepositoryBuilder(); $areaRepoBuilder->setSite($app['currentSite']); $areaRepoBuilder->setCountry($this->parameters['country']); $areaRepoBuilder->setParentArea($this->parameters['area']); $areaRepoBuilder->setIncludeDeleted(false); $this->parameters['childAreas'] = $areaRepoBuilder->fetchAll(); $this->parameters['startAreaBrowserFromScratch'] = false; } } $form = $app['form.factory']->create(new VenueNewForm($app['currentTimeZone'], $app), $venue); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid()) { $postAreas = $request->request->get('areas'); if (is_array($postAreas)) { $area = null; foreach ($postAreas as $areaCode) { if (substr($areaCode, 0, 9) == 'EXISTING:') { $area = $areaRepository->loadBySlug($app['currentSite'], substr($areaCode, 9)); } else { if (substr($areaCode, 0, 4) == 'NEW:' && $app['currentUserPermissions']->hasPermission('org.openacalendar', 'AREAS_CHANGE')) { $newArea = new AreaModel(); $newArea->setTitle(substr($areaCode, 4)); $areaRepository->create($newArea, $area, $app['currentSite'], $countryRepository->loadById($venue->getCountryId()), $app['currentUser']); $areaRepository->buildCacheAreaHasParent($newArea); $area = $newArea; } } } if ($area) { $venue->setAreaId($area->getId()); } } foreach ($app['extensions']->getExtensionsIncludingCore() as $extension) { $extension->addDetailsToVenue($venue); } $venueEditMetaData = new VenueEditMetaDataModel(); $venueEditMetaData->setUserAccount($app['currentUser']); if ($form->has('edit_comment')) { $venueEditMetaData->setEditComment($form->get('edit_comment')->getData()); } $venueRepository = new VenueRepository(); $venueRepository->createWithMetaData($venue, $app['currentSite'], $venueEditMetaData); return $app->redirect("/venue/" . $venue->getSlug()); } } $this->parameters['form'] = $form->createView(); return $app['twig']->render('site/venuenew/new.html.twig', $this->parameters); }
protected function build($slug, Request $request, Application $app) { global $CONFIG; $this->parameters = array('group' => null, 'venue' => null, 'country' => null, 'area' => null, 'parentAreas' => array(), 'childAreas' => array(), 'importurl' => null, 'eventIsDuplicateOf' => null); if (strpos($slug, "-")) { $slug = array_shift(explode("-", $slug, 2)); } $eventRepository = new EventRepository(); $this->parameters['event'] = $eventRepository->loadBySlug($app['currentSite'], $slug); if (!$this->parameters['event']) { return false; } if ($this->parameters['event']->getCountryID()) { $cr = new CountryRepository(); $this->parameters['country'] = $cr->loadById($this->parameters['event']->getCountryID()); } $areaID = null; if ($this->parameters['event']->getVenueID()) { $cr = new VenueRepository(); $this->parameters['venue'] = $cr->loadById($this->parameters['event']->getVenueID()); $areaID = $this->parameters['venue']->getAreaId(); } else { if ($this->parameters['event']->getAreaId()) { $areaID = $this->parameters['event']->getAreaId(); } } if ($areaID) { $ar = new AreaRepository(); $this->parameters['area'] = $ar->loadById($areaID); if (!$this->parameters['area']) { return false; } $checkArea = $this->parameters['area']->getParentAreaId() ? $ar->loadById($this->parameters['area']->getParentAreaId()) : null; while ($checkArea) { array_unshift($this->parameters['parentAreas'], $checkArea); $checkArea = $checkArea->getParentAreaId() ? $ar->loadById($checkArea->getParentAreaId()) : null; } } if ($this->parameters['event']->getImportUrlId()) { $iur = new ImportURLRepository(); $this->parameters['importurl'] = $iur->loadById($this->parameters['event']->getImportUrlId()); } $groupRB = new GroupRepositoryBuilder(); $groupRB->setEvent($this->parameters['event']); $this->parameters['groups'] = $groupRB->fetchAll(); if ($this->parameters['event']->getGroupId()) { foreach ($this->parameters['groups'] as $group) { if ($group->getId() == $this->parameters['event']->getGroupId()) { $this->parameters['group'] = $group; } } } if ($this->parameters['event']->getIsDuplicateOfId()) { $this->parameters['eventIsDuplicateOf'] = $eventRepository->loadByID($this->parameters['event']->getIsDuplicateOfId()); } $app['currentUserActions']->set("org.openacalendar", "eventHistory", true); $app['currentUserActions']->set("org.openacalendar", "eventEditDetails", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsDeleted() && !$this->parameters['event']->getIsCancelled()); $app['currentUserActions']->set("org.openacalendar", "eventEditDetailsRollback", $app['currentUserActions']->has("org.openacalendar", "eventEditDetails")); $app['currentUserActions']->set("org.openacalendar", "eventEditVenue", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsDeleted() && !$this->parameters['event']->getIsCancelled() && $app['currentSite']->getIsFeaturePhysicalEvents()); $app['currentUserActions']->set("org.openacalendar", "eventEditTags", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsDeleted() && !$this->parameters['event']->getIsCancelled() && $app['currentSite']->getIsFeatureTag()); $app['currentUserActions']->set("org.openacalendar", "eventEditGroups", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsDeleted() && !$this->parameters['event']->getIsCancelled() && $app['currentSite']->getIsFeatureGroup()); $app['currentUserActions']->set("org.openacalendar", "eventEditMedia", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsDeleted() && !$this->parameters['event']->getIsCancelled() && $CONFIG->isFileStore()); $app['currentUserActions']->set("org.openacalendar", "eventRecur", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsImported() && !$this->parameters['event']->getIsDeleted() && !$this->parameters['event']->getIsCancelled()); $app['currentUserActions']->set("org.openacalendar", "eventDelete", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsImported() && !$this->parameters['event']->getIsDeleted()); $app['currentUserActions']->set("org.openacalendar", "eventCancel", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsImported() && !$this->parameters['event']->getIsCancelled() && !$this->parameters['event']->getIsDeleted()); $app['currentUserActions']->set("org.openacalendar", "eventUndelete", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsImported() && $this->parameters['event']->getIsDeleted()); $app['currentUserActions']->set("org.openacalendar", "eventUncancel", $app['currentUserPermissions']->hasPermission("org.openacalendar", "EVENTS_CHANGE") && !$this->parameters['event']->getIsImported() && $this->parameters['event']->getIsCancelled()); return true; }
protected function getVenueSearchData() { $out = array('searchFieldsSubmitted' => $this->request->request->get('action') == 'searchVenues', 'searchTitle' => $this->request->request->get('searchTitle'), 'searchAddress' => $this->request->request->get('searchAddress'), 'searchArea' => $this->request->request->get('searchArea'), 'searchAreaSlug' => $this->request->request->get('searchAreaSlug'), 'searchAddressCode' => $this->request->request->get('searchAddressCode'), 'searchAreaObject' => null, 'venues' => array(), 'areas' => array(), 'venueSearchDone' => false); $countryRepository = new CountryRepository(); $out['country'] = $countryRepository->loadById($this->draftEvent->getDetailsValue('event.country_id')); $areaRepository = new AreaRepository(); $out['doesCountryHaveAnyNotDeletedAreas'] = $areaRepository->doesCountryHaveAnyNotDeletedAreas($this->site, $out['country']); if ($out['doesCountryHaveAnyNotDeletedAreas']) { // Area search if ($out['searchArea']) { $arb = new AreaRepositoryBuilder(); $arb->setIncludeDeleted(false); $arb->setIncludeParentLevels(1); $arb->setSite($this->site); $arb->setCountry($out['country']); $arb->setFreeTextSearch($out['searchArea']); $out['areas'] = $arb->fetchAll(); if (count($out['areas']) == 1 && !$out['searchAreaSlug']) { $out['searchAreaSlug'] = $out['areas'][0]->getSlug(); $out['searchAreaObject'] = $out['areas'][0]; } // has user selected a area and is it still in search results? If so select it. if (!$out['searchAreaObject'] && $out['searchAreaSlug'] && intval($out['searchAreaSlug'])) { foreach ($out['areas'] as $area) { if ($area->getSlug() == $out['searchAreaSlug']) { $out['searchAreaObject'] = $area; } } } } } // If user has not added any search fields. and the event is in a area. let's search by area by default. if (!$out['searchFieldsSubmitted'] && !$out['searchAreaObject'] && $this->draftEvent->getDetailsValue('incoming.area.id')) { $areaRepository = new AreaRepository(); $area = $areaRepository->loadById($this->draftEvent->getDetailsValue('incoming.area.id')); if ($area) { $out['searchAreaObject'] = $area; $out['searchArea'] = $area->getTitle(); $out['searchAreaSlug'] = $area->getSlug(); } } if ($out['searchAddressCode'] || $out['searchAddress'] || $out['searchTitle'] || $out['searchAreaObject']) { $vrb = new VenueRepositoryBuilder(); $vrb->setSite($this->site); $vrb->setCountry($out['country']); $vrb->setIncludeDeleted(false); if ($out['searchTitle']) { $vrb->setFreeTextSearchTitle($out['searchTitle']); } if ($out['searchAddress']) { $vrb->setFreeTextSearchAddress($out['searchAddress']); } if ($out['searchAddressCode']) { $vrb->setFreeTextSearchAddressCode($out['searchAddressCode']); } if ($out['searchAreaObject']) { $vrb->setArea($out['searchAreaObject']); } $vrb->setLimit(500); $out['venues'] = $vrb->fetchAll(); $out['venueSearchDone'] = true; } return $out; }
protected function run() { $this->localTimeZone = new \DateTimeZone("Europe/London"); $siteRepo = new \repositories\SiteRepository(); $site = $siteRepo->loadById($this->app['config']->singleSiteID); // TODO assumes single site! $areaRepository = new AreaRepository(); $venueRepository = new VenueRepository(); $countryRepository = new CountryRepository(); $countries = array(); $humanPopItRepository = new HumanPopItInfoRepository(); $areaMapItRepo = new AreaMapItInfoRepository(); $out = array('data' => array(), 'areasPastEvents' => array()); $erb = new EventRepositoryBuilder(); $erb->setSite($site); $erb->setIncludeDeleted(true); $erb->setIncludeCancelled(true); $erb->setAfterNow(); foreach ($erb->fetchAll() as $event) { $venue = null; $country = null; $area = null; $humans = array(); if ($event->getCountryId()) { if (!isset($countries[$event->getCountryId()])) { $countries[$event->getCountryId()] = $countryRepository->loadById($event->getCountryId()); } $country = $countries[$event->getCountryId()]; } if ($event->getVenueId()) { $venue = $venueRepository->loadById($event->getVenueId()); } if ($event->getAreaId()) { $area = $areaRepository->loadById($event->getAreaId()); } else { if ($venue && $venue->getAreaId()) { $area = $areaRepository->loadById($venue->getAreaId()); } } $thisOut = $this->addEvent($event, $venue, $area, $country); $thisOut['humans'] = array(); $mapitids = array(); if ($area) { $areamapit = $areaMapItRepo->getByAreaID($area->getId()); if ($areamapit) { $mapitids[] = $areamapit->getMapitId(); } } $hrb = new HumanRepositoryBuilder(); $hrb->setHumansForEvent($event); foreach ($hrb->fetchAll() as $human) { $popit = $humanPopItRepository->getByHumanID($human->getId()); $thisOut['humans'][] = array('popit_id' => $popit->getPopitId()); $arb = new AreaRepositoryBuilder(); $arb->setIncludeDeleted(false); $arb->setHuman($human); foreach ($arb->fetchAll() as $areaForHuman) { if (!$area || $area->getId() != $areaForHuman->getId()) { $areamapit = $areaMapItRepo->getByAreaID($areaForHuman->getId()); if ($areamapit) { $mapitids[] = $areamapit->getMapitId(); } } } } $thisOut['mapitids'] = array_values(array_unique($mapitids)); $out['data'][] = $thisOut; } $arb = new \com\meetyournextmp\repositories\builders\AreaRepositoryBuilder(); $arb->setLimit(1000); $arb->setIncludeDeleted(false); $arb->setIsMapItAreaOnly(true); foreach ($arb->fetchAll() as $area) { $erb = new EventRepositoryBuilder(); $erb->setIncludeDeleted(false); $erb->setIncludeCancelled(false); $erb->setArea($area); $erb->setBeforeNow(); $areamapit = $areaMapItRepo->getByAreaID($area->getId()); $out['areasPastEvents'][$areamapit->getMapitId()] = $erb->fetchCount(); } file_put_contents(APP_ROOT_DIR . DIRECTORY_SEPARATOR . 'webSingleSite' . DIRECTORY_SEPARATOR . 'datadump' . DIRECTORY_SEPARATOR . 'ynmpread.json', json_encode($out)); return array('result' => 'ok'); }