* <pre>
* 'create' - (boolean) Should the target mailbox be created?
* DEFAULT: false
+ * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+ * DEFAULT: No update.
* </pre>
*
* @return boolean True if successful, false if not.
try {
$imp_imap->copy($mbox, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move));
- $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($mbox);
- if (($action == 'move') && $imp_mailbox->isBuilt()) {
- $imp_mailbox->removeMsgs(new IMP_Indices($mbox, $msgIndices));
+ if (($action == 'move') &&
+ !empty($opts['mailboxob']) &&
+ $opts['mailboxob']->isBuilt()) {
+ $opts['mailboxob']->removeMsgs(new IMP_Indices($mbox, $msgIndices));
}
if ($spam_report) {
* <pre>
* 'keeplog' - (boolean) Should any history information of the message be
* kept?
+ * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+ * DEFAULT: No update.
* 'nuke' - (boolean) Override user preferences and nuke (i.e. permanently
* delete) the messages instead?
* </pre>
try {
$imp_imap->copy($mbox, $trash, array('ids' => $msgIndices, 'move' => true));
- $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($mbox);
- if ($imp_mailbox->isBuilt()) {
- $imp_mailbox->removeMsgs($imp_indices);
+ if (!empty($options['mailboxob']) &&
+ $options['mailboxob']->isBuilt()) {
+ $options['mailboxob']->removeMsgs($imp_indices);
}
} catch (Horde_Imap_Client_Exception $e) {
// @todo Check for overquota error.
try {
$imp_imap->store($mbox, array('add' => array('\\deleted'), 'ids' => $msgIndices));
if ($expunge_now) {
- $this->expungeMailbox($imp_indices->indices());
+ $this->expungeMailbox(
+ $imp_indices->indices(),
+ array(
+ 'mailboxob' => empty($opts['mailboxob']) ? null : $opts['mailboxob']
+ )
+ );
}
} catch (Horde_Imap_Client_Exception $e) {}
* @param IMP_Indices $indices An indices object.
* @param string $partid The MIME ID of the part to strip. All
* parts are stripped if null.
+ * @param array $opts Additional options:
+ * <pre>
+ * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+ * DEFAULT: No update.
+ * </pre>
*
* @return IMP_Indices Returns the new indices object.
* @throws IMP_Exception
*/
- public function stripPart($indices, $partid = null)
+ public function stripPart($indices, $partid = null, array $opts = array())
{
list($mbox, $uid) = $indices->getSingle();
if (!$uid) {
throw new IMP_Exception(_("An error occured while attempting to strip the attachment."));
}
- $this->delete($indices, array('nuke' => true, 'keeplog' => true));
+ $this->delete($indices, array(
+ 'keeplog' => true,
+ 'mailboxob' => empty($opts['mailboxob']) ? null : $opts['mailboxob'],
+ 'nuke' => true
+ ));
- $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($mbox, new IMP_Indices($mbox, $new_uid));
+ $indices_ob = new IMP_Indices($mbox, $new_uid);
+
+ if (!empty($opts['mailboxob'])) {
+ $opts['mailboxob']->setIndex($indices_ob);
+ }
/* We need to replace the old index in the query string with the
* new index. */
$_SERVER['QUERY_STRING'] = str_replace($uid, $new_uid, $_SERVER['QUERY_STRING']);
- return new IMP_Indices($mbox, $new_uid);
+ return $indices_ob;
}
/**
* <pre>
* 'list' - (boolean) Return a list of messages expunged.
* DEFAULT: false
+ * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+ * DEFAULT: No update.
* </pre>
*
* @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())
+ public function expungeMailbox($mbox_list, array $options = array())
{
$msg_list = !empty($options['list']);
try {
$update_list[$key] = $imp_imap->expunge($key, array('ids' => is_array($val) ? $val : array(), 'list' => $msg_list));
- $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($key);
- if ($imp_mailbox->isBuilt()) {
- $imp_mailbox->removeMsgs(is_array($val) ? new IMP_Indices($key, $val) : true);
+ if (!empty($opts['mailboxob']) &&
+ $opts['mailboxob']->isBuilt()) {
+ $opts['mailboxob']->removeMsgs(is_array($val) ? new IMP_Indices($key, $val) : true);
}
} catch (Horde_Imap_Client_Exception $e) {}
}
if ($vars->actionID == 'undelete_message') {
$imp_message->undelete($indices);
} else {
- $imp_message->delete($indices);
+ $imp_message->delete(
+ $indices,
+ array(
+ 'mailboxob' => $imp_mailbox
+ )
+ );
if ($prefs->getValue('mailbox_return')) {
_returnToMailbox($imp_mailbox->getMessageIndex());
require IMP_BASE . '/mailbox.php';
} else {
$newMbox = false;
}
- $imp_message->copy($targetMbox, ($vars->actionID == 'move_message') ? 'move' : 'copy', $indices, array('create' => $newMbox));
+ $imp_message->copy(
+ $targetMbox,
+ ($vars->actionID == 'move_message') ? 'move' : 'copy',
+ $indices,
+ array(
+ 'create' => $newMbox,
+ 'mailboxob' => $imp_mailbox
+ )
+ );
if ($prefs->getValue('mailbox_return')) {
_returnToMailbox($imp_mailbox->getMessageIndex());
require IMP_BASE . '/mailbox.php';
case 'strip_all':
case 'strip_attachment':
try {
- $imp_message->stripPart($indices, ($vars->actionID == 'strip_all') ? null : $vars->imapid);
+ $imp_message->stripPart(
+ $indices,
+ ($vars->actionID == 'strip_all') ? null : $vars->imapid,
+ array(
+ 'mailboxob' => $imp_mailbox
+ )
+ );
$notification->push(_("Attachment successfully stripped."), 'horde.success');
} catch (Horde_Exception $e) {
$notification->push($e);