try to detect changes on signatureID and Identity

This commit is contained in:
Klaus Leithoff 2013-10-07 12:17:33 +00:00
parent 746e6ea193
commit 35167898cd
3 changed files with 55 additions and 25 deletions

View File

@ -32,17 +32,29 @@ class mail_compose
'reply' => True, 'reply' => True,
'replyAll' => True, 'replyAll' => True,
'selectFolder' => True, 'selectFolder' => True,
'attachFromVFS' => True,
'action' => True 'action' => True
); );
var $destinations = array( /**
* class vars for destination, priorities, mimeTypes
*/
static $destinations = array(
'to' => 'to', 'to' => 'to',
'cc' => 'cc', 'cc' => 'cc',
'bcc' => 'bcc', 'bcc' => 'bcc',
'replyto' => 'replyto', 'replyto' => 'replyto',
'folder' => 'folder' 'folder' => 'folder'
); );
static $priorities = array(
1=>"high",
3=>"normal",
5=>"low"
);
static $mimeTypes = array(
"plain"=>"plain",
"html"=>"html"
);
/** /**
* Instance of mail_bo * Instance of mail_bo
* *
@ -62,15 +74,9 @@ class mail_compose
var $bopreferences; var $bopreferences;
var $bosignatures; var $bosignatures;
var $displayCharset; var $displayCharset;
var $composeID;
var $sessionData; var $sessionData;
/**
* Instance of Template class
*
* @var Template
*/
var $t;
function mail_compose() function mail_compose()
{ {
if (!isset($GLOBALS['egw_info']['flags']['js_link_registry'])) if (!isset($GLOBALS['egw_info']['flags']['js_link_registry']))
@ -100,6 +106,7 @@ class mail_compose
} }
if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail'); if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail');
/*
if (!isset($_POST['composeid']) && !isset($_GET['composeid'])) if (!isset($_POST['composeid']) && !isset($_GET['composeid']))
{ {
// create new compose session // create new compose session
@ -115,7 +122,7 @@ class mail_compose
$this->composeID = $_GET['composeid']; $this->composeID = $_GET['composeid'];
} }
*/
$this->mailPreferences =& $this->mail_bo->mailPreferences; $this->mailPreferences =& $this->mail_bo->mailPreferences;
} }
@ -127,12 +134,6 @@ class mail_compose
return strtr ($string, $trans_tbl); return strtr ($string, $trans_tbl);
} }
function attachFromVFS($target, $path=null)
{
error_log(__METHOD__.__LINE__.array2string($path));
return "var path=".json_encode($path)."; opener.app.mail.compose_closeVfsSelector(path);";
}
function action() function action()
{ {
$formData['identity'] = (int)$_POST['identity']; $formData['identity'] = (int)$_POST['identity'];
@ -293,7 +294,15 @@ class mail_compose
$_focusElement, $suppressSigOnTop, $isReply $_focusElement, $suppressSigOnTop, $isReply
)); ));
} }
if (!isset($_content['composeID'])||empty($_content['composeID']))
{
$this->composeID = $this->getComposeID();
$composeCache = egw_cache::getCache(egw_cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$callback=null,$callback_params=array(),$expiration=60*60*2);
}
else
{
$this->composeID = $_content['composeID'];
}
// VFS Selector was used // VFS Selector was used
if (is_array($_content['selectFromVFSForCompose'])) if (is_array($_content['selectFromVFSForCompose']))
{ {
@ -396,9 +405,19 @@ $CAtFStart = array2string($_content);
egw_framework::message(lang('Message saved successfully.'),'mail'); egw_framework::message(lang('Message saved successfully.'),'mail');
} }
} }
// all values are empty for a new compose window // form was submitted either by clicking a button or by changing one of the triggering selectboxes
if ($buttonClicked = false) // identity and signatureID; this might trigger that the signature in mail body may have to be altered
if (
(!empty($composeCache['identity']) && !empty($_content['identity']) && $_content['identity'] != $composeCache['identity']) ||
(!empty($composeCache['signatureID']) && !empty($_content['signatureID']) && $_content['signatureID'] != $composeCache['signatureID'])
)
{ {
$buttonClicked = true;
}
// all values are empty for a new compose window
if ($buttonClicked = true)
{
$suppressSigOnTop = true;
} }
$insertSigOnTop = false; $insertSigOnTop = false;
$content = (is_array($_content)?$_content:array()); $content = (is_array($_content)?$_content:array());
@ -1066,7 +1085,7 @@ $CAtFStart = array2string($_content);
//$content['bcc'] = array('kl@stylite.de','kl@leithoff.net'); //$content['bcc'] = array('kl@stylite.de','kl@leithoff.net');
// address stuff like from, to, cc, replyto // address stuff like from, to, cc, replyto
$destinationRows = 0; $destinationRows = 0;
foreach(array('to','cc','bcc','replyto','folder') as $destination) { foreach(self::$destinations as $destination) {
foreach((array)$content[$destination] as $key => $value) { foreach((array)$content[$destination] as $key => $value) {
if ($value=="NIL@NIL") continue; if ($value=="NIL@NIL") continue;
if ($destination=='replyto' && str_replace('"','',$value) == str_replace('"','',$identities[($presetId ? $presetId : $defaultIdentity)])) continue; if ($destination=='replyto' && str_replace('"','',$value) == str_replace('"','',$identities[($presetId ? $presetId : $defaultIdentity)])) continue;
@ -1108,13 +1127,23 @@ if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merg
$preserv['attachments'] = $content['attachments']; $preserv['attachments'] = $content['attachments'];
if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.' Attachments:'.array2string($content['attachments'])); if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.' Attachments:'.array2string($content['attachments']));
$preserv['composeID'] = $content['composeID'] = $this->composeID;
//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
$preserv['is_html'] = $content['is_html']; $preserv['is_html'] = $content['is_html'];
$preserv['is_plain'] = $content['is_plain']; $preserv['is_plain'] = $content['is_plain'];
if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType']; if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
$sel_options['mimeType'] = array("plain"=>"plain","html"=>"html"); $sel_options['mimeType'] = self::$mimeTypes;
$sel_options['priority'] = array(1=>"high",2=>"normal",3=>"low"); $sel_options['priority'] = self::$priorities;
if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=2; if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
if ($content['mimeType']=='html'); $content['rtfEditorFeatures']='simple-withimage';//egw_ckeditor_config::get_ckeditor_config(); if ($content['mimeType']=='html') $content['rtfEditorFeatures']='simple-withimage';//egw_ckeditor_config::get_ckeditor_config();
if (isset($_content['composeID'])||!empty($_content['composeID']))
{
$composeCache = $content;
unset($composeCache['body']);unset($composeCache['mail_htmltext']);unset($composeCache['mail_plaintext']);
egw_cache::setCache(egw_cache::SESSION,'email','composeIdCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2);
}
$etpl = new etemplate_new('mail.compose'); $etpl = new etemplate_new('mail.compose');
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,$readonlys,$preserv,2); $etpl->exec('mail.mail_compose.compose',$content,$sel_options,$readonlys,$preserv,2);

View File

@ -452,7 +452,7 @@ class mail_ui
if (empty($imapServer->host) && count($identities)==0 && $preferences->userDefinedAccounts) if (empty($imapServer->host) && count($identities)==0 && $preferences->userDefinedAccounts)
{ {
// redirect to new personal account // redirect to new personal account
egw::redirect_link('/index.php',array('menuaction'=>'mail.uipreferences.editAccountData', egw::redirect_link('/index.php',array('menuaction'=>'felamimail.uipreferences.editAccountData',
'accountID'=>"new", 'accountID'=>"new",
'msg' => lang("There is no IMAP Server configured.")." - ".lang("Please configure access to an existing individual IMAP account."), 'msg' => lang("There is no IMAP Server configured.")." - ".lang("Please configure access to an existing individual IMAP account."),
)); ));

View File

@ -9,6 +9,7 @@
<menulist> <menulist>
<menupopup id="identity" onchange="app.mail.submitOnChange"/> <menupopup id="identity" onchange="app.mail.submitOnChange"/>
</menulist> </menulist>
<textbox class="mail-index_quotaDisplayNone" readonly="true" id="composeID"/>
</hbox> </hbox>
<hbox> <hbox>
<button label="Send" id="button[send]"/> <buttononly value="saveAsDraft" id="button[saveAsDraft]" image="fileexport" onclick="app.mail.saveAsDraft"/> <button label="Send" id="button[send]"/> <buttononly value="saveAsDraft" id="button[saveAsDraft]" image="fileexport" onclick="app.mail.saveAsDraft"/>