diff --git a/addressbook/js/app.js b/addressbook/js/app.js
index 590678f4ee..e23cbd4525 100644
--- a/addressbook/js/app.js
+++ b/addressbook/js/app.js
@@ -770,7 +770,7 @@ app.classes.addressbook = AppJS.extend(
adb_mail_vcard: function(_action, _elems)
{
var link = {'preset[type]':[], 'preset[file]':[]};
- var content = {vcard:{file:[], type:[]}};
+ var content = {data:{files:{file:[], type:[]}}};
var nm = this.et2.getWidgetById('nm');
if(fetchAll(_elems, nm, jQuery.proxy(function(ids) {
this.adb_mail_vcard(_action, ids.map(function(num) {return {id:'addressbook::'+num};}));
@@ -786,8 +786,8 @@ app.classes.addressbook = AppJS.extend(
idToUse = idToUseArray[1];
link['preset[type]'].push("text/vcard; charset="+(egw.preference('vcard_charset', 'addressbook') || 'utf-8'));
link['preset[file]'].push("vfs://default/apps/addressbook/"+idToUse+"/.entry");
- content.vcard.file.push("vfs://default/apps/addressbook/"+idToUse+"/.entry");
- content.vcard.type.push("text/vcard; charset="+(egw.preference('vcard_charset', 'addressbook') || 'utf-8'));
+ content.data.files.file.push("vfs://default/apps/addressbook/"+idToUse+"/.entry");
+ content.data.files.type.push("text/vcard; charset="+(egw.preference('vcard_charset', 'addressbook') || 'utf-8'));
}
egw.openWithinWindow("mail", "setCompose", content, link, /mail.mail_compose.compose/);
@@ -854,7 +854,7 @@ app.classes.addressbook = AppJS.extend(
//remove comma in personal as it will confilict with mail content comma seperator in the process
personal = personal.replace(/,/g,'');
-
+
if(email_business)
{
emails.push((personal?personal+' <':'')+email_business+(personal?'>':''));
diff --git a/api/js/jsapi/egw_open.js b/api/js/jsapi/egw_open.js
index 9379a30871..bdabf6b921 100644
--- a/api/js/jsapi/egw_open.js
+++ b/api/js/jsapi/egw_open.js
@@ -482,7 +482,7 @@ egw.extend('open', egw.MODULE_WND_LOCAL, function(_egw, _wnd)
}
len += tmp.length;
}
- else
+ else if(_extra[i])
{
len += _extra[i].length;
}
diff --git a/filemanager/js/app.js b/filemanager/js/app.js
index 44e2a077d0..4b4bcc8c7b 100644
--- a/filemanager/js/app.js
+++ b/filemanager/js/app.js
@@ -260,13 +260,15 @@ app.classes.filemanager = AppJS.extend(
if (typeof attachments == 'undefined') attachments = this.get_clipboard_files();
if (!params || typeof params != 'object') params = {};
if (!(attachments instanceof Array)) attachments = [ attachments ];
+ var content = {data:{files:{file:[]}}};
for(var i=0; i < attachments.length; i++)
{
- params['preset[file]['+i+']'] = 'vfs://default'+attachments[i];
+ params['preset[file]['+i+']'] = 'vfs://default'+attachments[i];
+ content.data.files.file.push('vfs://default'+attachments[i]);
}
// always open compose in html mode, as attachment links look a lot nicer in html
params.mimeType = 'html';
- egw.open('', 'mail', 'add', params);
+ return egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/);
},
/**
diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php
index ffb45b609c..6e56b88bd0 100644
--- a/mail/inc/class.mail_compose.inc.php
+++ b/mail/inc/class.mail_compose.inc.php
@@ -313,6 +313,29 @@ class mail_compose
//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
+
+ // fetch appendix data which is an assistance input value consisiting of json data
+ if ($_content['appendix_data'])
+ {
+ $appendix_data = json_decode($_content['appendix_data'], true);
+ }
+
+ if ($appendix_data['emails'])
+ {
+ try {
+ $attched_uids = $this->_get_uids_as_attachments($appendix_data['emails']['ids'], $_content['serverID']);
+ if (is_array($attched_uids))
+ {
+ $_content['attachments'] = array_merge_recursive((array)$_content['attachments'], $attched_uids);
+ }
+ } catch (Exception $ex) {
+ Framework::message($ex->getMessage(), 'error');
+ }
+ $suppressSigOnTop = true;
+ unset($appendix_data);
+ $_content['appendix_data'] = '';
+ }
+
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
@@ -782,14 +805,13 @@ class mail_compose
// do not double insert a signature on a server roundtrip
if ($buttonClicked) $suppressSigOnTop = true;
- // On submit reads vcard_from_ab widget's value and addes them as attachments.
+ // On submit reads external_vcard widget's value and addes them as attachments.
// this happens when we send vcards from addressbook to an opened compose
// dialog.
- if ($_content['vcard_from_ab'])
+ if ($appendix_data['files'])
{
- $vcard = json_decode($_content['vcard_from_ab'], true);
- $_REQUEST['preset']['file'] = $vcard['file'];
- $_REQUEST['preset']['type'] = $vcard['type'];
+ $_REQUEST['preset']['file'] = $appendix_data['files']['file'];
+ $_REQUEST['preset']['type'] = $appendix_data['files']['type'];
$suppressSigOnTop = true;
unset($_content['attachments']);
$this->addPresetFiles($content, $insertSigOnTop, true);
@@ -3810,4 +3832,40 @@ class mail_compose
throw new $e;
}
}
+
+ /**
+ * Builds attachments from provided UIDs and add them to sessionData
+ *
+ * @param string|array $_ids series of message ids
+ * @param int $_serverID compose current profileID
+ *
+ * @return array returns an array of attachments
+ *
+ * @throws Exception throws exception on cross account attempt
+ */
+ function _get_uids_as_attachments ($_ids, $_serverID)
+ {
+ $ids = is_array($_ids) ? $_ids : explode(',', $_ids);
+ if (is_array($ids) && $_serverID)
+ {
+ $parts = mail_ui::splitRowID($ids[0]);
+ if ($_serverID != $parts['profileID'])
+ {
+ throw new Exception(lang('Cross account forward attachment is not allowed!'));
+ }
+ }
+ foreach ($ids as &$id)
+ {
+ $parts = mail_ui::splitRowID($id);
+ $mail_bo = $this->mail_bo;
+ $mail_bo->openConnection();
+ $mail_bo->reopen($parts['folder']);
+ $headers = $mail_bo->getMessageEnvelope($parts['msgUID'], null,false,$parts['folder']);
+ $this->addMessageAttachment($parts['msgUID'], null, $parts['folder'],
+ $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
+ 'MESSAGE/RFC822', $headers['SIZE'] ? $headers['SIZE'] : lang('unknown'));
+ $mail_bo->closeConnection();
+ }
+ return $this->sessionData['attachments'];
+ }
}
diff --git a/mail/js/app.js b/mail/js/app.js
index 5415f820e9..ef3b1eea32 100644
--- a/mail/js/app.js
+++ b/mail/js/app.js
@@ -638,6 +638,7 @@ app.classes.mail = AppJS.extend(
for(var j = 1; j < _elems.length; j++)
settings.id = settings.id + ',' + _elems[j].id;
}
+ return egw.openWithinWindow("mail", "setCompose", {data:{emails:{ids:settings.id}}}, settings, /mail.mail_compose.compose/);
}
else
{
@@ -689,10 +690,10 @@ app.classes.mail = AppJS.extend(
{
try
{
- if (field == 'vcard')
+ if (field == 'data')
{
- var vcard_from_ab = compose_et2[0].widgetContainer.getWidgetById('vcard_from_ab');
- vcard_from_ab.set_value(JSON.stringify(content.vcard));
+ var w = compose_et2[0].widgetContainer.getWidgetById('appendix_data');
+ w.set_value(JSON.stringify(content[field]));
return compose_et2[0].widgetContainer._inst.submit();
}
diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet
index bcab33e011..5a3dc9c25c 100644
--- a/mail/templates/default/compose.xet
+++ b/mail/templates/default/compose.xet
@@ -14,7 +14,7 @@
-
+