Skip to content

Commit

Permalink
Add Kronolith_Event::boundExceptions
Browse files Browse the repository at this point in the history
Conflicts:
	kronolith/lib/Event.php
  • Loading branch information
mrubinsk committed Aug 30, 2014
1 parent 6dc6687 commit 2b6870d
Showing 1 changed file with 50 additions and 55 deletions.
105 changes: 50 additions & 55 deletions kronolith/lib/Event.php
Expand Up @@ -1757,67 +1757,60 @@ public function toASAppointment(array $options = array())
* Any dates left in this list when we are done, must represent
* deleted instances of this recurring event.*/
if (!empty($this->recurrence) && $exceptions = $this->recurrence->getExceptions()) {
$kronolith_driver = Kronolith::getDriver(null, $this->calendar);
$search = new StdClass();
$search->start = $this->recurrence->getRecurStart();
$search->end = $this->recurrence->getRecurEnd();
$search->baseid = $this->uid;
$results = $kronolith_driver->search($search);
foreach ($results as $days) {
foreach ($days as $exception) {
$e = new Horde_ActiveSync_Message_Exception(array(
'protocolversion' => $options['protocolversion']));
$e->setDateTime(array(
'start' => $exception->start,
'end' => $exception->end,
'allday' => $exception->isAllDay()));

// The start time of the *original* recurring event
$e->setExceptionStartTime($exception->exceptionoriginaldate);
$originaldate = $exception->exceptionoriginaldate->format('Ymd');
$key = array_search($originaldate, $exceptions);
if ($key !== false) {
unset($exceptions[$key]);
}

// Remaining properties that could be different
$e->setSubject($exception->getTitle());
if (!$exception->isPrivate()) {
$e->setLocation($exception->location);
$e->setBody($exception->description);
}
$results = $this->boundExceptions();
foreach ($results as $exception) {
$e = new Horde_ActiveSync_Message_Exception(array(
'protocolversion' => $options['protocolversion']));
$e->setDateTime(array(
'start' => $exception->start,
'end' => $exception->end,
'allday' => $exception->isAllDay()));

// The start time of the *original* recurring event
$e->setExceptionStartTime($exception->exceptionoriginaldate);
$originaldate = $exception->exceptionoriginaldate->format('Ymd');
$key = array_search($originaldate, $exceptions);
if ($key !== false) {
unset($exceptions[$key]);
}

$e->setSensitivity($exception->private ?
Horde_ActiveSync_Message_Appointment::SENSITIVITY_PRIVATE :
Horde_ActiveSync_Message_Appointment::SENSITIVITY_NORMAL);
$e->setReminder($exception->alarm);
$e->setDTStamp($_SERVER['REQUEST_TIME']);
// Remaining properties that could be different
$e->setSubject($exception->getTitle());
if (!$exception->isPrivate()) {
$e->setLocation($exception->location);
$e->setBody($exception->description);
}

if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWELVEONE) {
switch ($exception->status) {
case Kronolith::STATUS_TENTATIVE;
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_TENTATIVE;
break;
case Kronolith::STATUS_NONE:
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_NORESPONSE;
break;
case Kronolith::STATUS_CONFIRMED:
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_ACCEPTED;
break;
default:
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_NONE;
}
$e->setSensitivity($exception->private ?
Horde_ActiveSync_Message_Appointment::SENSITIVITY_PRIVATE :
Horde_ActiveSync_Message_Appointment::SENSITIVITY_NORMAL);
$e->setReminder($exception->alarm);
$e->setDTStamp($_SERVER['REQUEST_TIME']);

if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWELVEONE) {
switch ($exception->status) {
case Kronolith::STATUS_TENTATIVE;
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_TENTATIVE;
break;
case Kronolith::STATUS_NONE:
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_NORESPONSE;
break;
case Kronolith::STATUS_CONFIRMED:
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_ACCEPTED;
break;
default:
$e->responsetype = Horde_ActiveSync_Message_Appointment::RESPONSE_NONE;
}
}

// Tags/Categories
if (!$exception->isPrivate()) {
foreach ($exception->tags as $tag) {
$e->addCategory($tag);
}
// Tags/Categories
if (!$exception->isPrivate()) {
foreach ($exception->tags as $tag) {
$e->addCategory($tag);
}

$message->addexception($e);
}

$message->addexception($e);
}

// Any dates left in $exceptions must be deleted exceptions
Expand Down Expand Up @@ -2586,9 +2579,11 @@ public function boundExceptions($flat = true)
$search->end = $this->recurrence->getRecurEnd();
$search->baseid = $this->uid;
$results = $kronolith_driver->search($search);

if (!$flat) {
return $results;
}

foreach ($results as $days) {
foreach ($days as $exception) {
$return[] = $exception;
Expand Down

0 comments on commit 2b6870d

Please sign in to comment.