WHERE image != '' AND image IS NOT NULL";
$results = $this->wpdb->get_results($sql, ARRAY_A);
echo '<pre>$results: ' . print_r($results, true) . '</pre>';
- $imgUrl = 'http://is0.gaslightmedia.com/discoverkalamazoo/CKImage/';
+ $imgUrl = 'http://is0.gaslightmedia.com/discoverkalamazoo/original/';
foreach ( $results as $event ) {
$imageFullUrl = $imgUrl . $event['image'];
$res = $ImageUpload->storeImage($imageFullUrl);
}
}
+ public function importEventFiles()
+ {
+ // get all events with images
+ $sql = "
+ SELECT id,file1,file2_descr,old_event_id
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "events
+ WHERE file1 != '' AND file1 IS NOT NULL";
+ $results = $this->wpdb->get_results($sql, ARRAY_A);
+ //echo '<pre>$results: ' . print_r($results, true) . '</pre>';
+ $fileUrl = 'http://is0.gaslightmedia.com/discoverkalamazoo/original/';
+ //echo '<pre>$results: ' . print_r($results, true) . '</pre>';
+ //exit;
+ foreach ( $results as $event ) {
+ $fileFullUrl = $fileUrl . $event['image'];
+ $fp = fopen( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $event['file1'], 'w+' );
+ $ch = curl_init( $fileUrl . $event['file1'] );
+ curl_setopt($ch, CURLOPT_TIMEOUT, 50);
+ curl_setopt($ch, CURLOPT_FILE, $fp);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ $fileData = curl_exec($ch);
+ $httpCode = curl_getinfo($ch);
+ curl_close($ch);
+ fclose($fp);
+ // Set correct file permissions
+ $oldUmask = umask(0);
+ chmod( GLM_MEMBERS_PLUGIN_FILES_PATH . '/' . $event['file1'], 0660 );
+ umask($oldUmask);
+ }
+ }
+
/**
* modelAction
*
break;
+ case 'eventFilesImport':
+
+ $this->importEventFiles();
+
+ break;
+
case 'eventimport':
$import = false;
SELECT *
FROM {$this->settings['schema']}.{$this->settings['tablename']}
WHERE edate >= '{$this->settings['sdate']}'::DATE";
- //$sql .=" AND reacur ";
+ //$sql .=" AND file != '' ";
try {
$events = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
$return .= '<pre>$events: ' . print_r($events, true) . '</pre>';
'intro' => $intro,
'descr' => $event['descr'],
'image' => $event['img'],
+ 'file1' => $event['file'],
+ 'file1_descr' => $event['filename'],
'cost' => $event['cost'],
'url' => $event['url'],
'ref_type' => $refType,
'%s',
'%s',
'%s',
+ '%s',
+ '%s',
'%d',
'%d',
'%s',
'intro' => $intro,
'descr' => $event['descr'],
'image' => $event['img'],
+ 'file1' => $event['file'],
+ 'file1_descr' => $event['filename'],
'cost' => $event['cost'],
'url' => $event['url'],
'old_event_id' => $event['id'],
'%s',
'%s',
'%s',
+ '%s',
+ '%s',
'%d',
'%d',
'%d',
);
}
// recurrences for the event
- $allDates = $event['reacur'];
- if ( $allDates && ( $event['bdate'] == $event['edate'] ) ) {
- $allDates = 0;
+ $recurringEvent = $event['reacur'];
+ if ( $recurringEvent && ( $event['bdate'] == $event['edate'] ) ) {
+ $recurringEvent = 0;
}
- $dayOfWeek =
- $monthOfYear =
- $weekOfMonth =
- $byDayOfMonth =
+ $dayOfWeek =
+ $monthOfYear =
+ $weekOfMonth =
+ $byDayOfMonth =
$lastDayOfMonth = null;
- if ( $allDates ) {
+ if ( $recurringEvent ) {
if ( $event['daysow'] ) {
$dayOfWeek = $event['daysow'];
+ } else {
+ $dayOfWeek = 127;
}
if ( $event['weekom'] ) {
switch ($event['weekom']) {
} else {
$weekOfMonth = 63;
}
- $monthOfYear = 4095;
+ $monthOfYear = 4096;
}
$btime = $this->getTime($event['btime']);
$etime = $this->getTime($event['etime']);
- $allDay = ( $event['all_day'] || !$event['btime'] );
+ $startTimeOnly = ($btime && !$etime);
+ if ( $startTimeOnly ) {
+ $etime = $btime;
+ }
+ $allDay = ( $event['all_day'] || !$btime );
$recurData =array(
'event' => $eventId,
'name' => 'Imported Event Schedule',
'start_time' => $btime,
'end_time' => $etime,
+ 'start_time_only' => $startTimeOnly,
'from_date' => $event['bdate'],
'to_date' => $event['edate'],
'all_day' => $allDay,
- 'recurring' => $allDates,
+ 'recurring' => $recurringEvent,
'month_of_year' => $monthOfYear,
'week_of_month' => $weekOfMonth,
'day_of_week' => $dayOfWeek,
'%s',
'%s',
'%s',
+ '%s',
'%d',
'%d',
'%d',