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));
 }