* Checks to see if the current index is valid.
* This function is only useful if an index was passed to the constructor.
*
- * @param boolean $rebuild Rebuild mailbox list, if needed.
- *
* @return boolean True if index is valid, false if not.
*/
public function isValidIndex($rebuild = true)
{
- if ($rebuild) {
- $this->_rebuild();
- $this->setIndex(0);
- }
return !is_null($this->_arrayIndex);
}
$this->_arrayIndex = $this->getArrayIndex($uid, $mailbox);
}
} elseif (!is_null($this->_arrayIndex)) {
- $this->_arrayIndex += $data;
- if (empty($this->_sorted[$this->_arrayIndex])) {
- $this->_arrayIndex = null;
+ $index = $this->_arrayIndex += $data;
+ if (isset($this->_sorted[$this->_arrayIndex])) {
+ $this->_rebuild();
+ } else {
+ $this->_rebuild(true);
+ $this->_arrayIndex = isset($this->_sorted[$index])
+ ? $index
+ : null;
}
- $this->_rebuild();
}
}
return;
}
- $msgcount = 0;
- $sortcount = count($this->_sorted);
-
/* Remove the current entry and recalculate the range. */
foreach ($indices as $mbox => $uid) {
$val = $this->getArrayIndex($uid, $mbox);
if ($this->_searchmbox) {
unset($this->_sortedMbox[$val]);
}
- ++$msgcount;
}
$this->_sorted = array_values($this->_sorted);
/* Make sure we have a valid index. */
$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
-if (!$imp_mailbox->isValidIndex(false)) {
+if (!$imp_mailbox->isValidIndex()) {
IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('a', 'm')->redirect();
}
/* Make sure we have a valid index. */
$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
-if (!$imp_mailbox->isValidIndex(false)) {
+if (!$imp_mailbox->isValidIndex()) {
_returnToMailbox(null, 'message_missing');
require IMP_BASE . '/mailbox.php';
exit;