* Returns a simple object suitable for json transport representing this
* event.
*
+ * @param boolean $allDay If not null, overrides whether the event is
+ * an all-day event.
* @param boolean $full Whether to return all event details.
* @param string $time_format The date() format to use for time formatting.
*
* @return object A simple object.
*/
- public function toJSON($full = false, $time_format = 'H:i')
+ public function toJson($allDay = null, $full = false, $time_format = 'H:i')
{
$json = new stdClass;
$json->t = $this->getTitle();
$json->c = $this->getCalendar();
$json->s = $this->start->toJson();
$json->e = $this->end->toJson();
- $json->al = $this->isAllDay();
+ $json->al = is_null($allDay) ? $this->isAllDay() : $allDay;
$json->bg = $this->_backgroundColor;
$json->fg = $this->_foregroundColor;
$json->pe = $this->hasPermission(PERMS_EDIT);
}
} else {
/* Event only occurs once. */
+ $allDay = $event->isAllDay();
/* Work out what day it starts on. */
if ($event->start->compareDateTime($startDate) < 0) {
$event->end->min != 0 ||
$event->end->sec != 0 ||
$event->start->compareDateTime($event->end) == 0 ||
- $event->isAllDay()) {
+ $allDay) {
$eventEnd = clone $event->end;
} else {
$eventEnd = new Horde_Date(
'mday' => $i,
'year' => $eventStart->year));
while ($loopDate->compareDateTime($eventEnd) <= 0) {
- if (!$event->isAllDay() ||
+ if (!$allDay ||
$loopDate->compareDateTime($eventEnd) != 0) {
$addEvent = clone $event;
'month' => $loopDate->month, 'mday' => $loopDate->mday, 'year' => $loopDate->year));
}
- $results[$loopDate->dateString()][$addEvent->getId()] = $json ? $addEvent->toJson() : $addEvent;
+ $results[$loopDate->dateString()][$addEvent->getId()] = $json ? $addEvent->toJson($allDay) : $addEvent;
}
$loopDate = new Horde_Date(
* @param Horde_Date $eventStart The event's start at the actual
* recurrence.
* @param Horde_Date $eventEnd The event's end at the actual recurrence.
- * @param boolean $json Store the results of the events' toJSON()
+ * @param boolean $json Store the results of the events' toJson()
* method?
*/
public static function addCoverDates(&$results, $event, $eventStart,
$loopDate = new Horde_Date(array('month' => $eventStart->month,
'mday' => $i,
'year' => $eventStart->year));
+ $allDay = $event->isAllDay();
while ($loopDate->compareDateTime($eventEnd) <= 0) {
- if (!$event->isAllDay() ||
+ if (!$allDay ||
$loopDate->compareDateTime($eventEnd) != 0) {
$addEvent = clone $event;
$addEvent->start = $eventStart;
$addEvent->end = $eventEnd;
- $results[$loopDate->dateString()][$addEvent->getId()] = $json ? $addEvent->toJson() : $addEvent;
+ $results[$loopDate->dateString()][$addEvent->getId()] = $json ? $addEvent->toJson($allDay) : $addEvent;
}
$loopDate = new Horde_Date(
array('month' => $eventStart->month,