From: Jan Schneider Date: Wed, 8 Apr 2009 13:40:09 +0000 (+0200) Subject: Don't render multi-day events as all-day events on the days they cover completely. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=18546505d480d9d50690d252c4f4b6eb84cb7ff0;p=horde.git Don't render multi-day events as all-day events on the days they cover completely. --- diff --git a/kronolith/ajax.php b/kronolith/ajax.php index e39736e9f..9293b344d 100644 --- a/kronolith/ajax.php +++ b/kronolith/ajax.php @@ -154,7 +154,7 @@ try { break; } $result = new stdClass; - $result->event = $event->toJSON(true, $prefs->getValue('twentyFour') ? 'H:i' : 'h:i A'); + $result->event = $event->toJson(null, true, $prefs->getValue('twentyFour') ? 'H:i' : 'h:i A'); break; case 'SaveEvent': diff --git a/kronolith/lib/Driver/Holidays.php b/kronolith/lib/Driver/Holidays.php index 8152cdd6a..a8f6e0d3a 100644 --- a/kronolith/lib/Driver/Holidays.php +++ b/kronolith/lib/Driver/Holidays.php @@ -33,7 +33,7 @@ class Kronolith_Driver_Holidays extends Kronolith_Driver * @param boolean $hasAlarm Only return events with alarms? Has no * effect in this driver. * @param boolean $json Store the results of the events' - * toJSON() method? + * toJson() method? * * @return array Events in the given time range. */ diff --git a/kronolith/lib/Driver/Horde.php b/kronolith/lib/Driver/Horde.php index c89781d2a..082b63471 100644 --- a/kronolith/lib/Driver/Horde.php +++ b/kronolith/lib/Driver/Horde.php @@ -45,7 +45,7 @@ class Kronolith_Driver_Horde extends Kronolith_Driver * $startDate - $endDate range. * @param boolean $hasAlarm Only return events with alarms? * @param boolean $json Store the results of the events' - * toJSON() method? + * toJson() method? * * @return array Events in the given time range. */ diff --git a/kronolith/lib/Driver/Ical.php b/kronolith/lib/Driver/Ical.php index 496e6903b..8fcf4b2ff 100644 --- a/kronolith/lib/Driver/Ical.php +++ b/kronolith/lib/Driver/Ical.php @@ -47,7 +47,7 @@ class Kronolith_Driver_Ical extends Kronolith_Driver * $startDate - $endDate range. * @param boolean $hasAlarm Only return events with alarms? * @param boolean $json Store the results of the events' - * toJSON() method? + * toJson() method? * * @return array Events in the given time range. */ diff --git a/kronolith/lib/Driver/Kolab.php b/kronolith/lib/Driver/Kolab.php index 1d4db7dfe..d035bed02 100644 --- a/kronolith/lib/Driver/Kolab.php +++ b/kronolith/lib/Driver/Kolab.php @@ -196,7 +196,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver * $startDate - $endDate range. * @param boolean $hasAlarm Only return events with alarms? * @param boolean $json Store the results of the events' - * toJSON() method? + * toJson() method? * * @return array Events in the given time range. */ diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index b524b6cef..ddf59eb11 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -226,7 +226,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver * $startDate - $endDate range. * @param boolean $hasAlarm Only return events with alarms? * @param boolean $json Store the results of the events' - * toJSON() method? + * toJson() method? * * @return array Events in the given time range. */ diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index 1c29bf142..dab48c6f2 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -1001,19 +1001,21 @@ abstract class Kronolith_Event * 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); diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 9f5aa1839..3233e621d 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -770,6 +770,7 @@ class Kronolith } } else { /* Event only occurs once. */ + $allDay = $event->isAllDay(); /* Work out what day it starts on. */ if ($event->start->compareDateTime($startDate) < 0) { @@ -792,7 +793,7 @@ class Kronolith $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( @@ -815,7 +816,7 @@ class Kronolith 'mday' => $i, 'year' => $eventStart->year)); while ($loopDate->compareDateTime($eventEnd) <= 0) { - if (!$event->isAllDay() || + if (!$allDay || $loopDate->compareDateTime($eventEnd) != 0) { $addEvent = clone $event; @@ -840,7 +841,7 @@ class Kronolith '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( @@ -860,7 +861,7 @@ class Kronolith * @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, @@ -870,13 +871,14 @@ class Kronolith $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,