Skip to content

Commit

Permalink
Merge branch 'pu/ss/fixtagsonrecureevents' into '2024.11'
Browse files Browse the repository at this point in the history
fix(Calendar): resolving rrule events is missing base event for tags

See merge request tine20/tine20!6622
  • Loading branch information
sstamer committed Feb 24, 2025
2 parents e9797dc + 675d086 commit c17cc93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tine20/Calendar/Convert/Event/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ 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);

$results = parent::fromTine20RecordSet($_records, $_filter, $_pagination);

// 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;
}
Expand Down
19 changes: 12 additions & 7 deletions tine20/Calendar/Model/Rrule.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,33 +562,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
*
Expand Down

0 comments on commit c17cc93

Please sign in to comment.