Hotfixes to get the Kolab storage driver to work with the new Imap_Client library.
authorGunnar Wrobel <p@rdus.de>
Fri, 6 Nov 2009 09:12:53 +0000 (10:12 +0100)
committerGunnar Wrobel <p@rdus.de>
Fri, 6 Nov 2009 09:12:53 +0000 (10:12 +0100)
framework/Kolab_Storage/lib/Horde/Kolab/Storage.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Imap.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php

index 6d86669..b7ee91f 100644 (file)
  */
 
 /**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
  * The Horde_Kolab_Storage class provides the means to access the
  * Kolab server storage for groupware objects.
  *
index 287a881..d43c4ed 100644 (file)
@@ -477,11 +477,14 @@ class Horde_Kolab_Storage_Data
         }
 
         /* Log the action on this item in the history log. */
-        $history = &Horde_History::singleton();
+        try {
+            $history = &Horde_History::singleton();
 
-        $history_id = $app . ':' . $this->_folder->getShareId() . ':' . $object_uid;
-        $history->log($history_id, array('action' => $action, 'ts' => $mod_ts),
-                      true);
+            $history_id = $app . ':' . $this->_folder->getShareId() . ':' . $object_uid;
+            $history->log($history_id, array('action' => $action, 'ts' => $mod_ts),
+                          true);
+        } catch (Horde_Exception $e) {
+        }
     }
 
 
index 3b74f52..cb62408 100644 (file)
@@ -47,6 +47,7 @@ class Horde_Kolab_Storage_Driver_Imap extends Horde_Kolab_Storage_Driver
         } else {
             $driver = 'socket';
         }
+
         $this->_imap = Horde_Imap_Client::factory($driver, $params);
     }
 
@@ -57,7 +58,7 @@ class Horde_Kolab_Storage_Driver_Imap extends Horde_Kolab_Storage_Driver
      */
     public function getMailboxes()
     {
-        return $this->_imap->listMailboxes('', Horde_Imap_Client::MBOX_ALL, array('flat' => true));
+        return $this->_imap->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array('flat' => true));
     }
 
     /**
@@ -229,9 +230,14 @@ class Horde_Kolab_Storage_Driver_Imap extends Horde_Kolab_Storage_Driver
     function getMessageHeader($mailbox, $uid, $peek_for_body = true)
     {
         $options = array('ids' => array($uid));
-        $criteria = array(Horde_Imap_Client::FETCH_HEADERTEXT => array());
-       $result = $this->_imap->fetch($mailbox, $criteria, $options);
-        return $result['headertext'][$uid];
+        $criteria = array(
+            Horde_Imap_Client::FETCH_HEADERTEXT => array(
+                array(
+                )
+            )
+        );
+        $result = $this->_imap->fetch($mailbox, $criteria, $options);
+        return $result[$uid]['headertext'][0];
     }
 
     /**
@@ -246,9 +252,14 @@ class Horde_Kolab_Storage_Driver_Imap extends Horde_Kolab_Storage_Driver
     function getMessageBody($mailbox, $uid)
     {
         $options = array('ids' => array($uid));
-        $criteria = array(Horde_Imap_Client::FETCH_BODYTEXT => array());
+        $criteria = array(
+            Horde_Imap_Client::FETCH_BODYTEXT => array(
+                array(
+                )
+            )
+        );
         $result = $this->_imap->fetch($mailbox, $criteria, $options);
-        return $result['bodytext'][$uid];
+        return $result[$uid]['bodytext'][0];
     }
 
     /**
@@ -295,7 +306,7 @@ class Horde_Kolab_Storage_Driver_Imap extends Horde_Kolab_Storage_Driver
     function getAnnotation($entry, $mailbox_name)
     {
         $result = $this->_imap->getMetadata($mailbox_name, $entry);
-        return $result[$entry];
+        return $result[$mailbox_name][$entry];
     }
 
     /**
index 9ee53c4..cdf6c27 100644 (file)
@@ -33,18 +33,18 @@ class Horde_Kolab_Storage_Folder
      * The root of the Kolab annotation hierarchy, used on the various IMAP
      * folder that are used by Kolab clients.
      */
-    const ANNOT_ROOT = '/vendor/kolab/';
+    const ANNOT_ROOT = '/shared/vendor/kolab/';
 
     /**
      * The annotation, as defined by the Kolab format spec, that is used to store
      * information about what groupware format the folder contains.
      */
-    const ANNOT_FOLDER_TYPE = '/vendor/kolab/folder-type';
+    const ANNOT_FOLDER_TYPE = '/shared/vendor/kolab/folder-type';
 
     /**
      * Horde-specific annotations on the imap folder have this prefix.
      */
-    const ANNOT_SHARE_ATTR = '/vendor/horde/share-';
+    const ANNOT_SHARE_ATTR = '/shared/vendor/horde/share-';
 
     /**
      * Kolab specific free/busy relevance
@@ -351,7 +351,7 @@ class Horde_Kolab_Storage_Folder
                 try {
                     $this->_connection->create($this->name);
                     $this->_connection->setAnnotation(self::ANNOT_FOLDER_TYPE, 
-                                                      array('value.shared' => $this->_type),
+                                                      $this->_type,
                                                       $this->name);
                     $this->trigger($this->name);
                     $this->_connection->delete($this->name);
@@ -592,7 +592,7 @@ class Horde_Kolab_Storage_Folder
             if ($attribute == 'desc') {
                 $entry = '/comment';
             } else {
-                $entry = HORDE_ANNOT_SHARE_ATTR . $attribute;
+                $entry = self::ANNOT_SHARE_ATTR . $attribute;
             }
             $annotation = $this->_getAnnotation($entry, $this->name);
             if (is_a($annotation, 'PEAR_Error')) {
@@ -964,7 +964,7 @@ class Horde_Kolab_Storage_Folder
             }
         }
 
-        $session = &Horde_Kolab_Session::singleton();
+        $session = &Horde_Kolab_Session_Singleton::singleton();
 
         // Update email headers
         $new_headers->addHeader('From', $session->user_mail);
@@ -1146,7 +1146,7 @@ class Horde_Kolab_Storage_Folder
 
         switch($type) {
         case 'event':
-            $session = &Horde_Kolab_Session::singleton();
+            $session = &Horde_Kolab_Session_Singleton::singleton();
             $url = sprintf('%s/trigger/%s/%s.pfb',
                            $session->freebusy_server, $owner, $subpath);
             break;