Skip to content

EspoCRM – Open Source CRM Application

Email template processor and htmlizer field check improvements

Yuriib3309f8b2060
diff --git a/application/Espo/Core/Htmlizer/Htmlizer.php b/application/Espo/Core/Htmlizer/Htmlizer.php
index 348614d585..1d769b89ec 100644
--- a/application/Espo/Core/Htmlizer/Htmlizer.php
+++ b/application/Espo/Core/Htmlizer/Htmlizer.php
@@ -36,6 +36,7 @@ use DOMDocument;
use DOMElement;
use DOMException;
use DOMXPath;
+use Espo\Core\AclManager;
use Espo\Core\Currency\PrecisionProvider;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Forbidden;
@@ -87,6 +88,7 @@ class Htmlizer
private Log $log,
private InjectableFactory $injectableFactory,
private PrecisionProvider $precisionProvider,
+ private AclManager $aclManager,
private ?Acl $acl = null,
) {}
@@ -830,20 +832,19 @@ class Htmlizer
*/
private function getForbiddenAttributes(string $entityType): array
{
+ $restrictedList = $this->aclManager->getScopeRestrictedAttributeList($entityType, [
+ Acl\GlobalRestriction::TYPE_FORBIDDEN,
+ Acl\GlobalRestriction::TYPE_INTERNAL,
+ Acl\GlobalRestriction::TYPE_ONLY_ADMIN,
+ ]);
+
if (!$this->acl) {
- return [];
+ return $restrictedList;
}
return array_merge(
+ $restrictedList,
$this->acl->getScopeForbiddenAttributeList($entityType),
- $this->acl->getScopeRestrictedAttributeList(
- $entityType,
- [
- Acl\GlobalRestriction::TYPE_FORBIDDEN,
- Acl\GlobalRestriction::TYPE_INTERNAL,
- Acl\GlobalRestriction::TYPE_ONLY_ADMIN,
- ]
- )
);
}
@@ -852,11 +853,7 @@ class Htmlizer
*/
private function getRestrictedLinks(Entity $entity): array
{
- if (!$this->acl) {
- return [];
- }
-
- return $this->acl->getScopeRestrictedLinkList(
+ return $this->aclManager->getScopeRestrictedLinkList(
$entity->getEntityType(),
[
Acl\GlobalRestriction::TYPE_FORBIDDEN,
diff --git a/application/Espo/Modules/Crm/Tools/MassEmail/SendingProcessor.php b/application/Espo/Modules/Crm/Tools/MassEmail/SendingProcessor.php
index 2ac5ea24ec..f4a5502592 100644
--- a/application/Espo/Modules/Crm/Tools/MassEmail/SendingProcessor.php
+++ b/application/Espo/Modules/Crm/Tools/MassEmail/SendingProcessor.php
@@ -159,7 +159,7 @@ class SendingProcessor
$emailData = $this->templateProcessor->process(
$emailTemplate,
TemplateParams::create()
- ->withApplyAcl(false) // @todo Revise.
+ ->withApplyAcl(false) // Has access to all fields.
->withCopyAttachments(false), // @todo Revise.
TemplateData::create()
->withParent($target)
diff --git a/application/Espo/Tools/EmailTemplate/Processor.php b/application/Espo/Tools/EmailTemplate/Processor.php
index 1d7ec0e2c4..3b7af4ba17 100644
--- a/application/Espo/Tools/EmailTemplate/Processor.php
+++ b/application/Espo/Tools/EmailTemplate/Processor.php
@@ -156,19 +156,19 @@ class Processor
$attributeList = $entity->getAttributeList();
- $forbiddenAttributeList = [];
+ $forbiddenAttributeList = $this->aclManager->getScopeRestrictedAttributeList(
+ $entity->getEntityType(),
+ [
+ GlobalRestriction::TYPE_FORBIDDEN,
+ GlobalRestriction::TYPE_INTERNAL,
+ GlobalRestriction::TYPE_ONLY_ADMIN,
+ ]
+ );
if (!$skipAcl) {
$forbiddenAttributeList = array_merge(
+ $forbiddenAttributeList,
$this->aclManager->getScopeForbiddenAttributeList($user, $entity->getEntityType()),
- $this->aclManager->getScopeRestrictedAttributeList(
- $entity->getEntityType(),
- [
- GlobalRestriction::TYPE_FORBIDDEN,
- GlobalRestriction::TYPE_INTERNAL,
- GlobalRestriction::TYPE_ONLY_ADMIN,
- ]
- )
);
}
@@ -225,16 +225,14 @@ class Processor
$entityDefs = $this->entityManager->getDefs()->getEntity($entity->getEntityType());
- $forbiddenLinkList = $skipAcl ?
- $this->aclManager->getScopeRestrictedLinkList(
- $entity->getEntityType(),
- [
- GlobalRestriction::TYPE_FORBIDDEN,
- GlobalRestriction::TYPE_INTERNAL,
- GlobalRestriction::TYPE_ONLY_ADMIN,
- ]
- ) :
- [];
+ $forbiddenLinkList = $this->aclManager->getScopeRestrictedLinkList(
+ $entity->getEntityType(),
+ [
+ GlobalRestriction::TYPE_FORBIDDEN,
+ GlobalRestriction::TYPE_INTERNAL,
+ GlobalRestriction::TYPE_ONLY_ADMIN,
+ ]
+ );
foreach ($entity->getRelationList() as $relation) {
if (in_array($relation, $forbiddenLinkList)) {
diff --git a/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php b/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php
index 59fcb6c349..1b2c5ae003 100644
--- a/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php
+++ b/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php
@@ -29,6 +29,7 @@
namespace tests\unit\Espo\Core\Htmlizer;
+use Espo\Core\AclManager;
use Espo\Core\Currency\PrecisionProvider;
use Espo\Core\Htmlizer\Htmlizer;
use Espo\Core\InjectableFactory;
@@ -105,6 +106,7 @@ class HtmlizerTest extends TestCase
log: $this->createMock(Log::class),
injectableFactory: $this->createMock(InjectableFactory::class),
precisionProvider: $this->createMock(PrecisionProvider::class),
+ aclManager: $this->createMock(AclManager::class),
);
}