More POP3 disabling - don't allow on-demand filtering
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 25 Jun 2009 21:51:58 +0000 (15:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 25 Jun 2009 21:51:58 +0000 (15:51 -0600)
imp/docs/CHANGES
imp/docs/INSTALL
imp/lib/Imap.php
imp/lib/api.php
ingo/config/backends.php.dist
ingo/lib/Script/imap.php

index 4b7c786..e8348b6 100644 (file)
@@ -28,8 +28,8 @@ v5.0-git
       UIDVALIDITY of mailbox has changed.
 [mms] Simplify forwarding - always attach entire message.
 [mms] Remember splitbar position on login/refresh (DIMP).
-[mms] Disable some advanced functions if using POP3 driver (caching,
-      searching, sorting) because it is too resource intensive.
+[mms] Disable advanced functions if using POP3 driver (caching, on-demand
+      filtering, searching, sorting) because it is too resource intensive.
 [mms] Use native PHP code for POP3 driver (c-client no longer required).
 [mms] All native IMP code now uses exceptions instead of PEAR_Errors.
 [mms] Fix wrong charset on filenames when stripping attachments (Bug #7220).
index 0347f10..33e5adb 100644 (file)
@@ -158,6 +158,11 @@ To function properly, IMP **requires** the following:
    The selected IMAP server MUST support IMAP4rev1 (RFC 3501).
    The selected POP server MUST support POP3 (RFC 1939/STD 53).
 
+   .. If using a POP server, caching, on-demand filtering, searching, and
+      sorting are disabled.
+      POP3 support is limited essentially to only viewing messages.
+      An IMAP server is REQUIRED for all other advanced features.
+
 The following items are not required, but are strongly **RECOMMENDED**:
 
 1. Sendmail or equivalent.
index b5c6158..a7e9af0 100644 (file)
@@ -161,7 +161,9 @@ class IMP_Imap
             return false;
         }
 
-        $protocol = isset($server['protocol']) ? strtolower($server['protocol']) : 'imap';
+        $protocol = isset($server['protocol'])
+            ? strtolower($server['protocol'])
+            : 'imap';
 
         $imap_config = array(
             'debug' => isset($server['debug']) ? $server['debug'] : null,
index e1fe156..a352140 100644 (file)
@@ -83,7 +83,7 @@ $_services['mailboxCacheId'] = array(
 
 $_services['server'] = array(
     'args' => array(),
-    'type' => 'string'
+    'type' => '{urn:horde}hashHash'
 );
 
 $_services['favouriteRecipients'] = array(
@@ -428,10 +428,15 @@ function _imp_mailboxCacheId($mailbox)
 }
 
 /**
- * Returns the currently logged on IMAP server.
- *
- * @return string  The server hostname.  Returns null if the user has not
- *                 authenticated into IMP yet.
+ * Returns information on the currently logged on IMAP server.
+ *
+ * @return mixed  Returns null if the user has not authenticated into IMP yet.
+ *                Otherwise, an array with the following entries:
+ * <pre>
+ * 'hostspec' - (string) The server hostname.
+ * 'port' - (integer) The server port.
+ * 'protocol' - (string) Either 'imap' or 'pop'.
+ * </pre>
  */
 function _imp_server()
 {
@@ -440,10 +445,14 @@ function _imp_server()
 
     if (IMP::checkAuthentication(true)) {
         $imap_obj = unserialize($_SESSION['imp']['imap_ob']);
-        return $imap_obj->getParam('hostspec');
-    } else {
-        return null;
+        return array(
+            'hostspec' => $imap_obj->getParam('hostspec'),
+            'port' => $imap_obj->getParam('hostspec'),
+            'protocol' => $_SESSION['imp']['protocol']
+        );
     }
+
+    return null;
 }
 
 /**
index c861426..8e5dc0b 100644 (file)
@@ -26,7 +26,8 @@
  *
  * script: (string) The type of Ingo_Script driver this server uses.
  *         Valid options:
- *           'imap'     - IMAP client side filtering
+ *           'imap'     - IMAP client side filtering (POP3 servers NOT
+                          supported)
  *           'maildrop' - Maildrop scripts
  *           'procmail' - Procmail scripts
  *           'sieve'    - Sieve scripts
index 9374c5a..145d293 100644 (file)
@@ -346,8 +346,13 @@ class Ingo_Script_imap extends Ingo_Script
      */
     public function canApply()
     {
-        return $this->performAvailable() &&
-               $GLOBALS['registry']->hasMethod('mail/server');
+        if ($this->performAvailable() &&
+            $GLOBALS['registry']->hasMethod('mail/server')) {
+            $server = $GLOBALS['registry']->call('mail/server');
+            return ($server['protocol'] == 'imap');
+        }
+
+        return false;
     }
 
     /**
@@ -357,11 +362,9 @@ class Ingo_Script_imap extends Ingo_Script
      */
     public function apply()
     {
-        if ($this->canApply()) {
-            return $this->perform(array('mailbox' => 'INBOX'));
-        }
-
-        return false;
+        return $this->canApply()
+            ? $this->perform(array('mailbox' => 'INBOX'))
+            : false;
     }
 
 }