$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations" );
$return = $this->addTimelyCategories();
+
+ $yearly_events =
+ $daily_events =
+ $weekly_events =
+ $interval_events =
+ $monthly_events =
+ $custom_date_events = 0;
$Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config);
require_once(GLM_MEMBERS_PLUGIN_PATH.'/models/admin/ajax/imageUpload.php');
}
// Insert the event data
$event_import_data = array(
- 'status' => $this->config['status_numb']['Active'],
- 'created' => $post['post_date'],
- 'updated' => $post['post_modified'],
- 'approved' => $post['post_modified'],
- 'name' => $post['post_title'],
+ 'status' => $this->config['status_numb']['Active'],
+ 'created' => $post['post_date'],
+ 'updated' => $post['post_modified'],
+ 'approved' => $post['post_modified'],
+ 'name' => $post['post_title'],
'name_slug' => $post['post_name'],
'intro' => substr( strip_tags( $post['post_content'] ), 0, 250 ),
'descr' => $post['post_content'],
'image' => $image,
'file1' => null,
- 'file1_descr' => null,
- 'cost' => $cost,
- 'free' => $is_free,
- 'url' => $event_data['contact_url'],
- 'old_event_id' => $post['ID'],
- 'ref_type' => null,
- 'ref_dest' => null,
- 'admin_name' => $event_data['contact_name'],
+ 'file1_descr' => null,
+ 'cost' => $cost,
+ 'free' => $is_free,
+ 'url' => $event_data['contact_url'],
+ 'old_event_id' => $post['ID'],
+ 'ref_type' => null,
+ 'ref_dest' => null,
+ 'admin_name' => $event_data['contact_name'],
'admin_org' => null,
- 'admin_email' => $event_data['contact_email'],
- 'admin_phone' => $event_data['contact_phone'],
+ 'admin_email' => $event_data['contact_email'],
+ 'admin_phone' => $event_data['contact_phone'],
'contact_email' => $event_data['contact_email'],
- 'contact_name' => $event_data['contact_name'],
+ 'contact_name' => $event_data['contact_name'],
'contact_phone' => $event_data['contact_phone'],
'notes' => null,
- 'hide_address' => null,
- 'use_member_location' => 0,
+ 'hide_address' => null,
+ 'use_member_location' => 0,
);
$event_data_format = array(
'%d',
$recurrence_rules = explode( ';', $event_data['recurrence_rules'] );
echo '<pre>$recurrence_rules: ' . print_r($recurrence_rules, true) . '</pre>';
foreach ( $recurrence_rules as $rule ) {
+ // check for RDATE , which are the custom dates that need to be serialized
if(strpos($rule, 'RDATE') !== false){
+ $custom_date_events++;
$rdate = $rule;
$rdate = substr($rdate,6);
$custom_times = explode(',', $rdate);
echo '<pre>$matches: ' . print_r($matches, true) . '</pre>';
switch ( $matches[1] ) {
case "WEEKLY":
+ $weekly_events++;
+ $weekly_rule = $recurrence_rules[1];
+ if(strpos($weekly_rule, "INTERVAL") !== false){
+ $weekly_interval = substr($weekly_rule, 9);
+ $loopLimit = floor(52 / $weekly_interval);
+ $interval_sum = $weekly_interval;
+ for($i = 0; $i < $loopLimit; $i++ ){
+ $date = date('Y-m-d',strtotime($from_date .'+'. $interval_sum .'weeks'));
+ $interval_dates[] = $date;
+ $interval_sum += $weekly_interval;
+ }
+ $serialized_custom_times = serialize($interval_dates);
+ }
$weekly = true;
// check for BYDAY
break;
case "DAILY":
+ $daily_events++;
$daily = true;
+ if(strpos($recurrence_rules[1], "INTERVAL") === false){
+ $month_of_year = 4095;
+ $day_of_month = 2147483647;
+ $by_day_of_month = true;
+ } else {
+ $interval = $recurrence_rules[1];
+ $interval = substr($interval, 9);
+ $loopLimit = floor(365 / $interval);
+ $interval_sum = $interval;
+ for($i = 0; $i < $loopLimit; $i++ ){
+ $date = date('Y-m-d',strtotime($from_date .'+'. $interval_sum .'days'));
+ $interval_dates[] = $date;
+ $interval_sum += $interval;
+ }
+ $serialized_custom_times = serialize($interval_dates);
+ }
+
break;
case "YEARLY":
- $sum = 0;
+ $yearly_events++;
+ $selected_from_date = substr($from_date, -2);
+ $selected_from_date--;
+ $selected_to_date = substr($to_date, -2);
+ $selected_to_date--;
+ $month_sum = 0;
$yearly = $recurrence_rules[1];
$yearly = substr($yearly,8);
$month_ints = explode(',', $yearly);
$month_sum += $ints;
}
$month_of_year = $month_sum;
- $day_of_month = 2147483647;
+ if($selected_from_date == $selected_to_date){
+ $selected_to_date++;
+ }
+ $day_of_month = pow(2,$selected_from_date ) + pow(2, $selected_to_date);
if($month_sum){
$by_day_of_month = 1;
}
break;
case "MONTHLY":
+ $monthly_events++;
$monthly = $recurrence_rules[1];
- $pos = strpos($monthly, "BYday");
- if($pos === false){
+ $byday_pos = strpos($monthly, "BYday");
+ $bymonthday_pos = strpos($monthly, "BYMONTHDAY");
+ if($byday_pos === false){
$monthly = substr($monthly, 11);
$day_ints = explode(',', $monthly);
foreach($day_ints as $day){
}
} else if ( preg_match( ';UNTIL=(.*);', $rule, $matches ) ) {
$to_date = date( 'Y-m-d', strtotime( $matches[1] ) );
- } else if ( preg_match( ';BYday=(.*);', $rule, $matches ) ) {
+
+ } else if ( preg_match( ';BYMONTH=(.*);', $rule, $matches ) ) {
+// $monthly = $recurrence_rules[1];
+//
+// $selected_from_date = substr($from_date, -2);
+// $selected_from_date--;
+// $selected_to_date = substr($to_date, -2);
+// $selected_to_date--;
+//
+// $monthly = substr($monthly, 8);
+// $month_ints = explode(',', $monthly);
+// foreach($month_ints as $day){
+// $day--;
+// $day = pow(2, $day);
+// $day_sum += $day;
+// }
+// $day_of_month = pow(2,$selected_from_date ) + pow(2,$selected_to_date);
+
+ }else if ( preg_match( ';BYday=(.*);', $rule, $matches ) ) {
echo '<pre>$matches: ' . print_r($matches, true) . '</pre>';
}
}
}
- }
+ }
if(!empty($custom_times)){
date_default_timezone_set('UTC');
$serialized_custom_times = serialize($custom_times);
)
);
$recurr_id = $this->wpdb->insert_id;
- var_dump($recurr_id);
$Recurrences->createRecurrenceTimesEntries( $recurr_id, true, true );
// location for the event
$has_location = ( $event_data['address'] || $event_data['venue'] );