* @param string $action Either 'spam' or 'notspam'.
* @param array $opts Additional options:
* <pre>
+ * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+ * DEFAULT: No update.
* 'noaction' - (boolean) Don't perform any action after reporting?
* DEFAULT: false
* </pre>
}
$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':
$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 {
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 {
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;
}
}
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') {
// '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
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);