Adding to end date for recurring events feature/timelyAnthony
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 8 Jun 2016 14:51:24 +0000 (10:51 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 8 Jun 2016 14:51:24 +0000 (10:51 -0400)
If the event has $recurring_event set to true and the from and to dates
are the same then adjust the end date to 2 years out.

models/admin/management/events.php

index 1f54ae4..8670b0b 100644 (file)
@@ -1352,7 +1352,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
   
                         }else if ( preg_match( ';BYday=(.*);', $rule, $matches ) ) {
                             
-                            echo '<pre>$matches: ' . print_r($matches, true) . '</pre>';
+                            echo '<pre>1354 $matches: ' . print_r($matches, true) . '</pre>';
                             
                             // check if the selection is the nth week with a selected day, if not parse the input as a list if selected days
                             if(strpos($matches[1], ",") == false){
@@ -1402,6 +1402,12 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                         $serialized_custom_times = serialize($stamp);
                     }
                 }
+                               if ($recurring_event && $from_date == $to_date ) {
+                                       // Add two years to the recurring event if dates match
+                                       $starting_datetime = new DateTime( $from_date );
+                                       $ending_date       = $starting_datetime->modify('2 years');
+                                       $to_date           = $ending_date->format( 'Y-m-d' );
+                               }
                 $all_day       = $event_data['allday'];
                 // for the recurrences part
                 $recur_data = array(