Copyright 1999-2016 Horde LLC (http://www.horde.org/) Copyright 2004-2008 Klarälvdalens Datakonsult AB Copyright 2011 Kolab Systems AG See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Chuck Hagenbuch (chuck@horde.org)
Author: Jan Schneider (jan@horde.org)
Author: Gunnar Wrobel (wrobel@pardus.de)
コード例 #1
0
ファイル: EventTest.php プロジェクト: jubinpatel/horde
 public function testBusyTimeRecurs()
 {
     $event = new Horde_Kolab_FreeBusy_Object_Event(array('start-date' => new Horde_Date('2011-11-11T11:11:00Z'), 'end-date' => new Horde_Date('2011-11-11T11:11:11Z'), 'show-time-as' => 'outofoffice', 'recurrence' => array('interval' => 1, 'cycle' => 'daily', 'range-type' => 'number', 'range' => 4)));
     $this->assertEquals(array(1321009860, 1321096260), $event->getBusyTimes(new Horde_Date('2011-11-10T11:10:59Z'), new Horde_Date('2011-11-12T11:11:12Z')));
 }
コード例 #2
0
ファイル: Kolab.php プロジェクト: jubinpatel/horde
 /**
  * Lists all events in the given time range.
  *
  * @param Horde_Date $startDate Start of range date object.
  * @param Horde_Date $endDate   End of range data object.
  *
  * @return array Events in the given time range.
  *
  * @throws Horde_Kolab_FreeBusy_Exception If retrieving the events failed.
  */
 public function listEvents(Horde_Date $startDate, Horde_Date $endDate)
 {
     try {
         $objects = $this->getData()->getObjects();
     } catch (Horde_Kolab_Storage_Exception $e) {
         //todo: prior exception
         throw new Horde_Kolab_FreeBusy_Exception($e);
     }
     $startts = $startDate->timestamp();
     $endts = $endDate->timestamp();
     $result = array();
     /**
      * PERFORMANCE START
      *
      * The following section has been performance optimized using
      * xdebug and kcachegrind.
      *
      * If there are many events it takes a lot of time and memory to create
      * new objects from the array and use those for time comparison. So the
      * code tries to use the original data array as long as possible and
      * only converts it to an object if really required (e.g. the event
      * actually lies in the time span or it recurs in which case the
      * calculations are more complex).
      */
     foreach ($objects as $object) {
         /* check if event period intersects with given period */
         if (!($object['start-date'] > $endts || $object['end-date'] < $startts)) {
             $result[] = new Horde_Kolab_FreeBusy_Object_Event($object);
             continue;
         }
         /* do recurrence expansion if not keeping anyway */
         if (isset($object['recurrence'])) {
             $event = new Horde_Kolab_FreeBusy_Object_Event($object);
             if ($event->recursIn($startDate, $endDate)) {
                 $result[] = $event;
             }
         }
     }
     /** PERFORMANCE END */
     return $result;
 }