From: Michael M Slusarz Date: Thu, 24 Dec 2009 08:13:31 +0000 (-0700) Subject: Fix determining starting index when in search mailboxes X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e6785ab91a4635bb9c46b980f72b5c1840de3c74;p=horde.git Fix determining starting index when in search mailboxes --- diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index d9986be4b..7730d5d17 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -71,15 +71,14 @@ class IMP_Mailbox protected $_changed = false; /** - * Attempts to return a reference to a concrete IMP_Mailbox instance. - * It will only create a new instance if no IMP_Mailbox instance with - * the same parameters currently exists. + * Attempts to return a reference to a concrete instance. + * It will only create a new instance if no instance with the same + * parameters currently exists. * * @param string $mailbox See constructor. - * @param integer $uid See constructor. + * @param string $uid UID string (UID . IMP::IDX_SEP . Mailbox). * - * @return mixed The created concrete IMP_Mailbox instance, or false - * on error. + * @return IMP_Mailbox The created instance. */ static public function singleton($mailbox, $uid = null) { @@ -96,7 +95,7 @@ class IMP_Mailbox * Constructor. * * @param string $mailbox The mailbox to work with. - * @param integer $uid The UID of the current message. + * @param string $uid UID string (UID . IMP::IDX_SEP . Mailbox). */ protected function __construct($mailbox, $uid = null) { @@ -131,7 +130,7 @@ class IMP_Mailbox /* Casting $_sorted to integers saves a significant amount of * space when json_encoding (no need to quote every value). Only * can do for IMAP though (since POP3 UIDs are not limited to - * integers. */ + * integers). */ $sorted = ($_SESSION['imp']['protocol'] == 'pop') ? $this->_sorted : array_map('intval', $this->_sorted); @@ -641,11 +640,11 @@ class IMP_Mailbox /** * Updates the message array index. * - * @param integer $data If $type is 'offset', the number of messages to - * increase array index by. If type is 'uid', - * sets array index to the value of the given - * message UID. - * @param string $type Either 'offset' or 'uid'. + * @param mixed $data If $type is 'offset', the number of messages to + * increase array index by. If type is 'uid', sets + * array index to the value of the given message + * UID string (UID . IMP::IDX_SEP . Mailbox). + * @param string $type Either 'offset' or 'uid'. */ public function setIndex($data, $type = 'uid') { @@ -661,10 +660,11 @@ class IMP_Mailbox break; case 'uid': - $this->_arrayIndex = $this->getArrayIndex($data); + list($uid, $mailbox) = explode(IMP::IDX_SEP, $data); + $this->_arrayIndex = $this->getArrayIndex($uid, $mailbox); if (empty($this->_arrayIndex)) { $this->_rebuild(true); - $this->_arrayIndex = $this->getArrayIndex($data); + $this->_arrayIndex = $this->getArrayIndex($uid, $mailbox); } break; } diff --git a/imp/message-mimp.php b/imp/message-mimp.php index 6c60fe1d8..a8d16f81a 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -22,7 +22,7 @@ require_once dirname(__FILE__) . '/lib/Application.php'; new IMP_Application(array('init' => true, 'tz' => true)); /* Make sure we have a valid index. */ -$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid']); +$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']); if (!$imp_mailbox->isValidIndex(false)) { header('Location: ' . IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox'])->setRaw(true)->add('a', 'm')); exit; diff --git a/imp/message.php b/imp/message.php index 1c53eb947..556133087 100644 --- a/imp/message.php +++ b/imp/message.php @@ -30,7 +30,7 @@ if (!$imp_search->isSearchMbox($imp_mbox['mailbox'])) { } /* Make sure we have a valid index. */ -$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid']); +$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']); if (!$imp_mailbox->isValidIndex(false)) { _returnToMailbox(null, 'message_missing'); require IMP_BASE . '/mailbox.php'; diff --git a/imp/thread.php b/imp/thread.php index db58096e2..8b7a6db12 100644 --- a/imp/thread.php +++ b/imp/thread.php @@ -18,7 +18,7 @@ new IMP_Application(array('init' => true, 'tz' => true)); */ $mode = Horde_Util::getFormData('mode', 'thread'); -$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid']); +$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']); $error = false; if ($mode == 'thread') {