/** * Populate this object * @since Version 3.9.1 * @return void * @param int|string $id */ private function populate($id) { $row = $this->load($id); if (!isset($row) || !is_array($row)) { return; } $this->title = $row['title']; $this->desc = $row['description']; $this->meta = json_decode($row['meta'], true); $this->slug = $row['slug']; $this->status = isset($row['status']) ? $row['status'] : Events::STATUS_APPROVED; if (!isset($row['user_id'])) { $row['user_id'] = 45; } $this->setAuthor(UserFactory::CreateUser($row['user_id'])); $this->flickr_tag = "railpage:event=" . $this->id; if (filter_var($row['category_id'], FILTER_VALIDATE_INT)) { $this->Category = Factory::CreateEventCategory($row['category_id']); } if (filter_var($row['organisation_id'], FILTER_VALIDATE_INT)) { $this->Organisation = OrganisationsFactory::CreateOrganisation($row['organisation_id']); } if (!empty($row['lat']) && round($row['lat'], 3) != "0.000" && !empty($row['lon']) && round($row['lon'], 3) != "0.000") { $this->Place = Place::Factory($row['lat'], $row['lon']); } $this->createUrls(); $this->Templates = new stdClass(); $this->Templates->view = sprintf("%s/event.tpl", $this->Module->Paths->html); }
/** * Constructor * @since Version 3.8.7 * @param int $id */ public function __construct($id = NULL) { parent::__construct(); $this->Module = new Module("events"); $this->namespace = $this->Module->namespace; if (!filter_var($id, FILTER_VALIDATE_INT)) { return; } if (!($row = $this->db->fetchRow("SELECT * FROM event_dates WHERE id = ?", $id))) { return; } $this->id = $id; $this->Event = Factory::CreateEvent($row['event_id']); $this->Date = new DateTime($row['date']); $this->meta = json_decode($row['meta'], true); $this->status = $row['status']; $this->url = new Url("/events?mode=event.date&event_id=" . $this->Event->id . "&date_id=" . $this->id); $this->url->approve = sprintf("/events?mode=event.date.setstatus&date_id=%d&status=%d", $this->id, self::STATUS_RUNNING); $this->url->reject = sprintf("/events?mode=event.date.setstatus&date_id=%d&status=%d", $this->id, self::STATUS_REJECTED); $this->url->cancel = sprintf("/events?mode=event.date.setstatus&date_id=%d&status=%d", $this->id, self::STATUS_CANCELLED); $this->url->export = sprintf("/events/export/date/%d.ics", $this->id); $this->setAuthor(UserFactory::CreateUser($row['user_id'])); if ($row['start'] != "00:00:00") { $this->Start = new DateTime($row['date'] . " " . $row['start']); } if ($row['end'] != "00:00:00") { $this->End = new DateTime($row['date'] . " " . $row['end']); } if (isset($this->meta['lat']) && empty($this->meta['lat'])) { unset($this->meta['lat']); } if (isset($this->meta['lon']) && empty($this->meta['lon'])) { unset($this->meta['lon']); } if (isset($this->meta['lat']) && isset($this->meta['lon'])) { $this->Place = Place::Factory($this->meta['lat'], $this->meta['lon']); } try { if ($this->Event->Place instanceof Place && !empty($this->Event->Place->Region->timezone)) { $this->Date->setTimezone(new DateTimeZone($this->Event->Place->Region->timezone)); if ($this->Start instanceof DateTime) { $this->Start->setTimezone(new DateTimeZone($this->Event->Place->Region->timezone)); } if ($this->End instanceof DateTime) { $this->End->setTimezone(new DateTimeZone($this->Event->Place->Region->timezone)); } } } catch (Exception $e) { printArray($e->getMessage()); printArray($this->Event->Place->Region->timezone); } }