Fix inline images of compose do not get stored as links into integrated applications like infolog, tracker or calendar

This commit is contained in:
Hadi Nategh 2016-09-21 15:52:50 +02:00
parent 1e1447e135
commit 83de4986c8
2 changed files with 16 additions and 4 deletions

View File

@ -6573,7 +6573,7 @@ class Mail
* @param Mailer $_mailObject instance of the Mailer Object to be used
* @param string $_html2parse the html to parse and to be altered, if conditions meet
* @param $mail_bo mail bo object
* @return void
* @return array|null return inline images stored as tmp file in vfs as array of attachments otherwise null
*/
static function processURL2InlineImages(Mailer $_mailObject, &$_html2parse, $mail_bo)
{
@ -6678,7 +6678,14 @@ class Mail
$_html2parse = str_replace($images[0][$i], $images[1][$i].'="'.$cid.'"', $_html2parse);
}
}
$attachments [] = array(
'name' => $filename,
'type' => $mimeType,
'file' => $attachment_file,
'tmp_name' => $attachment_file
);
}
return is_array($attachments) ? $attachments : null;
}
}

View File

@ -2226,6 +2226,8 @@ class mail_compose
* @param array $_formData
* @param array $_identity
* @param boolean $_autosaving =false true: autosaving, false: save-as-draft or send
*
* @return array returns found inline images as attachment structure
*/
function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
{
@ -2359,7 +2361,7 @@ class mail_compose
$_mailObject->setBody($this->convertHTMLToText($body, true, true));
}
// convert URL Images to inline images - if possible
if (!$_autosaving) Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
{
$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@ -2464,6 +2466,7 @@ class mail_compose
}
if ($connection_opened) $mail_bo->closeConnection();
}
return is_array($inline_images)?$inline_images:array();
}
/**
@ -2826,8 +2829,8 @@ class mail_compose
}
//error_log($this->sessionData['mailaccount']);
//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['mailidentity']).'->'.array2string($identity));
// create the messages
$this->createMessage($mail, $_formData, $identity);
// create the messages and store inline images
$inline_images = $this->createMessage($mail, $_formData, $identity);
// remember the identity
if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
@ -3157,6 +3160,8 @@ class mail_compose
if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
{
$this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images);
foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
{
$entryid = $_formData['to_integrate_ids'][0][$app_key];