protected function setImportedEventFromMeetupData(ImportedEventModel $importedEvent, $meetupData) { $changesToSave = false; if (property_exists($meetupData, 'description')) { $description = $meetupData->description; var_dump($description); if ($importedEvent->getDescription() != $description) { $importedEvent->setDescription($description); $changesToSave = true; } } $start = new \DateTime('', new \DateTimeZone('UTC')); $start->setTimestamp($meetupData->time / 1000); if (property_exists($meetupData, 'duration') && $meetupData->duration) { $end = new \DateTime('', new \DateTimeZone('UTC')); $end->setTimestamp($meetupData->time / 1000); $end->add(new \DateInterval("PT" . $meetupData->duration / 1000 . "S")); } else { $end = clone $start; $end->add(new \DateInterval("PT3H")); } if (!$importedEvent->getStartAt() || $importedEvent->getStartAt()->getTimeStamp() != $start->getTimeStamp()) { $importedEvent->setStartAt($start); $changesToSave = true; } if (!$importedEvent->getEndAt() || $importedEvent->getEndAt()->getTimeStamp() != $end->getTimeStamp()) { $importedEvent->setEndAt($end); $changesToSave = true; } if ($importedEvent->getTitle() != $meetupData->name) { $importedEvent->setTitle($meetupData->name); $changesToSave = true; } if ($importedEvent->getUrl() != $meetupData->event_url) { $importedEvent->setUrl($meetupData->event_url); $changesToSave = true; } if ($importedEvent->getTimezone() != $meetupData->timezone) { $importedEvent->setTimezone($meetupData->timezone); $changesToSave = true; } if ($importedEvent->getTicketUrl() != $meetupData->event_url) { $importedEvent->setTicketUrl($meetupData->event_url); $changesToSave = true; } return $changesToSave; }
protected function setImportedEventFromFBData(ImportedEventModel $importedEvent, $fbData) { $changesToSave = false; if ($importedEvent->getDescription() != $fbData['description']) { $importedEvent->setDescription($fbData['description']); $changesToSave = true; } $start = new \DateTime($fbData['start_time'], new \DateTimeZone('UTC')); if ($fbData['end_time']) { $end = new \DateTime($fbData['end_time'], new \DateTimeZone('UTC')); } else { $end = clone $start; } if ($fbData['is_date_only']) { $start->setTime(0, 0, 0); $end->setTime(23, 59, 59); } if (!$importedEvent->getStartAt() || $importedEvent->getStartAt()->getTimeStamp() != $start->getTimeStamp()) { $importedEvent->setStartAt($start); $changesToSave = true; } if (!$importedEvent->getEndAt() || $importedEvent->getEndAt()->getTimeStamp() != $end->getTimeStamp()) { $importedEvent->setEndAt($end); $changesToSave = true; } if ($importedEvent->getTitle() != $fbData['name']) { $importedEvent->setTitle($fbData['name']); $changesToSave = true; } if ($importedEvent->getUrl() != $fbData['url']) { $importedEvent->setUrl($fbData['url']); $changesToSave = true; } if ($importedEvent->getTimezone() != $fbData['timezone']) { $importedEvent->setTimezone($fbData['timezone']); $changesToSave = true; } if ($importedEvent->getTicketUrl() != $fbData['ticket_uri']) { $importedEvent->setTicketUrl($fbData['ticket_uri']); $changesToSave = true; } return $changesToSave; }
protected function setOurEventFromEventObject(ImportedEventModel $importedEvent, $event) { $changesToSave = false; if ($importedEvent->getTitle() != $event->eventTitle) { $importedEvent->setTitle($event->eventTitle); $changesToSave = true; } $description = $event->eventDetails . "\n\n"; $description .= $event->additionalInfo . "\n\n"; $description .= $event->practicalities . "\n\n"; $description .= $event->contactName . "\n"; $description .= $event->organisation . "\n"; $description .= $event->contactEmail . "\n"; $description .= $event->contactPhone . "\n"; $description .= $event->organisedBy . "\n"; $description .= $event->eventLocation . "\n"; $description .= $event->constitName . "\n"; $description .= $event->eventPostcode . "\n"; $description .= $event->eventDate . " " . $event->eventTime . "\n"; if ($importedEvent->getDescription() != $description) { $importedEvent->setDescription($description); $changesToSave = true; } if ($importedEvent->getUrl() != $event->url) { $importedEvent->setUrl($event->url); $changesToSave = true; } $importedEvent->setTimezone("Europe/London"); $p = new ParseDateTimeRangeString(TimeSource::getDateTime(), "Europe/London"); $r = $p->parse($event->eventDate . " " . $event->eventTime); if (!$importedEvent->getStartAt() || $importedEvent->getStartAt()->getTimeStamp() != $r->getStart()->getTimeStamp()) { $importedEvent->setStartAt(clone $r->getStart()); $changesToSave = true; } if (!$importedEvent->getEndAt() || $importedEvent->getEndAt()->getTimeStamp() != $r->getEnd()->getTimeStamp()) { $importedEvent->setEndAt(clone $r->getEnd()); $changesToSave = true; } return $changesToSave; }
protected function setOurEventFromIcalEvent(ImportedEventModel $importedEvent, ICalEvent $icalevent) { $changesToSave = false; if ($importedEvent->getDescription() != $icalevent->getDescription()) { $importedEvent->setDescription($icalevent->getDescription()); $changesToSave = true; } if ($importedEvent->getTimezone() != $this->icalParser->getTimeZoneIdentifier()) { $importedEvent->setTimezone($this->icalParser->getTimeZoneIdentifier()); $changesToSave = true; } if (!$importedEvent->getStartAt() || $importedEvent->getStartAt()->getTimeStamp() != $icalevent->getStart()->getTimeStamp()) { $importedEvent->setStartAt(clone $icalevent->getStart()); $changesToSave = true; } if (!$importedEvent->getEndAt() || $importedEvent->getEndAt()->getTimeStamp() != $icalevent->getEnd()->getTimeStamp()) { $importedEvent->setEndAt(clone $icalevent->getEnd()); $changesToSave = true; } if ($importedEvent->getTitle() != $icalevent->getSummary()) { $importedEvent->setTitle($icalevent->getSummary()); $changesToSave = true; } if ($importedEvent->getUrl() != $icalevent->getUrl()) { $importedEvent->setUrl($icalevent->getUrl()); $changesToSave = true; } if ($this->importURLRun->hasFlag(ImportURLRun::$FLAG_SET_TICKET_URL_AS_URL) && $importedEvent->getTicketUrl() != $icalevent->getUrl()) { $importedEvent->setTicketUrl($icalevent->getUrl()); $changesToSave = true; } if ($icalevent->getRRule()) { $reoccur = array('ical_rrule' => $icalevent->getRRule(), 'ical_exdates' => array()); foreach ($icalevent->getExDates() as $exDate) { $reoccur['ical_exdates'][] = array('properties' => $exDate->getProperties(), 'values' => $exDate->getValues()); } } else { $reoccur = array(); } if ($importedEvent->setReoccurIfDifferent($reoccur)) { $changesToSave = true; } return $changesToSave; }