This commit is contained in:
Yuri Kuznetsov
2024-02-07 11:58:36 +02:00
8 changed files with 101 additions and 7 deletions

View File

@@ -70,7 +70,7 @@ class Saver implements SaverInterface
$emailAddressData = $entity->get('emailAddressData');
}
if ($emailAddressData !== null) {
if ($emailAddressData !== null && $entity->isAttributeChanged('emailAddressData')) {
$this->storeData($entity);
return;

View File

@@ -75,7 +75,7 @@ class Saver implements SaverInterface
$phoneNumberData = $entity->get('phoneNumberData');
}
if ($phoneNumberData !== null) {
if ($phoneNumberData !== null && $entity->isAttributeChanged('phoneNumberData')) {
$this->storeData($entity);
return;

View File

@@ -0,0 +1,48 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Modules\Crm\Classes\Acl\MassEmail\LinkCheckers;
use Espo\Core\Acl\LinkChecker;
use Espo\Entities\InboundEmail;
use Espo\Entities\User;
use Espo\Modules\Crm\Entities\MassEmail;
use Espo\ORM\Entity;
/**
* @implements LinkChecker<MassEmail, InboundEmail>
* @noinspection PhpUnused
*/
class InboundEmailLinkChecker implements LinkChecker
{
public function check(User $user, Entity $entity, Entity $foreignEntity): bool
{
return $foreignEntity->smtpIsForMassEmail();
}
}

View File

@@ -1,3 +1,6 @@
{
"ownershipCheckerClassName": "Espo\\Modules\\Crm\\Classes\\Acl\\MassEmail\\OwnershipChecker"
"ownershipCheckerClassName": "Espo\\Modules\\Crm\\Classes\\Acl\\MassEmail\\OwnershipChecker",
"linkCheckerClassNameMap": {
"inboundEmail": "Espo\\Modules\\Crm\\Classes\\Acl\\MassEmail\\LinkCheckers\\InboundEmailLinkChecker"
}
}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "espocrm",
"version": "8.1.3",
"version": "8.1.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "espocrm",
"version": "8.1.3",
"version": "8.1.4",
"hasInstallScript": true,
"license": "AGPL-3.0-or-later",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "8.1.3",
"version": "8.1.4",
"description": "Open-source CRM.",
"repository": {
"type": "git",

View File

@@ -30,10 +30,13 @@
namespace tests\integration\Espo\Core\FieldProcessing;
use Espo\Core\ORM\EntityManager;
use Espo\Modules\Crm\Entities\Lead;
use Espo\Core\Field\EmailAddress;
use Espo\Core\Field\EmailAddressGroup;
use Espo\Core\Record\ServiceContainer;
use Espo\Core\Record\UpdateParams;
use Espo\Modules\Crm\Entities\Contact;
use tests\integration\Core\BaseTestCase;
class EmailAddressTest extends BaseTestCase
@@ -137,4 +140,22 @@ class EmailAddressTest extends BaseTestCase
$this->assertEquals('test-1@test.com', $lead->getEmailAddress());
}
public function testEmailAddress3(): void
{
$service = $this->getContainer()->getByClass(ServiceContainer::class)->getByClass(Contact::class);
$em = $this->getEntityManager();
/** @var Contact $contact */
$contact = $em->createEntity(Contact::ENTITY_TYPE);
/** @noinspection PhpUnhandledExceptionInspection */
$service->update($contact->getId(), (object) [
'emailAddress' => 'test@test.com',
], UpdateParams::create());
$em->refreshEntity($contact);
$this->assertEquals('test@test.com', $contact->getEmailAddress());
}
}

View File

@@ -33,6 +33,10 @@ use Espo\Core\ORM\EntityManager;
use Espo\Core\Field\PhoneNumber;
use Espo\Core\Field\PhoneNumberGroup;
use Espo\Modules\Crm\Entities\Lead;
use Espo\Core\Record\ServiceContainer;
use Espo\Core\Record\UpdateParams;
use Espo\Modules\Crm\Entities\Contact;
use tests\integration\Core\BaseTestCase;
class PhoneNumberTest extends BaseTestCase
@@ -115,4 +119,22 @@ class PhoneNumberTest extends BaseTestCase
$this->assertEquals('+0000000001', $lead->getPhoneNumber());
}
public function testPhoneNumber2(): void
{
$service = $this->getContainer()->getByClass(ServiceContainer::class)->getByClass(Contact::class);
$em = $this->getEntityManager();
/** @var Contact $contact */
$contact = $em->createEntity(Contact::ENTITY_TYPE);
/** @noinspection PhpUnhandledExceptionInspection */
$service->update($contact->getId(), (object) [
'phoneNumber' => '+11111111111',
], UpdateParams::create());
$em->refreshEntity($contact);
$this->assertEquals('+11111111111', $contact->getPhoneNumber());
}
}