Various POP3 changes/fixes.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 3 Mar 2009 06:55:04 +0000 (23:55 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 4 Mar 2009 19:52:05 +0000 (12:52 -0700)
imp/config/servers.php.dist
imp/docs/INSTALL
imp/js/src/imp.js
imp/lib/Fetchmail/imap.php
imp/lib/IMP.php
imp/lib/Imap.php
imp/mailbox.php
imp/message.php
imp/search.php
imp/test.php

index 3a356dc..46e9c7f 100644 (file)
  *
  * protocol: (string) Either 'pop' or 'imap' (DEFAULT).
  *
- *           If using 'pop' you will connect to a POP3 mail server and all
- *           folder options will be automatically turned off (POP3 does
- *           not support folders).  If you want folders (and for much
- *           improved performance) it is HIGHLY RECOMMENDED that IMAP should
- *           be used instead.  The PHP imap module must be built into PHP in
- *           order to use a POP3 server.
+ *           'imap' requires a IMAP4rev1 (RFC 3501) compliant server.
+ *
+ *           'pop' requires a POP3 (RFC 1939) compliant server. All folder
+ *           options will be automatically turned off (POP3 does
+ *           not support folders).  Other advanced functions will also be
+ *           disabled (e.g. caching, searching, sorting).
  *
  * secure: (mixed) One of the following values:
  *         'ssl' - Use SSL to connect to the server.
index 40b3482..1b3a89a 100644 (file)
@@ -110,7 +110,7 @@ To function properly, IMP **requires** the following:
       See http://www.php.net/openssl for information on compiling OpenSSL
       into PHP.
 
-   b. tidy ``--with-tidy`` (PHP 5+ only)
+   b. tidy ``--with-tidy``
 
       The tidy PHP extension is required if you want IMP to sanitize the
       output of HTML messages before displaying to the user and if you want
@@ -118,68 +118,13 @@ To function properly, IMP **requires** the following:
       composition mode.  See ``imp/config/mime_drivers.php.dist`` for
       further instructions on how to enable this feature.
 
-   The following PHP options are **OPTIONAL** and only required for certain
-   configurations:
-
-   a. POP3 support ``--with-imap``
-
-      ** This extensions is only required for POP3 servers. If accessing **
-      ** mail via IMAP, this extension is NOT necessary.                 **
-
-      IMP **requires** the PHP imap extension to provide POP3 support.
-      To compile the imap extension, the UW-IMAP c-client library must be
-      present on your system.  For help with compiling the imap extension into
-      PHP, you can view the PHP imap manual entry:
-
-         http://www.php.net/imap
-
-      Because installation of the imap extension can be a non-trivial matter,
-      further configuration help/advice follows.
-
-      The UW-IMAP c-client library is available from
-
-         ftp://ftp.cac.washington.edu/imap/
-
-      The most recent code is normally located in a file named 'imap.tar.Z'.
-
-      After building the c-client library (instructions are at the top of
-      the Makefile in the base directory of the UW imap package), you may
-      need to rename the compiled library file so the local build system can
-      find it.  For example, compilation of c-client results in a file named
-      'c-client.a' in the 'c-client' directory.  On Linux (at least) this file
-      needs to be renamed or linked to libc-client.a, e.g.:
-
-         ln -s c-client.a libc-client.a
-
-      IMP can use POP3-SSL if available.  SSL support needs to be built-in to
-      both the c-client library and the PHP extension (see the
-      ``--with-imap-ssl`` configure option to PHP).
-
-      If using TLS or SSL to connect to the POP3 server, OpenSSL support is
-      **required** in PHP. See `OpenSSL Support`_ below.
-
-      .. Tip:: If you notice strange behavior when running IMP (e.g. blank
-               screens when accessing certain messages, blank message bodies)
-               you should always try recompiling PHP with a different version
-               of c-client.  The different versions of the c-client library and
-               PHP do not always work well together, and often all it takes is
-               to recompile with a different c-client version and the problems
-               will go away.
-
-      .. Tip:: If running the webserver changerooted (i.e. the default setting
-               on OpenBSD), you may need additional configuration on your
-               system to ensure the c-client library works properly.
-               See: `Configuring c-client for changerooted webservers`_
-
-      .. _`Configuring c-client for changerooted webservers`: http://lists.horde.org/archives/imp/Week-of-Mon-20050321/041502.html
-
 3. The following PEAR modules:
    (See `horde/docs/INSTALL`_ for instructions on installing PEAR modules)
 
    a. Auth_SASL [OPTIONAL]
 
-      Auth_SASL is required if your IMAP server uses CRAM-MD5 or DIGEST-MD5
-      authentication.
+      Auth_SASL is required only if your IMAP server uses CRAM-MD5 or
+      DIGEST-MD5 authentication.
 
 4. The following PECL modules:
    (See `horde/docs/INSTALL`_ for instructions on installing PECL modules)
index e9f7674..6925d9d 100644 (file)
@@ -88,9 +88,9 @@ IMP.unblockImages = function(e)
 
 document.observe('dom:loaded', function() {
     // If menu is present, attach event handlers to folder switcher.
-    var tmp = $('menuform');
+    var tmp = $('openfoldericon');
     if (tmp) {
-        tmp.observe('change', IMP.menuFolderSubmit.bind(IMP));
-        $('openfoldericon').down().observe('click', IMP.menuFolderSubmit.bind(IMP, true));
+        $('menuform').observe('change', IMP.menuFolderSubmit.bind(IMP));
+        tmp.down().observe('click', IMP.menuFolderSubmit.bind(IMP, true));
     }
 });
index cb2aba3..5f13b36 100644 (file)
@@ -124,7 +124,7 @@ class IMP_Fetchmail_imap extends IMP_Fetchmail
         );
 
         try {
-            $this->_ob = Horde_Imap_Client::getInstance(($protocols[$this->_params['protocol']]['string'] == 'imap') ? 'Socket' : 'Cclient_pop3', $imap_config);
+            $this->_ob = Horde_Imap_Client::getInstance(($protocols[$this->_params['protocol']]['string'] == 'imap') ? 'Socket' : 'Socket_Pop3', $imap_config);
         } catch (Horde_Imap_Client_Exception $e) {
             throw new Horde_Exception(_("Cannot connect to the remote mail server: ") . $e->getMessage());
         }
index c809714..c1c906a 100644 (file)
@@ -658,7 +658,9 @@ class IMP
             $menu->add(Util::nocacheUrl(Horde::applicationUrl('folders.php')), _("_Folders"), 'folders/folder.png');
         }
 
-        $menu->add($menu_search_url, _("_Search"), 'search.png', $registry->getImageDir('horde'));
+        if ($_SESSION['imp']['protocol'] != 'pop') {
+            $menu->add($menu_search_url, _("_Search"), 'search.png', $registry->getImageDir('horde'));
+        }
 
         if (($_SESSION['imp']['protocol'] != 'pop') &&
             $prefs->getValue('fetchmail_menu')) {
@@ -1152,6 +1154,15 @@ class IMP
             'limit' => false
         );
 
+        /* Restrict POP3 sorting to arrival only.  Although possible to
+         * abstract other sorting methods, all other methods require a
+         * download of all messages, which is too much overhead.*/
+        if ($_SESSION['imp']['protocol'] == 'pop') {
+            $ob['by'] = Horde_Imap_Client::SORT_ARRIVAL;
+            $ob['limit'] = true;
+            return $ob;
+        }
+
         /* Can't do threaded searches in search mailboxes. */
         if (!self::threadSortAvailable($mbox)) {
             if ($ob['by'] == Horde_Imap_Client::SORT_THREAD) {
@@ -1194,7 +1205,8 @@ class IMP
      */
     static public function threadSortAvailable($mbox)
     {
-        return !$GLOBALS['imp_search']->isSearchMbox($mbox) &&
+        return ($_SESSION['imp']['protocol'] == 'imap') &&
+               !$GLOBALS['imp_search']->isSearchMbox($mbox) &&
                (!$GLOBALS['prefs']->getValue('use_trash') ||
                 !$GLOBALS['prefs']->getValue('use_vtrash') ||
                 $GLOBALS['imp_search']->isVTrashFolder($mbox));
index 7eb8d9d..b5957ac 100644 (file)
@@ -195,7 +195,7 @@ class IMP_Imap
         }
 
         try {
-            $ob = Horde_Imap_Client::getInstance(($protocol == 'imap') ? 'Socket' : 'Cclient_pop3', $imap_config);
+            $ob = Horde_Imap_Client::getInstance(($protocol == 'imap') ? 'Socket' : 'Socket_Pop3', $imap_config);
         } catch (Horde_Imap_Client_Exception $e) {
             return false;
         }
index 7d9dda6..1700222 100644 (file)
@@ -451,22 +451,24 @@ if (isset($filter_url)) {
     $hdr_template->set('filter', Horde::link($filter_url, sprintf(_("Apply Filters to %s"), $rawtitle)) . Horde::img('filters.png', _("Apply Filters")) . '</a>');
 }
 $hdr_template->set('search', false);
-if (!$search_mbox) {
-    $hdr_template->set('search', Horde::link(Util::addParameter(Horde::applicationUrl('search.php'), 'search_mailbox', $imp_mbox['mailbox']), sprintf(_("Search %s"), $rawtitle)) . Horde::img('search.png', _("Search"), '', $graphicsdir) . '</a>');
-    if (!$readonly) {
-        $hdr_template->set('empty', Horde::link(Util::addParameter($mailbox_imp_url, array('actionID' => 'empty_mailbox', 'mailbox' => $imp_mbox['mailbox'], 'mailbox_token' => $mailbox_token)), _("Empty folder"), '', '', "ImpMessage.confirmDialog(this.href, '" . addslashes(_("Are you sure you wish to delete all mail in this folder?")) . "'); return false;") . Horde::img('empty_spam.png', _("Empty folder")) . '</a>');
-    }
-} else {
-    if ($imp_search->isEditableVFolder()) {
-        $edit_search = sprintf(_("Edit Virtual Folder Definition for %s"), htmlspecialchars($rawtitle));
-        $hdr_template->set('delete_vfolder', Horde::link($imp_search->deleteURL(), sprintf(_("Delete Virtual Folder Definition for %s"), htmlspecialchars($rawtitle)), null, null, "if (confirm('" . addslashes(_("Are you sure you want to delete this Virtual Folder Definition?")) . "')) { return true; } else { return false; }") . Horde::img('delete.png', sprintf(_("Delete Virtual Folder Definition for %s"), $rawtitle), '', $graphicsdir) . '</a>');
+if ($_SESSION['imp']['protocol'] != 'pop') {
+    if (!$search_mbox) {
+        $hdr_template->set('search', Horde::link(Util::addParameter(Horde::applicationUrl('search.php'), 'search_mailbox', $imp_mbox['mailbox']), sprintf(_("Search %s"), $rawtitle)) . Horde::img('search.png', _("Search"), '', $graphicsdir) . '</a>');
+        if (!$readonly) {
+            $hdr_template->set('empty', Horde::link(Util::addParameter($mailbox_imp_url, array('actionID' => 'empty_mailbox', 'mailbox' => $imp_mbox['mailbox'], 'mailbox_token' => $mailbox_token)), _("Empty folder"), '', '', "ImpMessage.confirmDialog(this.href, '" . addslashes(_("Are you sure you wish to delete all mail in this folder?")) . "'); return false;") . Horde::img('empty_spam.png', _("Empty folder")) . '</a>');
+        }
     } else {
-        if (!$vfolder) {
-            $edit_search = _("Edit Search Query");
+        if ($imp_search->isEditableVFolder()) {
+            $edit_search = sprintf(_("Edit Virtual Folder Definition for %s"), htmlspecialchars($rawtitle));
+            $hdr_template->set('delete_vfolder', Horde::link($imp_search->deleteURL(), sprintf(_("Delete Virtual Folder Definition for %s"), htmlspecialchars($rawtitle)), null, null, "if (confirm('" . addslashes(_("Are you sure you want to delete this Virtual Folder Definition?")) . "')) { return true; } else { return false; }") . Horde::img('delete.png', sprintf(_("Delete Virtual Folder Definition for %s"), $rawtitle), '', $graphicsdir) . '</a>');
+        } else {
+            if (!$vfolder) {
+                $edit_search = _("Edit Search Query");
+            }
+        }
+        if (isset($edit_search)) {
+            $hdr_template->set('search', Horde::link($imp_search->editURL(), $edit_search) . Horde::img('edit.png', $edit_search, '', $graphicsdir) . '</a>');
         }
-    }
-    if (isset($edit_search)) {
-        $hdr_template->set('search', Horde::link($imp_search->editURL(), $edit_search) . Horde::img('edit.png', $edit_search, '', $graphicsdir) . '</a>');
     }
 }
 $hdr_template->set('msgcount', $msg_count);
index 962b25d..4ee6658 100644 (file)
@@ -515,7 +515,7 @@ if (!IMP::$printMode) {
         $a_template->set('redirect', Horde::widget(IMP::composeLink(array(), array('actionID' => 'redirect_compose') + $compose_params), _("Redirect"), 'widget', '', '', _("Redirec_t"), true));
     }
 
-    if (isset($imp_search) && !$imp_search->searchMboxID()) {
+    if (IMP::threadSortAvailable($imp_mbox['mailbox'])) {
         $a_template->set('show_thread', Horde::widget(Util::addParameter(IMP::generateIMPUrl('thread.php', $imp_mbox['mailbox'], $index, $mailbox_name), array('start' => $msgindex)), _("View Thread"), 'widget', '', '', _("_View Thread"), true));
     }
 
index fb3c88d..8acc38f 100644 (file)
 require_once dirname(__FILE__) . '/lib/base.php';
 require_once 'Horde/Help.php';
 
+/* Redirect back to the mailbox if searching is not allowed. */
+if ($_SESSION['imp']['protocol'] == 'pop') {
+    $notification->push(_("Searching is not available with a POP3 server."), 'horde.error');
+    header('Location: ' . Horde::applicationUrl('mailbox.php', true));
+    exit;
+}
+
 $actionID = Util::getFormData('actionID');
 $edit_query = Util::getFormData('edit_query');
 $edit_query_vfolder = Util::getFormData('edit_query_vfolder');
index 308d312..14e7d35 100644 (file)
@@ -24,7 +24,7 @@ function _doConnectionTest()
         'secure' => ($_POST['port'] == 'yes')
     );
 
-    $driver = ($_POST['server_type'] == 'imap') ? 'Socket' : 'Cclient_pop3';
+    $driver = ($_POST['server_type'] == 'imap') ? 'Socket' : 'Socket_Pop3';
 
     try {
         $imap_client = Horde_Imap_Client::getInstance($driver, $imap_config);
@@ -158,11 +158,6 @@ $module_list = array(
         'error' => 'IMP requires the idn module (installed via PECL) in order to handle Internationalized Domain Names.',
         'fatal' => false
     ),
-    'imap' => array(
-        'descrip' => 'IMAP Support',
-        'error' => 'IMP requires the imap module to interact with the mail server.  It is required ONLY for POP3 access.',
-        'fatal' => false
-    ),
     'openssl' => array(
         'descrip' => 'OpenSSL Support',
         'error' => 'The openssl module is required to use S/MIME in IMP. Compile PHP with <code>--with-openssl</code> to activate.',