From adbb46d02c69375aa3baafac0f529307167426f3 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 13 Sep 2022 10:12:28 +0300 Subject: [PATCH] system template inline attachments --- application/Espo/Core/Htmlizer/Htmlizer.php | 9 ++++++--- application/Espo/Core/Htmlizer/TemplateRenderer.php | 10 +++++++++- .../Espo/Modules/Crm/Business/Event/Invitations.php | 4 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/application/Espo/Core/Htmlizer/Htmlizer.php b/application/Espo/Core/Htmlizer/Htmlizer.php index 944d35ea79..4bdb30bdb7 100644 --- a/application/Espo/Core/Htmlizer/Htmlizer.php +++ b/application/Espo/Core/Htmlizer/Htmlizer.php @@ -133,7 +133,8 @@ class Htmlizer string $template, ?string $cacheId = null, ?array $additionalData = null, - bool $skipLinks = false + bool $skipLinks = false, + bool $skipInlineAttachmentHandling = false ): string { $template = str_replace('entityManager) { + if (!$skipInlineAttachmentHandling && $this->entityManager) { /** @var string $html */ $html = preg_replace_callback( '/\?entryPoint=attachment\&id=([A-Za-z0-9]*)/', diff --git a/application/Espo/Core/Htmlizer/TemplateRenderer.php b/application/Espo/Core/Htmlizer/TemplateRenderer.php index 6390a0525a..9e757a249b 100644 --- a/application/Espo/Core/Htmlizer/TemplateRenderer.php +++ b/application/Espo/Core/Htmlizer/TemplateRenderer.php @@ -44,6 +44,7 @@ class TemplateRenderer private ?User $user = null; private ?Entity $entity = null; private bool $skipRelations = false; + private bool $skipInlineAttachmentHandling = false; private bool $applyAcl = false; private bool $useUserTimezone = false; private HtmlizerFactory $htmlizerFactory; @@ -97,6 +98,12 @@ class TemplateRenderer return $this; } + public function setSkipInlineAttachmentHandling(bool $skipInlineAttachmentHandling = true): self + { + $this->skipInlineAttachmentHandling = $skipInlineAttachmentHandling; + + return $this; + } public function setApplyAcl(bool $applyAcl = true): self { $this->applyAcl = $applyAcl; @@ -139,7 +146,8 @@ class TemplateRenderer $template, null, $this->data, - $this->skipRelations + $this->skipRelations, + $this->skipInlineAttachmentHandling ); } diff --git a/application/Espo/Modules/Crm/Business/Event/Invitations.php b/application/Espo/Modules/Crm/Business/Event/Invitations.php index bbcaef646a..a77149b407 100644 --- a/application/Espo/Modules/Crm/Business/Event/Invitations.php +++ b/application/Espo/Modules/Crm/Business/Event/Invitations.php @@ -174,6 +174,7 @@ class Invitations $subjectTpl, 'invitation-email-subject-' . $entity->getEntityType(), $data, + true, true ); @@ -182,7 +183,8 @@ class Invitations $bodyTpl, 'invitation-email-body-' . $entity->getEntityType(), $data, - false + false, + true ); $email->set('subject', $subject);