Adapt freebusy parser to new ical parser from libcalendaring plugin (#2146)

This commit is contained in:
Thomas Bruederli 2013-08-25 12:37:07 +02:00
parent ec42d07053
commit 3f62bf917f

View file

@ -935,28 +935,25 @@ class kolab_driver extends calendar_driver
// parse free-busy information using Horde classes // parse free-busy information using Horde classes
if ($fbdata) { if ($fbdata) {
$fbcal = $this->cal->get_ical()->get_parser(); $ical = $this->cal->get_ical();
$fbcal->parsevCalendar($fbdata); $ical->import($fbdata);
if ($fb = $fbcal->findComponent('vfreebusy')) { if ($fb = $ical->freebusy) {
$result = array(); $result = array();
$params = $fb->getExtraParams(); foreach ($fb['periods'] as $tuple) {
foreach ($fb->getBusyPeriods() as $from => $to) { list($from, $to, $type) = $tuple;
if ($to == null) // no information, assume free $result[] = array($from->format('U'), $to->format('U'), isset($fbtypemap[$type]) ? $fbtypemap[$type] : calendar::FREEBUSY_BUSY);
break;
$type = $params[$from]['FBTYPE'];
$result[] = array($from, $to, isset($fbtypemap[$type]) ? $fbtypemap[$type] : calendar::FREEBUSY_BUSY);
} }
// we take 'dummy' free-busy lists as "unknown" // we take 'dummy' free-busy lists as "unknown"
if (empty($result) && ($comment = $fb->getAttribute('COMMENT')) && stripos($comment, 'dummy')) if (empty($result) && !empty($fb['comment']) && stripos($fb['comment'], 'dummy'))
return false; return false;
// set period from $start till the begin of the free-busy information as 'unknown' // set period from $start till the begin of the free-busy information as 'unknown'
if (($fbstart = $fb->getStart()) && $start < $fbstart) { if ($fb['start'] && ($fbstart = $fb['start']->format('U')) && $start < $fbstart) {
array_unshift($result, array($start, $fbstart, calendar::FREEBUSY_UNKNOWN)); array_unshift($result, array($start, $fbstart, calendar::FREEBUSY_UNKNOWN));
} }
// pad period till $end with status 'unknown' // pad period till $end with status 'unknown'
if (($fbend = $fb->getEnd()) && $fbend < $end) { if ($fb['end'] && ($fbend = $fb['end']->format('U')) && $fbend < $end) {
$result[] = array($fbend, $end, calendar::FREEBUSY_UNKNOWN); $result[] = array($fbend, $end, calendar::FREEBUSY_UNKNOWN);
} }