}
public function getCategoryId( $category )
{
+ $category_id = null;
$category_id = $this->wpdb->get_var(
$this->wpdb->prepare(
"SELECT id
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories
- WHERE lower(name) = %d",
- strtolower($category)
+ WHERE name = %s",
+ trim($category)
)
);
if ( $category_id ) {
$this->wpdb->insert(
GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'categories',
array(
- 'name' => $category,
+ 'name' => trim($category),
'parent' => 0
),
array(
$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "recurrences" );
$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times" );
$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories" );
+ $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories" );
$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations" );
}
public function importIcalFeed( $feed_id )
if ( $debug ) {
$out .= '<pre>$events: ' . print_r( $events, true ) . '</pre>';
}
+ $origTimeZone = date_default_timezone_get();
+ $wpTimeZone = get_option('timezone_string');
+ date_default_timezone_set( $wpTimeZone );
if ( $events ) {
foreach ( $events as $event ) {
if ( $debug ) {
}
$contact = array();
$image = '';
- $event['DESCRIPTION']
- = str_replace( '\n', "<br>", $event['DESCRIPTION'] );
- $intro = substr( strip_tags( $event['DESCRIPTION'] ), 0 ,150);
+ $event['DESCRIPTION'] = str_replace( '\n', "<br>", $event['DESCRIPTION'] );
+ $event['DESCRIPTION'] = str_replace( 'ENCODING=QUOTED-PRINTABLE:', "", $event['DESCRIPTION'] );
+ $event['SUMMARY'] = str_replace( 'ENCODING=QUOTED-PRINTABLE:', "", $event['SUMMARY'] );
+ $intro = substr( strip_tags( $event['DESCRIPTION'] ), 0 ,150);
if ( isset( $event['CONTACT'] ) ) {
// Remove the backslashes
$eventContact = str_replace( '\\', '', $event['CONTACT'] );
$event_data = array(
'status' => $this->config['status_numb']['Active'],
'ref_type' => 10,
- 'created' => $ical->iCalDateToUnixTimestamp( $event['CREATED'] ),
- 'updated' => $ical->iCalDateToUnixTimestamp( $event['CREATED'] ),
+ 'created' => ( isset( $event['CREATED'] ) ? $ical->iCalDateToUnixTimestamp( $event['CREATED'] ) : time() ),
+ 'updated' => ( isset( $event['CREATED'] ) ? $ical->iCalDateToUnixTimestamp( $event['CREATED'] ) : time() ),
'approved' => null,
'ical_uid' => $event['UID'],
'name' => $event['SUMMARY'],
'%s',
'%s',
);
- if ( !$debug ) {
- if ( $event_id ) {
- $this->wpdb->update(
- GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
- $event_data,
- array( 'id' => $event_id ),
- $event_data_format,
- '%d'
- );
- } else {
- $this->wpdb->insert(
- GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
- $event_data,
- $event_data_format
- );
- $event_id = $this->wpdb->insert_id;
- }
+ if ( $event_id ) {
+ $this->wpdb->update(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
+ $event_data,
+ array( 'id' => $event_id ),
+ $event_data_format,
+ '%d'
+ );
} else {
- continue;
+ $this->wpdb->insert(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
+ $event_data,
+ $event_data_format
+ );
+ $event_id = $this->wpdb->insert_id;
}
if ( !$event_id ) {
continue;
'%d'
);
// Categories
+ $category_data = null;
+ $categoryId = null;
if ( isset( $event['CATEGORIES'] ) ) {
$category_data = explode( ',', $event['CATEGORIES'] );
foreach ( $category_data as $category ) {
'%d'
);
}
+ unset( $categoryId );
}
}
// Location Data
if ( isset( $event['LOCATION'] ) ) {
$location_data = explode( ',', str_replace( '\\', '', $event['LOCATION'] ) );
- $place = ( isset( $location_data[0] ) ? $location_data[0]: '');
- $address = ( isset( $location_data[1] ) ? $location_data[1]: '');
- $city = ( isset( $location_data[2] ) ? $location_data[2]: '');
- $state = ( isset( $location_data[3] ) ? $location_data[3]: '');
- $zip = ( isset( $location_data[4] ) ? $location_data[4]: '');
+ // Place will be before the first dash
+ $placeParts = explode( ' - ', $location_data[0] );
+ $place = ( isset( $placeParts[0] ) ? $placeParts[0]: '');
+ $address = ( isset( $placeParts[1] ) ? $placeParts[1]: '');
+ $city = ( isset( $location_data[1] ) ? $location_data[1]: '');
+ $state = ( isset( $location_data[2] ) ? $location_data[2]: '');
+ $zip = ( isset( $location_data[3] ) ? $location_data[3]: '');
$location = array(
'event' => $event_id,
'name' => $place,
$to_date = date( 'Y-m-d', $ending );
$btime = date( 'H:i', $starting );
$etime = date( 'H:i', $ending );
+
$freq = $byday = $until = '';
if ( isset( $event['RRULE'] ) ) {
$recurring_event = 1;
'%d',
'%d'
);
+ date_default_timezone_set( $origTimeZone );
return $out;
}