mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
* Mail: composed mails saved as draft contains again attachments, drafts created by autosaving every 2 minutes do not for performance reasons
This commit is contained in:
parent
343bffd902
commit
0413898ce4
@ -2142,10 +2142,11 @@ class mail_compose
|
|||||||
* @param egw_mailer $_mailObject
|
* @param egw_mailer $_mailObject
|
||||||
* @param array $_formData
|
* @param array $_formData
|
||||||
* @param array $_identity
|
* @param array $_identity
|
||||||
* @param boolean $_send =false true: create to send message: false: create to save as draft
|
* @param boolean $_autosaving =false true: autosaving, false: save-as-draft or send
|
||||||
*/
|
*/
|
||||||
function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_send=false)
|
function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
|
||||||
{
|
{
|
||||||
|
//error_log(__METHOD__."(, formDate[filemode]=$_formData[filemode], _autosaving=".array2string($_autosaving).') '.function_backtrace());
|
||||||
$mail_bo = $this->mail_bo;
|
$mail_bo = $this->mail_bo;
|
||||||
$activeMailProfile = emailadmin_account::read($this->mail_bo->profileID);
|
$activeMailProfile = emailadmin_account::read($this->mail_bo->profileID);
|
||||||
|
|
||||||
@ -2233,7 +2234,7 @@ class mail_compose
|
|||||||
$signature = mail_bo::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
|
$signature = mail_bo::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if ($_formData['attachments'] && $_formData['filemode'] != egw_sharing::ATTACH && $_send)
|
if ($_formData['attachments'] && $_formData['filemode'] != egw_sharing::ATTACH && !$_autosaving)
|
||||||
{
|
{
|
||||||
$attachment_links = $this->getAttachmentLinks($_formData['attachments'], $_formData['filemode'],
|
$attachment_links = $this->getAttachmentLinks($_formData['attachments'], $_formData['filemode'],
|
||||||
$_formData['mimeType'] == 'html',
|
$_formData['mimeType'] == 'html',
|
||||||
@ -2267,7 +2268,7 @@ class mail_compose
|
|||||||
$_mailObject->setBody($this->convertHTMLToText($body, true, true));
|
$_mailObject->setBody($this->convertHTMLToText($body, true, true));
|
||||||
}
|
}
|
||||||
// convert URL Images to inline images - if possible
|
// convert URL Images to inline images - if possible
|
||||||
if ($_send) mail_bo::processURL2InlineImages($_mailObject, $body);
|
if (!$_autosaving) mail_bo::processURL2InlineImages($_mailObject, $body);
|
||||||
if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
|
if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
|
||||||
{
|
{
|
||||||
$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
|
$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
|
||||||
@ -2343,7 +2344,8 @@ class mail_compose
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($_formData['filemode'] == egw_sharing::ATTACH)
|
// attach files not for autosaving
|
||||||
|
elseif ($_formData['filemode'] == egw_sharing::ATTACH && !$_autosaving)
|
||||||
{
|
{
|
||||||
if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
|
if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
|
||||||
{
|
{
|
||||||
@ -2431,9 +2433,11 @@ class mail_compose
|
|||||||
* Save compose mail as draft
|
* Save compose mail as draft
|
||||||
*
|
*
|
||||||
* @param array $content content sent from client-side
|
* @param array $content content sent from client-side
|
||||||
|
* @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
|
||||||
*/
|
*/
|
||||||
public function ajax_saveAsDraft ($content)
|
public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
|
||||||
{
|
{
|
||||||
|
//error_log(__METHOD__."(, action=$action)");
|
||||||
$response = egw_json_response::get();
|
$response = egw_json_response::get();
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
||||||
@ -2455,7 +2459,7 @@ class mail_compose
|
|||||||
$folder = $this->mail_bo->getDraftFolder();
|
$folder = $this->mail_bo->getDraftFolder();
|
||||||
$this->mail_bo->reopen($folder);
|
$this->mail_bo->reopen($folder);
|
||||||
$status = $this->mail_bo->getFolderStatus($folder);
|
$status = $this->mail_bo->getFolderStatus($folder);
|
||||||
if (($messageUid = $this->saveAsDraft($formData,$folder)))
|
if (($messageUid = $this->saveAsDraft($formData, $folder, $action)))
|
||||||
{
|
{
|
||||||
// saving as draft, does not mean closing the message
|
// saving as draft, does not mean closing the message
|
||||||
$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
|
$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
|
||||||
@ -2538,13 +2542,14 @@ class mail_compose
|
|||||||
/**
|
/**
|
||||||
* Save message as draft to specific folder
|
* Save message as draft to specific folder
|
||||||
*
|
*
|
||||||
* @param type $_formData content
|
* @param array $_formData content
|
||||||
* @param type $savingDestination destination folder
|
* @param string &$savingDestination ='' destination folder
|
||||||
|
* @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
|
||||||
* @return boolean return messageUID| false due to an error
|
* @return boolean return messageUID| false due to an error
|
||||||
*/
|
*/
|
||||||
function saveAsDraft($_formData, &$savingDestination='')
|
function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]')
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__.__LINE__);
|
//error_log(__METHOD__."(..., $savingDestination, action=$action)");
|
||||||
$mail_bo = $this->mail_bo;
|
$mail_bo = $this->mail_bo;
|
||||||
$mail = new egw_mailer($this->mail_bo->profileID);
|
$mail = new egw_mailer($this->mail_bo->profileID);
|
||||||
|
|
||||||
@ -2568,7 +2573,7 @@ class mail_compose
|
|||||||
|
|
||||||
$flags = '\\Seen \\Draft';
|
$flags = '\\Seen \\Draft';
|
||||||
|
|
||||||
$this->createMessage($mail, $_formData, $identity);
|
$this->createMessage($mail, $_formData, $identity, $action === 'autosaving');
|
||||||
|
|
||||||
// folder list as Customheader
|
// folder list as Customheader
|
||||||
if (!empty($this->sessionData['folder']))
|
if (!empty($this->sessionData['folder']))
|
||||||
|
@ -176,7 +176,7 @@ app.classes.mail = AppJS.extend(
|
|||||||
// Prepare display dialog for printing
|
// Prepare display dialog for printing
|
||||||
// copies iframe content to a DIV, as iframe causes
|
// copies iframe content to a DIV, as iframe causes
|
||||||
// trouble for multipage printing
|
// trouble for multipage printing
|
||||||
jQuery('#mail-display_mailDisplayBodySrc').on('load', function(){self.mail_prepare_print()});
|
jQuery('#mail-display_mailDisplayBodySrc').on('load', function(){self.mail_prepare_print();});
|
||||||
|
|
||||||
this.mail_isMainWindow = false;
|
this.mail_isMainWindow = false;
|
||||||
this.mail_display();
|
this.mail_display();
|
||||||
@ -199,7 +199,7 @@ app.classes.mail = AppJS.extend(
|
|||||||
|
|
||||||
// Set autosaving interval to 2 minutes for compose message
|
// Set autosaving interval to 2 minutes for compose message
|
||||||
this.W_INTERVALS.push(window.setInterval(function (){
|
this.W_INTERVALS.push(window.setInterval(function (){
|
||||||
that.saveAsDraft(null,that.et2.getWidgetById('button[saveAsDraft]'),'autosaving');
|
that.saveAsDraft(null, 'autosaving');
|
||||||
}, 120000));
|
}, 120000));
|
||||||
|
|
||||||
/* Control focus actions on subject to handle expanders properly.*/
|
/* Control focus actions on subject to handle expanders properly.*/
|
||||||
@ -3157,20 +3157,21 @@ app.classes.mail = AppJS.extend(
|
|||||||
* Save as Draft (VFS)
|
* Save as Draft (VFS)
|
||||||
* -handel both actions save as draft and save as draft and print
|
* -handel both actions save as draft and save as draft and print
|
||||||
*
|
*
|
||||||
* @param {egw object} _egw
|
* @param {egwAction} _egw_action
|
||||||
* @param {widget object} _widget
|
* @param {array|string} _action string "autosaving", if that triggered the action
|
||||||
* @param {string} _action autosaving trigger action
|
|
||||||
*/
|
*/
|
||||||
saveAsDraft: function(_egw_action, _action)
|
saveAsDraft: function(_egw_action, _action)
|
||||||
{
|
{
|
||||||
//this.et2_obj.submit();
|
//this.et2_obj.submit();
|
||||||
var content = this.et2.getArrayMgr('content').data;
|
var content = this.et2.getArrayMgr('content').data;
|
||||||
if (_egw_action )
|
var action = _action;
|
||||||
|
if (_egw_action && _action !== 'autosaving')
|
||||||
{
|
{
|
||||||
var action = _action == 'autosaving'?_action: _egw_action.id;
|
action = _egw_action.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
var widgets = ['from','to','cc','bcc','subject','folder','replyto','mailaccount', 'mail_htmltext', 'mail_plaintext', 'lastDrafted'];
|
var widgets = ['from','to','cc','bcc','subject','folder','replyto','mailaccount',
|
||||||
|
'mail_htmltext', 'mail_plaintext', 'lastDrafted', 'filemode', 'expiration', 'password'];
|
||||||
var widget = {};
|
var widget = {};
|
||||||
for (var index in widgets)
|
for (var index in widgets)
|
||||||
{
|
{
|
||||||
@ -3183,7 +3184,7 @@ app.classes.mail = AppJS.extend(
|
|||||||
var self = this;
|
var self = this;
|
||||||
if (content)
|
if (content)
|
||||||
{
|
{
|
||||||
this.egw.json('mail.mail_compose.ajax_saveAsDraft',[content],function(_data){
|
this.egw.json('mail.mail_compose.ajax_saveAsDraft',[content, action],function(_data){
|
||||||
self.savingDraft_response(_data,action);
|
self.savingDraft_response(_data,action);
|
||||||
}).sendRequest(true);
|
}).sendRequest(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user