diff --git a/tine20/Calendar/Convert/Event/Json.php b/tine20/Calendar/Convert/Event/Json.php index aee12fc5389..7d3cf4fa38f 100644 --- a/tine20/Calendar/Convert/Event/Json.php +++ b/tine20/Calendar/Convert/Event/Json.php @@ -204,7 +204,8 @@ public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records = NULL, Calendar_Controller_Event::getInstance()->getAlarms($_records); Calendar_Convert_Event_Json::resolveGrantsOfExternalOrganizers($_records); - Calendar_Model_Rrule::mergeAndRemoveNonMatchingRecurrences($_records, $_filter); + $removedEvents = Calendar_Model_Rrule::mergeAndRemoveNonMatchingRecurrences($_records, $_filter); + $removedResults = parent::fromTine20RecordSet($removedEvents, $_filter, $_pagination); $_records->sortByPagination($_pagination); @@ -212,7 +213,7 @@ public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records = NULL, // NOTE: parent::fromTine20RecordSet does not expand values in recurring instances (tags, notes, attachments, (system) cf's // therefore we copy anything not scheduling related manualy here (NOTE freebusy infos have no id) - $baseEventMap = array_reduce($results, function ($map, $result) { + $baseEventMap = array_reduce(array_merge($results, $removedResults), function ($map, $result) { if (isset($result['id']) && !preg_match('/^fakeid/', $result['id'])) { $map[$result['id']] = $result; } diff --git a/tine20/Calendar/Model/Rrule.php b/tine20/Calendar/Model/Rrule.php index 117050b670f..f229b4d57fc 100644 --- a/tine20/Calendar/Model/Rrule.php +++ b/tine20/Calendar/Model/Rrule.php @@ -570,33 +570,38 @@ protected static function addRecurrence($_recurrence, $_eventSet) $_eventSet->addRecord($_recurrence); } - + /** * merge recurrences amd remove all events that do not match period filter - * + * * @param Tinebase_Record_RecordSet $_events * @param Calendar_Model_EventFilter $_filter + * @return Tinebase_Record_RecordSet $removedEvents */ public static function mergeAndRemoveNonMatchingRecurrences(Tinebase_Record_RecordSet $_events, Calendar_Model_EventFilter $_filter = null) { + $removedEvents = new Tinebase_Record_RecordSet(Calendar_Model_Event::class); if (!$_filter) { - return; + return $removedEvents; } - + $period = $_filter->getFilter('period', false, true); if ($period) { self::mergeRecurrenceSet($_events, $period->getFrom(), $period->getUntil()); - + foreach ($_events as $event) { if (! $event->isInPeriod($period)) { - if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . ' (' . __LINE__ + if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . ' (' . __LINE__ . ') Removing not matching event ' . $event->summary); + $removedEvents->addRecord($event); $_events->removeRecord($event); } } } + return $removedEvents; } - + + /** * returns next occurrence _ignoring exceptions_ or NULL if there is none/not computable *