Fix mailbox page location when deleting last msg in mailbox.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 6 Jan 2009 06:57:12 +0000 (23:57 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 6 Jan 2009 06:57:12 +0000 (23:57 -0700)
imp/lib/Mailbox.php
imp/message.php

index 535431c..b3f8845 100644 (file)
@@ -28,13 +28,6 @@ class IMP_Mailbox
     protected $_arrayIndex = null;
 
     /**
-     * The location of the last message we were at.
-     *
-     * @var integer
-     */
-    protected $_lastArrayIndex = null;
-
-    /**
      * The array of sorted indices.
      *
      * @var array
@@ -365,9 +358,7 @@ class IMP_Mailbox
      */
     public function getMessageIndex()
     {
-        return (is_null($this->_arrayIndex) && is_null($this->_lastArrayIndex))
-            ? 1
-            : $this->_arrayIndex + 1;
+        return is_null($this->_arrayIndex) ? 1 : $this->_arrayIndex + 1;
     }
 
     /**
@@ -559,7 +550,6 @@ class IMP_Mailbox
         switch ($type) {
         case 'offset':
             if (!is_null($this->_arrayIndex)) {
-                $this->_lastArrayIndex = $this->_arrayIndex;
                 $this->_arrayIndex += $data;
                 if (empty($this->_sorted[$this->_arrayIndex])) {
                     $this->_arrayIndex = null;
@@ -569,7 +559,7 @@ class IMP_Mailbox
             break;
 
         case 'uid':
-            $this->_arrayIndex = $this->_lastArrayIndex = $this->getArrayIndex($data);
+            $this->_arrayIndex = $this->getArrayIndex($data);
             break;
         }
     }
index 4dc4483..2d2f049 100644 (file)
@@ -16,7 +16,7 @@ function _returnToMailbox($startIndex = null, $actID = null)
 {
     $GLOBALS['actionID'] = $actID;
     $GLOBALS['from_message_page'] = true;
-    $GLOBALS['startIndex'] = $startIndex;
+    $GLOBALS['start'] = $startIndex;
 }
 
 function _moveAfterAction()
@@ -86,7 +86,6 @@ case 'print_message':
 
 case 'delete_message':
 case 'undelete_message':
-    $imp_message = &IMP_Message::singleton();
     if ($actionID == 'undelete_message') {
         $imp_message->undelete($indices_array);
     } else {
@@ -105,8 +104,6 @@ case 'undelete_message':
 case 'move_message':
 case 'copy_message':
     if (($targetMbox = Util::getFormData('targetMbox')) !== null) {
-        $imp_message = &IMP_Message::singleton();
-
         if (Util::getFormData('newMbox', 0) == 1) {
             $targetMbox = IMP::folderPref($targetMbox, true);
             $newMbox = true;
@@ -148,7 +145,6 @@ case 'flag_message':
         } else {
             $set = true;
         }
-        $imp_message = &IMP_Message::singleton();
         $imp_message->flag(array($flag), $indices_array, $set);
         if ($prefs->getValue('mailbox_return')) {
             _returnToMailbox($imp_mailbox->getMessageIndex());
@@ -169,7 +165,6 @@ case 'add_address':
 
 case 'strip_all':
 case 'strip_attachment':
-    $imp_message = &IMP_Message::singleton();
     $result = $imp_message->stripPart($indices_array, ($actionID == 'strip_all') ? null : Util::getFormData('imapid'));
     if (is_a($result, 'PEAR_Error')) {
         $notification->push($result, 'horde.error');
@@ -184,7 +179,7 @@ $message_token = IMP::getRequestToken('imp.message');
  * message array, so we will return to mailbox.php if that is the
  * case. */
 if (!$imp_mailbox->isValidIndex()) {
-    _returnToMailbox($imp_mailbox->getMessageIndex());
+    _returnToMailbox($imp_mailbox->getMessageCount());
     require IMP_BASE . '/mailbox.php';
     exit;
 }