Kronolith::listEvents PHP Méthode

listEvents() public static méthode

Returns all the events that happen each day within a time period
Deprecation:
public static listEvents ( Horde_Date $startDate, Horde_Date $endDate, array $calendars = null, array $options = [] ) : array
$startDate Horde_Date The start of the time range.
$endDate Horde_Date The end of the time range.
$calendars array The calendars to check for events.
$options array Additional options: - show_recurrence: (boolean) Return every instance of a recurring event? DEFAULT: false (Only return recurring events once inside $startDate - $endDate range) - has_alarm: (boolean) Only return events with alarms. DEFAULT: false (Return all events) - json: (boolean) Store the results of the event's toJson() method? DEFAULT: false - cover_dates: (boolean) Add the events to all days that they cover? DEFAULT: true - hide_exceptions: (boolean) Hide events that represent exceptions to a recurring event. DEFAULT: false (Do not hide exception events) - fetch_tags: (boolean) Fetch tags for all events. DEFAULT: false (Do not fetch event tags)
Résultat array The events happening in this time period.
    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;
    }

Usage Example

Exemple #1
0
 /**
  *
  * @param Horde_Date $date  The day for this view
  * @param array $events     An array of Kronolith_Event objects
  *
  * @return Kronolith_View_Day
  */
 public function __construct(Horde_Date $date, array $events = null)
 {
     parent::__construct($date->month, $date->mday, $date->year);
     $this->sidebyside = $GLOBALS['prefs']->getValue('show_shared_side_by_side');
     if ($this->sidebyside) {
         $allCalendars = Kronolith::listInternalCalendars();
         foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $cid) {
             $this->_currentCalendars[$cid] = $allCalendars[$cid];
             $this->all_day_events[$cid] = array();
         }
     } else {
         $this->_currentCalendars = array(0);
     }
     if ($events === null) {
         try {
             $events = Kronolith::listEvents($this, new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->mday)));
             $this->events = array_shift($events);
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e, 'horde.error');
             $this->events = array();
         }
     } else {
         $this->events = $events;
     }
     if (!is_array($this->events)) {
         $this->events = array();
     }
 }
All Usage Examples Of Kronolith::listEvents