Skip to content

Commit

Permalink
Consider implementing X-MICROSOFT-CDO-BUSYSTATUS markuspoerschke#32
Browse files Browse the repository at this point in the history
  • Loading branch information
puhr-mde committed Dec 3, 2019
1 parent 5d3aaca commit aea8494
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/example6.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/example7.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<b>Happy Christmas!</b>');
Expand Down
46 changes: 46 additions & 0 deletions src/Component/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -73,6 +78,11 @@ class Event extends Component
*/
protected $noTime = false;

/**
* @var string
*/
protected $msBusyStatus = null;

/**
* @var string
*/
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
*
Expand Down
17 changes: 17 additions & 0 deletions tests/Eluceo/iCal/Component/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit aea8494

Please sign in to comment.