From e9b6553ab40022c09b5afea96aaedabe212bf515 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 25 Nov 2022 09:24:04 -0700 Subject: [PATCH] Calendar: If an event went from recurring to non-recurring, recurring events could still be displayed --- calendar/inc/class.calendar_ui.inc.php | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index dad329aab0..1d25c29a0c 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -690,10 +690,10 @@ class calendar_ui if(!$event['recur_type'] || $recurrence_date) { $this->to_client($event); - $response->generic('data', array('uid' => 'calendar::'.$event['row_id'], 'data' => $event)); + $response->generic('data', array('uid' => 'calendar::' . $event['row_id'], 'data' => $event)); } - // If it's recurring, try to send the next month or so - else if($event['recur_type'] ) + // If it is (or was) recurring, try to send the next month or so + if($event['recur_type'] || (!$event['recur_type'] && $old_event['recur_type'])) { $this_month = new Api\DateTime('next month'); $data = []; @@ -711,17 +711,20 @@ class calendar_ui } while($old_rrule->valid() && $occurrence <= $this_month); } - $rrule = calendar_rrule::event2rrule($event, true); - $rrule->rewind(); - do + if($event['recur_type']) { - $occurrence = $rrule->current(); - $converted = $this->bo->read($event['id'], $occurrence); - $this->to_client($converted); - $data['calendar::' . $converted['row_id']] = $converted; - $rrule->next(); + $rrule = calendar_rrule::event2rrule($event, true); + $rrule->rewind(); + do + { + $occurrence = $rrule->current(); + $converted = $this->bo->read($event['id'], $occurrence); + $this->to_client($converted); + $data['calendar::' . $converted['row_id']] = $converted; + $rrule->next(); + } + while($rrule->valid() && $occurrence <= $this_month); } - while($rrule->valid() && $occurrence <= $this_month); // Now we have to go through and send each one individually, since client side data can't handle more than one foreach($data as $uid => $cal_data)