convert() public method

Convert the free/busy data from the XML to an array.
public convert ( Horde_Date $start, Horde_Date $end, integer $interval ) : array
$start Horde_Date The start of the requested free/busy data.
$end Horde_Date The end of the requested free/busy data.
$interval integer The interval of the data.
return array The data array representing the XML data.
Beispiel #1
0
 public function testConversionTwo()
 {
     $owa = new Horde_Kolab_FreeBusy_Freebusy_Helper_Owa(fopen(__DIR__ . '/../../../fixtures/owa_freebusy.xml', 'r'));
     $result = $owa->convert(new Horde_Date('2009-09-25T00:00:00-07:00'), new Horde_Date('2009-09-26T00:00:00-07:00'), 30);
     $this->assertEquals(array(0 => '2009-09-25 03:00:00 - 2009-09-25 05:00:00: busy', 1 => '2009-09-25 12:30:00 - 2009-09-25 14:30:00: tentative'), $this->_readable($result['*****@*****.**']));
 }
Beispiel #2
0
 /**
  * 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)
 {
     $url = $this->_params['url'] . '/public/?cmd=freebusy' . '&start=' . $startDate->format('c') . '&end=' . $endDate->format('c') . '&interval=' . $this->_params['interval'] . '&u=SMTP:' . $this->_owner->getOwner();
     $response = $this->_client->get($url, array('User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)'));
     if ($response->code !== 200) {
         throw new Horde_Kolab_FreeBusy_Exception_NotFound(sprintf('Unable to fetch free/busy information from %s', $url));
     }
     $owa = new Horde_Kolab_FreeBusy_Freebusy_Helper_Owa($response->getStream());
     $result = $owa->convert($startDate, $endDate, $this->_params['interval']);
     if (!isset($result[$this->_owner->getOwner()])) {
         return array();
     }
     $events = array();
     foreach ($result[$this->_owner->getOwner()] as $item) {
         $events[] = new Horde_Kolab_FreeBusy_Object_Event($item);
     }
     return $events;
 }