private function loadImportURLIfNeeded() { if (!$this->importURL && property_exists($this->data, 'importurl') && $this->data->importurl) { $repo = new ImportURLRepository(); $this->importURL = $repo->loadById($this->data->importurl); } }
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; }