PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.1.21
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.1.21
2.1.22 2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 All 56 releases
← All changes | core/wpbm-ics.php +68 -18 2.0.14 → 2.1.21 View file →
@@ -105,9 +105,9 @@
105 105 if ( false === strpos( $ics_content, 'VEVENT' ) ) {
106 106 return new WP_Error( 'wpbm_ics_error', '<strong>[WPBM Error]</strong> ' . __( 'File does not contain events' ) . ' ' , 'wrong_ics_content' );
107 107 }
108 108
109 -
109 + $ics_content = trim($ics_content); //FixIn: 2.1.9.2
110 110 $icalobj = new ZCiCal( $ics_content ); // create the ical object
111 111
112 112
113 113 $events_count = 0;
@@ -147,9 +147,27 @@
147 147
148 148
149 149 // Add Booking fields, like "_BOOKING_DATES, _BOOKING_SUMMARY, ..."
150 150 foreach ( $ics_events as $i_key => $i_event) {
151 -
151 +
152 + //FixIn: 2.0.23.1
153 + /**
154 + * The spec says that if DTSTART has a DATE data type, and there is no DTEND then the event finishes at the end of the day that it starts.
155 + * But if DTSTART has a full DATE-TIME data type, and there is no DTEND then it finishes at the same time that it starts.
156 + *
157 + * It's in section 3.6.1 of RFC 5545 (https://www.rfc-editor.org/rfc/rfc5545#page-54):
158 + *
159 + * For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE value type but no "DTEND" nor "DURATION" property,
160 + * the event's duration is taken to be one day. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME value
161 + * type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property.
162 + */
163 + if ( ( empty( $ics_events[ $i_key ]['DTEND'] ) )
164 + && ( ! empty( $ics_events[ $i_key ]['DTSTART'] ) ) ) {
165 +
166 + $ics_events[ $i_key ]['DTEND'] = 'null';
167 + }
168 +
169 +
152 170 $dates_arr = wpbm_get_dates_arr_from_ics_dates( $ics_events[ $i_key ][ 'DTSTART' ]
153 171 , $ics_events[ $i_key ][ 'DTEND' ]
154 172 , ( empty( $ics_events[ $i_key ]['RRULE'] ) ? '' : $ics_events[ $i_key ]['RRULE'] )
155 173 , ( empty( $ics_events[ $i_key ]['RDATE'] ) ? '' : $ics_events[ $i_key ]['RDATE'] )
@@ -163,22 +181,31 @@
163 181 $ics_events[ $i_key ]['_BOOKING_DESCRIPTION'] = '';
164 182 $ics_events[ $i_key ]['_BOOKING_LOCATION'] = '';
165 183 $ics_events[ $i_key ]['_BOOKING_UID'] = '';
166 184 $ics_events[ $i_key ]['_BOOKING_MODIFIED'] = '';
167 -
168 - if ( ! empty( $ics_events[ $i_key ][ 'SUMMARY' ] ) )
169 - $ics_events[ $i_key ]['_BOOKING_SUMMARY'] = $ics_events[ $i_key ][ 'SUMMARY' ];
170 - if ( ! empty( $ics_events[ $i_key ][ 'DESCRIPTION' ] ) )
171 - $ics_events[ $i_key ]['_BOOKING_DESCRIPTION'] = $ics_events[ $i_key ][ 'DESCRIPTION' ];
172 - if ( ! empty( $ics_events[ $i_key ][ 'LOCATION' ] ) )
173 - $ics_events[ $i_key ]['_BOOKING_LOCATION'] = $ics_events[ $i_key ][ 'LOCATION' ];
174 -
185 + $ics_events[ $i_key ]['_BOOKING_ATTENDEE'] = '';
186 +
187 + if ( ! empty( $ics_events[ $i_key ]['SUMMARY'] ) ) {
188 + $ics_events[ $i_key ]['_BOOKING_SUMMARY'] = $ics_events[ $i_key ]['SUMMARY'];
189 + }
190 + if ( ! empty( $ics_events[ $i_key ]['DESCRIPTION'] ) ) {
191 + $ics_events[ $i_key ]['_BOOKING_DESCRIPTION'] = $ics_events[ $i_key ]['DESCRIPTION'];
192 + }
193 + if ( ! empty( $ics_events[ $i_key ]['LOCATION'] ) ) {
194 + $ics_events[ $i_key ]['_BOOKING_LOCATION'] = $ics_events[ $i_key ]['LOCATION'];
195 + }
196 +
197 + if ( ! empty( $ics_events[ $i_key ]['ATTENDEE'] ) ) {
198 + $ics_events[ $i_key ]['_BOOKING_ATTENDEE'] = $ics_events[ $i_key ]['ATTENDEE'];
199 + }
175 200 // [email protected] - ID of event from ICS
176 - // 15ig8t0i739kajgjc8ekc386dt_20170815 - ID of event during import from Google Calendar (probabaly created by ID before @ + first date)
177 - if ( ! empty( $ics_events[ $i_key ][ 'UID' ] ) )
178 - $ics_events[ $i_key ]['_BOOKING_UID'] = $ics_events[ $i_key ][ 'UID' ];
179 - if ( ! empty( $ics_events[ $i_key ][ 'LAST-MODIFIED' ] ) )
180 - $ics_events[ $i_key ]['_BOOKING_MODIFIED'] = date_i18n( 'Y-m-d H:i:s' , ZDateHelper::fromiCaltoUnixDateTime( $ics_events[ $i_key ][ 'LAST-MODIFIED' ] ) );
201 + // 15ig8t0i739kajgjc8ekc386dt_20170815 - ID of event during import from Google Calendar (probably created by ID before @ + first date)
202 + if ( ! empty( $ics_events[ $i_key ]['UID'] ) ) {
203 + $ics_events[ $i_key ]['_BOOKING_UID'] = $ics_events[ $i_key ]['UID'];
204 + }
205 + if ( ! empty( $ics_events[ $i_key ]['LAST-MODIFIED'] ) ) {
206 + $ics_events[ $i_key ]['_BOOKING_MODIFIED'] = date_i18n( 'Y-m-d H:i:s', ZDateHelper::fromiCaltoUnixDateTime( $ics_events[ $i_key ]['LAST-MODIFIED'] ) );
207 + }
181 208
182 209 }
183 210
184 211 return array( 'data' => $ics_data, 'events' => $ics_events );
@@ -203,11 +230,34 @@
203 230 )
204 231 */
205 232 function wpbm_get_dates_arr_from_ics_dates( $start_date_ics, $end_date_ics, $ics_rules , $ics_rdates ) {
206 233
234 + //FixIn: 2.0.23.1
235 + /**
236 + * The spec says that if DTSTART has a DATE data type, and there is no DTEND then the event finishes at the end of the day that it starts.
237 + * But if DTSTART has a full DATE-TIME data type, and there is no DTEND then it finishes at the same time that it starts.
238 + *
239 + * It's in section 3.6.1 of RFC 5545 (https://www.rfc-editor.org/rfc/rfc5545#page-54):
240 + *
241 + * For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE value type but no "DTEND" nor "DURATION" property,
242 + * the event's duration is taken to be one day. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME value
243 + * type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property.
244 + */
245 + if ('null' === $end_date_ics) {
246 + $end_date_ics = wpbm_ics_date_reset_seconds( $start_date_ics ); // 20170614T120000
247 +
248 + $start_date_unix_calc = ZDateHelper::fromiCaltoUnixDateTime(
249 + wpbm_ics_date_reset_seconds( $start_date_ics )
250 + ); // 1499644800 - 20170710
251 +
252 + $end_date_ics = strtotime( '+1 minute', $start_date_unix_calc );
253 + $end_date_ics = ZDateHelper::fromUnixDateTimetoiCal( $end_date_ics );
254 + }
255 +
256 +
207 257 $start_date_ics = wpbm_ics_date_reset_seconds( $start_date_ics ); // 20170614T120000
208 - $end_date_ics = wpbm_ics_date_reset_seconds( $end_date_ics ); // 20170614T120000
209 -
258 + $end_date_ics = wpbm_ics_date_reset_seconds( $end_date_ics ); // 20170614T120000
259 +
210 260 // FREQ=MONTHLY;COUNT=4;BYDAY=2MO - Rules
211 261 $start_date_unix = ZDateHelper::fromiCaltoUnixDateTime( $start_date_ics ); // 1499644800 - 20170710
212 262 $end_date_unix = ZDateHelper::fromiCaltoUnixDateTime( $end_date_ics ); // 1499904000 - 20170713
213 263
@@ -248,9 +298,9 @@
248 298 $initial_time_interval_unix[] = $internal_date_unix;
249 299 }
250 300
251 301 // Same for end date/time +2 seconds for having time like 10:00:02
252 - if ( substr( $end_date, 11 ) != '00:00:00' ) $initial_time_interval_unix[] = $end_date_unix + 2; // End time for specific time slot
302 + if ( substr( $end_date, 11 ) != '00:00:00' ) $initial_time_interval_unix[] = $end_date_unix - 8; // End time for specific time slot //FixIn: 2.0.22.2 //FixIn: 9.0.1.3 //FixIn: 2.0.21.1
253 303 // We do not need to add END date, if the TIME == '00:00:00', because EVENT ended at previous date
254 304
255 305 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
256 306