Commit 05ae2fd1 authored by Nicolò Caruso's avatar Nicolò Caruso
Browse files

Merge non blocking events

parent 85424d7e
......@@ -626,5 +626,38 @@ function bat_api_services_events_index_calendar($unit_ids, $unit_types, $start_d
}
}
return $events_json;
$events_json = _bat_api_merge_non_blocking_events($events_json);
return array_values($events_json);
}
/**
* Merge non blocking events.
*
* @param $events array
*
* @return array
*/
function _bat_api_merge_non_blocking_events($events) {
$prev_id = FALSE;
foreach ($events as $id => $event) {
if ($prev_id !== FALSE && $event['rendering'] == 'background' && !$event['blocking']) {
$last_event = $events[$prev_id];
if ($last_event['rendering'] == 'background' && !$last_event['blocking']) {
if ($last_event['resourceId'] == $event['resourceId'] &&
$last_event['title'] == $event['title'] &&
$last_event['color'] == $event['color']) {
$events[$prev_id]['end'] = $event['end'];
unset($events[$id]);
continue;
}
}
}
$prev_id = $id;
}
return $events;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment