* email: improve the switching of signatures in HTML mode

This commit is contained in:
Klaus Leithoff 2012-07-12 13:58:12 +00:00
parent a7231e99aa
commit 3bad7e4177
3 changed files with 33 additions and 6 deletions

View File

@ -1441,10 +1441,32 @@ class ajaxfelamimail
//error_log(__METHOD__.'Old+:'.$oldSigText.'#');
$sigText = felamimail_bo::merge($sigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
//error_log(__METHOD__.'new+:'.$sigText.'#');
$oldSigText = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($oldSigText):$oldSigText));
$htmlConfig = felamimail_bo::$htmLawed_config;
$htmlConfig['comment'] = 2;
$oldSigText = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($oldSigText,$htmlConfig,array(),true):$oldSigText));
//error_log(__METHOD__.'Old(clean):'.$oldSigText.'#');
$_content = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($_content):$_content));
$found = strpos($_content,trim($oldSigText));
$_content = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($_content,$htmlConfig,array(),true):$_content));
if ($_currentMode == 'html')
{
$found = strpos($_content,"<!-- HTMLSIGBEGIN -->");
$endSig = strpos($_content,"<!-- HTMLSIGEND -->");
if ($found !== false && $endSig !== false)
{
$lengthSig = $endSig-($found+strlen('<!-- HTMLSIGBEGIN -->'));
$_content = substr_replace($_content,$sigText,$found+strlen('<!-- HTMLSIGBEGIN -->'),$lengthSig);
//error_log(__METHOD__.__LINE__.'->'.$_content);
$found = false; // this way we skip further replacement efforts
}
else
{
// try the old way
$found = strpos($_content,trim($oldSigText));
}
}
else
{
$found = strpos($_content,trim($oldSigText));
}
if ($found !== false && $_oldSig != -2 && !(empty($oldSigText) || trim($bocompose->convertHTMLToText($oldSigText)) ==''))
{
//error_log(__METHOD__.'Old Content:'.$_content.'#');

View File

@ -821,7 +821,7 @@
$_mailObject->Body = $bostationery->render($this->sessionData['stationeryID'],$_formData['body'],$signature);
} else {
$_mailObject->Body = $_formData['body'] .
($disableRuler ?'<br>':'<hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">').
($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').
$signature;
}
$_mailObject->AltBody = $this->convertHTMLToText($_formData['body']).
@ -840,6 +840,10 @@
}
// convert URL Images to inline images - if possible
if ($_convertLinks) felamimail_bo::processURL2InlineImages($_mailObject, $_mailObject->Body);
if (strpos($_mailObject->Body,"<!-- HTMLSIGBEGIN -->")!==false)
{
$_mailObject->Body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$_mailObject->Body);
}
} else {
$_mailObject->IsHTML(false);
$_mailObject->Body = $this->convertHTMLToText($_formData['body'],false);

View File

@ -576,13 +576,14 @@
{
$insertSigOnTop = true;
if($sessionData['mimeType'] == 'html') {
$before = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">');
$before = ($disableRuler ?'&nbsp;<br>':'&nbsp;<br><hr style="border:1px dotted silver; width:90%;">');
$inbetween = '&nbsp;<br>';
} else {
$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
$inbetween = "\r\n";
}
$sigText = felamimail_bo::merge($signature->fm_signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
if ($sessionData['mimeType'] == 'html') $sigText = "<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->";
$sessionData['body'] = $before.($sessionData['mimeType'] == 'html'?$sigText:$this->bocompose->convertHTMLToText($sigText)).$inbetween.$sessionData['body'];
}
// prepare body
@ -862,7 +863,7 @@
false,
true
);
print '<div id="divFolderTree" style="overflow:auto; width:320px; height:450px; margin-bottom: 0px;padding-left: 0px; padding-top:0px; z-index:100; border : 1px solid Silver;"></div>';
print '<div id="divFolderTree" style="overflow:auto; width:320px; height:450px; margin-bottom:0px; padding-left:0px; padding-top:0px; z-index:100; border:1px solid Silver;"></div>';
print $folderTree;
}