ref
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Classes\FieldProcessing\Email;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Name\Link;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\Repositories\EmailAddress as EmailAddressRepository;
|
||||
@@ -44,17 +45,15 @@ use Espo\Entities\User;
|
||||
*/
|
||||
class StringDataLoader implements Loader
|
||||
{
|
||||
private EntityManager $entityManager;
|
||||
private User $user;
|
||||
private const LINK_EMAIL_ADDRESSES = Link::EMAIL_ADDRESSES;
|
||||
|
||||
/** @var array<string, string> */
|
||||
private $fromEmailAddressNameCache = [];
|
||||
|
||||
public function __construct(EntityManager $entityManager, User $user)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->user = $user;
|
||||
}
|
||||
public function __construct(
|
||||
private EntityManager $entityManager,
|
||||
private User $user
|
||||
) {}
|
||||
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
@@ -63,8 +62,7 @@ class StringDataLoader implements Loader
|
||||
$userEmailAddressIdList = [];
|
||||
|
||||
$emailAddressCollection = $this->entityManager
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'emailAddresses')
|
||||
->getRelation($this->user, self::LINK_EMAIL_ADDRESSES)
|
||||
->select([Attribute::ID])
|
||||
->find();
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ use Espo\Core\Acl;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Mail\Account\SendingAccountProvider;
|
||||
use Espo\Core\Mail\ConfigDataProvider;
|
||||
use Espo\Core\Record\Hook\SaveHook;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
@@ -47,8 +47,8 @@ class CheckFromAddress implements SaveHook
|
||||
public function __construct(
|
||||
private User $user,
|
||||
private SendingAccountProvider $sendingAccountProvider,
|
||||
private Config $config,
|
||||
private Acl $acl,
|
||||
private ConfigDataProvider $configDataProvider,
|
||||
) {}
|
||||
|
||||
public function process(Entity $entity): void
|
||||
@@ -88,12 +88,11 @@ class CheckFromAddress implements SaveHook
|
||||
|
||||
if (
|
||||
$system &&
|
||||
$this->config->get('outboundEmailIsShared') &&
|
||||
$system->getEmailAddress()
|
||||
$this->configDataProvider->isOutboundEmailShared() &&
|
||||
$system->getEmailAddress() &&
|
||||
$fromAddress === strtolower($system->getEmailAddress())
|
||||
) {
|
||||
if ($fromAddress === strtolower($system->getEmailAddress())) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Forbidden("Not allowed 'from' address.");
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Classes\Select\Email\Where\ItemConverters;
|
||||
|
||||
use Espo\Core\Name\Link;
|
||||
use Espo\Core\Select\Where\ItemConverter;
|
||||
use Espo\Core\Select\Where\Item;
|
||||
|
||||
@@ -237,8 +238,7 @@ class InFolder implements ItemConverter
|
||||
protected function getEmailAddressIdList(): array
|
||||
{
|
||||
$emailAddressList = $this->entityManager
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'emailAddresses')
|
||||
->getRelation($this->user, Link::EMAIL_ADDRESSES)
|
||||
->select([Attribute::ID])
|
||||
->find();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user