Don't render multi-day events as all-day events on the days they cover completely.
authorJan Schneider <jan@horde.org>
Wed, 8 Apr 2009 13:40:09 +0000 (15:40 +0200)
committerJan Schneider <jan@horde.org>
Wed, 8 Apr 2009 13:40:09 +0000 (15:40 +0200)
kronolith/ajax.php
kronolith/lib/Driver/Holidays.php
kronolith/lib/Driver/Horde.php
kronolith/lib/Driver/Ical.php
kronolith/lib/Driver/Kolab.php
kronolith/lib/Driver/Sql.php
kronolith/lib/Event.php
kronolith/lib/Kronolith.php

index e39736e..9293b34 100644 (file)
@@ -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':
index 8152cdd..a8f6e0d 100644 (file)
@@ -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.
      */
index c89781d..082b634 100644 (file)
@@ -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.
      */
index 496e690..8fcf4b2 100644 (file)
@@ -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.
      */
index 1d4db7d..d035bed 100644 (file)
@@ -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.
      */
index b524b6c..ddf59eb 100644 (file)
@@ -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.
      */
index 1c29bf1..dab48c6 100644 (file)
@@ -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);
index 9f5aa18..3233e62 100644 (file)
@@ -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,