From 3367cb96eac79d4708bb963d48f2cbc0610730d7 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 22 Dec 2009 13:39:20 -0700 Subject: [PATCH] Add imapOb API call to IMP. 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 | 38 ++++++++++---------------------------- ingo/lib/Script/Imap/Live.php | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/imp/lib/Api.php b/imp/lib/Api.php index 949d3f05d..d5ab7b289 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -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(); + } + } diff --git a/ingo/lib/Script/Imap/Live.php b/ingo/lib/Script/Imap/Live.php index dee3fac41..76af17916 100644 --- a/ingo/lib/Script/Imap/Live.php +++ b/ingo/lib/Script/Imap/Live.php @@ -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(); } } -- 2.11.0