From: Steve Sutton Date: Thu, 2 Mar 2017 18:54:17 +0000 (-0500) Subject: Update the ical feed and ical feed imort X-Git-Tag: v1.6.12^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1c0605fe3569f9a4d8451b97c5808f866ffc90a3;p=WP-Plugins%2Fglm-member-db-events.git Update the ical feed and ical feed imort Adding the ability to pass the custom dates and deal with our new event ical feed in the import for feeds. --- diff --git a/index.php b/index.php index 978da17..b922db5 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Events * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.6.11 + * Version: 1.6.12 * Author: Chuck Scott * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -20,7 +20,7 @@ * @package glmMembersDatabaseEventsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.6.11 + * @version 1.6.12 */ /* @@ -38,7 +38,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.11'); +define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.12'); define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.1'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/front/events/icalFeed.php b/models/front/events/icalFeed.php index 4fd0a83..fe3b7e6 100644 --- a/models/front/events/icalFeed.php +++ b/models/front/events/icalFeed.php @@ -259,6 +259,17 @@ EOD; } $output .= "\nRRULE:" . $freq .";BYDAY=" . $daysInWeek . ";UNTIL=" . $this->icalDateFormat($event['ending_timestamp']); + // Check now for the Specific dates + if ( isset( $event['recurrences'][0]['specific_dates'] ) && is_array( $event['recurrences'][0]['specific_dates'] ) ) { + $rDates = array(); + foreach ( $event['recurrences'][0]['specific_dates'] as $eDate ) { + $rDates[] = str_replace( '-', '', $eDate ); + } + if ( !empty( $rDates ) ) { + $output .= "\nRDATE;VALUE=DATE:"; + $output .= implode( ',',$rDates ); + } + } } } $output .= $eventTemplateEnd; diff --git a/models/front/events/icalFeedImport.php b/models/front/events/icalFeedImport.php index 3fa8f81..f386bc6 100644 --- a/models/front/events/icalFeedImport.php +++ b/models/front/events/icalFeedImport.php @@ -95,6 +95,9 @@ class GlmMembersFront_events_icalFeedImport $feed_id ) ); + if ( $debug ) { + $out .= '
$feed_url: ' . print_r( $feed_url, true ) . '
'; + } // Set new updated date for feed $this->wpdb->update( GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'feed_import', @@ -118,21 +121,44 @@ class GlmMembersFront_events_icalFeedImport } if ( $events ) { foreach ( $events as $event ) { + if ( $debug ) { + $out .= '
$event: ' . print_r( $event, true ) . '
'; + } $contact = array(); $image = ''; $event['DESCRIPTION'] = str_replace( '\n', "
", $event['DESCRIPTION'] ); $intro = substr( strip_tags( $event['DESCRIPTION'] ), 0 ,150); if ( isset( $event['CONTACT'] ) ) { - $contact_data = explode( ',', str_replace( '\\', '', $event['CONTACT'] ) ); + // Remove the backslashes + $eventContact = str_replace( '\\', '', $event['CONTACT'] ); if ( $debug ) { - //$out .= '
$contact_data: ' . print_r( $contact_data, true ) . '
'; + $out .= '
$eventContact: ' . print_r( $eventContact, true ) . '
'; + } + + // Check if the event CONTACT has semi colons in it. + // If it does then the CONTACT string hold the contact email phone and name. + if ( strpos( $eventContact, ';' ) !== false ) { + $contact_data = explode( ';', $eventContact ); + if ( $debug ) { + $out .= '
' . __LINE__ . '$contact_data: ' . print_r( $contact_data, true ) . '
'; + } + $contact = array( + 'email' => $contact_data[0], + 'phone' => $contact_data[2], + 'name' => $contact_data[3], + ); + } else { + $contact_data = explode( ',', $eventContact ); + if ( $debug ) { + $out .= '
$contact_data: ' . print_r( $contact_data, true ) . '
'; + } + $contact = array( + 'name' => $contact_data[0], + 'email' => $contact_data[1], + 'phone' => $contact_data[2], + ); } - $contact = array( - 'name' => $contact_data[0], - 'email' => $contact_data[1], - 'phone' => $contact_data[2], - ); } else { $contact = array( 'name' => '', @@ -189,7 +215,7 @@ class GlmMembersFront_events_icalFeedImport 'contact_phone' => $contact['phone'], ); if ( $debug ) { - //$out .= '
$event_data: ' . print_r( $event_data, true ) . '
'; + $out .= '
$event_data: ' . print_r( $event_data, true ) . '
'; } $event_data_format = array( '%d', @@ -207,21 +233,25 @@ class GlmMembersFront_events_icalFeedImport '%s', '%s', ); - if ( $event_id ) { - $this->wpdb->update( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events', - $event_data, - array( 'id' => $event_id ), - $event_data_format, - '%d' - ); + 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; + } } else { - $this->wpdb->insert( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events', - $event_data, - $event_data_format - ); - $event_id = $this->wpdb->insert_id; + continue; } if ( !$event_id ) { continue; @@ -375,6 +405,18 @@ class GlmMembersFront_events_icalFeedImport } } } + if ( isset( $event['RDATE'] ) && preg_match( '%VALUE=DATE:(.*)%', $event['RDATE'], $matches ) ) { + $rDates = explode( ',', $matches[1] ); + foreach ( $rDates as $key => &$rDate ) { + if ( preg_match( '%([0-9]{4})([0-9]{2})([0-9]{2})%', $rDate, $rDateMatches ) ) { + $rDate = $rDateMatches[1].'-'.$rDateMatches[2].'-'.$rDateMatches[3]; + } + } + $serialized_times = serialize($rDates); + $recurring_event = 1; + $month_of_year = 0; + $week_of_month = 0; + } if ( $btime === $etime ) { if ( $btime === '00:00' ) { $all_day = true;