* email: feature for html-mails -> convert images included as link to inline images (attachments to the mail)

This commit is contained in:
Klaus Leithoff 2011-11-23 12:43:40 +00:00
parent 778935ff72
commit 39c6b6ca90
4 changed files with 28 additions and 12 deletions

View File

@ -689,7 +689,7 @@
$GLOBALS['egw']->session->appsession('compose_session_data_'.$this->composeID,'felamimail',$this->sessionData);
}
function createMessage(&$_mailObject, $_formData, $_identity, $_signature = false)
function createMessage(&$_mailObject, $_formData, $_identity, $_signature = false, $_convertLinks=false)
{
$bofelamimail = $this->bofelamimail;
$_mailObject->PluginDir = EGW_SERVER_ROOT."/phpgwapi/inc/";
@ -787,7 +787,11 @@
{
$disableRuler = true;
}
$signature = felamimail_bo::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
if($signature)
{
$signature = felamimail_bo::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
}
if($_formData['mimeType'] =='html') {
$_mailObject->IsHTML(true);
if(!empty($signature)) {
@ -814,6 +818,8 @@
}
$_mailObject->AltBody = $this->convertHTMLToText($_formData['body']);
}
// convert URL Images to inline images - if possible
if ($_convertLinks) felamimail_bo::processURL2InlineImages($_mailObject, $_mailObject->Body);
} else {
$_mailObject->IsHTML(false);
$_mailObject->Body = $this->convertHTMLToText($_formData['body'],false);
@ -980,7 +986,7 @@
#error_log($this->sessionData['identity']);
#error_log(print_r($identity,true));
// create the messages
$this->createMessage($mail, $_formData, $identity, $signature);
$this->createMessage($mail, $_formData, $identity, $signature, true);
// remember the identity
if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";

View File

@ -4398,6 +4398,7 @@ class felamimail_bo
if(isset($images[2])) {
foreach($images[2] as $i => $url) {
$basedir = '';
$needTempFile = true;
//error_log(__METHOD__.__LINE__.$url);
//error_log(__METHOD__.__LINE__.$GLOBALS['egw_info']['server']['webserver_url']);
//error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']));
@ -4421,17 +4422,25 @@ class felamimail_bo
list($garbage,$vfspart) = explode('webdav.php',$myUrl,2);
$myUrl = $vfspart;
$basedir = 'vfs://default';
$needTempFile = false;
}
}
if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; }
//error_log(__METHOD__.__LINE__.$basedir.$myUrl);
$data = file_get_contents($basedir.urldecode($myUrl));
if ($data)
if ($needTempFile) $data = file_get_contents($basedir.urldecode($myUrl));
if ($data || $needTempFile === false)
{
$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$tmpfile = fopen($attachment_file,'w');
fwrite($tmpfile,$data);
fclose($tmpfile);
if ($needTempFile)
{
$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$tmpfile = fopen($attachment_file,'w');
fwrite($tmpfile,$data);
fclose($tmpfile);
}
else
{
$attachment_file = $basedir.urldecode($myUrl);
}
//error_log(__METHOD__.__LINE__.' '.$url.' -> '.$basedir.$myUrl. ' TmpFile:'.$tmpfile);
if ( $_mailObject->AddEmbeddedImage($attachment_file, md5($filename), $filename, 'base64',$mimeType) ) {
$_html2parse = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $_html2parse);

View File

@ -380,7 +380,7 @@
$this->t->set_var('compose_id',$this->composeID);
// the editorobject is needed all the time (since we use CKEDITOR3
//$editorObject = html::initCKEditor('400px','simple');
$this->t->set_var('ckeditorConfig', egw_ckeditor_config::get_ckeditor_config());//$editorObject->jsEncode($editorObject->config));
$this->t->set_var('ckeditorConfig', egw_ckeditor_config::get_ckeditor_config('simple-withimage'));//$editorObject->jsEncode($editorObject->config));
// check for some error messages from last posting attempt
if($errorInfo = $this->bocompose->getErrorInfo())
@ -540,7 +540,7 @@
}
// prepare body
if($sessionData['mimeType'] == 'html') {
$mode = 'simple';
$mode = 'simple-withimage';
#if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck'])) $mode = 'egw_simple_spellcheck';
$style="border:0px; width:100%; height:400px;";
// dont run purify, as we already did that (getCleanHTML).

View File

@ -235,7 +235,8 @@ class egw_ckeditor_config
case 'extended': default:
$config['toolbar'][] = array('Bold','Italic','Underline');
$config['toolbar'][] = array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock');
$config['toolbar'][] = array('BulletedList','NumberedList'/*,'Smiley'*/,'Outdent','Indent','Undo','Redo');
if ($mode == 'simple-withimage') $config['toolbar'][] = array('BulletedList','NumberedList','Image'/*,'Smiley'*/,'Outdent','Indent','Undo','Redo');
else $config['toolbar'][] = $config['toolbar'][] = array('BulletedList','NumberedList'/*,'Smiley'*/,'Outdent','Indent','Undo','Redo');
$config['toolbar'][] = array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print');
if ($mode == 'extended')