v5.0-git
--------
+[mms] Add strip attachments support in DIMP.
[mms] Add PGP & S/MIME compose support to DIMP.
[mms] Check for incorrect identity on compose if a single recipient address
is tied to a different identity than the sending identity.
var DimpBase = {
// Vars used and defaulting to null/false:
- // cfolderaction, folder, folderswitch, pollPE, pp, resize, rownum,
- // search, splitbar, template, uid, viewport
+ // cfolderaction, folder, folderswitch, pollPE, pp, preview_replace,
+ // resize, rownum, search, splitbar, template, uid, viewport
// msglist_template_horiz and msglist_template_vert set via
// js/mailbox-dimp.js
cacheids: {},
this.toggleButtons();
if (e.memo.opts.right || !count) {
- this.clearPreviewPane();
+ if (!this.preview_replace) {
+ this.clearPreviewPane();
+ }
} else if ((count == 1) && DIMP.conf.preview_pref) {
this.loadPreview(sel.get('dataob').first());
}
location.hash = encodeURIComponent('msg:' + row.view + ':' + row.imapuid);
},
+ _stripAttachmentCallback: function(r)
+ {
+ // Let the normal viewport refresh code and preview display code
+ // handle replacing the current preview. Set preview_replace to
+ // prevent a refresh flicker, since viewport refreshing would normally
+ // cause the preview pane to be cleared.
+ if (DimpCore.inAjaxCallback) {
+ this.preview_replace = true;
+ this.uid = r.response.newuid;
+ this._stripAttachmentCallback.bind(this, r).defer();
+ return;
+ }
+
+ this.preview_replace = false;
+
+ // Remove old cache value.
+ this._expirePPCache([ this._getPPId(r.olduid, r.oldmbox) ]);
+ },
+
// opts = mailbox, uid
updateMsgLog: function(log, opts)
{
DimpCore.popupWindow(DimpCore.addURLParam(DIMP.conf.URI_VIEW, { uid: this.pp.imapuid, mailbox: this.pp.view, actionID: 'print_attach', id: elt.readAttribute('mimeid') }, true), this.pp.imapuid + '|' + this.pp.view + '|print', IMP.printWindow);
e.stop();
return;
+ } else if (elt.hasClassName('stripAtc')) {
+ this.loadingImg('msg', true);
+ DimpCore.doAction('stripAttachment', this.viewport.addRequestParams({ id: elt.readAttribute('mimeid') }), { uids: this.viewport.createSelection('dataob', this.pp), callback: this._stripAttachmentCallback.bind(this) });
+ e.stop();
+ return;
}
}
DimpCore.popupWindow(DimpCore.addURLParam(DIMP.conf.URI_VIEW, { uid: this.uid, mailbox: this.mailbox, actionID: 'print_attach', id: elt.readAttribute('mimeid') }, true), this.uid + '|' + this.mailbox + '|print', IMP.printWindow);
e.stop();
return;
+ } else if (elt.hasClassName('stripAtc')) {
+ DimpCore.reloadMessage({
+ actionID: 'strip_attachment',
+ mailbox: this.mailbox,
+ id: elt.readAttribute('mimeid'),
+ uid: this.uid
+ });
+ e.stop();
+ return;
}
break;
}
DimpCore.updateMsgLog(this.log);
}
+ if (this.strip && DIMP.baseWindow && DIMP.baseWindow.DimpBase) {
+ DIMP.baseWindow.DimpBase.poll();
+ }
+
$('dimpLoading').hide();
$('pageContainer').show();
*
* Variables used:
* <pre>
- * 'uid' - (string) Indices of the messages to isend MDN for (IMAP sequence
+ * 'uid' - (string) Indices of the messages to send MDN for (IMAP sequence
* string).
* 'view' - (string) The current full mailbox.
* </pre>
}
/**
+ * AJAX action: strip attachment.
+ *
+ * See the list of variables needed for _changed() and
+ * _checkUidvalidity(). Additional variables used:
+ * <pre>
+ * 'uid' - (string) Index of the messages to preview (IMAP sequence
+ * string) - must be single index.
+ * </pre>
+ *
+ * @return mixed False on failure, the return from showPreview() on
+ * success along with these properties:
+ * <pre>
+ * 'newuid' - (integer) UID of new message.
+ * 'oldmbox' - (string) Mailbox of old message.
+ * 'olduid' - (integer) UID of old message.
+ * 'ViewPort' - (object) See _viewPortData().
+ * </pre>
+ */
+ public function stripAttachment()
+ {
+ $indices = new IMP_Indices($this->_vars->uid);
+ if ($indices->count() != 1) {
+ return false;
+ }
+
+ $change = $this->_changed(false);
+ if (is_null($change)) {
+ return false;
+ }
+
+ try {
+ $new_indices = $GLOBALS['injector']->getInstance('IMP_Message')->stripPart($indices, $this->_vars->id);
+ } catch (IMP_Exception $e) {
+ $GLOBALS['notification']->push($e);
+ return false;
+ }
+
+ $GLOBALS['notification']->push(_("Attachment successfully stripped."), 'horde.success');
+
+ $this->_vars->uid = strval($new_indices);
+
+ $result = $this->showPreview();
+ $new_indices_list = $new_indices->getSingle();
+ $result->newuid = intval($new_indices_list[1]);
+ $old_indices_list = $indices->getSingle();
+ $result->oldmbox = $old_indices_list[0];
+ $result->olduid = intval($old_indices_list[1]);
+ $result->ViewPort = $this->_viewPortData(true);
+
+ return $result;
+ }
+
+ /**
* AJAX action: Add an attachment to a compose message.
*
* Variables used:
* Generate the information necessary for a ViewPort request from/to the
* browser.
*
- * @param boolean $change True if cache information has changed.
+ * @param boolean $change True if cache information has changed.
*
* @return array See IMP_Views_ListMessages::listMessages().
*/
const SUMMARY_PRINT = 1024;
const SUMMARY_PRINT_STUB = 2048;
const SUMMARY_STRIP_LINK = 4096;
+ const SUMMARY_STRIP_STUB = 8192;
/* Rendering mask entries. */
const RENDER_FULL = 1;
* Output: parts = 'print'
*
* IMP_Contents::SUMMARY_STRIP_LINK
+ * IMP_Contents::SUMMARY_STRIP_STUB
* Output: parts = 'strip'
* </pre>
*
/* Strip Attachment? Allow stripping of base parts other than the
* base multipart and the base text (body) part. */
- if (($mask & self::SUMMARY_STRIP_LINK) &&
+ if ((($mask & self::SUMMARY_STRIP_LINK) ||
+ ($mask & self::SUMMARY_STRIP_STUB)) &&
($id != 0) &&
(intval($id) != 1) &&
(strpos($id, '.') === false)) {
- $url = Horde::selfUrl(true)->remove(array('actionID', 'imapid', 'uid'))->add(array('actionID' => 'strip_attachment', 'imapid' => $id, 'uid' => $this->_uid, 'message_token' => Horde::getRequestToken('imp.impcontents')));
- $part['strip'] = Horde::link($url, _("Strip Attachment"), 'deleteImg', null, "return window.confirm('" . addslashes(_("Are you sure you wish to PERMANENTLY delete this attachment?")) . "');") . '</a>';
+ if ($mask & self::SUMMARY_STRIP_LINK) {
+ $url = Horde::selfUrl(true)->remove(array('actionID', 'imapid', 'uid'))->add(array('actionID' => 'strip_attachment', 'imapid' => $id, 'uid' => $this->_uid, 'message_token' => Horde::getRequestToken('imp.impcontents')));
+ $part['strip'] = Horde::link($url, _("Strip Attachment"), 'deleteImg', null, "return window.confirm('" . addslashes(_("Are you sure you wish to PERMANENTLY delete this attachment?")) . "');") . '</a>';
+ } else {
+ $part['strip'] = Horde::link('#', _("Strip Attachment"), 'deleteImg stripAtc', null, null, null, null, array('mimeid' => $id)) . '</a>';
+ }
}
return $part;
* @param string $partid The MIME ID of the part to strip. All
* parts are stripped if null.
*
+ * @return IMP_Indices Returns the new indices object.
* @throws IMP_Exception
*/
public function stripPart($indices, $partid = null)
/* 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 $result;
}
+ if (!isset($fetch_ret[$uid]['headertext'])) {
+ $result['error'] = $error_msg;
+ $result['errortype'] = 'horde.error';
+ return $result;
+ }
+
/* Parse MIME info and create the body of the message. */
try {
$imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb(new IMP_Indices($mailbox, $uid));
IMP_Contents::SUMMARY_DESCRIP_LINK |
IMP_Contents::SUMMARY_DOWNLOAD |
IMP_Contents::SUMMARY_DOWNLOAD_ZIP |
- IMP_Contents::SUMMARY_PRINT_STUB;
+ IMP_Contents::SUMMARY_PRINT_STUB |
+ IMP_Contents::SUMMARY_STRIP_STUB;
$part_info = $part_info_display = array('icon', 'description', 'size', 'download', 'download_zip');
$part_info_display[] = 'print';
+ $part_info_display[] = 'strip';
/* Do MDN processing now. */
if ($imp_ui->MDNCheck($mailbox, $uid, $mime_headers)) {
require_once dirname(__FILE__) . '/lib/Application.php';
Horde_Registry::appInit('imp', array('impmode' => 'dimp'));
-$folder = Horde_Util::getFormData('folder');
-$uid = Horde_Util::getFormData('uid');
-if (!$uid || !$folder) {
+$vars = Horde_Variables::getDefaultVariables();
+
+if (!$vars->uid || !$vars->folder) {
exit;
}
$imp_ui = new IMP_Ui_Message();
-$readonly = $injector->getInstance('IMP_Imap')->getOb()->isReadOnly($folder);
+$js_onload = $js_out = array();
+$readonly = $injector->getInstance('IMP_Imap')->getOb()->isReadOnly($vars->folder);
+
+switch ($vars->actionID) {
+case 'strip_attachment':
+ try {
+ $indices = $injector->getInstance('IMP_Message')->stripPart(new IMP_Indices($vars->folder, $vars->uid), $vars->id);
+ $js_out[] = 'DimpFullmessage.strip = 1';
+ list(,$vars->uid) = $indices->getSingle();
+ $notification->push(_("Attachment successfully stripped."), 'horde.success');
+ } catch (IMP_Exception $e) {
+ $notification->push($e);
+ }
+ break;
+}
$args = array(
'headers' => array_diff(array_keys($imp_ui->basicHeaders()), array('subject')),
- 'mailbox' => $folder,
+ 'mailbox' => $vars->folder,
'preview' => false,
- 'uid' => $uid
+ 'uid' => $vars->uid
);
$show_msg = new IMP_Views_ShowMessage();
array('md5.js', 'horde')
);
-$js_onload = $js_out = array();
foreach (array('from', 'to', 'cc', 'bcc', 'replyTo', 'log', 'uid', 'mailbox') as $val) {
if (!empty($show_msg_result[$val])) {
$js_out[] = 'DimpFullmessage.' . $val . ' = ' . Horde_Serialize::serialize($show_msg_result[$val], Horde_Serialize::JSON);
if (!$disable_compose) {
$compose_args = array(
- 'folder' => $folder,
+ 'folder' => $vars->folder,
'messageCache' => '',
'popup' => false,
'qreply' => true,
- 'uid' => $uid,
+ 'uid' => $vars->uid,
);
$compose_result = IMP_Views_Compose::showCompose($compose_args);
<div class="headercloseimg closeImg" id="windowclose" title="X"></div>
<div><?php echo IMP_Dimp::actionButton(array('class' => 'hasmenu', 'icon' => 'Reply', 'id' => 'reply_link', 'title' => _("Reply"))) ?></div>
<div><?php echo IMP_Dimp::actionButton(array('class' => 'hasmenu', 'icon' => 'Forward', 'id' => 'forward_link', 'title' => _("Forward"))) ?></div>
-<?php if (!empty($conf['spam']['reporting']) && (!$conf['spam']['spamfolder'] || ($folder != IMP::folderPref($prefs->getValue('spam_folder'), true)))): ?>
+<?php if (!empty($conf['spam']['reporting']) && (!$conf['spam']['spamfolder'] || ($vars->folder != IMP::folderPref($prefs->getValue('spam_folder'), true)))): ?>
<div><?php echo IMP_Dimp::actionButton(array('icon' => 'Spam', 'id' => 'button_spam', 'title' => _("Spam"))) ?></div>
<?php endif; ?>
-<?php if (!empty($conf['notspam']['reporting']) && (!$conf['notspam']['spamfolder'] || ($folder == IMP::folderPref($prefs->getValue('spam_folder'), true)))): ?>
+<?php if (!empty($conf['notspam']['reporting']) && (!$conf['notspam']['spamfolder'] || ($vars->folder == IMP::folderPref($prefs->getValue('spam_folder'), true)))): ?>
<div><?php echo IMP_Dimp::actionButton(array('icon' => 'Ham', 'id' => 'button_ham', 'title' => _("Innocent"))) ?></div>
<?php endif; ?>
<?php if (!$readonly): ?>