Fixes to Cclient_Pop3 driver.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 3 Mar 2009 20:18:08 +0000 (13:18 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 4 Mar 2009 19:46:23 +0000 (12:46 -0700)
Disable caching in POP3 driver.
Need to check for empty, not isset.
Add support for delete/undelete.

framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php

index 81fa1e1..684c107 100644 (file)
@@ -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);
     }
 
     /**