mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-28 08:02:31 +01:00
- Use mail_id in app.mail.compose() when there's no rows passed
- Some code consolidation in preparation for tracking open compose windows
This commit is contained in:
parent
ec2de1c7e6
commit
3b3986e27d
@ -281,6 +281,20 @@ class mail_compose
|
|||||||
error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
|
error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
|
||||||
|
|
||||||
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
|
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
|
||||||
|
if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
|
||||||
|
if (isset($_GET['part_id'])) $replyID = $_GET['part_id'];
|
||||||
|
|
||||||
|
// Process different places we can use as a start for composing an email
|
||||||
|
if($_GET['from'] && $replyID)
|
||||||
|
{
|
||||||
|
$_content = array_merge((array)$_content, $this->getComposeFrom(
|
||||||
|
// Parameters needed for fetching appropriate data
|
||||||
|
$replyID, $_GET['part_id'], $_GET['from'],
|
||||||
|
// Additionally may be changed
|
||||||
|
$_focusElement, $suppressSigOnTop, $isReply
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// VFS Selector was used
|
// VFS Selector was used
|
||||||
if (is_array($_content['selectFromVFSForCompose']))
|
if (is_array($_content['selectFromVFSForCompose']))
|
||||||
{
|
{
|
||||||
@ -1115,36 +1129,60 @@ if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.' Attachment
|
|||||||
$etpl->exec('mail.mail_compose.testhtmlarea',$content,$sel_options,$readonlys,$preserv,2);
|
$etpl->exec('mail.mail_compose.testhtmlarea',$content,$sel_options,$readonlys,$preserv,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function composeFromDraft() {
|
/**
|
||||||
$replyID = $_GET['uid'];
|
* Get pre-fill a new compose based on an existing email
|
||||||
$hA = mail_ui::splitRowID($replyID);
|
*
|
||||||
$replyID = $hA['msgUID'];
|
* @param type $mail_id If composing based on an existing mail, this is the ID of the mail
|
||||||
|
* @param type $part_id For multi-part mails, indicates which part
|
||||||
|
* @param type $from Indicates what the mail is based on, and how to extract data.
|
||||||
|
* One of 'compose', 'composeasnew', 'reply', 'reply_all' or 'forward'
|
||||||
|
* @param boolean $_focusElement varchar subject, to, body supported
|
||||||
|
* @param boolean $suppressSigOnTop
|
||||||
|
* @param boolean $isReply
|
||||||
|
*
|
||||||
|
* @return mixed[] Content array pre-filled according to source mail
|
||||||
|
*/
|
||||||
|
private function getComposeFrom($mail_id, $part_id, $from, &$_focusElement, &$suppressSigOnTop, &$isReply)
|
||||||
|
{
|
||||||
|
$content = array();
|
||||||
|
|
||||||
|
$hA = mail_ui::splitRowID($mail_id);
|
||||||
|
$msgUID = $hA['msgUID'];
|
||||||
$folder = $hA['folder'];
|
$folder = $hA['folder'];
|
||||||
$icServer = $hA['profileID'];
|
$icServer = $hA['profileID'];
|
||||||
|
|
||||||
if (!empty($folder) && !empty($replyID) ) {
|
if (!empty($folder) && !empty($msgUID) )
|
||||||
// this fill the session data with the values from the original email
|
|
||||||
$content = $this->getDraftData($icServer, $folder, $replyID);
|
|
||||||
}
|
|
||||||
$this->compose($content,null,'body',$suppressSigOnTop=true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function forward() {
|
|
||||||
$replyID = $_GET['reply_id'];
|
|
||||||
$partID = $_GET['part_id'];
|
|
||||||
$hA = mail_ui::splitRowID($replyID);
|
|
||||||
$replyID = $hA['msgUID'];
|
|
||||||
$folder = $hA['folder'];
|
|
||||||
$icServer = $hA['profileID'];
|
|
||||||
$mode = false;
|
|
||||||
if (isset($_GET['mode']) && ($_GET['mode']=='forwardasattach'||$_GET['mode']=='forwardinline')) $mode = ($_GET['mode']=='forwardinline'?'inline':'asattach');
|
|
||||||
if (!empty($replyID))
|
|
||||||
{
|
{
|
||||||
// this fill the session data with the values from the original email
|
// this fill the session data with the values from the original email
|
||||||
$content = $this->getForwardData($icServer, $folder, $replyID, $partID, $mode);
|
switch($from)
|
||||||
|
{
|
||||||
|
case 'composeasnew':
|
||||||
|
case 'composefromdraft':
|
||||||
|
$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
|
||||||
|
|
||||||
|
$_focusElement = 'body';
|
||||||
|
$suppressSigOnTop = true;
|
||||||
|
break;
|
||||||
|
case 'reply':
|
||||||
|
case 'replyAll':
|
||||||
|
$content = $this->getReplyData($from == 'reply' ? 'single' : 'all', $icServer, $folder, $msgUID, $part_id);
|
||||||
|
|
||||||
|
$_focusElement = 'body';
|
||||||
|
$supressSigOnTop = true;
|
||||||
|
$isReply = true;
|
||||||
|
break;
|
||||||
|
case 'forward':
|
||||||
|
$mode = ($_GET['mode']=='forwardinline'?'inline':'asattach');
|
||||||
|
$content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode);
|
||||||
|
|
||||||
|
$isReply = ($mode?$mode=='inline':$this->preferencesArray['message_forwarding'] == 'inline');
|
||||||
|
$_focusElement = 'to';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_log('Unhandled compose source: ' . $from);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$handleAsReply = ($mode?$mode=='inline':$this->preferencesArray['message_forwarding'] == 'inline');
|
return $content;
|
||||||
$this->compose($content,null,'to',false, $handleAsReply);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAttachment()
|
function getAttachment()
|
||||||
@ -1215,47 +1253,7 @@ if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.' Attachment
|
|||||||
print $folderTree;
|
print $folderTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
function composeAsNew() {
|
|
||||||
$replyID = $_GET['reply_id'];
|
|
||||||
$partID = $_GET['part_id'];
|
|
||||||
$hA = mail_ui::splitRowID($replyID);
|
|
||||||
$replyID = $hA['msgUID'];
|
|
||||||
$folder = $hA['folder'];
|
|
||||||
$icServer = $hA['profileID'];
|
|
||||||
if (!empty($folder) && !empty($replyID) ) {
|
|
||||||
// this fill the session data with the values from the original email
|
|
||||||
$content = $this->getDraftData($icServer, $folder, $replyID, $partID);
|
|
||||||
}
|
|
||||||
$this->compose($content,null,'body',true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reply() {
|
|
||||||
$replyID = $_GET['reply_id'];
|
|
||||||
$partID = $_GET['part_id'];
|
|
||||||
$hA = mail_ui::splitRowID($replyID);
|
|
||||||
$replyID = $hA['msgUID'];
|
|
||||||
$folder = $hA['folder'];
|
|
||||||
$icServer = $hA['profileID'];
|
|
||||||
if (!empty($folder) && !empty($replyID) ) {
|
|
||||||
// this fill the session data with the values from the original email
|
|
||||||
$content = $this->getReplyData('single', $icServer, $folder, $replyID, $partID);
|
|
||||||
}
|
|
||||||
$this->compose($content,null,'body',false,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function replyAll() {
|
|
||||||
$replyID = $_GET['reply_id'];
|
|
||||||
$partID = $_GET['part_id'];
|
|
||||||
$hA = mail_ui::splitRowID($replyID);
|
|
||||||
$replyID = $hA['msgUID'];
|
|
||||||
$folder = $hA['folder'];
|
|
||||||
$icServer = $hA['profileID'];
|
|
||||||
if (!empty($folder) && !empty($replyID) ) {
|
|
||||||
// this fill the session data with the values from the original email
|
|
||||||
$content = $this->getReplyData('all', $icServer, $folder, $replyID, $partID);
|
|
||||||
}
|
|
||||||
$this->compose($content,null,'body',false,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* previous bocompose stuff
|
* previous bocompose stuff
|
||||||
@ -1588,7 +1586,7 @@ if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.' Attachment
|
|||||||
$userEMailAddresses = $this->preferences->getUserEMailAddresses();
|
$userEMailAddresses = $this->preferences->getUserEMailAddresses();
|
||||||
|
|
||||||
// get message headers for specified message
|
// get message headers for specified message
|
||||||
#print "AAAA: $_folder, $_uid, $_partID<br>";
|
print "AAAA: $_folder, $_uid, $_partID<br>";
|
||||||
$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
|
$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
|
||||||
#$headers = $mail_bo->getMessageHeader($_uid, $_partID);
|
#$headers = $mail_bo->getMessageHeader($_uid, $_partID);
|
||||||
$this->sessionData['uid'] = $_uid;
|
$this->sessionData['uid'] = $_uid;
|
||||||
|
109
mail/js/app.js
109
mail/js/app.js
@ -194,73 +194,60 @@ app.mail = AppJS.extend(
|
|||||||
*/
|
*/
|
||||||
mail_compose: function(_action, _elems)
|
mail_compose: function(_action, _elems)
|
||||||
{
|
{
|
||||||
var idsToProcess = '';
|
// Extra info passed to egw.open()
|
||||||
var multipleIds = false;
|
var settings = {
|
||||||
var url = window.egw_webserverUrl+'/index.php?';
|
// 'Source' Mail UID
|
||||||
|
id: '',
|
||||||
|
// How to pull data from the Mail IDs for the compose
|
||||||
|
from: ''
|
||||||
|
};
|
||||||
|
|
||||||
if (typeof _elems == 'undefined')
|
if (typeof _elems == 'undefined')
|
||||||
{
|
{
|
||||||
var h = egw().open('','mail','add');
|
// No ids, try from content
|
||||||
return true;
|
settings.id = this.et2.getArrayMgr("content").getEntry('mail_id') || '';
|
||||||
}
|
}
|
||||||
if (_elems.length > 1) multipleIds = true;
|
else
|
||||||
//for (var i=0; i<_elems.length; i++)
|
|
||||||
//{
|
|
||||||
// if (i>0) idsToProcess += ',';
|
|
||||||
// idsToProcess += _elems[i].id;
|
|
||||||
//}
|
|
||||||
//alert('mail_'+_action.id+'('+idsToProcess+')');
|
|
||||||
if (_action.id == 'compose')
|
|
||||||
{
|
{
|
||||||
if (multipleIds == false)
|
// We only handle one for everything but forward
|
||||||
{
|
settings.id = _elems[0].id;
|
||||||
if (_elems.length == 1) mail_parentRefreshListRowStyle(_elems[0].id,_elems[0].id);
|
|
||||||
url += 'menuaction=mail.mail_compose.compose';
|
|
||||||
this.mail_openComposeWindow(url)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.mail_compose('forward',_elems);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (_action.id == 'composefromdraft')
|
|
||||||
|
switch(_action.id)
|
||||||
{
|
{
|
||||||
url += 'menuaction=mail.mail_compose.composeFromDraft';
|
case 'compose':
|
||||||
url += '&id='+_elems[0].id;
|
if (_elems.length == 1)
|
||||||
egw_openWindowCentered(url,'composeasnew_'+_elems[0].id,870,egw_getWindowOuterHeight());
|
{
|
||||||
}
|
mail_parentRefreshListRowStyle(settings.id,settings.id);
|
||||||
if (_action.id == 'composeasnew')
|
}
|
||||||
{
|
else
|
||||||
url += 'menuaction=mail.mail_compose.composeAsNew';
|
{
|
||||||
url += '&reply_id='+_elems[0].id;
|
return this.mail_compose('forward',_elems);
|
||||||
egw_openWindowCentered(url,'composeasnew_'+_elems[0].id,870,egw_getWindowOuterHeight());
|
}
|
||||||
}
|
break;
|
||||||
if (_action.id == 'reply')
|
case 'forward':
|
||||||
{
|
case 'forwardinline':
|
||||||
url += 'menuaction=mail.mail_compose.reply';
|
case 'forwardasattach':
|
||||||
url += '&reply_id='+_elems[0].id;
|
if (_elems.length||_action.id == 'forwardasattach')
|
||||||
egw_openWindowCentered(url,'reply_'+_elems[0].id,870,egw_getWindowOuterHeight());
|
{
|
||||||
}
|
url = 'menuaction=mail.mail_compose.compose';
|
||||||
if (_action.id == 'reply_all')
|
return this.mail_openComposeWindow(url,_action.id == 'forwardasattach', _elems);
|
||||||
{
|
}
|
||||||
url += 'menuaction=mail.mail_compose.replyAll';
|
else
|
||||||
url += '&reply_id='+_elems[0].id;
|
{
|
||||||
egw_openWindowCentered(url,'replyAll_'+_elems[0].id,870,egw_getWindowOuterHeight());
|
settings.from = 'forward';
|
||||||
}
|
settings.mode = 'forwardinline';
|
||||||
if (_action.id == 'forward'||_action.id == 'forwardinline'||_action.id == 'forwardasattach')
|
}
|
||||||
{
|
break;
|
||||||
if (multipleIds||_action.id == 'forwardasattach')
|
default:
|
||||||
{
|
// No further client side processing needed for these
|
||||||
url += 'menuaction=mail.mail_compose.compose';
|
settings.from = _action.id;
|
||||||
mail_openComposeWindow(url,_action.id == 'forwardasattach');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url += 'menuaction=mail.mail_compose.forward';
|
|
||||||
url += '&reply_id='+_elems[0].id;
|
|
||||||
url += '&mode=forwardinline';
|
|
||||||
egw_openWindowCentered(url,'forward_'+_elems[0].id,870,egw_getWindowOuterHeight());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var window_name = settings.from + '_' + settings.id;
|
||||||
|
|
||||||
|
egw().open('','mail','add',settings,window_name);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -333,7 +320,7 @@ app.mail = AppJS.extend(
|
|||||||
sMessageList= 'AsForward&forwardmails=1&folder='+activeFolderB64+'&reply_id='+sMessageList.substring(0,sMessageList.length-1);
|
sMessageList= 'AsForward&forwardmails=1&folder='+activeFolderB64+'&reply_id='+sMessageList.substring(0,sMessageList.length-1);
|
||||||
}
|
}
|
||||||
//alert(sMessageList);
|
//alert(sMessageList);
|
||||||
egw_openWindowCentered(_url+sMessageList,'compose',870,egw_getWindowOuterHeight());
|
egw_openWindowCentered(window.egw_webserverUrl+'/index.php?'+_url+sMessageList,'compose',870,egw_getWindowOuterHeight());
|
||||||
}
|
}
|
||||||
//ToDo: reset message selection
|
//ToDo: reset message selection
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user