work in progress for compose

This commit is contained in:
Klaus Leithoff 2013-07-20 07:23:55 +00:00
parent 67d6775f54
commit 5b476d38e7
8 changed files with 2778 additions and 56 deletions

View File

@ -534,6 +534,36 @@ class mail_bo
return $selectedID;
}
/**
* generateIdentityString
* construct the string representing an Identity passed by $identity
* @var array/object $identity, identity object that holds realname, organization, emailaddress and signatureid
* @var boolean $fullString full or false=NamePart only is returned
* @return string - constructed of identity object data as defined in mailConfig
*/
static function generateIdentityString($identity, $fullString=true)
{
if (is_null(self::$mailConfig)) self::$mailConfig = config::read('mail');
// not set? -> use default, means full display of all available data
if (!isset(self::$mailConfig['how2displayIdentities'])) self::$mailConfig['how2displayIdentities']='';
switch (self::$mailConfig['how2displayIdentities'])
{
case 'email';
//$retData = str_replace('@',' ',$identity->emailAddress).($fullString===true?' <'.$identity->emailAddress.'>':'');
$retData = $identity->emailAddress.($fullString===true?' <'.$identity->emailAddress.'>':'');
break;
case 'nameNemail';
$retData = (!empty($identity->realName)?$identity->realName:substr_replace($identity->emailAddress,'',strpos($identity->emailAddress,'@'))).($fullString===true?' <'.$identity->emailAddress.'>':'');
break;
case 'orgNemail';
$retData = (!empty($identity->organization)?$identity->organization:substr_replace($identity->emailAddress,'',0,strpos($identity->emailAddress,'@')+1)).($fullString===true?' <'.$identity->emailAddress.'>':'');
break;
default:
$retData = $identity->realName.(!empty($identity->organization)?' '.$identity->organization:'').($fullString===true?' <'.$identity->emailAddress.'>':'');
}
return $retData;
}
/**
* closes a connection on the active Server ($this->icServer)
*
@ -4512,6 +4542,16 @@ class mail_bo
return $attachmentData;
}
/**
* getRandomString - function to be used to fetch a random string and md5 encode that one
* @param none
* @return string - a random number which is md5 encoded
*/
static function getRandomString() {
mt_srand((float) microtime() * 1000000);
return md5(mt_rand (100000, 999999));
}
/**
* functions to allow access to mails through other apps to fetch content
* used in infolog, tracker

File diff suppressed because it is too large Load Diff

View File

@ -84,9 +84,14 @@ class mail_hooks
'view_popup' => '850xegw_getWindowOuterHeight()',
'view_list' => 'mail.mail_ui.index',
'add' => array(
'menuaction' => 'felamimail.uicompose.compose',
'menuaction' => 'mail.mail_compose.compose',
),
'add_popup' => '850xegw_getWindowOuterHeight()',
'edit' => array(
'menuaction' => 'mail.mail_compose.compose',
),
'edit_id' => 'id',
'edit_popup' => '850xegw_getWindowOuterHeight()',
// register fmail as handler for .eml files
'mime' => array(
'message/rfc822' => array(
@ -788,7 +793,13 @@ class mail_hooks
// Destination div for folder tree
$file[] = array(
'no_lang' => true,
'text'=>'<span id="tree_target" class="dtree" />',
'text'=>'<span id="mail-index_buttonmailcreate" class="button" />',
'link'=>false,
'icon' => false
);
$file[] = array(
'no_lang' => true,
'text'=>'<span id="mail-tree_target" class="dtree" />',
'link'=>false,
'icon' => false
);

View File

@ -64,12 +64,12 @@ class mail_ui
* @var array
*/
var $searchTypes = array(
'quick' => 'quicksearch',
'subject' => 'subject',
'body' => 'message body',
'from' => 'from',
'to' => 'to',
'cc' => 'cc',
'quick' => 'quicksearch', // lang('quicksearch')
'subject' => 'subject', // lang('subject')
'body' => 'message body', // lang('message body')
'from' => 'from', // lang('from')
'to' => 'to', // lang('to')
'cc' => 'cc', // lang('cc')
);
/**
@ -78,12 +78,12 @@ class mail_ui
* @var array
*/
var $statusTypes = array(
'any' => 'any status',
'flagged' => 'flagged',
'unseen' => 'unread',
'answered' => 'replied',
'seen' => 'read',
'deleted' => 'deleted',
'any' => 'any status',// lang('any status')
'flagged' => 'flagged', // lang('flagged')
'unseen' => 'unread', // lang('unread')
'answered' => 'replied', // lang('replied')
'seen' => 'read', // lang('read')
'deleted' => 'deleted', // lang('deleted')
);
/**
@ -222,11 +222,11 @@ class mail_ui
if ($this->mail_bo->icServer->_connected == 1 && $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
{
$this->statusTypes = array_merge($this->statusTypes,array(
'keyword1' => 'urgent',
'keyword2' => 'job',
'keyword3' => 'personal',
'keyword4' => 'to do',
'keyword5' => 'later',
'keyword1' => 'urgent',//lang('urgent'),
'keyword2' => 'job', //lang('job'),
'keyword3' => 'personal',//lang('personal'),
'keyword4' => 'to do', //lang('to do'),
'keyword5' => 'later', //lang('later'),
));
}
@ -1546,6 +1546,9 @@ unset($query['actions']);
//_debug_array($_REQUEST);
if(isset($_GET['id'])) $rowID = $_GET['id'];
if(isset($_GET['part'])) $partID = $_GET['part'];
$htmlOptions = $this->mail_bo->htmlOptions;
if (!empty($_GET['tryastext'])) $htmlOptions = "only_if_no_text";
if (!empty($_GET['tryashtml'])) $htmlOptions = "always_display";
$hA = self::splitRowID($rowID);
$uid = $hA['msgUID'];
@ -1576,7 +1579,7 @@ unset($query['actions']);
'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
#print "<pre>";print_r($rawheaders);print"</pre>";exit;
$mailBody = $this->get_load_email_data($uid, $partID, $mailbox,false);
$mailBody = $this->get_load_email_data($uid, $partID, $mailbox, $htmlOptions,false);
//error_log(__METHOD__.__LINE__.$mailBody);
$this->mail_bo->closeConnection();
$etpl = new etemplate_new('mail.display');
@ -2201,7 +2204,7 @@ unset($query['actions']);
}
function get_load_email_data($uid, $partID, $mailbox,$fullHeader=true)
function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null,$fullHeader=true)
{
// seems to be needed, as if we open a mail from notification popup that is
// located in a different folder, we experience: could not parse message
@ -2209,11 +2212,13 @@ unset($query['actions']);
$this->mailbox = $mailbox;
$this->uid = $uid;
$this->partID = $partID;
$bodyParts = $this->mail_bo->getMessageBody($uid, '', $partID, '', false, $mailbox);
$bufferHtmlOptions = $this->mail_bo->htmlOptions;
if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
$bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, '', false, $mailbox);
//error_log(__METHOD__.__LINE__.array2string($bodyParts));
$meetingRequest = false;
$fetchEmbeddedImages = false;
if ($this->mail_bo->htmlOptions !='always_display') $fetchEmbeddedImages = true;
if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, '',$fetchEmbeddedImages,true);
foreach ((array)$attachments as $key => $attach)
{
@ -2229,6 +2234,7 @@ $this->partID = $partID;
'method' => $attach['method'],
'sender' => $sender,
));
$this->mail_bo->htmlOptions = $bufferHtmlOptions;
return ExecMethod( 'calendar.calendar_uiforms.meeting',
array('event'=>null,'msg'=>'','useSession'=>true)
);
@ -2241,6 +2247,7 @@ $this->partID = $partID;
$this->showBody($this->getdisplayableBody($bodyParts), false,$fullHeader);
//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
$this->mail_bo->htmlOptions = $bufferHtmlOptions;
return $frameHtml;
}

View File

@ -114,11 +114,13 @@ app.mail = AppJS.extend(
*
* @param _action
* @param _senders - the representation of the elements(s) the action is to be performed on
* @param _mode - you may pass the mode. if not given view is used (tryastext|tryashtml are supported)
*/
mail_open: function(_action, _senders) {
mail_open: function(_action, _senders, _mode) {
//console.log("mail_open",_action, _senders);
var _id = _senders[0].id;
// reinitialize the buffer-info on selected mails
if (!(_mode == 'tryastext' || _mode == 'tryashtml' || _mode == 'view')) _mode = 'view';
this.mail_selectedMails = [];
this.mail_selectedMails.push(_id);
this.mail_currentlyFocussed = _id;
@ -126,7 +128,7 @@ app.mail = AppJS.extend(
var dataElem = egw.dataGetUIDdata(_id);
var subject = dataElem.data.subject;
//alert('Open Message:'+_id+' '+subject);
var h = egw().open( _id,'mail','view','view'+_id );
var h = egw().open( _id,'mail','view',_mode+'='+_id.replace(/=/g,"_") );
egw(h).ready(function() {
h.document.title = subject;
});
@ -140,21 +142,7 @@ app.mail = AppJS.extend(
*/
mail_openAsHtml: function(_action, _elems)
{
//alert('mail_open('+_elems[0].id+')');
if (activeFolderB64 == draftFolderB64 || activeFolderB64 == templateFolderB64)
{
// _action.id='composefromdraft';
// mail_compose(_action,_elems);
}
else
{
var url = window.egw_webserverUrl+'/index.php?';
url += 'menuaction=felamimail.uidisplay.display'; // todo compose for Draft folder
url += '&uid='+_elems[0].id;
url += '&tryashtml=1';
egw_openWindowCentered(_url,'displayMessage_'+_elems[0].id,'700','600',window.outerWidth/2,window.outerHeight/2);
}
this.mail_open(_action, _elems,'tryashtml');
},
/**
@ -165,21 +153,146 @@ app.mail = AppJS.extend(
*/
mail_openAsText: function(_action, _elems)
{
//alert('mail_open('+_elems[0].id+')');
if (activeFolderB64 == draftFolderB64 || activeFolderB64 == templateFolderB64)
this.mail_open(_action, _elems,'tryastext');
},
/**
* Compose, reply or forward a message
*
* @param _action _action.id is 'compose', 'composeasnew', 'reply', 'reply_all' or 'forward' (forward can be multiple messages)
* @param _elems _elems[0].id is the row-id
*/
mail_compose: function(_action, _elems)
{
var idsToProcess = '';
var multipleIds = false;
var url = window.egw_webserverUrl+'/index.php?';
if (typeof _elems == 'undefined')
{
// _action.id='composefromdraft';
// mail_compose(_action,_elems);
var h = egw().open('','mail','add');
return true;
}
if (_elems.length > 1) multipleIds = true;
//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)
{
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')
{
url += 'menuaction=mail.mail_compose.composeFromDraft';
url += '&id='+_elems[0].id;
egw_openWindowCentered(url,'composeasnew_'+_elems[0].id,700,egw_getWindowOuterHeight());
}
if (_action.id == 'composeasnew')
{
url += 'menuaction=mail.mail_compose.composeAsNew';
url += '&reply_id='+_elems[0].id;
egw_openWindowCentered(url,'composeasnew_'+_elems[0].id,700,egw_getWindowOuterHeight());
}
if (_action.id == 'reply')
{
url += 'menuaction=mail.mail_compose.reply';
url += '&reply_id='+_elems[0].id;
egw_openWindowCentered(url,'reply_'+_elems[0].id,700,egw_getWindowOuterHeight());
}
if (_action.id == 'reply_all')
{
url += 'menuaction=mail.mail_compose.replyAll';
url += '&reply_id='+_elems[0].id;
egw_openWindowCentered(url,'replyAll_'+_elems[0].id,700,egw_getWindowOuterHeight());
}
if (_action.id == 'forward'||_action.id == 'forwardinline'||_action.id == 'forwardasattach')
{
if (multipleIds||_action.id == 'forwardasattach')
{
url += 'menuaction=mail.mail_compose.compose';
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,700,egw_getWindowOuterHeight());
}
}
},
/**
* Compose, reply or forward a message
*
* @param _url url to open
* @param forwardByCompose boolean to decide about the method
*/
mail_openComposeWindow: function(_url,forwardByCompose,_elems) {
var Check=true;
var alreadyAsked=false;
var _messageList;
var sMessageList='';
//var cbAllMessages = document.getElementById('selectAllMessagesCheckBox').checked;
// check if mailgrid exists, before accessing it
var cbAllVisibleMessages;
if (typeof forwardByCompose == 'undefined') forwardByCompose = true;
if (forwardByCompose == false)
{
cbAllMessages = cbAllVisibleMessages = Check = false;
}
if (typeof prefAskForMultipleForward == 'undefined') prefAskForMultipleForward = egw.preference('prefaskformultipleforward','mail');
if (cbAllMessages == true || cbAllVisibleMessages == true)
{
Check = confirm(egw.lang('multiple forward of all mesages'));
alreadyAsked=true;
}
if ((cbAllMessages == true || cbAllVisibleMessages == true ) && Check == true)
{
//_messageList = 'all'; // all is not supported by now, only visibly selected messages are chosen
_messageList = this.mail_getFormData(_elems);
}
else
{
var url = window.egw_webserverUrl+'/index.php?';
url += 'menuaction=felamimail.uidisplay.display'; // todo compose for Draft folder
url += '&uid='+_elems[0].id;
url += '&tryastext=1';
egw_openWindowCentered(_url,'displayMessage_'+_elems[0].id,'700','600',window.outerWidth/2,window.outerHeight/2);
if (Check == true) _messageList = this.mail_getFormData(_elems);
}
if (typeof _messageList != 'undefined')
{
for (var i in _messageList['msg']) {
//alert('eigenschaft:'+_messageList['msg'][i]);
sMessageList=sMessageList+_messageList['msg'][i]+',';
//sMessageList.concat(',');
}
}
if (prefAskForMultipleForward == 1 && Check == true && alreadyAsked == false && sMessageList.length >0 && _messageList['msg'].length>1)
{
askme = egw.lang('multipleforward');
//if (cbAllMessages == true || cbAllVisibleMessages == true) askme = egw_appWindow('felamimail').lang_confirm_all_messages; // not supported
Check = confirm(askme);
}
//alert("Check:"+Check+" MessageList:"+sMessageList+"#");
if (Check != true) sMessageList=''; // deny the appending off selected messages to new compose -> reset the sMessageList
if (Check == true || sMessageList=='')
{
if (sMessageList.length >0) {
sMessageList= 'AsForward&forwardmails=1&folder='+activeFolderB64+'&reply_id='+sMessageList.substring(0,sMessageList.length-1);
}
//alert(sMessageList);
egw_openWindowCentered(_url+sMessageList,'compose',700,egw_getWindowOuterHeight());
}
//ToDo: reset message selection
},
/**

View File

@ -280,7 +280,7 @@ pre {
/*
influence the tree display and scrolling behavior
*/
#tree_target {
#mail-tree_target {
min-height: 35px;
max-height: 450px;
display: block;
@ -298,23 +298,32 @@ input[type=button] {
background-position: left;
}
#messageIFRAME {
#mail-index_messageIFRAME {
width: 100%;
height: 100%;
border: 0;
}
.mailDisplay, #mailPreview {
#mail-index_button\[mailcreate\] {
width: 99%;
text-align: left;
padding-left: 25px;
background-image: url(images/write_mail.png) !important;
background-position: left;
background-repeat: no-repeat;
}
.mailDisplay, #mail-index_mailPreview {
overflow: hidden;
position: relative;
margin-top: 3px;
}
#mailPreviewIcons {
#mail-index_mailPreviewIcons {
position: absolute;
right: 0;
top: 0;
}
#mailPreviewContainer {
#mail-index_mailPreviewContainer {
position: absolute;
border: 1px solid silver;
top: 55px;

View File

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="mail.compose" template="" lang="" group="0" version="1.9.001">
<html id="msg"/>
<vbox class="mailCompose mailComposeHeaderSection" width="100%">
<hbox class="mailComposeHeaders" width="100%">
<description value="From"/>
<html id="mail_composefromaddress" readonly="true"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<description value="on behalf of"/>
<html id="mail_composeonbehalfofaddress" readonly="true"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<description value="Cc"/>
<html id="mail_composeccaddress" readonly="true"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<description value="Bcc"/>
<html id="mail_composebccaddress" readonly="true"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<description value="Date"/>
<date-time align="left" id="mail_composedate" readonly="true"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<description value="Subject"/>
<description align="left" id="mail_composesubject" readonly="true"/>
</hbox>
<hbox class="mail_Composeicons">
<html id="mail_composeicons"/>
</hbox>
</vbox>
<vbox class="mailCompose" width="100%">
<hbox disabled="!@is_html">
<htmlarea span="all" id="mailtext" mode="$cont[rtfEditorFeatures]" height="320px" width="100%" toolbar="true" base_href="$cont[upload_dir]"/>
</hbox>
<hbox disabled="@is_html">
<textbox multiline="true" rows="15" cols="120" span="all" id="mailtext"/>
</hbox>
<box class="mailComposeAttachments">
<html id="mail_composeattachments"/>
</box>
</vbox>
</template>
</overlay>

View File

@ -38,7 +38,8 @@
</grid>
</template>
<template id="mail.index" template="" lang="" group="0" version="1.9.001">
<tree autoloading="mail.mail_ui.ajax_foldertree" id="nm[foldertree]" onclick="app.mail.mail_changeFolder(widget.event_args[0],widget);" parent_node="tree_target"/>
<tree autoloading="mail.mail_ui.ajax_foldertree" id="nm[foldertree]" onclick="app.mail.mail_changeFolder(widget.event_args[0],widget);" parent_node="mail-tree_target"/>
<buttononly id="button[mailcreate]" onclick="app.mail.mail_compose(false);" label="Compose" parent_node="mail-index_buttonmailcreate"/>
<html id="msg"/>
<split dock_side="bottomDock" id="mailSplitter" orientation="h">
<nextmatch id="nm" onselect="app.mail.mail_preview" template="mail.index.rows"/>