Basic fixes to get kronolith working with the Kolab backend.
authorGunnar Wrobel <p@rdus.de>
Thu, 11 Mar 2010 18:49:14 +0000 (19:49 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Thu, 11 Mar 2010 21:35:02 +0000 (22:35 +0100)
kronolith/lib/Driver/Kolab.php
kronolith/lib/Event/Kolab.php

index f49902a..df6a6ab 100644 (file)
 class Kronolith_Driver_Kolab extends Kronolith_Driver
 {
     /**
+     * The session handler.
+     *
+     * @var Horde_Kolab_Session
+     */
+    private $_session;
+
+    /**
      * Our Kolab server connection.
      *
      * @var Kolab
@@ -43,11 +50,38 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
     private $_store;
 
     /**
+     * Set the session handler.
+     *
+     * @param Horde_Kolab_Session $session The session handler.
+     *
+     * @return NULL
+     */
+    public function setSession(Horde_Kolab_Session $session)
+    {
+        $this->_session = $session;
+    }
+
+    /**
+     * Retrieve a connected kolab session.
+     *
+     * @return Horde_Kolab_Session The connected session.
+     *
+     * @throws Horde_Kolab_Session_Exception
+     */
+    public function getSession()
+    {
+        if (!isset($this->_session)) {
+            $this->_session = Horde_Kolab_Session_Singleton::singleton();
+        }
+        return $this->_session;
+    }
+
+    /**
      * Attempts to open a Kolab Groupware folder.
      */
     public function initialize()
     {
-        $this->_kolab = new Kolab();
+        $this->_kolab = $this->getSession()->getStorage();
         $this->reset();
     }
 
@@ -101,11 +135,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
         }
 
         // Connect to the Kolab backend
-        $result = $this->_kolab->open($this->calendar, 1);
-        if ($result instanceof PEAR_Error) {
-            throw new Kronolith_Exception($result);
-        }
-        $this->_store = $this->_kolab->_storage;
+        $this->_store = $this->_kolab->getShareData($this->calendar, 'event');
 
         // build internal event cache
         $this->_events_cache = array();
@@ -125,7 +155,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
         $allevents = $this->listEvents($date, null, false, true);
         $events = array();
 
-        foreach ($allevents as $eventId) {
+        foreach ($allevents as $eventId => $data) {
             $event = $this->getEvent($eventId);
             if (!$event->recurs()) {
                 $start = new Horde_Date($event->start);
@@ -381,7 +411,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
         $this->synchronize(true);
 
         if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
-            Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($event->calendar));
+            //Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($event->calendar));
         }
 
         return $event->uid;
@@ -412,8 +442,8 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
         }
 
         if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
-            Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($this->calendar));
-            Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($newCalendar));
+            //Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($this->calendar));
+            //Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($newCalendar));
         }
 
         return $event;
@@ -433,7 +463,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
 
         $result = $this->_store->deleteAll($calendar);
         if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
-            Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($calendar));
+            //Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($calendar));
         }
     }
 
@@ -466,7 +496,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver
             $history->log('kronolith:' . $event->calendar . ':' . $event->uid, array('action' => 'delete'), true);
 
             if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
-                Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($event->calendar));
+                //Kolab::triggerFreeBusyUpdate($this->_store->parseFolder($event->calendar));
             }
 
             unset($this->_events_cache[$eventId]);
index 3b2f522..e05f1b5 100644 (file)
@@ -167,7 +167,7 @@ class Kronolith_Event_Kolab extends Kronolith_Event
         $event['sensitivity'] = $this->private ? 'private' : 'public';
 
         // Only set organizer if this is a new event
-        if ($this->getID() == null) {
+        if ($this->_id == null) {
             $organizer = array(
                             'display-name' => Kronolith::getUserName($this->creator),
                             'smtp-address' => Kronolith::getUserEmail($this->creator)