* Mail: take opened compose dialogs into account when trying to forward attachment, share files into mail or vcard attachment from addressbook

This commit is contained in:
Hadi Nategh 2018-07-11 14:39:28 +02:00
parent 484ea5cc60
commit cc3e00f9f1
6 changed files with 78 additions and 17 deletions

View File

@ -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?'>':''));

View File

@ -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;
}

View File

@ -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/);
},
/**

View File

@ -312,6 +312,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'];
@ -781,14 +804,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);
@ -3813,4 +3835,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'];
}
}

View File

@ -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();
}
@ -2126,7 +2127,7 @@ app.classes.mail = AppJS.extend(
// to reset iframes to the normal status
this.loadIframe();
// reset nm action selection, seems actions system accumulate selected items
// and that leads to corruption for selected all actions
this.et2.getWidgetById(this.nm_index).controller._selectionMgr.resetSelection();

View File

@ -14,7 +14,7 @@
<checkbox statustext="check to receive a notification when the message is read (note: not all clients support this and/or the receiver may not authorize the notification)" id="disposition" options="on,off"/>
<checkbox statustext="check to sign the message on send" id="smime_sign" options="on,off"/>
<checkbox statustext="check to encrypt the message on send" id="smime_encrypt" options="on,off"/>
<textbox id="vcard_from_ab"/>
<textbox id="appendix_data"/>
<passwd id="smime_passphrase"/>
<taglist id="to_integrate_ids"/>
<menulist>