Mail: Add non-editable attachment block placeholder

This commit is contained in:
nathan 2024-06-28 09:47:54 -06:00
parent b879b5eb7e
commit c51f77a9dd
2 changed files with 13 additions and 5 deletions

View File

@ -267,7 +267,8 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
"visualblocks visualchars image link media template fullscreen",
"codesample table charmap hr pagebreak nonbreaking anchor toc ",
"insertdatetime advlist lists textcolor wordcount imagetools ",
"colorpicker textpattern help paste code searchreplace tabfocus"
"colorpicker textpattern help paste code searchreplace tabfocus",
"noneditable"
],
toolbar: et2_htmlarea.TOOLBAR_SIMPLE,
block_formats: "Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;"+

View File

@ -1400,6 +1400,12 @@ class mail_compose
// set filemode icons for all attachments
if(!empty($content['attachments']))
{
// Make sure placeholder is there
$attachment_block = '<fieldset class="attachments mceNonEditable"><legend>Download attachments</legend>' . lang('Attachments') . '</fieldset>';
if($content['is_html'] && strpos($content['mail_htmltext'], $attachment_block) == false)
{
$content['mail_htmltext'] .= $attachment_block;
}
foreach($content['attachments'] as &$attach)
{
$attach['is_dir'] = !empty($attach['file']) && is_dir($attach['file']);
@ -2567,13 +2573,13 @@ class mail_compose
case 'html':
$body = $_formData['body'];
static $ruler = '<hr class="ruler"';
static $attachment_block = '<fieldset class="attachments mceNonEditable"';
if (!empty($attachment_links))
{
// if we have a ruler, replace it with the attachment block
if (strpos($body, $ruler) !== false)
// if we have a placeholder, replace it with the attachment block
if(strpos($body, $attachment_block) !== false)
{
$body = preg_replace('#'.$ruler.'[^>]*>#', $attachment_links, $body);
$body = preg_replace('#' . $attachment_block . '[^>]*>.*</fieldset>#', $attachment_links, $body);
}
// else place it before the signature
elseif (strpos($body, '<!-- HTMLSIGBEGIN -->') !== false)
@ -2585,6 +2591,7 @@ class mail_compose
$body .= $attachment_links;
}
}
static $ruler = '<hr class="ruler"';
$body = str_replace($ruler, '<hr', $body); // remove id from ruler, to not replace in cited mails
if(!empty($signature))