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";
/**
* 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);
}
/**
*/
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);
}
/**
*/
public function createSearchID($id)
{
- return IMP::SEARCH_MBOX . $this->_strip($id);
+ return 'impsearch' . "\0" . $this->_strip($id);
}
/**
* '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
$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.