diff --git a/examples/example6.php b/examples/example6.php index 10400993..83f87622 100644 --- a/examples/example6.php +++ b/examples/example6.php @@ -14,6 +14,7 @@ $vEvent->setDtStart(new \DateTime('2012-12-24')); $vEvent->setDtEnd(new \DateTime('2012-12-24')); $vEvent->setNoTime(true); +$vEvent->setMsBusyStatus("FREE"); $vEvent->setSummary('Christmas'); // add some location information for apple devices diff --git a/examples/example7.php b/examples/example7.php index 1f8013e7..c5adbeb1 100644 --- a/examples/example7.php +++ b/examples/example7.php @@ -14,6 +14,7 @@ $vEvent->setDtStart(new \DateTime('2012-12-24')); $vEvent->setDtEnd(new \DateTime('2012-12-24')); $vEvent->setNoTime(true); +$vEvent->setMsBusyStatus("FREE"); $vEvent->setSummary('Christmas'); $vEvent->setDescription('Happy Christmas!'); $vEvent->setDescriptionHTML('Happy Christmas!'); diff --git a/src/Component/Event.php b/src/Component/Event.php index b753ac1e..d452b93b 100644 --- a/src/Component/Event.php +++ b/src/Component/Event.php @@ -36,6 +36,11 @@ class Event extends Component const STATUS_CONFIRMED = 'CONFIRMED'; const STATUS_CANCELLED = 'CANCELLED'; + const MS_BUSYSTATUS_FREE = 'FREE'; + const MS_BUSYSTATUS_TENTATIVE = 'TENTATIVE'; + const MS_BUSYSTATUS_BUSY = 'BUSY'; + const MS_BUSYSTATUS_OOF = 'OOF'; + /** * @var string */ @@ -73,6 +78,11 @@ class Event extends Component */ protected $noTime = false; + /** + * @var string + */ + protected $msBusyStatus = null; + /** * @var string */ @@ -356,6 +366,11 @@ public function buildPropertyBag() $propertyBag->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE'); } + if (null != $this->msBusyStatus) { + $propertyBag->set('X-MICROSOFT-CDO-BUSYSTATUS', $this->msBusyStatus); + $propertyBag->set('X-MICROSOFT-CDO-INTENDEDSTATUS', $this->msBusyStatus); + } + if (null != $this->categories) { $propertyBag->set('CATEGORIES', $this->categories); } @@ -482,6 +497,37 @@ public function setNoTime($noTime) return $this; } + /** + * @param $msBusyStatus + * + * @return $this + * + * @throws \InvalidArgumentException + */ + public function setMsBusyStatus($msBusyStatus) + { + $msBusyStatus = strtoupper($msBusyStatus); + if ($msBusyStatus == self::MS_BUSYSTATUS_FREE + || $msBusyStatus == self::MS_BUSYSTATUS_TENTATIVE + || $msBusyStatus == self::MS_BUSYSTATUS_BUSY + || $msBusyStatus == self::MS_BUSYSTATUS_OOF + ) { + $this->msBusyStatus = $msBusyStatus; + } else { + throw new \InvalidArgumentException('Invalid value for status'); + } + + return $this; + } + + /** + * @return string|null + */ + public function getMsBusyStatus() + { + return $this->msBusyStatus; + } + /** * @param int $sequence * diff --git a/tests/Eluceo/iCal/Component/EventTest.php b/tests/Eluceo/iCal/Component/EventTest.php index 5b6c4170..a46e2ff7 100644 --- a/tests/Eluceo/iCal/Component/EventTest.php +++ b/tests/Eluceo/iCal/Component/EventTest.php @@ -105,6 +105,23 @@ public function testSetNoTime() $this->assertArrayHasKey('DTSTAMP', $result); } + public function testSetMsBusyTime() + { + $event = new Event('19960401T080045Z-4000F192713-0052@host1.com'); + $event->setMsBusyStatus("FREE"); + $result = $event->buildPropertyBag()->getIterator()->getArrayCopy(); + + $this->assertSame('X-MICROSOFT-CDO-BUSYSTATUS:FREE', $result['X-MICROSOFT-CDO-BUSYSTATUS']->toLine()); + } + + public function testGetMsBusyTime() + { + $event = new Event('19960401T080045Z-4000F192713-0052@host1.com'); + $event->setMsBusyStatus("FREE"); + + $this->assertSame("FREE", $event->getMsBusyStatus()); + } + public function testSetSequence() { $event = new Event('19960401T080045Z-4000F192713-0052@host1.com');