public function getForImportedEvent(ImportedEventModel $importedEventModel)
 {
     global $DB;
     $stat = $DB->prepare("SELECT event_recur_set.* FROM event_recur_set " . " JOIN event_information ON event_information.event_recur_set_id = event_recur_set.id " . " JOIN imported_event_is_event ON imported_event_is_event.event_id = event_information.id " . " WHERE imported_event_is_event.imported_event_id = :id");
     $stat->execute(array('id' => $importedEventModel->getId()));
     if ($stat->rowCount() > 0) {
         $ers = new EventRecurSetModel();
         $ers->setFromDataBaseRow($stat->fetch());
         return $ers;
     }
 }
 public function delete(ImportedEventModel $importedEvent)
 {
     global $DB;
     $stat = $DB->prepare("UPDATE imported_event SET is_deleted='1' WHERE id=:id");
     $stat->execute(array('id' => $importedEvent->getId()));
 }
 /**
  * 
  * This is a bit broken - in theory this could return multiple events (in the case of a imported event with recurrence) 
  * But for now that can't happen so just return one event.
  * 
  * @global \repositories\type $DB
  * @param \models\ImportedEventModel $importedEvent
  * @return \models\EventModel
  */
 public function loadByImportedEvent(\models\ImportedEventModel $importedEvent)
 {
     global $DB;
     $stat = $DB->prepare("SELECT event_information.*, group_information.title AS group_title, group_information.id AS group_id  FROM event_information " . " JOIN imported_event_is_event ON imported_event_is_event.event_id = event_information.id " . " LEFT JOIN event_in_group ON event_in_group.event_id = event_information.id AND event_in_group.removed_at IS NULL AND event_in_group.is_main_group = '1' " . " LEFT JOIN group_information ON group_information.id = event_in_group.group_id " . " WHERE imported_event_is_event.imported_event_id = :id");
     $stat->execute(array('id' => $importedEvent->getId()));
     if ($stat->rowCount() > 0) {
         $event = new EventModel();
         $event->setFromDataBaseRow($stat->fetch());
         return $event;
     }
 }
 public function createLink(ImportedEventModel $importedEvent, EventModel $event)
 {
     global $DB;
     $stat = $DB->prepare("INSERT INTO imported_event_is_event (imported_event_id, event_id, created_at) " . "VALUES (:imported_event_id, :event_id, :created_at)");
     $stat->execute(array('imported_event_id' => $importedEvent->getId(), 'event_id' => $event->getId(), 'created_at' => \TimeSource::getFormattedForDataBase()));
 }