Use new identifier for search mailboxes
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 2 Jun 2009 21:28:25 +0000 (15:28 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 2 Jun 2009 21:34:23 +0000 (15:34 -0600)
imp/lib/IMP.php
imp/lib/Search.php
imp/lib/base.php

index 94a97d8..7439dc4 100644 (file)
@@ -31,9 +31,6 @@ class IMP
     const MAILBOX_START_FIRSTPAGE = 3;
     const MAILBOX_START_LASTPAGE = 4;
 
-    /* IMP mailbox labels. */
-    const SEARCH_MBOX = '**search_';
-
     /* IMP internal indexing strings. */
     // String used to separate messages.
     const MSG_SEP = "\0";
index 97a871e..4e2c18f 100644 (file)
@@ -614,16 +614,13 @@ class IMP_Search
     /**
      * Is the given mailbox a search mailbox?
      *
-     * @param string $id  The search query id to use (by default, will use
-     *                    the current ID set in the object).
+     * @param string $id  The mailbox name.
      *
      * @return boolean  Whether the given mailbox name is a search mailbox.
      */
-    public function isSearchMbox($id = null)
+    static public function isSearchMbox($id)
     {
-        return is_null($id)
-            ? !empty($this->_id)
-            : isset($_SESSION['imp']['search']['q'][$this->_strip($id)]);
+        return (strpos($id, null) !== false);
     }
 
     /**
@@ -663,9 +660,14 @@ class IMP_Search
      */
     protected function _strip($id)
     {
-        return is_null($id)
-            ? $this->_id
-            : ((strpos($id, IMP::SEARCH_MBOX) === 0) ? substr($id, strlen(IMP::SEARCH_MBOX)) : $id);
+        if (is_null($id)) {
+            return $this->_id;
+        }
+
+        $pos = strpos($id, null);
+        return ($pos === false)
+            ? $id
+            : substr($id, $pos);
     }
 
     /**
@@ -677,7 +679,7 @@ class IMP_Search
      */
     public function createSearchID($id)
     {
-        return IMP::SEARCH_MBOX . $this->_strip($id);
+        return 'impsearch' . "\0" . $this->_strip($id);
     }
 
     /**
index 70d5be7..bdb09f4 100644 (file)
@@ -10,7 +10,7 @@
  *                      'none'  - Do not authenticate
  *                      Default - Authenticate to IMAP/POP server
  *   $compose_page    - If true, we are on IMP's compose page
- *   $dimp_logout      - Logout and redirect to the login page.
+ *   $dimp_logout     - Logout and redirect to the login page.
  *   $login_page      - If true, we are on IMP's login page
  *   $mimp_debug      - If true, output text/plain version of page.
  *   $no_compress     - Controls whether the page should be compressed
@@ -204,7 +204,7 @@ if ((IMP::loginTasksFlag() === 2) &&
 $GLOBALS['imp_mbox'] = IMP::getCurrentMailboxInfo();
 
 // Initialize IMP_Search object.
-$GLOBALS['imp_search'] = new IMP_Search(array('id' => (isset($_SESSION['imp']) && strpos($GLOBALS['imp_mbox']['mailbox'], IMP::SEARCH_MBOX) === 0) ? $GLOBALS['imp_mbox']['mailbox'] : null));
+$GLOBALS['imp_search'] = new IMP_Search(array('id' => (isset($_SESSION['imp']) && IMP_Search::isSearchMbox($GLOBALS['imp_mbox']['mailbox'])) ? $GLOBALS['imp_mbox']['mailbox'] : null));
 
 if ($viewmode == 'mimp') {
     // Mobile markup renderer.