From 5164bea912fe9e2ecd1ef5fc4c4d218b72e946e3 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 17 Mar 2009 12:50:28 -0600 Subject: [PATCH] Correctly return message list in expungeMailbox() --- imp/ajax.php | 2 +- imp/lib/Message.php | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/imp/ajax.php b/imp/ajax.php index 9c4b8857e..f23a7d436 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -630,7 +630,7 @@ case 'PurgeDeleted': $change = ($sort['by'] == SORTTHREAD); } $imp_message = IMP_Message::singleton(); - $expunged = $imp_message->expungeMailbox(array($mbox => 1)); + $expunged = $imp_message->expungeMailbox(array($mbox => 1), array('list' => true)); if (!empty($expunged[$mbox])) { $expunge_count = count($expunged[$mbox]); $display_folder = IMP::displayFolder($mbox); diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 723587baf..5de531ddf 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -598,24 +598,29 @@ class IMP_Message * If the value is not an array, all messages * flagged as deleted in the mailbox will be * deleted. + * @param array $options Additional options: + *
+     * 'list' - (boolean) Return a list of messages expunged.
+     *          DEFAULT: false
+     * 
* - * @return array An array of mailbox names as keys and UIDs as values - * that were expunged. + * @return array If 'list' option is true, an array of mailbox names as + * keys and UIDs as values that were expunged. */ - public function expungeMailbox($mbox_list) + public function expungeMailbox($mbox_list, $options = array()) { - global $imp_search; + $msg_list = !empty($options['list']); if (empty($mbox_list)) { - return array(); + return $msg_list ? array() : null; } $process_list = $update_list = array(); foreach (array_keys($mbox_list) as $key) { if (!$GLOBALS['imp_imap']->isReadOnly($key)) { - if ($imp_search->isSearchMbox($key)) { - foreach ($imp_search->getSearchFolders($key) as $skey) { + if ($GLOBALS['imp_search']->isSearchMbox($key)) { + foreach ($GLOBALS['imp_search']->getSearchFolders($key) as $skey) { $process_list[$skey] = $mbox_list[$key]; } } else { @@ -632,11 +637,14 @@ class IMP_Message if ($imp_mailbox->isBuilt()) { $imp_mailbox->removeMsgs(is_array($val) ? array($key => $val) : true); } - $update_list[$key] = $val; + + if ($msg_list) { + $update_list[$key] = $val; + } } catch (Horde_Imap_Client_Exception $e) {} } - return $update_list; + return $msg_list ? $update_list : null; } /** -- 2.11.0