* 'type' - TODO
* 'to' - TODO
* 'uid' - TODO
+ * 'uids' - TODO
* </pre>
*
* Copyright 2005-2010 The Horde Project (http://www.horde.org/)
$identity->setDefault($vars->identity);
}
-/* Initialize the IMP_Compose:: object. */
+/* Init objects. */
$imp_compose = $injector->getInstance('IMP_Compose')->getOb();
-
-/* Init IMP_Ui_Compose:: object. */
$imp_ui = new IMP_Ui_Compose();
$show_editor = false;
$title = _("New Message");
-if (in_array($vars->type, array('reply', 'reply_all', 'reply_auto', 'reply_list', 'forward_attach', 'forward_auto', 'forward_body', 'forward_both', 'forward_redirect', 'resume'))) {
- if (!$vars->uid || !$vars->folder) {
- $vars->type = 'new';
- }
-
- try {
- $imp_contents = $injector->getInstance('IMP_Contents')->getOb(new IMP_Indices($vars->folder, $vars->uid));
- } catch (Horde_Exception $e) {
- $notification->push(_("Requested message not found."), 'horde.error');
- $vars->uid = $vars->folder = null;
- $vars->type = 'new';
- }
-}
-
switch ($vars->type) {
case 'reply':
case 'reply_all':
case 'reply_auto':
case 'reply_list':
- $reply_msg = $imp_compose->replyMessage($vars->type, $imp_contents, $header['to']);
+ try {
+ $contents = $imp_ui->getContents($vars);
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
+ break;
+ }
+
+ $reply_msg = $imp_compose->replyMessage($vars->type, reset($contents), $header['to']);
$msg = $reply_msg['body'];
$header = $reply_msg['headers'];
$header['replytype'] = 'reply';
case 'forward_auto':
case 'forward_body':
case 'forward_both':
- $fwd_msg = $imp_compose->forwardMessage($vars->type, $imp_contents);
- $msg = $fwd_msg['body'];
- $header = $fwd_msg['headers'];
- $header['replytype'] = 'forward';
- $title = $header['title'];
- if ($fwd_msg['format'] == 'html') {
- $show_editor = true;
+ if ($vars->uids) {
+ if (!in_array($vars->type, array('forward_attach', 'forward_auto'))) {
+ $notification->push(_("Multiple messages can only be forwarded as attachments."), 'horde.warning');
+ }
+
+ try {
+ $header = array(
+ 'replytype' => 'forward',
+ 'subject' => $imp_compose->attachImapMessage(new IMP_Indices($vars->uids))
+ );
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
+ break;
+ }
+
+ $rte = $show_editor = ($prefs->getValue('compose_html') && $_SESSION['imp']['rteavail']);
+ } else {
+ if (!($contents = $imp_ui->getContents($vars))) {
+ break;
}
- if ($vars->type == 'forward_auto') {
- $fillform_opts['auto'] = $fwd_msg['type'];
+ try {
+ $contents = $imp_ui->getContents($vars);
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
+ break;
}
- $vars->type = 'forward';
- if (!$prefs->isLocked('default_identity') &&
- !is_null($fwd_msg['identity'])) {
- $identity->setDefault($fwd_msg['identity']);
+ $fwd_msg = $imp_compose->forwardMessage($vars->type, $contents);
+ $msg = $fwd_msg['body'];
+ $header = $fwd_msg['headers'];
+ $header['replytype'] = 'forward';
+ $title = $header['title'];
+ if ($fwd_msg['format'] == 'html') {
+ $show_editor = true;
+ }
+ if ($vars->type == 'forward_auto') {
+ $fillform_opts['auto'] = $fwd_msg['type'];
+ }
+
+ if (!$prefs->isLocked('default_identity') &&
+ !is_null($fwd_msg['identity'])) {
+ $identity->setDefault($fwd_msg['identity']);
+ }
}
+
+ $vars->type = 'forward';
break;
case 'forward_redirect':
- $imp_compose->redirectMessage($imp_contents);
- $get_sig = false;
- $title = _("Redirect");
- $vars->type = 'redirect';
+ try {
+ $contents = $imp_ui->getContents($vars);
+ $imp_compose->redirectMessage(reset($contents));
+ $get_sig = false;
+ $title = _("Redirect");
+ $vars->type = 'redirect';
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
+ }
break;
case 'resume':
} else {
$imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc', 'redirect_to'));
$imp_ui->attachSpellChecker();
-
$sig = $identity->getSignature($show_editor ? 'html' : 'text');
if ($get_sig && !empty($sig)) {
if ($identity->getValue('sig_first')) {
$title = _("New Message");
switch ($vars->actionID) {
case 'mailto':
- if (!($imp_contents = $imp_ui->getIMPContents(new IMP_Indices(IMP::$thismailbox, IMP::$uid)))) {
+ try {
+ $contents = $imp_ui->getContents();
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
break;
}
- $imp_headers = $imp_contents->getHeaderOb();
+
+ $imp_headers = $contents->getHeaderOb();
$header['to'] = '';
if ($vars->mailto) {
$header['to'] = $imp_headers->getValue('to');
case 'reply_all':
case 'reply_auto':
case 'reply_list':
- if (!($imp_contents = $imp_ui->getIMPContents(new IMP_Indices(IMP::$thismailbox, IMP::$uid)))) {
+ try {
+ $contents = $imp_ui->getContents();
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
break;
}
- $reply_msg = $imp_compose->replyMessage($vars->actionID, $imp_contents, $vars->to);
+ $reply_msg = $imp_compose->replyMessage($vars->actionID, $contents, $vars->to);
$msg = $reply_msg['body'];
$header = $reply_msg['headers'];
$format = $reply_msg['format'];
case 'forward_auto':
case 'forward_body':
case 'forward_both':
- if (!($imp_contents = $imp_ui->getIMPContents(new IMP_Indices(IMP::$thismailbox, IMP::$uid)))) {
+ try {
+ $contents = $imp_ui->getContents();
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
break;
}
- $fwd_msg = $imp_compose->forwardMessage($vars->actionID, $imp_contents);
+ $fwd_msg = $imp_compose->forwardMessage($vars->actionID, $contents);
$msg = $fwd_msg['body'];
$header = $fwd_msg['headers'];
$format = $fwd_msg['format'];
break;
case 'redirect_compose':
- if (!($imp_contents = $imp_ui->getIMPContents(new IMP_Indices(IMP::$thismailbox, IMP::$uid)))) {
- break;
+ try {
+ $contents = $imp_ui->getContents();
+ $imp_compose->redirectMessage($contents);
+ $title = _("Redirect");
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
}
- $imp_compose->redirectMessage($imp_contents);
- $title = _("Redirect");
break;
case 'redirect_send':
exit;
case 'fwd_digest':
- if (isset($vars->fwddigest) &&
- (($subject_header = $imp_compose->attachIMAPMessage(new IMP_Indices($vars->fwddigest))) !== false)) {
- $header['subject'] = $subject_header;
+ if (isset($vars->fwddigest)) {
+ try {
+ $header['subject'] = $imp_compose->attachImapMessage(new IMP_Indices($vars->fwddigest));
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
+ }
}
break;
v5.0-git
--------
+[mms] Allow multiple messages to be forwarded in a single outgoing message
+ (DIMP) (Request #9132).
[mms] Add personal recipient message filter (Request #8659).
[mms] Add mailing list message filter (Request #8659).
[mms] Add ability to define search criteria to be applied to any mailbox
composeMailbox: function(type)
{
var sel = this.viewport.getSelected();
- if (!sel.size()) {
- return;
+ if (sel.size()) {
+ DimpCore.compose(type, { uids: sel });
}
- sel.get('dataob').each(function(s) {
- DimpCore.compose(type, { folder: s.view, uid: s.imapuid });
- });
},
loadMailbox: function(f, opts)
}
if (elt) {
- tmp = this.viewport.createSelection('domid', elt.identify()).get('dataob').first();
- if (tmp.draft && this.viewport.getMetaData('drafts')) {
- DimpCore.compose('resume', { folder: tmp.view, uid: tmp.imapuid })
+ tmp = this.viewport.createSelection('domid', elt.identify()).get('dataob');
+ if (tmp.first().draft && this.viewport.getMetaData('drafts')) {
+ DimpCore.compose('resume', { uids: tmp });
} else {
this.msgWindow(tmp);
}
compose: function(type, args)
{
- var url = DIMP.conf.URI_COMPOSE;
- args = args || {};
+ var params = {};
if (type) {
- args.type = type;
+ params.type = type;
+ }
+
+ if (type.startsWith('forward') || !args.uids) {
+ if (type.startsWith('forward')) {
+ params.uids = this.toRangeString(this.selectionToRange(args.uids));
+ }
+ this.popupWindow(this.addURLParam(DIMP.conf.URI_COMPOSE, params), 'compose' + new Date().getTime());
+ } else {
+ args.uids.get('dataob').each(function(d) {
+ params.folder = d.view;
+ params.uid = d.imapuid;
+ this.popupWindow(this.addURLParam(DIMP.conf.URI_COMPOSE, params), 'compose' + new Date().getTime());
+ }, this);
}
- this.popupWindow(this.addURLParam(url, args), 'compose' + new Date().getTime());
},
popupWindow: function(url, name, onload)
if ($attach &&
in_array($type, array('forward_attach', 'forward_both'))) {
- $this->attachIMAPMessage(new IMP_Indices($contents));
+ try {
+ $this->attachImapMessage(new IMP_Indices($contents));
+ } catch (IMP_Exception $e) {
+ }
}
if (in_array($type, array('forward_body', 'forward_both'))) {
*
* @param IMP_Indices $indices An indices object.
*
- * @return mixed String or false.
+ * @return string Subject string.
+ * @throws IMP_Exception
*/
- public function attachIMAPMessage($indices)
+ public function attachImapMessage($indices)
{
if (!count($indices)) {
return false;
$part->setName(_("Forwarded Message"));
$part->setContents($contents->fullMessageText(array('stream' => true)));
- try {
- $this->addMIMEPartAttachment($part);
- } catch (IMP_Compose_Exception $e) {
- $GLOBALS['notification']->push($e);
- return false;
- }
+ // Throws IMP_Compose_Exception.
+ $this->addMIMEPartAttachment($part);
}
if ($attached == 1) {
$name = Horde_String::truncate($name, 80);
}
return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->getBaseSubject($name, array('keepblob' => true));
- } else {
- return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
}
+
+ return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
}
/**
}
/**
- * Get the IMP_Contents:: object for a Mailbox/UID.
+ * Create the IMP_Contents objects needed to create a message.
*
- * @param IMP_Indices $indices An indices object.
+ * @param Horde_Variables $vars The variables object.
*
- * @return boolean|IMP_Contents The contents object, or false on error.
+ * @return IMP_Contents The IMP_Contents object.
+ * @throws IMP_Exception
*/
- public function getIMPContents($indices)
+ public function getContents($vars = null)
{
- try {
- return $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($indices);
- } catch (IMP_Exception $e) {
- $GLOBALS['notification']->push(_("Could not retrieve the message from the mail server."), 'horde.error');
+ $ob = null;
+
+ if (is_null($vars)) {
+ /* IMP: compose.php */
+ $indices = new IMP_Indices(IMP::$thismailbox, IMP::$uid);
+ } elseif ($vars->folder && $vars->uid) {
+ /* DIMP: compose-dimp.php */
+ $indices = new IMP_Indices($vars->folder, $vars->uid);
}
- return false;
+ if (!is_null($ob)) {
+ try {
+ $ob = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($indices);
+ } catch (Horde_Exception $e) {}
+ }
+
+ if (is_null($ob)) {
+ if (!is_null($vars)) {
+ $vars->folder = $vars->uid = null;
+ $vars->type = 'new';
+ }
+
+ throw new IMP_Exception(_("Could not retrieve message data from the mail server."));
+ }
+
+ return $ob;
}
/**