public static function listEvents($startDate, $endDate, $calendars = null, array $options = array())
{
$options = array_merge(array('show_recurrence' => true, 'has_alarm' => false, 'show_remote' => true, 'hide_exceptions' => false, 'cover_dates' => true, 'fetch_tags' => false), $options);
$results = array();
/* Internal calendars. */
if (!isset($calendars)) {
$calendars = $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS);
}
$driver = self::getDriver();
foreach ($calendars as $calendar) {
try {
$driver->open($calendar);
$events = $driver->listEvents($startDate, $endDate, $options);
self::mergeEvents($results, $events);
} catch (Kronolith_Exception $e) {
$GLOBALS['notification']->push($e);
}
}
// Resource calendars
if (count($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_RESOURCE_CALENDARS)) && !empty($GLOBALS['conf']['resources']['enabled'])) {
$driver = self::getDriver('Resource');
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_RESOURCE_CALENDARS) as $calendar) {
try {
$driver->open($calendar);
$events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => $options['show_recurrence']));
self::mergeEvents($results, $events);
} catch (Kronolith_Exception $e) {
$GLOBALS['notification']->push($e);
}
}
}
if ($options['show_remote']) {
/* Horde applications providing listTimeObjects. */
if (count($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS))) {
$driver = self::getDriver('Horde');
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS) as $external_cal) {
try {
$driver->open($external_cal);
$events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => $options['show_recurrence']));
self::mergeEvents($results, $events);
} catch (Kronolith_Exception $e) {
$GLOBALS['notification']->push($e);
}
}
}
/* Remote Calendars. */
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_REMOTE_CALENDARS) as $url) {
try {
$driver = self::getDriver('Ical', $url);
$events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => $options['show_recurrence']));
self::mergeEvents($results, $events);
} catch (Kronolith_Exception $e) {
$GLOBALS['notification']->push($e);
}
}
/* Holidays. */
$display_holidays = $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_HOLIDAYS);
if (count($display_holidays) && !empty($GLOBALS['conf']['holidays']['enable'])) {
$driver = self::getDriver('Holidays');
foreach ($display_holidays as $holiday) {
try {
$driver->open($holiday);
$events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => $options['show_recurrence']));
self::mergeEvents($results, $events);
} catch (Kronolith_Exception $e) {
$GLOBALS['notification']->push($e);
}
}
}
}
/* Sort events. */
$results = self::sortEvents($results);
return $results;
}