Implement getEvent().
authorJan Schneider <jan@horde.org>
Sat, 7 Nov 2009 18:41:50 +0000 (19:41 +0100)
committerJan Schneider <jan@horde.org>
Mon, 9 Nov 2009 16:08:18 +0000 (17:08 +0100)
kronolith/lib/Driver/Horde.php

index 9770b02..198f020 100644 (file)
@@ -59,8 +59,6 @@ class Kronolith_Driver_Horde extends Kronolith_Driver
             return array();
         }
 
-        $eventsList = $this->_params['registry']->call($this->api . '/listTimeObjects', array(array($category), $startDate, $endDate));
-
         if (is_null($startDate)) {
             $startDate = new Horde_Date(array('mday' => 1,
                                               'month' => 1,
@@ -72,6 +70,8 @@ class Kronolith_Driver_Horde extends Kronolith_Driver
                                             'year' => 9999));
         }
 
+        $eventsList = $this->_params['registry']->call($this->api . '/listTimeObjects', array(array($category), $startDate, $endDate));
+
         $startDate = clone $startDate;
         $startDate->hour = $startDate->min = $startDate->sec = 0;
         $endDate = clone $endDate;
@@ -104,9 +104,18 @@ class Kronolith_Driver_Horde extends Kronolith_Driver
         return $results;
     }
 
+    /**
+     * @todo: implement getTimeObject in timeobjects API.
+     */
     public function getEvent($eventId = null)
     {
-        return new Kronolith_Event_Horde($this);
+        $events = $this->listEvents();
+        foreach ($events as $day) {
+            if (isset($day[$eventId])) {
+                return $day[$eventId];
+            }
+        }
+        return PEAR::raiseError(_("Event not found"));
     }
 
 }