From 4c4c0dcbd4fa52ac3c99af620d9207d1255de65a Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 3 Mar 2009 13:18:08 -0700 Subject: [PATCH] Fixes to Cclient_Pop3 driver. Disable caching in POP3 driver. Need to check for empty, not isset. Add support for delete/undelete. --- .../lib/Horde/Imap/Client/Cclient/Pop3.php | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php index 81fa1e10b..684c10764 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php @@ -4,6 +4,8 @@ * 1939) via the PHP imap (c-client) module. This driver is an abstraction * layer allowing POP3 commands to be used based on its IMAP equivalents. * + * Caching is not supported in this driver. + * * PHP IMAP module: http://www.php.net/imap * * No additional paramaters from those defined in Horde_Imap_Client_Cclient. @@ -27,10 +29,14 @@ class Horde_Imap_Client_Cclient_Pop3 extends Horde_Imap_Client_Cclient public function __construct($params) { $this->_service = 'pop3'; - if (!isset($params['port'])) { + if (empty($params['port'])) { $params['port'] = ($params['secure'] == 'ssl') ? 995 : 110; } + parent::__construct($params); + + // Disable caching. + $this->_params['cache'] = array('fields' => array()); } /** @@ -40,7 +46,7 @@ class Horde_Imap_Client_Cclient_Pop3 extends Horde_Imap_Client_Cclient */ protected function _capability() { - throw new Horde_Imap_Client_Exception('IMAP CAPABILITY command not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED); + throw new Horde_Imap_Client_Exception('CAPABILITY command not supported in this POP3 driver.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED); } /** @@ -337,7 +343,28 @@ class Horde_Imap_Client_Cclient_Pop3 extends Horde_Imap_Client_Cclient */ protected function _store($options) { - throw new Horde_Imap_Client_Exception('Flagging messages not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED); + /* Only support deleting/undeleting messages. */ + if (isset($options['replace'])) { + if (count(array_intersect($options['replace'], array('\\deleted')))) { + $options['add'] = array('\\deleted'); + } else { + $options['remove'] = array('\\deleted'); + } + unset($options['replace']); + } else { + if (!empty($options['add']) && + count(array_intersect($options['add'], array('\\deleted')))) { + $options['add'] = array('\\deleted'); + } + + if (!empty($options['remove']) && + !count(array_intersect($options['remove'], array('\\deleted')))) { + $options['add'] = array(); + $options['remove'] = array('\\deleted'); + } + } + + return parent::_store($options); } /** -- 2.11.0