Add imapOb API call to IMP.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 22 Dec 2009 20:39:20 +0000 (13:39 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 22 Dec 2009 20:39:20 +0000 (13:39 -0700)
Remove API calls (msgEnvelope, mailboxCacheId) that are nothing more
than wrappers around the Horde_Imap_Client object. Just let the calling
application directly access the object instead.

imp/lib/Api.php
ingo/lib/Script/Imap/Live.php

index 949d3f0..d5ab7b2 100644 (file)
@@ -152,21 +152,6 @@ class IMP_Api extends Horde_Registry_Api
     }
 
     /**
-     * Return envelope information for the given list of indices.
-     *
-     * @param string $mailbox  The name of the mailbox (UTF7-IMAP).
-     * @param array $indices   The list of UIDs.
-     *
-     * @return array  The envelope information. See
-     *                Horde_Imap_Client_Base::fetch() for the format.
-     * @throws Horde_Imap_Client_Exception
-     */
-    public function msgEnvelope($mailbox, $indices)
-    {
-        return $GLOBALS['imp_imap']->ob()->fetch($mailbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $indices));
-    }
-
-    /**
      * Perform a search query on the remote IMAP server.
      *
      * @param string $mailbox                        The name of the source
@@ -181,19 +166,6 @@ class IMP_Api extends Horde_Registry_Api
     }
 
     /**
-     * Returns the cache ID value for a mailbox
-     *
-     * @param string $mailbox  The name of the source mailbox (UTF7-IMAP).
-     *
-     * @return string  The cache ID string.
-     * @throws Horde_Imap_Client_Exception
-     */
-    public function mailboxCacheId($mailbox)
-    {
-        return $GLOBALS['imp_imap']->ob()->getCacheId($mailbox);
-    }
-
-    /**
      * Returns information on the currently logged on IMAP server.
      *
      * @return mixed  An array with the following entries:
@@ -231,4 +203,14 @@ class IMP_Api extends Horde_Registry_Api
         return $sentmail->favouriteRecipients($limit, $filter);
     }
 
+    /**
+     * Returns the Horde_Imap_Client object created using the IMP credentials.
+     *
+     * @return Horde_Imap_Client_Base  The imap object.
+     */
+    public function imapOb($mailbox, $indices)
+    {
+        return $GLOBALS['imp_imap']->ob();
+    }
+
 }
index dee3fac..76af179 100644 (file)
@@ -53,9 +53,14 @@ class Ingo_Script_Imap_Live extends Ingo_Script_Imap_Api
      */
     public function fetchEnvelope($indices)
     {
-        return $GLOBALS['registry']->hasMethod('mail/msgEnvelope')
-            ? $GLOBALS['registry']->call('mail/msgEnvelope', array($this->_params['mailbox'], $indices))
-            : false;
+        if ($GLOBALS['registry']->hasMethod('mail/imapOb')) {
+            $ob = $GLOBALS['registry']->call('mail/imapOb');
+            try {
+                return $ob->fetch($this->_params['mailbox'], array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $indices));
+            } catch (Horde_Imap_Client_Exception $e) {}
+        }
+
+        return false;
     }
 
     /**
@@ -102,9 +107,14 @@ class Ingo_Script_Imap_Live extends Ingo_Script_Imap_Api
      */
     protected function _cacheId()
     {
-        return $GLOBALS['registry']->hasMethod('mail/mailboxCacheId')
-            ? $GLOBALS['registry']->call('mail/mailboxCacheId', array($this->_params['mailbox']))
-            : time();
+        if ($GLOBALS['registry']->hasMethod('mail/imapOb')) {
+            $ob = $GLOBALS['registry']->call('mail/imapOb');
+            try {
+                return $ob->getCacheId($this->_params['mailbox']);
+            } catch (Horde_Imap_Client_Exception $e) {}
+        }
+
+        return time();
     }
 
 }