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 addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array()) { 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(), 'custom_fields' => array()); $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 (is_array($groups)) { $out['groups'] = array(); foreach ($groups as $group) { $out['groups'][] = array('slug' => $group->getSlug(), 'title' => $group->getTitle(), 'description' => $group->getDescription()); } } 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()); } if (is_array($eventMedias)) { $out['medias'] = array(); $siteurl = $CONFIG->getWebSiteDomainSecure($this->site->getSlug()); foreach ($eventMedias as $eventMedia) { $out['medias'][] = array('slug' => $eventMedia->getSlug(), 'title' => $eventMedia->getTitle(), 'sourceUrl' => $eventMedia->getSourceUrl(), 'sourcetext' => $eventMedia->getSourceText(), 'picture' => array('fullURL' => $siteurl . '/media/' . $eventMedia->getSlug() . '/full', 'normalURL' => $siteurl . '/media/' . $eventMedia->getSlug() . '/normal', 'thumbnailURL' => $siteurl . '/media/' . $eventMedia->getSlug() . '/thumbnail')); } } if ($this->site) { foreach ($this->site->getCachedEventCustomFieldDefinitionsAsModels() as $customField) { $out['custom_fields'][$customField->getKey()] = $event->getCustomField($customField); } } $this->events[] = $out; }
public function applyChangeToFutureEvents() { $startDiff = $this->initalEvent->getStartAtInUTC()->diff($this->initialEventJustBeforeLastChange->getStartAtInUTC()); $endDiff = $this->initalEvent->getEndAtInUTC()->diff($this->initialEventJustBeforeLastChange->getEndAtInUTC()); foreach ($this->futureEvents as $futureEvent) { $this->futureEventsProposedChanges[$futureEvent->getSlug()] = new EventInRecurSetProposedChangesModel(); if (($this->initalEventLastChange->getCountryIdChanged() || $this->initalEventLastChange->getVenueIdChanged() || $this->initalEventLastChange->getAreaIdChanged()) && ($this->initalEvent->getCountryId() != $futureEvent->getCountryId() || $this->initalEvent->getAreaId() != $futureEvent->getAreaId() || $this->initalEvent->getVenueId() != $futureEvent->getVenueId())) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setCountryAreaVenueIdChangePossible(true); if ($this->initialEventJustBeforeLastChange->getCountryId() != $futureEvent->getCountryId() || $this->initialEventJustBeforeLastChange->getAreaId() != $futureEvent->getAreaId() || $this->initialEventJustBeforeLastChange->getVenueId() != $futureEvent->getVenueId()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setCountryAreaVenueIdChangeSelected(true); } } if ($this->initalEventLastChange->getSummaryChanged()) { $summary = $this->initalEvent->getSummary(); // change month title $currentMonthLong = $this->initalEvent->getStartAtInUTC()->format('F'); $currentMonthShort = $this->initalEvent->getStartAtInUTC()->format('M'); if (stripos($summary, $currentMonthLong) !== false) { $summary = str_ireplace($currentMonthLong, $futureEvent->getStartAtInUTC()->format('F'), $summary); } else { if (stripos($summary, $currentMonthShort) !== false) { $summary = str_ireplace($currentMonthShort, $futureEvent->getStartAtInUTC()->format('M'), $summary); } } if ($summary != $futureEvent->getSummary()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setSummary($summary); $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setSummaryChangePossible(true); $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setSummaryChangeSelected(true); } } if ($this->initalEventLastChange->getDescriptionChanged() && $this->initalEvent->getDescription() != $futureEvent->getDescription()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setDescriptionChangePossible(true); if ($this->initialEventJustBeforeLastChange->getDescription() == $futureEvent->getDescription()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setDescriptionChangeSelected(true); } } if ($this->initalEventLastChange->getUrlChanged() && $this->initalEvent->getUrl() != $futureEvent->getUrl()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setUrlChangePossible(true); if ($this->initialEventJustBeforeLastChange->getUrl() == $futureEvent->getUrl()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setUrlChangeSelected(true); } } if ($this->initalEventLastChange->getTicketUrlChanged() && $this->initalEvent->getTicketUrl() != $futureEvent->getTicketUrl()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setTicketUrlChangePossible(true); if ($this->initialEventJustBeforeLastChange->getTicketUrl() == $futureEvent->getTicketUrl()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setTicketUrlChangeSelected(true); } } if ($this->initalEventLastChange->getTimezoneChanged() && $this->initalEvent->getTimezone() != $futureEvent->getTimezone()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setTimezoneChangePossible(true); if ($this->initialEventJustBeforeLastChange->getTimezone() == $futureEvent->getTimezone()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setTimezoneChangeSelected(true); } } if ($this->initalEventLastChange->getIsPhysicalChanged() && $this->initalEvent->getIsPhysical() != $futureEvent->getIsPhysical()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setIsPhysicalChangePossible(true); if ($this->initialEventJustBeforeLastChange->getIsPhysical() == $futureEvent->getIsPhysical()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setIsPhysicalChangeSelected(true); } } if ($this->initalEventLastChange->getIsVirtualChanged() && $this->initalEvent->getIsVirtual() != $futureEvent->getIsVirtual()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setIsVirtualChangePossible(true); if ($this->initialEventJustBeforeLastChange->getIsVirtual() == $futureEvent->getIsVirtual()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setIsVirtualChangeSelected(true); } } if ($this->initalEventLastChange->getIsCancelledChanged() && $this->initalEvent->getIsCancelled() != $futureEvent->getIsCancelled()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setIsCancelledChangePossible(true); if ($this->initialEventJustBeforeLastChange->getIsCancelled() == $futureEvent->getIsCancelled()) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setIsCancelledChangeSelected(true); } } if ($startDiff->y != 0 || $startDiff->m != 0 || $startDiff->d != 0 || $startDiff->h != 0 || $startDiff->i != 0 || $startDiff->s != 0 || ($endDiff->y != 0 || $endDiff->m != 0 || $endDiff->d != 0 || $endDiff->h != 0 || $endDiff->i != 0 || $endDiff->s != 0)) { $start = clone $futureEvent->getStartAtInUTC(); $start->sub($startDiff); $end = clone $futureEvent->getEndAtInUTC(); $end->sub($endDiff); $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setStartEndAtChangePossible(true); $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setStartEndAtChangeSelected(true); $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setStartAt($start); $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setEndAt($end); } foreach ($this->customFields as $customField) { if ($this->initalEventLastChange->hasCustomField($customField) && $this->initalEvent->getCustomField($customField) != $futureEvent->getCustomField($customField)) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setCustomFieldChangePossible($customField, true); if ($this->initialEventJustBeforeLastChange->getCustomField($customField) == $futureEvent->getCustomField($customField)) { $this->futureEventsProposedChanges[$futureEvent->getSlug()]->setCustomFieldChangeSelected($customField, true); } } } } }
public function addEvent(EventModel $event, $groups = array(), VenueModel $venue = null, AreaModel $area = null, CountryModel $country = null, $eventMedias = array()) { global $CONFIG; $siteSlug = $this->site ? $this->site->getSlug() : $event->getSiteSlug(); $txt = $this->getIcalLine('BEGIN', 'VEVENT'); $txt .= $this->getIcalLine('UID', $event->getSlug() . '@' . $siteSlug . "." . $CONFIG->webSiteDomain); $url = $CONFIG->isSingleSiteMode ? 'http://' . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl() : 'http://' . $siteSlug . "." . $CONFIG->webSiteDomain . '/event/' . $event->getSlugForUrl(); $txt .= $this->getIcalLine('URL', $url); if ($event->getIsDeleted()) { $txt .= $this->getIcalLine('SUMMARY', $event->getSummaryDisplay() . " [DELETED]"); $txt .= $this->getIcalLine('METHOD', 'CANCEL'); $txt .= $this->getIcalLine('STATUS', 'CANCELLED'); $txt .= $this->getIcalLine('DESCRIPTION', 'DELETED'); } else { if ($event->getIsCancelled()) { $txt .= $this->getIcalLine('SUMMARY', $event->getSummaryDisplay() . " [CANCELLED]"); $txt .= $this->getIcalLine('METHOD', 'CANCEL'); $txt .= $this->getIcalLine('STATUS', 'CANCELLED'); $txt .= $this->getIcalLine('DESCRIPTION', 'CANCELLED'); } else { $txt .= $this->getIcalLine('SUMMARY', $event->getSummaryDisplay()); $description = ''; foreach ($this->extraHeaders as $extraHeader) { $description .= $extraHeader->getText() . "\n\n"; } $description .= $event->getDescription() . "\n" . $url . "\n" . "Powered by " . $CONFIG->siteTitle; foreach ($this->extraFooters as $extraFooter) { $description .= "\n" . $extraFooter->getText(); } $txt .= $this->getIcalLine('DESCRIPTION', $description); $descriptionHTML = "<html><body>"; foreach ($this->extraHeaders as $extraHeader) { $descriptionHTML .= "<p>" . $extraHeader->getHtml() . "</p>"; } $descriptionHTML .= "<p>" . str_replace("\r", "", str_replace("\n", "<br>", htmlentities($event->getDescription()))) . "</p>"; //if ($event->getUrl()) $descriptionHTML .= '<p>More info: <a href="'.$event->getUrl().'">'.$event->getUrl().'</a></p>'; $descriptionHTML .= '<p>More info: <a href="' . $url . '">' . $url . '</a></p>'; $descriptionHTML .= '<p style="font-style:italic;font-size:80%">Powered by <a href="' . $url . '">' . $CONFIG->siteTitle . '</a>'; foreach ($this->extraFooters as $extraFooter) { $descriptionHTML .= "<br>" . $extraFooter->getHtml(); } $descriptionHTML .= '</p>'; $descriptionHTML .= '</body></html>'; $txt .= $this->getIcalLine("X-ALT-DESC;FMTTYPE=text/html", $descriptionHTML); $locationDetails = array(); if ($event->getVenue() && $event->getVenue()->getTitle()) { $locationDetails[] = $event->getVenue()->getTitle(); } if ($event->getVenue() && $event->getVenue()->getAddress()) { $locationDetails[] = $event->getVenue()->getAddress(); } if ($event->getArea() && $event->getArea()->getTitle()) { $locationDetails[] = $event->getArea()->getTitle(); } if ($event->getVenue() && $event->getVenue()->getAddressCode()) { $locationDetails[] = $event->getVenue()->getAddressCode(); } if ($locationDetails) { $txt .= $this->getIcalLine('LOCATION', implode(", ", $locationDetails)); } if ($event->getVenue() && $event->getVenue()->getLat() && $event->getVenue()->getLng()) { $txt .= $this->getIcalLine('GEO', $event->getVenue()->getLat() . ";" . $event->getVenue()->getLng()); } } } $txt .= $this->getIcalLine('DTSTART', $event->getStartAt()->format("Ymd") . "T" . $event->getStartAt()->format("His") . "Z"); $txt .= $this->getIcalLine('DTEND', $event->getEndAt()->format("Ymd") . "T" . $event->getEndAt()->format("His") . "Z"); $txt .= $this->getIcalLine('END', 'VEVENT'); $this->events[] = $txt; }
public function update(EventModel $event, $fields, EventEditMetaDataModel $eventEditMetaDataModel) { $alreadyInTransaction = $this->db->inTransaction(); // Make Information Data $fieldsSQL1 = array(); $fieldsParams1 = array('id' => $event->getId()); foreach ($fields as $field) { if ($field == 'custom') { $fieldsSQL1[] = " custom_fields = :custom_fields "; $fieldsParams1['custom_fields'] = json_encode($event->getCustomFields()); } else { $fieldsSQL1[] = " " . $field . "=:" . $field . " "; if ($field == 'summary') { $fieldsParams1['summary'] = substr($event->getSummary(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'description') { $fieldsParams1['description'] = $event->getDescription(); } else { if ($field == 'start_at') { $fieldsParams1['start_at'] = $event->getStartAt()->format("Y-m-d H:i:s"); } else { if ($field == 'end_at') { $fieldsParams1['end_at'] = $event->getEndAt()->format("Y-m-d H:i:s"); } else { if ($field == 'venue_id') { $fieldsParams1['venue_id'] = $event->getVenueId(); } else { if ($field == 'area_id') { $fieldsParams1['area_id'] = $event->getAreaId(); } else { if ($field == 'country_id') { $fieldsParams1['country_id'] = $event->getCountryId(); } else { if ($field == 'timezone') { $fieldsParams1['timezone'] = substr($event->getTimezone(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'url') { $fieldsParams1['url'] = substr($event->getUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'ticket_url') { $fieldsParams1['ticket_url'] = substr($event->getTicketUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'is_physical') { $fieldsParams1['is_physical'] = $event->getIsPhysical() ? 1 : 0; } else { if ($field == 'is_virtual') { $fieldsParams1['is_virtual'] = $event->getIsVirtual() ? 1 : 0; } else { if ($field == 'is_cancelled') { $fieldsParams1['is_cancelled'] = $event->getIsCancelled() ? 1 : 0; } else { if ($field == 'is_deleted') { $fieldsParams1['is_deleted'] = $event->getIsDeleted() ? 1 : 0; } else { if ($field == 'is_duplicate_of_id') { $fieldsParams1['is_duplicate_of_id'] = $event->getIsDuplicateOfId(); } } } } } } } } } } } } } } } } } // Make History Data $fieldsSQL2 = array('event_id', 'user_account_id', 'created_at', 'approved_at', 'from_ip'); $fieldsSQLParams2 = array(':event_id', ':user_account_id', ':created_at', ':approved_at', ':from_ip'); $fieldsParams2 = array('event_id' => $event->getId(), 'user_account_id' => $eventEditMetaDataModel->getUserAccount() ? $eventEditMetaDataModel->getUserAccount()->getId() : null, 'created_at' => $this->timesource->getFormattedForDataBase(), 'approved_at' => $this->timesource->getFormattedForDataBase(), 'from_ip' => $eventEditMetaDataModel->getIp()); if ($eventEditMetaDataModel->getRevertedFromHistoryCreatedAt()) { $fieldsSQL2[] = ' reverted_from_created_at '; $fieldsSQLParams2[] = ' :reverted_from_created_at '; $fieldsParams2['reverted_from_created_at'] = $eventEditMetaDataModel->getRevertedFromHistoryCreatedAt()->format("Y-m-d H:i:s"); } if ($eventEditMetaDataModel->getEditComment()) { $fieldsSQL2[] = ' edit_comment '; $fieldsSQLParams2[] = ' :edit_comment '; $fieldsParams2['edit_comment'] = $eventEditMetaDataModel->getEditComment(); } foreach ($this->possibleFields as $field) { if (in_array($field, $fields) || $field == 'summary') { $fieldsSQL2[] = " " . $field . " "; $fieldsSQLParams2[] = " :" . $field . " "; if ($field == 'summary') { $fieldsParams2['summary'] = substr($event->getSummary(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'description') { $fieldsParams2['description'] = $event->getDescription(); } else { if ($field == 'start_at') { $fieldsParams2['start_at'] = $event->getStartAt()->format("Y-m-d H:i:s"); } else { if ($field == 'end_at') { $fieldsParams2['end_at'] = $event->getEndAt()->format("Y-m-d H:i:s"); } else { if ($field == 'venue_id') { $fieldsParams2['venue_id'] = $event->getVenueId(); } else { if ($field == 'area_id') { $fieldsParams2['area_id'] = $event->getAreaId(); } else { if ($field == 'country_id') { $fieldsParams2['country_id'] = $event->getCountryId(); } else { if ($field == 'timezone') { $fieldsParams2['timezone'] = substr($event->getTimezone(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'url') { $fieldsParams2['url'] = substr($event->getUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'ticket_url') { $fieldsParams2['ticket_url'] = substr($event->getTicketUrl(), 0, VARCHAR_COLUMN_LENGTH_USED); } else { if ($field == 'is_physical') { $fieldsParams2['is_physical'] = $event->getIsPhysical() ? 1 : 0; } else { if ($field == 'is_virtual') { $fieldsParams2['is_virtual'] = $event->getIsVirtual() ? 1 : 0; } else { if ($field == 'is_cancelled') { $fieldsParams2['is_cancelled'] = $event->getIsCancelled() ? 1 : 0; } else { if ($field == 'is_deleted') { $fieldsParams2['is_deleted'] = $event->getIsDeleted() ? 1 : 0; } else { if ($field == 'is_duplicate_of_id') { $fieldsParams2['is_duplicate_of_id'] = $event->getIsDuplicateOfId(); } } } } } } } } } } } } } } } $fieldsSQL2[] = " " . $field . "_changed "; $fieldsSQLParams2[] = " 0 "; } else { $fieldsSQL2[] = " " . $field . "_changed "; $fieldsSQLParams2[] = " -2 "; } } if (in_array("custom", $fields)) { $fieldsSQL2[] = " custom_fields "; $fieldsSQLParams2[] = " :custom_fields "; $fieldsParams2['custom_fields'] = json_encode($event->getCustomFields()); $fieldsSQL2[] = " custom_fields_changed "; $fieldsSQLParams2[] = " 0 "; } else { $fieldsSQL2[] = " custom_fields_changed "; $fieldsSQLParams2[] = " -2 "; } try { if (!$alreadyInTransaction) { $this->db->beginTransaction(); } // Information SQL $stat = $this->db->prepare("UPDATE event_information SET " . implode(",", $fieldsSQL1) . " WHERE id=:id"); $stat->execute($fieldsParams1); // History SQL $stat = $this->db->prepare("INSERT INTO event_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; }