Skip dupes in freebusy list
This commit is contained in:
parent
37b25b5c53
commit
0c1c2757ef
3 changed files with 9 additions and 41 deletions
|
@ -172,8 +172,7 @@ class libvcalendar
|
|||
}
|
||||
}
|
||||
else if ($ve->name == 'VFREEBUSY') {
|
||||
$this->_parse_freebusy($ve);
|
||||
break;
|
||||
$this->objects[] = $this->_parse_freebusy($ve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +453,8 @@ class libvcalendar
|
|||
*/
|
||||
private function _parse_freebusy($ve)
|
||||
{
|
||||
$this->freebusy = array('periods' => array());
|
||||
$this->freebusy = array('_type' => 'freebusy', 'periods' => array());
|
||||
$seen = array();
|
||||
|
||||
foreach ($ve->children as $prop) {
|
||||
if (!($prop instanceof VObject\Property))
|
||||
|
@ -476,6 +476,10 @@ class libvcalendar
|
|||
$periods = explode(',', $prop->value);
|
||||
$fbtype = strval($prop['FBTYPE']) ?: 'BUSY';
|
||||
|
||||
// skip dupes
|
||||
if ($seen[$prop->value.':'.$fbtype]++)
|
||||
continue;
|
||||
|
||||
foreach ($periods as $period) {
|
||||
// Every period is formatted as [start]/[end]. The start is an
|
||||
// absolute UTC time, the end may be an absolute UTC time, or
|
||||
|
|
|
@ -138,8 +138,8 @@ class libvcalendar_test extends PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertInstanceOf('DateTime', $freebusy['start'], "'start' property is DateTime object");
|
||||
$this->assertInstanceOf('DateTime', $freebusy['end'], "'end' property is DateTime object");
|
||||
$this->assertEquals(50, count($freebusy['periods']), "Number of freebusy periods defined");
|
||||
$this->assertEquals(48, count($ical->get_busy_periods()), "Number of busy periods found");
|
||||
$this->assertEquals(11, count($freebusy['periods']), "Number of freebusy periods defined");
|
||||
$this->assertEquals(9, count($ical->get_busy_periods()), "Number of busy periods found");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,48 +10,12 @@ DTEND:20131122T140026Z
|
|||
FREEBUSY;FBTYPE=FREE:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130826T110000Z/20130826T150000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130827T100000Z/20130827T160000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130828T100000Z/20130828T120000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T090000Z/20130830T093000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130830T093000Z/20130830T100000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20130930T070000Z/20130930T160000Z
|
||||
FREEBUSY:20131104T113000Z/20131104T160000Z
|
||||
FREEBUSY:20131104T113000Z/20131104T160000Z
|
||||
FREEBUSY:20131104T113000Z/20131104T160000Z
|
||||
FREEBUSY:20131104T113000Z/20131104T160000Z
|
||||
FREEBUSY;FBTYPE=OOF:20131104T113000Z/20131104T160000Z
|
||||
FREEBUSY;FBTYPE=BUSY-TENTATIVE:20131104T113000Z/20131104T160000Z
|
||||
|
|
Loading…
Add table
Reference in a new issue