From: Michael M Slusarz Date: Mon, 27 Sep 2010 05:51:05 +0000 (-0600) Subject: Fix updating mailbox after reporting as spam X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c290069b9aac6172344281ac2efedda2620b95d3;p=horde.git Fix updating mailbox after reporting as spam --- diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index 8dc29c85d..545ec1fd9 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -23,6 +23,8 @@ class IMP_Spam * @param string $action Either 'spam' or 'notspam'. * @param array $opts Additional options: *
+     * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+     *               DEFAULT: No update.
      * 'noaction' - (boolean) Don't perform any action after reporting?
      *              DEFAULT: false
      * 
@@ -183,6 +185,11 @@ class IMP_Spam } $notification->push($msg, 'horde.message'); + $mbox_args = array(); + if (isset($opts['mailboxob'])) { + $mbox_args['mailboxob'] = $opts['mailboxob']; + } + /* Delete/move message after report. */ switch ($action) { case 'spam': @@ -191,7 +198,7 @@ class IMP_Spam $imp_message = $GLOBALS['injector']->getInstance('IMP_Message'); switch ($result) { case 1: - $msg_count = $imp_message->delete($indices); + $msg_count = $imp_message->delete($indices, $mbox_args); if ($msg_count === false) { $result = 0; } else { @@ -206,7 +213,7 @@ class IMP_Spam case 2: $targetMbox = $GLOBALS['prefs']->getValue('spam_folder'); if ($targetMbox) { - if (!$imp_message->copy(IMP::folderPref($targetMbox, true), 'move', $indices, array('create' => true))) { + if (!$imp_message->copy(IMP::folderPref($targetMbox, true), 'move', $indices, array_merge($mbox_args, array('create' => true)))) { $result = 0; } } else { @@ -222,7 +229,7 @@ class IMP_Spam if (empty($opts['noaction']) && ($result = $GLOBALS['prefs']->getValue('move_ham_after_report'))) { $imp_message = $GLOBALS['injector']->getInstance('IMP_Message'); - if (!$imp_message->copy('INBOX', 'move', $indices)) { + if (!$imp_message->copy('INBOX', 'move', $indices, $mbox_args)) { $result = 0; } } diff --git a/imp/message-mimp.php b/imp/message-mimp.php index eb833825d..328857af9 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -50,9 +50,8 @@ case 'u': if ($readonly) { break; } - $index_ob = $imp_mailbox->getIMAPIndex(); $msg_index = $imp_mailbox->getMessageIndex(); - $imp_indices = new IMP_Indices($index_ob['mailbox'], $index_ob['uid']); + $imp_indices = new IMP_Indices($imp_mailbox); $imp_message = $injector->getInstance('IMP_Message'); if ($vars->a == 'd') { @@ -71,10 +70,8 @@ case 'u': // 'ri' = report innocent case 'rs': case 'ri': - $index_ob = $imp_mailbox->getIMAPIndex(); $msg_index = $imp_mailbox->getMessageIndex(); - - $msg_delete = (IMP_Spam::reportSpam(new IMP_Indices($index_ob['mailbox'], $index_ob['uid']), $vars->a == 'rs' ? 'spam' : 'innocent') === 1); + $msg_delete = (IMP_Spam::reportSpam(new IMP_Indices($imp_mailbox), $vars->a == 'rs' ? 'spam' : 'innocent', array('mailboxob' => $imp_mailbox)) === 1); break; // 'pa' = part action diff --git a/imp/message.php b/imp/message.php index 0e1890b09..dba6e696a 100644 --- a/imp/message.php +++ b/imp/message.php @@ -137,7 +137,7 @@ case 'copy_message': case 'spam_report': case 'notspam_report': $action = str_replace('_report', '', $vars->actionID); - switch (IMP_Spam::reportSpam($indices, $action)) { + switch (IMP_Spam::reportSpam($indices, $action, array('mailboxob' => $imp_mailbox))) { case 1: if ($imp_ui->moveAfterAction()) { $imp_mailbox->setIndex(1);