function agenda_group_events_for_block in Agenda 6.2
Same name and namespace in other branches
- 7.2 agenda.module \agenda_group_events_for_block()
- 7 agenda.module \agenda_group_events_for_block()
Group events by date for a block. Is not a part of agenda_get_events() to allow passing self-constructed events during testing.
Parameters
array $block: Block for which events are going to be groupped.
array $events: An array of events to be groupped.
Return value
array An array of groupped events.
See also
AgendaBlockTestCase::testNicknamedDays()
File
- ./
agenda.module, line 538
Code
function agenda_group_events_for_block($block, array $events) {
$groupedevents = array();
foreach ($events as $event) {
$groupedevents[$event['when']][] = $event;
}
ksort($groupedevents);
// Filter the events based on their date.
$datelimit = $block->datelimit;
$count = 0;
$events = array();
foreach ($groupedevents as $date => $eventdata) {
if ($count >= $datelimit) {
break;
}
$events[$date] = $eventdata;
$count++;
}
return $events;
}