function __construct(ImportedEventModel $importedEvent) { $reoccur = $importedEvent->getReoccur(); if (isset($reoccur) && isset($reoccur['ical_rrule']) && $reoccur['ical_rrule']) { $icaldata = new ICalData(clone $importedEvent->getStartAt(), clone $importedEvent->getEndAt(), $reoccur['ical_rrule'], $importedEvent->getTimezone()); if (isset($reoccur['ical_exdates']) && is_array($reoccur['ical_exdates'])) { foreach ($reoccur['ical_exdates'] as $exdate) { $icaldata->addExDateByString($exdate['values'], $exdate['properties']); } } $unraveler = new Unraveler($icaldata); $unraveler->setIncludeOriginalEvent(true); $unraveler->process(); $results = $unraveler->getResults(); foreach ($results as $wantedTimes) { $newImportedOccurrenceEvent = new ImportedEventOccurrenceModel(); $newImportedOccurrenceEvent->setFromImportedEventModel($importedEvent); $newImportedOccurrenceEvent->setStartAt($wantedTimes->getStart()); $newImportedOccurrenceEvent->setEndAt($wantedTimes->getEnd()); $this->importedEventOccurrences[] = $newImportedOccurrenceEvent; } $this->toMultiples = true; } else { // If not a reoccuring event, there will still be 1 occurence ..... $newImportedOccurrenceEvent = new ImportedEventOccurrenceModel(); $newImportedOccurrenceEvent->setFromImportedEventModel($importedEvent); $this->importedEventOccurrences[] = $newImportedOccurrenceEvent; $this->toMultiples = false; } }
public function edit(ImportedEventModel $importedEvent) { global $DB; $stat = $DB->prepare("UPDATE imported_event SET title=:title, description=:description, " . "start_at=:start_at, end_at=:end_at, timezone=:timezone, is_deleted='1', url = :url, " . "ticket_url = :ticket_url, reoccur=:reoccur WHERE id=:id"); $stat->execute(array('id' => $importedEvent->getId(), 'title' => substr($importedEvent->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED), 'description' => $importedEvent->getDescription(), 'start_at' => $importedEvent->getStartAtInUTC()->format("Y-m-d H:i:s"), 'end_at' => $importedEvent->getEndAtInUTC()->format("Y-m-d H:i:s"), 'timezone' => $importedEvent->getTimezone(), 'url' => $importedEvent->getUrl(), 'ticket_url' => $importedEvent->getTicketUrl(), 'reoccur' => $importedEvent->getReoccur() ? json_encode($importedEvent->getReoccur()) : null)); }
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 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; }