Bug #9004: expungeMailbox() should return an IMP_Indices() object
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 May 2010 08:25:24 +0000 (02:25 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 May 2010 08:25:42 +0000 (02:25 -0600)
imp/lib/Ajax/Application.php
imp/lib/Message.php

index 2ea581a..49d371f 100644 (file)
@@ -1201,9 +1201,7 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
      */
     public function purgeDeleted()
     {
-        $indices = new IMP_Indices($this->_vars->uid);
         $change = $this->_changed(true);
-
         if (is_null($change)) {
             return false;
         }
@@ -1215,11 +1213,10 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
 
         $expunged = $GLOBALS['injector']->getInstance('IMP_Message')->expungeMailbox(array($this->_vars->view => 1), array('list' => true));
 
-        if (empty($expunged[$this->_vars->view])) {
+        if (!($expunge_count = $expunged->count())) {
             return false;
         }
 
-        $expunge_count = count($expunged[$this->_vars->view]);
         $display_folder = IMP::displayFolder($this->_vars->view);
         if ($expunge_count == 1) {
             $GLOBALS['notification']->push(sprintf(_("1 message was purged from \"%s\"."), $display_folder), 'horde.success');
index 685089a..8f21414 100644 (file)
@@ -663,15 +663,15 @@ class IMP_Message
      *          DEFAULT: false
      * </pre>
      *
-     * @return array  If 'list' option is true, an array of mailbox names as
-     *                keys and UIDs as values that were expunged.
+     * @return IMP_Indices  If 'list' option is true, an indices object
+     *                      containing the messages that have been expunged.
      */
     public function expungeMailbox($mbox_list, $options = array())
     {
         $msg_list = !empty($options['list']);
 
         if (empty($mbox_list)) {
-            return $msg_list ? array() : null;
+            return $msg_list ? new IMP_Indices() : null;
         }
 
         $imp_imap = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb();
@@ -711,7 +711,9 @@ class IMP_Message
             } catch (Horde_Imap_Client_Exception $e) {}
         }
 
-        return $msg_list ? $update_list : null;
+        if ($msg_list) {
+            return new IMP_Indices($update_list);
+        }
     }
 
     /**