ref
This commit is contained in:
@@ -29,22 +29,18 @@
|
||||
|
||||
namespace Espo\Classes\Acl\Attachment;
|
||||
|
||||
use Espo\Entities\{
|
||||
User,
|
||||
Note,
|
||||
Attachment,
|
||||
};
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\User;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
AclManager,
|
||||
Acl\ScopeData,
|
||||
Acl\DefaultAccessChecker,
|
||||
Acl\AccessEntityCREDChecker,
|
||||
Acl\Traits\DefaultAccessCheckerDependency,
|
||||
};
|
||||
use Espo\Core\Acl\AccessEntityCREDChecker;
|
||||
use Espo\Core\Acl\DefaultAccessChecker;
|
||||
use Espo\Core\Acl\ScopeData;
|
||||
use Espo\Core\Acl\Traits\DefaultAccessCheckerDependency;
|
||||
use Espo\Core\AclManager;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @implements AccessEntityCREDChecker<Attachment>
|
||||
@@ -53,9 +49,8 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
{
|
||||
use DefaultAccessCheckerDependency;
|
||||
|
||||
private $aclManager;
|
||||
|
||||
private $entityManager;
|
||||
private AclManager $aclManager;
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(
|
||||
DefaultAccessChecker $defaultAccessChecker,
|
||||
@@ -145,7 +140,7 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
|
||||
if ($note->getTargetType() === Note::TARGET_USERS) {
|
||||
$isRelated = $this->entityManager
|
||||
->getRDBRepository('Note')
|
||||
->getRDBRepository(Note::ENTITY_TYPE)
|
||||
->getRelation($note, 'users')
|
||||
->isRelated($user);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
|
||||
if ($note->getTargetType() === Note::TARGET_USERS) {
|
||||
$isRelated = $this->entityManager
|
||||
->getRDBRepository('Note')
|
||||
->getRDBRepository(Note::ENTITY_TYPE)
|
||||
->getRelation($note, 'users')
|
||||
->isRelated($user);
|
||||
|
||||
|
||||
@@ -29,11 +29,10 @@
|
||||
|
||||
namespace Espo\Classes\AppParams;
|
||||
|
||||
use Espo\Core\{
|
||||
Acl,
|
||||
Select\SelectBuilderFactory,
|
||||
ORM\EntityManager,
|
||||
};
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Select\SelectBuilderFactory;
|
||||
use Espo\Entities\Template;
|
||||
use Espo\Tools\App\AppParam;
|
||||
|
||||
/**
|
||||
@@ -42,9 +41,7 @@ use Espo\Tools\App\AppParam;
|
||||
class TemplateEntityTypeList implements AppParam
|
||||
{
|
||||
private Acl $acl;
|
||||
|
||||
private SelectBuilderFactory $selectBuilderFactory;
|
||||
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(
|
||||
@@ -62,7 +59,7 @@ class TemplateEntityTypeList implements AppParam
|
||||
*/
|
||||
public function get(): array
|
||||
{
|
||||
if (!$this->acl->checkScope('Template')) {
|
||||
if (!$this->acl->checkScope(Template::ENTITY_TYPE)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -70,7 +67,7 @@ class TemplateEntityTypeList implements AppParam
|
||||
|
||||
$query = $this->selectBuilderFactory
|
||||
->create()
|
||||
->from('Template')
|
||||
->from(Template::ENTITY_TYPE)
|
||||
->withAccessControlFilter()
|
||||
->buildQueryBuilder()
|
||||
->select(['entityType'])
|
||||
@@ -78,12 +75,12 @@ class TemplateEntityTypeList implements AppParam
|
||||
->build();
|
||||
|
||||
$templateCollection = $this->entityManager
|
||||
->getRDBRepository('Template')
|
||||
->getRDBRepositoryByClass(Template::class)
|
||||
->clone($query)
|
||||
->find();
|
||||
|
||||
foreach ($templateCollection as $template) {
|
||||
$list[] = $template->get('entityType');
|
||||
$list[] = $template->getTargetEntityType();
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
||||
@@ -30,30 +30,22 @@
|
||||
namespace Espo\Classes\FieldProcessing\Email;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Repositories\EmailAddress as EmailAddressRepository;
|
||||
|
||||
use Espo\Core\{
|
||||
FieldProcessing\Loader,
|
||||
FieldProcessing\Loader\Params,
|
||||
ORM\EntityManager,
|
||||
};
|
||||
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Entities\User;
|
||||
|
||||
/**
|
||||
* @implements Loader<\Espo\Entities\Email>
|
||||
* @implements Loader<Email>
|
||||
*/
|
||||
class StringDataLoader implements Loader
|
||||
{
|
||||
private $entityManager;
|
||||
private EntityManager $entityManager;
|
||||
private User $user;
|
||||
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
/** @var array<string, string> */
|
||||
private $fromEmailAddressNameCache = [];
|
||||
|
||||
public function __construct(EntityManager $entityManager, User $user)
|
||||
@@ -66,21 +58,22 @@ class StringDataLoader implements Loader
|
||||
{
|
||||
/** @var Email $entity */
|
||||
|
||||
$userEmailAdddressIdList = [];
|
||||
$userEmailAddressIdList = [];
|
||||
|
||||
$emailAddressCollection = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'emailAddresses')
|
||||
->select(['id'])
|
||||
->find();
|
||||
|
||||
foreach ($emailAddressCollection as $emailAddress) {
|
||||
$userEmailAdddressIdList[] = $emailAddress->getId();
|
||||
$userEmailAddressIdList[] = $emailAddress->getId();
|
||||
}
|
||||
|
||||
if (
|
||||
in_array($entity->get('fromEmailAddressId'), $userEmailAdddressIdList) ||
|
||||
$entity->get('createdById') === $this->user->getId() && $entity->get('status') === Email::STATUS_SENT
|
||||
in_array($entity->get('fromEmailAddressId'), $userEmailAddressIdList) ||
|
||||
$entity->get('createdById') === $this->user->getId() &&
|
||||
$entity->getStatus() === Email::STATUS_SENT
|
||||
) {
|
||||
$entity->loadLinkMultipleField('toEmailAddresses');
|
||||
|
||||
@@ -114,7 +107,7 @@ class StringDataLoader implements Loader
|
||||
if (!array_key_exists($fromEmailAddressId, $this->fromEmailAddressNameCache)) {
|
||||
$person = $this->getEmailAddressRepository()->getEntityByAddressId($fromEmailAddressId, null, true);
|
||||
|
||||
$fromName = $person ? $person->get('name') : null;
|
||||
$fromName = $person?->get('name');
|
||||
|
||||
$this->fromEmailAddressNameCache[$fromEmailAddressId] = $fromName;
|
||||
}
|
||||
|
||||
@@ -29,24 +29,20 @@
|
||||
|
||||
namespace Espo\Classes\FieldProcessing\Email;
|
||||
|
||||
use Espo\Entities\Email;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\{
|
||||
FieldProcessing\Loader,
|
||||
FieldProcessing\Loader\Params,
|
||||
ORM\EntityManager,
|
||||
};
|
||||
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Entities\User;
|
||||
|
||||
/**
|
||||
* @implements Loader<\Espo\Entities\Email>
|
||||
* @implements Loader<Email>
|
||||
*/
|
||||
class UserColumnsLoader implements Loader
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
private $user;
|
||||
private EntityManager $entityManager;
|
||||
private User $user;
|
||||
|
||||
public function __construct(EntityManager $entityManager, User $user)
|
||||
{
|
||||
@@ -57,8 +53,12 @@ class UserColumnsLoader implements Loader
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
$emailUser = $this->entityManager
|
||||
->getRDBRepository('EmailUser')
|
||||
->select(['isRead', 'isImportant', 'inTrash'])
|
||||
->getRDBRepository(Email::RELATIONSHIP_EMAIL_USER)
|
||||
->select([
|
||||
Email::USERS_COLUMN_IS_READ,
|
||||
Email::USERS_COLUMN_IS_IMPORTANT,
|
||||
Email::USERS_COLUMN_IN_TRASH,
|
||||
])
|
||||
->where([
|
||||
'deleted' => false,
|
||||
'userId' => $this->user->getId(),
|
||||
@@ -67,17 +67,17 @@ class UserColumnsLoader implements Loader
|
||||
->findOne();
|
||||
|
||||
if (!$emailUser) {
|
||||
$entity->set('isRead', null);
|
||||
$entity->clear('isImportant');
|
||||
$entity->clear('inTrash');
|
||||
$entity->set(Email::USERS_COLUMN_IS_READ, null);
|
||||
$entity->clear(Email::USERS_COLUMN_IS_IMPORTANT);
|
||||
$entity->clear(Email::USERS_COLUMN_IN_TRASH);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$entity->set([
|
||||
'isRead' => $emailUser->get('isRead'),
|
||||
'isImportant' => $emailUser->get('isImportant'),
|
||||
'inTrash' => $emailUser->get('inTrash'),
|
||||
Email::USERS_COLUMN_IS_READ => $emailUser->get(Email::USERS_COLUMN_IS_READ),
|
||||
Email::USERS_COLUMN_IS_IMPORTANT => $emailUser->get(Email::USERS_COLUMN_IS_IMPORTANT),
|
||||
Email::USERS_COLUMN_IN_TRASH => $emailUser->get(Email::USERS_COLUMN_IN_TRASH),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,27 +29,26 @@
|
||||
|
||||
namespace Espo\Classes\FieldProcessing\User;
|
||||
|
||||
use Espo\Entities\AuthLogRecord;
|
||||
use Espo\Entities\AuthToken;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\{
|
||||
FieldProcessing\Loader,
|
||||
FieldProcessing\Loader\Params,
|
||||
ORM\EntityManager,
|
||||
Acl,
|
||||
Acl\Table,
|
||||
};
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @implements Loader<\Espo\Entities\User>
|
||||
* @implements Loader<User>
|
||||
*/
|
||||
class LastAccessLoader implements Loader
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
private $acl;
|
||||
private EntityManager $entityManager;
|
||||
private Acl $acl;
|
||||
|
||||
public function __construct(EntityManager $entityManager, Acl $acl)
|
||||
{
|
||||
@@ -67,7 +66,7 @@ class LastAccessLoader implements Loader
|
||||
}
|
||||
|
||||
$authToken = $this->entityManager
|
||||
->getRDBRepository('AuthToken')
|
||||
->getRDBRepository(AuthToken::ENTITY_TYPE)
|
||||
->select(['id', 'lastAccess'])
|
||||
->where([
|
||||
'userId' => $entity->getId(),
|
||||
@@ -87,7 +86,7 @@ class LastAccessLoader implements Loader
|
||||
try {
|
||||
$dt = new DateTime($lastAccess);
|
||||
}
|
||||
catch (Exception $e) {}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
$where = [
|
||||
@@ -100,7 +99,7 @@ class LastAccessLoader implements Loader
|
||||
}
|
||||
|
||||
$authLogRecord = $this->entityManager
|
||||
->getRDBRepository('AuthLogRecord')
|
||||
->getRDBRepository(AuthLogRecord::ENTITY_TYPE)
|
||||
->select(['id', 'createdAt'])
|
||||
->where($where)
|
||||
->order('requestTime', true)
|
||||
|
||||
@@ -29,19 +29,18 @@
|
||||
|
||||
namespace Espo\Classes\Jobs;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\Config,
|
||||
ORM\EntityManager,
|
||||
Job\JobDataLess,
|
||||
};
|
||||
use Espo\Entities\AuthToken;
|
||||
use Espo\Core\Job\JobDataLess;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class AuthTokenControl implements JobDataLess
|
||||
{
|
||||
private $config;
|
||||
|
||||
private $entityManager;
|
||||
private Config $config;
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(Config $config, EntityManager $entityManager)
|
||||
{
|
||||
@@ -67,7 +66,7 @@ class AuthTokenControl implements JobDataLess
|
||||
|
||||
$dt->modify('-' . $authTokenLifetime . ' hours');
|
||||
|
||||
$authTokenLifetimeThreshold = $dt->format('Y-m-d H:i:s');
|
||||
$authTokenLifetimeThreshold = $dt->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
|
||||
|
||||
$whereClause['createdAt<'] = $authTokenLifetimeThreshold;
|
||||
}
|
||||
@@ -77,13 +76,13 @@ class AuthTokenControl implements JobDataLess
|
||||
|
||||
$dt->modify('-' . $authTokenMaxIdleTime . ' hours');
|
||||
|
||||
$authTokenMaxIdleTimeThreshold = $dt->format('Y-m-d H:i:s');
|
||||
$authTokenMaxIdleTimeThreshold = $dt->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
|
||||
|
||||
$whereClause['lastAccess<'] = $authTokenMaxIdleTimeThreshold;
|
||||
}
|
||||
|
||||
$tokenList = $this->entityManager
|
||||
->getRDBRepository('AuthToken')
|
||||
->getRDBRepository(AuthToken::ENTITY_TYPE)
|
||||
->where($whereClause)
|
||||
->limit(0, 500)
|
||||
->find();
|
||||
|
||||
@@ -29,13 +29,12 @@
|
||||
|
||||
namespace Espo\Classes\Select\Email\Helpers;
|
||||
|
||||
use Espo\{
|
||||
ORM\EntityManager,
|
||||
};
|
||||
use Espo\Entities\EmailAddress;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
class EmailAddressHelper
|
||||
{
|
||||
private $entityManager;
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
@@ -45,7 +44,7 @@ class EmailAddressHelper
|
||||
public function getEmailAddressIdByValue(string $value): ?string
|
||||
{
|
||||
$emailAddress = $this->entityManager
|
||||
->getRDBRepository('EmailAddress')
|
||||
->getRDBRepository(EmailAddress::ENTITY_TYPE)
|
||||
->where([
|
||||
'lower' => strtolower($value),
|
||||
])
|
||||
|
||||
@@ -33,14 +33,14 @@ use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
|
||||
use Espo\Entities\ExternalAccount as ExternalAccountEntity;
|
||||
use Espo\Entities\Integration as IntegrationEntity;
|
||||
use Espo\Services\ExternalAccount as Service;
|
||||
|
||||
use Espo\Core\{
|
||||
Controllers\RecordBase,
|
||||
Api\Request,
|
||||
Api\Response,
|
||||
Record\ReadParams,
|
||||
};
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Controllers\RecordBase;
|
||||
use Espo\Core\Record\ReadParams;
|
||||
|
||||
use stdClass;
|
||||
|
||||
@@ -50,13 +50,13 @@ class ExternalAccount extends RecordBase
|
||||
|
||||
protected function checkAccess(): bool
|
||||
{
|
||||
return $this->acl->checkScope('ExternalAccount');
|
||||
return $this->acl->checkScope(ExternalAccountEntity::ENTITY_TYPE);
|
||||
}
|
||||
|
||||
public function getActionList(Request $request, Response $response): stdClass
|
||||
{
|
||||
$integrations = $this->entityManager
|
||||
->getRDBRepository('Integration')
|
||||
->getRDBRepository(IntegrationEntity::ENTITY_TYPE)
|
||||
->find();
|
||||
|
||||
$list = [];
|
||||
@@ -103,7 +103,7 @@ class ExternalAccount extends RecordBase
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$entity = $this->entityManager->getEntity('Integration', $integration);
|
||||
$entity = $this->entityManager->getEntityById(IntegrationEntity::ENTITY_TYPE, $integration);
|
||||
|
||||
if ($entity) {
|
||||
return (object) [
|
||||
@@ -147,7 +147,7 @@ class ExternalAccount extends RecordBase
|
||||
$data->data = null;
|
||||
}
|
||||
|
||||
$entity = $this->entityManager->getEntity('ExternalAccount', $id);
|
||||
$entity = $this->entityManager->getEntityById(ExternalAccountEntity::ENTITY_TYPE, $id);
|
||||
|
||||
if (!$entity) {
|
||||
throw new NotFound();
|
||||
|
||||
@@ -29,22 +29,15 @@
|
||||
|
||||
namespace Espo\Core\Acl\Table;
|
||||
|
||||
use Espo\Entities\Team;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\Entities\Role as RoleEntity;
|
||||
|
||||
class DefaultRoleListProvider implements RoleListProvider
|
||||
{
|
||||
private $user;
|
||||
|
||||
private $entityManager;
|
||||
|
||||
public function __construct(User $user, EntityManager $entityManager)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
public function __construct(private User $user, private EntityManager $entityManager)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @return Role[]
|
||||
@@ -55,7 +48,7 @@ class DefaultRoleListProvider implements RoleListProvider
|
||||
|
||||
/** @var iterable<RoleEntity> $userRoleList */
|
||||
$userRoleList = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'roles')
|
||||
->find();
|
||||
|
||||
@@ -63,16 +56,16 @@ class DefaultRoleListProvider implements RoleListProvider
|
||||
$roleList[] = $role;
|
||||
}
|
||||
|
||||
/** @var iterable<\Espo\Entities\Team> $teamList */
|
||||
/** @var iterable<Team> $teamList */
|
||||
$teamList = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'teams')
|
||||
->find();
|
||||
|
||||
foreach ($teamList as $team) {
|
||||
/** @var iterable<RoleEntity> $teamRoleList */
|
||||
$teamRoleList = $this->entityManager
|
||||
->getRDBRepository('Team')
|
||||
->getRDBRepository(Team::ENTITY_TYPE)
|
||||
->getRelation($team, 'roles')
|
||||
->find();
|
||||
|
||||
|
||||
@@ -29,19 +29,17 @@
|
||||
|
||||
namespace Espo\Core\Console\Commands;
|
||||
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
Authentication\AuthToken\Manager as AuthTokenManager,
|
||||
Console\Command,
|
||||
Console\Command\Params,
|
||||
Console\IO,
|
||||
};
|
||||
use Espo\Entities\User;
|
||||
use Espo\Core\Authentication\AuthToken\Manager as AuthTokenManager;
|
||||
use Espo\Core\Console\Command;
|
||||
use Espo\Core\Console\Command\Params;
|
||||
use Espo\Core\Console\IO;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
class AuthTokenCheck implements Command
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
private $authTokenManager;
|
||||
private EntityManager $entityManager;
|
||||
private AuthTokenManager $authTokenManager;
|
||||
|
||||
public function __construct(EntityManager $entityManager, AuthTokenManager $authTokenManager)
|
||||
{
|
||||
@@ -74,7 +72,7 @@ class AuthTokenCheck implements Command
|
||||
$userId = $authToken->getUserId();
|
||||
|
||||
$user = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->select('id')
|
||||
->where([
|
||||
'id' => $userId,
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Console\Command;
|
||||
use Espo\Core\Console\Command\Params;
|
||||
use Espo\Core\Console\IO;
|
||||
|
||||
use Espo\Entities\Extension as ExtensionEntity;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\Upgrades\ExtensionManager;
|
||||
@@ -43,11 +44,9 @@ use Throwable;
|
||||
|
||||
class Extension implements Command
|
||||
{
|
||||
private $container;
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $fileManager;
|
||||
private Container $container;
|
||||
private EntityManager $entityManager;
|
||||
private FileManager $fileManager;
|
||||
|
||||
public function __construct(Container $container, EntityManager $entityManager, FileManager $fileManager)
|
||||
{
|
||||
@@ -103,8 +102,6 @@ class Extension implements Command
|
||||
}
|
||||
|
||||
$this->runInstall($file, $io);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private function runInstall(string $file, IO $io): void
|
||||
@@ -169,7 +166,7 @@ class Extension implements Command
|
||||
|
||||
if ($id) {
|
||||
$record = $this->entityManager
|
||||
->getRDBRepository('Extension')
|
||||
->getRDBRepository(ExtensionEntity::ENTITY_TYPE)
|
||||
->where([
|
||||
'id' => $id,
|
||||
'isInstalled' => true,
|
||||
@@ -194,7 +191,7 @@ class Extension implements Command
|
||||
}
|
||||
|
||||
$record = $this->entityManager
|
||||
->getRDBRepository('Extension')
|
||||
->getRDBRepository(ExtensionEntity::ENTITY_TYPE)
|
||||
->where([
|
||||
'name' => $name,
|
||||
'isInstalled' => true,
|
||||
@@ -253,7 +250,7 @@ class Extension implements Command
|
||||
private function printList(IO $io): void
|
||||
{
|
||||
$collection = $this->entityManager
|
||||
->getRDBRepository('Extension')
|
||||
->getRDBRepository(ExtensionEntity::ENTITY_TYPE)
|
||||
->find();
|
||||
|
||||
$count = is_countable($collection) ? count($collection) : iterator_count($collection);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Console\Commands;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
Utils\PasswordHash,
|
||||
@@ -62,7 +63,7 @@ class SetPassword implements Command
|
||||
|
||||
$em = $this->entityManager;
|
||||
|
||||
$user = $em->getRDBRepository('User')
|
||||
$user = $em->getRDBRepository(User::ENTITY_TYPE)
|
||||
->where(['userName' => $userName])
|
||||
->findOne();
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ use Espo\Entities\ExternalAccount as ExternalAccountEntity;
|
||||
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\{
|
||||
ORM\Repository\SaveOption,
|
||||
Utils\Metadata,
|
||||
Utils\Config,
|
||||
InjectableFactory,
|
||||
ExternalAccount\OAuth2\Client as OAuth2Client};
|
||||
use Espo\Core\ExternalAccount\Clients\IClient;
|
||||
use Espo\Core\ExternalAccount\OAuth2\Client as OAuth2Client;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\ORM\Repository\SaveOption;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
@@ -111,7 +111,7 @@ class ClientManager
|
||||
$externalAccountEntity->set('refreshToken', $data['refreshToken']);
|
||||
}
|
||||
|
||||
$copy = $this->entityManager->getEntity('ExternalAccount', $externalAccountEntity->getId());
|
||||
$copy = $this->entityManager->getEntity(ExternalAccountEntity::ENTITY_TYPE, $externalAccountEntity->getId());
|
||||
|
||||
if (!$copy) {
|
||||
return;
|
||||
@@ -150,10 +150,11 @@ class ClientManager
|
||||
}
|
||||
|
||||
/** @var IntegrationEntity|null $integrationEntity */
|
||||
$integrationEntity = $this->entityManager->getEntity('Integration', $integration);
|
||||
$integrationEntity = $this->entityManager->getEntity(IntegrationEntity::ENTITY_TYPE, $integration);
|
||||
|
||||
/** @var ExternalAccountEntity|null $externalAccountEntity */
|
||||
$externalAccountEntity = $this->entityManager->getEntity('ExternalAccount', $integration . '__' . $userId);
|
||||
$externalAccountEntity = $this->entityManager
|
||||
->getEntity(ExternalAccountEntity::ENTITY_TYPE, $integration . '__' . $userId);
|
||||
|
||||
if (!$externalAccountEntity) {
|
||||
throw new Error("External Account {$integration} not found for {$userId}.");
|
||||
@@ -195,10 +196,11 @@ class ClientManager
|
||||
protected function createOAuth2(string $integration, string $userId): ?object
|
||||
{
|
||||
/** @var IntegrationEntity|null $integrationEntity */
|
||||
$integrationEntity = $this->entityManager->getEntity('Integration', $integration);
|
||||
$integrationEntity = $this->entityManager->getEntity(IntegrationEntity::ENTITY_TYPE, $integration);
|
||||
|
||||
/** @var ExternalAccountEntity|null $externalAccountEntity */
|
||||
$externalAccountEntity = $this->entityManager->getEntity('ExternalAccount', $integration . '__' . $userId);
|
||||
$externalAccountEntity = $this->entityManager
|
||||
->getEntity(ExternalAccountEntity::ENTITY_TYPE, $integration . '__' . $userId);
|
||||
|
||||
/** @var class-string $className */
|
||||
$className = $this->metadata->get("integrations.{$integration}.clientClassName");
|
||||
@@ -317,7 +319,7 @@ class ClientManager
|
||||
$id = $externalAccountEntity->getId();
|
||||
|
||||
$e = $this->entityManager
|
||||
->getRDBRepository('ExternalAccount')
|
||||
->getRDBRepository(ExternalAccountEntity::ENTITY_TYPE)
|
||||
->select(['id', 'isLocked'])
|
||||
->where(['id' => $id])
|
||||
->findOne();
|
||||
@@ -336,7 +338,7 @@ class ClientManager
|
||||
$id = $externalAccountEntity->getId();
|
||||
|
||||
$e = $this->entityManager
|
||||
->getRDBRepository('ExternalAccount')
|
||||
->getRDBRepository(ExternalAccountEntity::ENTITY_TYPE)
|
||||
->select(['id', 'isLocked'])
|
||||
->where(['id' => $id])
|
||||
->findOne();
|
||||
@@ -360,7 +362,7 @@ class ClientManager
|
||||
$id = $externalAccountEntity->getId();
|
||||
|
||||
$e = $this->entityManager
|
||||
->getRDBRepository('ExternalAccount')
|
||||
->getRDBRepository(ExternalAccountEntity::ENTITY_TYPE)
|
||||
->select(['id', 'isLocked'])
|
||||
->where(['id' => $id])
|
||||
->findOne();
|
||||
@@ -378,7 +380,7 @@ class ClientManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Espo\Core\ExternalAccount\Clients\IClient $client
|
||||
* @param IClient $client
|
||||
* @throws Error
|
||||
*/
|
||||
public function reFetchClient(object $client): void
|
||||
@@ -387,7 +389,7 @@ class ClientManager
|
||||
|
||||
$id = $externalAccountEntity->getId();
|
||||
|
||||
$e = $this->entityManager->getEntity('ExternalAccount', $id);
|
||||
$e = $this->entityManager->getEntityById(ExternalAccountEntity::ENTITY_TYPE, $id);
|
||||
|
||||
if (!$e) {
|
||||
throw new Error("External Account Client Manager: Client {$id} not found in DB.");
|
||||
|
||||
@@ -419,7 +419,7 @@ class Saver implements SaverInterface
|
||||
if ($phoneNumberValue !== $entity->getFetched('phoneNumber')) {
|
||||
|
||||
$phoneNumberNew = $this->entityManager
|
||||
->getRDBRepository('PhoneNumber')
|
||||
->getRDBRepository(PhoneNumber::ENTITY_TYPE)
|
||||
->where([
|
||||
'name' => $phoneNumberValue,
|
||||
])
|
||||
|
||||
@@ -67,7 +67,7 @@ class RoleListProvider implements RoleListProviderInterface
|
||||
|
||||
/** @var iterable<PortalRole> $userRoleList */
|
||||
$userRoleList = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'portalRoles')
|
||||
->find();
|
||||
|
||||
@@ -77,7 +77,7 @@ class RoleListProvider implements RoleListProviderInterface
|
||||
|
||||
/** @var iterable<PortalRole> $portalRoleList */
|
||||
$portalRoleList = $this->entityManager
|
||||
->getRDBRepository('Portal')
|
||||
->getRDBRepository(Portal::ENTITY_TYPE)
|
||||
->getRelation($this->portal, 'portalRoles')
|
||||
->find();
|
||||
|
||||
|
||||
@@ -29,21 +29,18 @@
|
||||
|
||||
namespace Espo\Core\Portal;
|
||||
|
||||
use Espo\Entities\Portal;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\Exceptions\{
|
||||
Error,
|
||||
NotFound,
|
||||
Forbidden,
|
||||
};
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
|
||||
use Espo\Core\{
|
||||
Container\ContainerBuilder,
|
||||
Portal\Container as PortalContainer,
|
||||
Portal\Container\ContainerConfiguration as PortalContainerConfiguration,
|
||||
Portal\Utils\Config,
|
||||
Application as BaseApplication,
|
||||
};
|
||||
use Espo\Core\Application as BaseApplication;
|
||||
use Espo\Core\Container\ContainerBuilder;
|
||||
use Espo\Core\Portal\Container as PortalContainer;
|
||||
use Espo\Core\Portal\Container\ContainerConfiguration as PortalContainerConfiguration;
|
||||
use Espo\Core\Portal\Utils\Config;
|
||||
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
@@ -91,11 +88,11 @@ class Application extends BaseApplication
|
||||
/** @var EntityManager $entityManager */
|
||||
$entityManager = $this->container->get('entityManager');
|
||||
|
||||
$portal = $entityManager->getEntity('Portal', $portalId);
|
||||
$portal = $entityManager->getEntity(Portal::ENTITY_TYPE, $portalId);
|
||||
|
||||
if (!$portal) {
|
||||
$portal = $entityManager
|
||||
->getRDBRepository('Portal')
|
||||
->getRDBRepository(Portal::ENTITY_TYPE)
|
||||
->where(['customId' => $portalId])
|
||||
->findOne();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Core\Rebuild\Actions;
|
||||
use Espo\Core\Rebuild\RebuildAction;
|
||||
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\ScheduledJob;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
@@ -39,9 +40,8 @@ use Espo\ORM\EntityManager;
|
||||
*/
|
||||
class ScheduledJobs implements RebuildAction
|
||||
{
|
||||
private $metadata;
|
||||
|
||||
private $entityManager;
|
||||
private Metadata $metadata;
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(Metadata $metadata, EntityManager $entityManager)
|
||||
{
|
||||
@@ -70,10 +70,10 @@ class ScheduledJobs implements RebuildAction
|
||||
$systemJobNameList[] = $jobName;
|
||||
|
||||
$sj = $this->entityManager
|
||||
->getRDBRepository('ScheduledJob')
|
||||
->getRDBRepository(ScheduledJob::ENTITY_TYPE)
|
||||
->where([
|
||||
'job' => $jobName,
|
||||
'status' => 'Active',
|
||||
'status' => ScheduledJob::STATUS_ACTIVE,
|
||||
'scheduling' => $defs['scheduling'],
|
||||
])
|
||||
->findOne();
|
||||
@@ -83,7 +83,7 @@ class ScheduledJobs implements RebuildAction
|
||||
}
|
||||
|
||||
$existingJob = $this->entityManager
|
||||
->getRDBRepository('ScheduledJob')
|
||||
->getRDBRepository(ScheduledJob::ENTITY_TYPE)
|
||||
->where([
|
||||
'job' => $jobName,
|
||||
])
|
||||
@@ -99,9 +99,9 @@ class ScheduledJobs implements RebuildAction
|
||||
$name = $defs['name'];
|
||||
}
|
||||
|
||||
$this->entityManager->createEntity('ScheduledJob', [
|
||||
$this->entityManager->createEntity(ScheduledJob::ENTITY_TYPE, [
|
||||
'job' => $jobName,
|
||||
'status' => 'Active',
|
||||
'status' => ScheduledJob::STATUS_ACTIVE,
|
||||
'scheduling' => $defs['scheduling'],
|
||||
'isInternal' => true,
|
||||
'name' => $name,
|
||||
@@ -109,7 +109,7 @@ class ScheduledJobs implements RebuildAction
|
||||
}
|
||||
|
||||
$internalScheduledJobList = $this->entityManager
|
||||
->getRDBRepository('ScheduledJob')
|
||||
->getRDBRepository(ScheduledJob::ENTITY_TYPE)
|
||||
->where([
|
||||
'isInternal' => true,
|
||||
])
|
||||
@@ -120,7 +120,7 @@ class ScheduledJobs implements RebuildAction
|
||||
|
||||
if (!in_array($jobName, $systemJobNameList)) {
|
||||
$this->entityManager
|
||||
->getRDBRepository('ScheduledJob')
|
||||
->getRDBRepository(ScheduledJob::ENTITY_TYPE)
|
||||
->deleteFromDb($scheduledJob->getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,9 @@ namespace Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\Job\MetadataProvider;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\ClassFinder,
|
||||
Utils\Language,
|
||||
Utils\System,
|
||||
Utils\DateTime as DateTimeUtil,
|
||||
ORM\EntityManager,
|
||||
};
|
||||
use Espo\Entities\Job;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
@@ -46,15 +42,11 @@ use DateTime;
|
||||
class ScheduledJob
|
||||
{
|
||||
protected string $cronFile = 'cron.php';
|
||||
|
||||
/**
|
||||
* Period to check if crontab is configured properly.
|
||||
*/
|
||||
protected string $checkingCronPeriod = '25 hours';
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
/** @var array<string,string> */
|
||||
protected $cronSetup = [
|
||||
'linux' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BINARY} -f {CRON-FILE} > /dev/null 2>&1',
|
||||
'windows' => '{PHP-BINARY} -f {FULL-CRON-PATH}',
|
||||
@@ -63,13 +55,9 @@ class ScheduledJob
|
||||
];
|
||||
|
||||
private ClassFinder $classFinder;
|
||||
|
||||
private Language $language;
|
||||
|
||||
private EntityManager $entityManager;
|
||||
|
||||
private MetadataProvider $metadataProvider;
|
||||
|
||||
private System $systemUtil;
|
||||
|
||||
public function __construct(
|
||||
@@ -184,6 +172,6 @@ class ScheduledJob
|
||||
]
|
||||
];
|
||||
|
||||
return (bool) $this->entityManager->getRDBRepository('Job')->findOne($selectParams);
|
||||
return (bool) $this->entityManager->getRDBRepository(Job::ENTITY_TYPE)->findOne($selectParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ class EmailAddress extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'EmailAddress';
|
||||
|
||||
public const RELATION_ENTITY_EMAIL_ADDRESS = 'EntityEmailAddress';
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return void
|
||||
|
||||
@@ -156,7 +156,7 @@ class Note extends Entity
|
||||
$attachmentsIds = $data->attachmentsIds;
|
||||
|
||||
$collection = $this->entityManager
|
||||
->getRDBRepository('Attachment')
|
||||
->getRDBRepository(Attachment::ENTITY_TYPE)
|
||||
->select(['id', 'name', 'type'])
|
||||
->order('createdAt')
|
||||
->where([
|
||||
|
||||
@@ -37,6 +37,8 @@ class PhoneNumber extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'PhoneNumber';
|
||||
|
||||
public const RELATION_ENTITY_PHONE_NUMBER = 'EntityPhoneNumber';
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return void
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Business\Distribution\Lead;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Lead;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
@@ -49,7 +50,7 @@ class LeastBusy
|
||||
/**
|
||||
* @param Team $team
|
||||
* @param ?string $targetUserPosition
|
||||
* @return User|null
|
||||
* @return ?User
|
||||
*/
|
||||
public function getUser($team, $targetUserPosition = null)
|
||||
{
|
||||
@@ -80,11 +81,15 @@ class LeastBusy
|
||||
foreach ($userList as $user) {
|
||||
$where = [
|
||||
'assignedUserId' => $user->getId(),
|
||||
'status<>' => ['Converted', 'Recycled', 'Dead'],
|
||||
'status<>' => [
|
||||
Lead::STATUS_CONVERTED,
|
||||
Lead::STATUS_RECYCLED,
|
||||
Lead::STATUS_DEAD,
|
||||
],
|
||||
];
|
||||
|
||||
$count = $this->entityManager
|
||||
->getRDBRepository('Lead')
|
||||
->getRDBRepository(Lead::ENTITY_TYPE)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
@@ -108,7 +113,7 @@ class LeastBusy
|
||||
}
|
||||
|
||||
if ($foundUserId !== false) {
|
||||
return $this->entityManager->getEntity('User', $foundUserId);
|
||||
return $this->entityManager->getEntityById(User::ENTITY_TYPE, $foundUserId);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Business\Distribution\Lead;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Lead;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
@@ -82,7 +83,7 @@ class RoundRobin
|
||||
}
|
||||
|
||||
$lead = $this->entityManager
|
||||
->getRDBRepository('Lead')
|
||||
->getRDBRepository(Lead::ENTITY_TYPE)
|
||||
->where([
|
||||
'assignedUserId' => $userIdList
|
||||
])
|
||||
@@ -102,6 +103,6 @@ class RoundRobin
|
||||
}
|
||||
}
|
||||
|
||||
return $this->entityManager->getEntity('User', $userIdList[$num]);
|
||||
return $this->entityManager->getEntity(User::ENTITY_TYPE, $userIdList[$num]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,29 +29,30 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Classes\FieldProcessing\Campaign;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Campaign;
|
||||
use Espo\Modules\Crm\Entities\CampaignLogRecord;
|
||||
use Espo\Modules\Crm\Entities\Lead;
|
||||
use Espo\Modules\Crm\Entities\Opportunity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\{
|
||||
FieldProcessing\Loader,
|
||||
FieldProcessing\Loader\Params,
|
||||
ORM\EntityManager,
|
||||
Acl,
|
||||
Currency\ConfigDataProvider as CurrencyConfigDataProvider,
|
||||
};
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Currency\ConfigDataProvider as CurrencyConfigDataProvider;
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use PDO;
|
||||
|
||||
use const PHP_ROUND_HALF_EVEN;
|
||||
|
||||
/**
|
||||
* @implements Loader<\Espo\Modules\Crm\Entities\Campaign>
|
||||
* @implements Loader<Campaign>
|
||||
*/
|
||||
class StatsLoader implements Loader
|
||||
{
|
||||
private EntityManager $entityManager;
|
||||
|
||||
private Acl $acl;
|
||||
|
||||
private CurrencyConfigDataProvider $currencyDataProvider;
|
||||
|
||||
public function __construct(
|
||||
@@ -67,10 +68,10 @@ class StatsLoader implements Loader
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
$sentCount = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
'action' => 'Sent',
|
||||
'action' => CampaignLogRecord::ACTION_SENT,
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
@@ -82,10 +83,10 @@ class StatsLoader implements Loader
|
||||
$entity->set('sentCount', $sentCount);
|
||||
|
||||
$openedCount = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
'action' => 'Opened',
|
||||
'action' => CampaignLogRecord::ACTION_OPENED,
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
@@ -95,32 +96,28 @@ class StatsLoader implements Loader
|
||||
$openedPercentage = null;
|
||||
|
||||
if ($sentCount > 0) {
|
||||
$openedPercentage = round(
|
||||
$openedCount / $sentCount * 100, 2,
|
||||
PHP_ROUND_HALF_EVEN
|
||||
);
|
||||
$openedPercentage = round($openedCount / $sentCount * 100, 2, PHP_ROUND_HALF_EVEN);
|
||||
}
|
||||
|
||||
$entity->set('openedPercentage', $openedPercentage);
|
||||
|
||||
$clickedCount = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
'action' => 'Clicked',
|
||||
'action' => CampaignLogRecord::ACTION_CLICKED,
|
||||
'isTest' => false,
|
||||
'id=s' => [
|
||||
'entityType' => 'CampaignLogRecord',
|
||||
'selectParams' => [
|
||||
'select' => ['MIN:id'],
|
||||
'whereClause' => [
|
||||
'action' => 'Clicked',
|
||||
'isTest' => false,
|
||||
'campaignId' => $entity->getId(),
|
||||
],
|
||||
'groupBy' => ['queueItemId'],
|
||||
],
|
||||
],
|
||||
'id=s' => SelectBuilder::create()
|
||||
->select('MIN:id')
|
||||
->from(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'action' => CampaignLogRecord::ACTION_CLICKED,
|
||||
'isTest' => false,
|
||||
'campaignId' => $entity->getId(),
|
||||
])
|
||||
->group('queueItemId')
|
||||
->build()
|
||||
->getRaw(),
|
||||
])
|
||||
->count();
|
||||
|
||||
@@ -138,10 +135,10 @@ class StatsLoader implements Loader
|
||||
$entity->set('clickedPercentage', $clickedPercentage);
|
||||
|
||||
$optedInCount = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
'action' => 'Opted In',
|
||||
'action' => CampaignLogRecord::ACTION_OPTED_IN,
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
@@ -153,10 +150,10 @@ class StatsLoader implements Loader
|
||||
$entity->set('optedInCount', $optedInCount);
|
||||
|
||||
$optedOutCount = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
'action' => 'Opted Out',
|
||||
'action' => CampaignLogRecord::ACTION_OPTED_OUT,
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
@@ -175,10 +172,10 @@ class StatsLoader implements Loader
|
||||
$entity->set('optedOutPercentage', $optedOutPercentage);
|
||||
|
||||
$bouncedCount = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
'action' => 'Bounced',
|
||||
'action' => CampaignLogRecord::ACTION_BOUNCED,
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
@@ -196,9 +193,9 @@ class StatsLoader implements Loader
|
||||
|
||||
$entity->set('bouncedPercentage', $bouncedPercentage);
|
||||
|
||||
if ($this->acl->check('Lead')) {
|
||||
if ($this->acl->check(Lead::ENTITY_TYPE)) {
|
||||
$leadCreatedCount = $this->entityManager
|
||||
->getRDBRepository('Lead')
|
||||
->getRDBRepository(Lead::ENTITY_TYPE)
|
||||
->where([
|
||||
'campaignId' => $entity->getId(),
|
||||
])
|
||||
@@ -211,16 +208,16 @@ class StatsLoader implements Loader
|
||||
$entity->set('leadCreatedCount', $leadCreatedCount);
|
||||
}
|
||||
|
||||
if ($this->acl->check('Opportunity')) {
|
||||
if ($this->acl->check(Opportunity::ENTITY_TYPE)) {
|
||||
$entity->set('revenueCurrency', $this->currencyDataProvider->getDefaultCurrency());
|
||||
|
||||
$query = $this->entityManager
|
||||
->getQueryBuilder()
|
||||
->select()
|
||||
->from('Opportunity')
|
||||
->from(Opportunity::ENTITY_TYPE)
|
||||
->select(['SUM:amountConverted'])
|
||||
->where([
|
||||
'stage' => 'Closed Won',
|
||||
'stage' => Opportunity::STAGE_CLOSED_WON,
|
||||
'campaignId' => $entity->getId(),
|
||||
])
|
||||
->group('opportunity.campaignId')
|
||||
|
||||
+7
-11
@@ -29,28 +29,24 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Classes\FieldProcessing\TargetList;
|
||||
|
||||
use Espo\Modules\Crm\Entities\TargetList;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\Core\{
|
||||
FieldProcessing\Loader,
|
||||
FieldProcessing\Loader\Params,
|
||||
ORM\EntityManager,
|
||||
};
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @implements Loader<\Espo\Modules\Crm\Entities\TargetList>
|
||||
* @implements Loader<TargetList>
|
||||
*/
|
||||
class EntryCountLoader implements Loader
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
/** @var string[] */
|
||||
private array $targetLinkList;
|
||||
|
||||
private EntityManager $entityManager;
|
||||
|
||||
private Metadata $metadata;
|
||||
|
||||
public function __construct(EntityManager $entityManager, Metadata $metadata)
|
||||
@@ -74,7 +70,7 @@ class EntryCountLoader implements Loader
|
||||
|
||||
foreach ($this->targetLinkList as $link) {
|
||||
$count += $this->entityManager
|
||||
->getRDBRepository('TargetList')
|
||||
->getRDBRepository(TargetList::ENTITY_TYPE)
|
||||
->getRelation($entity, $link)
|
||||
->count();
|
||||
}
|
||||
|
||||
+10
-11
@@ -29,10 +29,10 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Classes\FormulaFunctions\ExtGroup\AccountGroup;
|
||||
|
||||
use Espo\Core\Formula\{
|
||||
Functions\BaseFunction,
|
||||
ArgumentList,
|
||||
};
|
||||
use Espo\Modules\Crm\Entities\Account;
|
||||
use Espo\Modules\Crm\Entities\Contact;
|
||||
use Espo\Core\Formula\ArgumentList;
|
||||
use Espo\Core\Formula\Functions\BaseFunction;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
@@ -73,7 +73,7 @@ class FindByEmailAddressType extends BaseFunction implements
|
||||
|
||||
$em = $this->entityManager;
|
||||
|
||||
$account = $em->getRDBRepository('Account')
|
||||
$account = $em->getRDBRepository(Account::ENTITY_TYPE)
|
||||
->where([
|
||||
'emailAddress' => $emailAddress,
|
||||
])
|
||||
@@ -84,12 +84,11 @@ class FindByEmailAddressType extends BaseFunction implements
|
||||
}
|
||||
|
||||
$ignoreList = json_decode(
|
||||
$this->fileManager->getContents(
|
||||
'application/Espo/Modules/Crm/Resources/data/freeEmailProviderDomains.json'
|
||||
)
|
||||
$this->fileManager
|
||||
->getContents('application/Espo/Modules/Crm/Resources/data/freeEmailProviderDomains.json')
|
||||
) ?? [];
|
||||
|
||||
$contact = $em->getRDBRepository('Contact')
|
||||
$contact = $em->getRDBRepository(Contact::ENTITY_TYPE)
|
||||
->where([
|
||||
'emailAddress' => $emailAddress,
|
||||
])
|
||||
@@ -97,7 +96,7 @@ class FindByEmailAddressType extends BaseFunction implements
|
||||
|
||||
if ($contact) {
|
||||
if (!in_array($domain, $ignoreList)) {
|
||||
$account = $em->getRDBRepository('Account')
|
||||
$account = $em->getRDBRepository(Account::ENTITY_TYPE)
|
||||
->join('contacts')
|
||||
->where([
|
||||
'emailAddress*' => '%@' . $domain,
|
||||
@@ -120,7 +119,7 @@ class FindByEmailAddressType extends BaseFunction implements
|
||||
return null;
|
||||
}
|
||||
|
||||
$account = $em->getRDBRepository('Account')
|
||||
$account = $em->getRDBRepository(Account::ENTITY_TYPE)
|
||||
->where([
|
||||
'emailAddress*' => '%@' . $domain,
|
||||
])
|
||||
|
||||
@@ -37,6 +37,9 @@ class KnowledgeBaseArticle extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'KnowledgeBaseArticle';
|
||||
|
||||
public const STATUS_PUBLISHED = 'Published';
|
||||
public const STATUS_ARCHIVED = 'Archived';
|
||||
|
||||
public function getOrder(): ?int
|
||||
{
|
||||
return $this->get('order');
|
||||
|
||||
@@ -22,17 +22,14 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Jobs;
|
||||
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
Job\JobDataLess,
|
||||
};
|
||||
use Espo\Core\Utils\DateTime;
|
||||
use Espo\Modules\Crm\Entities\KnowledgeBaseArticle;
|
||||
use Espo\Core\Job\JobDataLess;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
class ControlKnowledgeBaseArticleStatus implements JobDataLess
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
@@ -42,15 +39,15 @@ class ControlKnowledgeBaseArticleStatus implements JobDataLess
|
||||
public function run(): void
|
||||
{
|
||||
$list = $this->entityManager
|
||||
->getRDBRepository('KnowledgeBaseArticle')
|
||||
->getRDBRepository(KnowledgeBaseArticle::ENTITY_TYPE)
|
||||
->where([
|
||||
'expirationDate<=' => date('Y-m-d'),
|
||||
'status' => 'Published',
|
||||
'expirationDate<=' => date(DateTime::SYSTEM_DATE_FORMAT),
|
||||
'status' => KnowledgeBaseArticle::STATUS_PUBLISHED,
|
||||
])
|
||||
->find();
|
||||
|
||||
foreach ($list as $e) {
|
||||
$e->set('status', 'Archived');
|
||||
$e->set('status', KnowledgeBaseArticle::STATUS_ARCHIVED);
|
||||
|
||||
$this->entityManager->saveEntity($e);
|
||||
}
|
||||
|
||||
@@ -29,17 +29,19 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\Core\Repositories\Database;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Tools\Stream\Service as StreamService;
|
||||
use Espo\Core\Di;
|
||||
|
||||
/**
|
||||
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\CaseObj>
|
||||
* @extends Database<\Espo\Modules\Crm\Entities\CaseObj>
|
||||
*/
|
||||
class CaseObj extends \Espo\Core\Repositories\Database implements
|
||||
Di\ServiceFactoryAware
|
||||
class CaseObj extends Database implements
|
||||
Di\InjectableFactoryAware
|
||||
{
|
||||
use Di\ServiceFactorySetter;
|
||||
use Di\InjectableFactorySetter;
|
||||
|
||||
protected ?StreamService $streamService = null;
|
||||
|
||||
@@ -53,15 +55,15 @@ class CaseObj extends \Espo\Core\Repositories\Database implements
|
||||
protected function getStreamService(): StreamService
|
||||
{
|
||||
if (!$this->streamService) {
|
||||
/** @var StreamService $service */
|
||||
$service = $this->serviceFactory->create('Stream');
|
||||
|
||||
$this->streamService = $service;
|
||||
$this->streamService = $this->injectableFactory->create(StreamService::class);
|
||||
}
|
||||
|
||||
return $this->streamService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Move to hooks.
|
||||
*/
|
||||
protected function handleAfterSaveContacts(Entity $entity): void
|
||||
{
|
||||
if (!$entity->isAttributeChanged('contactId')) {
|
||||
@@ -74,11 +76,11 @@ class CaseObj extends \Espo\Core\Repositories\Database implements
|
||||
|
||||
if ($fetchedContactId) {
|
||||
$previousPortalUser = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->select(['id'])
|
||||
->where([
|
||||
'contactId' => $fetchedContactId,
|
||||
'type' => 'portal',
|
||||
'type' => User::TYPE_PORTAL,
|
||||
])
|
||||
->findOne();
|
||||
|
||||
@@ -96,11 +98,11 @@ class CaseObj extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
|
||||
$portalUser = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->select(['id'])
|
||||
->where([
|
||||
'contactId' => $contactId,
|
||||
'type' => 'portal',
|
||||
'type' => User::TYPE_PORTAL,
|
||||
'isActive' => true,
|
||||
])
|
||||
->findOne();
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Account as AccountEntity;
|
||||
use Espo\Modules\Crm\Entities\Lead as LeadEntity;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Repositories\Event as EventRepository;
|
||||
use Espo\Core\Di;
|
||||
@@ -107,7 +109,7 @@ class Meeting extends EventRepository implements
|
||||
|
||||
}
|
||||
|
||||
if ($parentType === 'Lead') {
|
||||
if ($parentType === LeadEntity::ENTITY_TYPE) {
|
||||
$columnList[] = 'status';
|
||||
$columnList[] = 'createdAccountId';
|
||||
$columnList[] = 'createdAccountName';
|
||||
@@ -124,13 +126,13 @@ class Meeting extends EventRepository implements
|
||||
$accountName = null;
|
||||
|
||||
if ($parent) {
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
if ($parent instanceof AccountEntity) {
|
||||
$accountId = $parent->getId();
|
||||
$accountName = $parent->get('name');
|
||||
}
|
||||
else if (
|
||||
$parent->getEntityType() == 'Lead' &&
|
||||
$parent->get('status') == 'Converted' &&
|
||||
$parent instanceof LeadEntity &&
|
||||
$parent->getStatus() === LeadEntity::STATUS_CONVERTED &&
|
||||
$parent->get('createdAccountId')
|
||||
) {
|
||||
$accountId = $parent->get('createdAccountId');
|
||||
@@ -140,7 +142,7 @@ class Meeting extends EventRepository implements
|
||||
if (
|
||||
!$accountId && $parent->get('accountId') &&
|
||||
$parent instanceof CoreEntity &&
|
||||
$parent->getRelationParam('account', 'entity') == 'Account'
|
||||
$parent->getRelationParam('account', 'entity') === AccountEntity::ENTITY_TYPE
|
||||
) {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
@@ -156,7 +158,7 @@ class Meeting extends EventRepository implements
|
||||
!$entity->get('accountName')
|
||||
) {
|
||||
$account = $this->entityManager
|
||||
->getRDBRepository('Account')
|
||||
->getRDBRepository(AccountEntity::ENTITY_TYPE)
|
||||
->select(['id', 'name'])
|
||||
->where(['id' => $entity->get('accountId')])
|
||||
->findOne();
|
||||
|
||||
@@ -29,19 +29,30 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\Core\Utils\DateTime;
|
||||
use Espo\Modules\Crm\Entities\Account as AccountEntity;
|
||||
use Espo\Modules\Crm\Entities\Contact as ContactEntity;
|
||||
use Espo\Modules\Crm\Entities\Lead as LeadEntity;
|
||||
use Espo\Modules\Crm\Entities\Task as TaskEntity;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Repositories\Event as EventRepository;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
|
||||
class Task extends EventRepository
|
||||
{
|
||||
protected $reminderSkippingStatusList = ['Completed', 'Canceled'];
|
||||
protected $reminderSkippingStatusList = [
|
||||
TaskEntity::STATUS_COMPLETED,
|
||||
TaskEntity::STATUS_CANCELED,
|
||||
];
|
||||
|
||||
/**
|
||||
* @todo Move to hooks.
|
||||
*/
|
||||
protected function beforeSave(Entity $entity, array $options = [])
|
||||
{
|
||||
if ($entity->isAttributeChanged('status')) {
|
||||
if ($entity->get('status') == 'Completed') {
|
||||
$entity->set('dateCompleted', date('Y-m-d H:i:s'));
|
||||
if ($entity->get('status') == TaskEntity::STATUS_COMPLETED) {
|
||||
$entity->set('dateCompleted', date(DateTime::SYSTEM_DATE_TIME_FORMAT));
|
||||
} else {
|
||||
$entity->set('dateCompleted', null);
|
||||
}
|
||||
@@ -81,7 +92,7 @@ class Task extends EventRepository
|
||||
$columnList[] = 'contactId';
|
||||
}
|
||||
|
||||
if ($parentType === 'Lead') {
|
||||
if ($parentType === LeadEntity::ENTITY_TYPE) {
|
||||
$columnList[] = 'status';
|
||||
$columnList[] = 'createdAccountId';
|
||||
$columnList[] = 'createdAccountName';
|
||||
@@ -102,11 +113,14 @@ class Task extends EventRepository
|
||||
$contactName = null;
|
||||
|
||||
if ($parent) {
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
if ($parent instanceof AccountEntity) {
|
||||
$accountId = $parent->getId();
|
||||
$accountName = $parent->get('name');
|
||||
}
|
||||
else if ($parent->getEntityType() == 'Lead' && $parent->get('status') == 'Converted') {
|
||||
else if (
|
||||
$parent instanceof LeadEntity &&
|
||||
$parent->getStatus() == LeadEntity::STATUS_CONVERTED
|
||||
) {
|
||||
if ($parent->get('createdAccountId')) {
|
||||
$accountId = $parent->get('createdAccountId');
|
||||
$accountName = $parent->get('createdAccountName');
|
||||
@@ -117,7 +131,7 @@ class Task extends EventRepository
|
||||
$contactName = $parent->get('createdContactName');
|
||||
}
|
||||
}
|
||||
else if ($parent->getEntityType() == 'Contact') {
|
||||
else if ($parent instanceof ContactEntity) {
|
||||
$contactId = $parent->getId();
|
||||
$contactName = $parent->get('name');
|
||||
}
|
||||
@@ -126,7 +140,7 @@ class Task extends EventRepository
|
||||
!$accountId &&
|
||||
$parent->get('accountId') &&
|
||||
$parent instanceof CoreEntity &&
|
||||
$parent->getRelationParam('account', 'entity') == 'Account'
|
||||
$parent->getRelationParam('account', 'entity') === AccountEntity::ENTITY_TYPE
|
||||
) {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
@@ -135,7 +149,7 @@ class Task extends EventRepository
|
||||
!$contactId &&
|
||||
$parent->get('contactId') &&
|
||||
$parent instanceof CoreEntity &&
|
||||
$parent->getRelationParam('contact', 'entity') == 'Contact'
|
||||
$parent->getRelationParam('contact', 'entity') === ContactEntity::ENTITY_TYPE
|
||||
) {
|
||||
$contactId = $parent->get('contactId');
|
||||
}
|
||||
@@ -152,7 +166,7 @@ class Task extends EventRepository
|
||||
!$entity->get('accountName')
|
||||
) {
|
||||
$account = $this->entityManager
|
||||
->getRDBRepository('Account')
|
||||
->getRDBRepository(AccountEntity::ENTITY_TYPE)
|
||||
->select(['id', 'name'])
|
||||
->where(['id' => $entity->get('accountId')])
|
||||
->findOne();
|
||||
@@ -167,7 +181,7 @@ class Task extends EventRepository
|
||||
!$entity->get('contactName')
|
||||
) {
|
||||
$contact = $this->entityManager
|
||||
->getRDBRepository('Contact')
|
||||
->getRDBRepository(ContactEntity::ENTITY_TYPE)
|
||||
->select(['id', 'name'])
|
||||
->where(['id' => $entity->get('contactId')])
|
||||
->findOne();
|
||||
|
||||
@@ -29,26 +29,22 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Services;
|
||||
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Modules\Crm\Entities\Campaign;
|
||||
use Espo\Modules\Crm\Entities\CampaignLogRecord as CampaignLogRecordEntity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\ORM\Query\Select;
|
||||
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Modules\Crm\Entities\TargetList as TargetListEntity;
|
||||
|
||||
use Espo\Core\Record\Collection as RecordCollection;
|
||||
use Espo\Services\Record;
|
||||
|
||||
use Espo\Core\Select\SearchParams;
|
||||
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use PDO;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
/**
|
||||
@@ -64,11 +60,8 @@ class TargetList extends Record implements
|
||||
* @var string[]
|
||||
*/
|
||||
protected $targetLinkList = [];
|
||||
|
||||
protected $noEditAccessRequiredLinkList = [];
|
||||
|
||||
protected $duplicatingLinkList = [];
|
||||
|
||||
protected $linkMandatorySelectAttributeList = [];
|
||||
|
||||
/**
|
||||
@@ -138,20 +131,20 @@ class TargetList extends Record implements
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$campaign = $this->entityManager->getEntity('Campaign', $sourceCampaignId);
|
||||
$campaign = $this->entityManager->getEntity(Campaign::ENTITY_TYPE, $sourceCampaignId);
|
||||
|
||||
if (!$campaign) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
if (!$this->acl->check($campaign, 'read')) {
|
||||
if (!$this->acl->check($campaign, Table::ACTION_READ)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$queryBuilder = $this->entityManager
|
||||
->getQueryBuilder()
|
||||
->select()
|
||||
->from('CampaignLogRecord')
|
||||
->from(CampaignLogRecordEntity::ENTITY_TYPE)
|
||||
->where([
|
||||
'isTest' => false,
|
||||
'campaignId' => $sourceCampaignId,
|
||||
@@ -177,7 +170,7 @@ class TargetList extends Record implements
|
||||
$notQueryBuilder->select(['id']);
|
||||
|
||||
$list = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecordEntity::ENTITY_TYPE)
|
||||
->clone($queryBuilder->build())
|
||||
->find();
|
||||
|
||||
@@ -201,7 +194,7 @@ class TargetList extends Record implements
|
||||
]);
|
||||
|
||||
$existing = $this->entityManager
|
||||
->getRDBRepository('CampaignLogRecord')
|
||||
->getRDBRepository(CampaignLogRecordEntity::ENTITY_TYPE)
|
||||
->clone($cloneQueryBuilder->build())
|
||||
->findOne();
|
||||
}
|
||||
@@ -227,7 +220,7 @@ class TargetList extends Record implements
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
if (!$this->acl->check($entity, 'edit')) {
|
||||
if (!$this->acl->check($entity, Table::ACTION_EDIT)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
@@ -438,7 +431,7 @@ class TargetList extends Record implements
|
||||
$link = $map[$targetType];
|
||||
|
||||
$this->entityManager
|
||||
->getRDBRepository('TargetList')
|
||||
->getRDBRepository(TargetListEntity::ENTITY_TYPE)
|
||||
->getRelation($targetList, $link)
|
||||
->updateColumnsById($targetId, ['optedOut' => false]);
|
||||
|
||||
|
||||
@@ -29,18 +29,16 @@
|
||||
|
||||
namespace Espo\ORM\Mapper;
|
||||
|
||||
use Espo\ORM\{
|
||||
Entity,
|
||||
Collection,
|
||||
Query\Select,
|
||||
};
|
||||
use Espo\ORM\Collection;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\Query\Select;
|
||||
|
||||
interface RDBMapper extends Mapper
|
||||
{
|
||||
/**
|
||||
* Relate an entity with another entity.
|
||||
*
|
||||
* @param array<string,mixed>|null $columnData
|
||||
* @param array<string, mixed>|null $columnData
|
||||
*/
|
||||
public function relate(Entity $entity, string $relationName, Entity $foreignEntity, ?array $columnData): bool;
|
||||
|
||||
@@ -52,7 +50,7 @@ interface RDBMapper extends Mapper
|
||||
/**
|
||||
* Unrelate an entity from another entity by a given ID.
|
||||
*
|
||||
* @param array<string,mixed>|null $columnData
|
||||
* @param array<string, mixed>|null $columnData
|
||||
*/
|
||||
public function relateById(Entity $entity, string $relationName, string $id, ?array $columnData = null): bool;
|
||||
|
||||
@@ -69,7 +67,7 @@ interface RDBMapper extends Mapper
|
||||
/**
|
||||
* Update relationship columns.
|
||||
*
|
||||
* @param array<string,mixed> $columnData
|
||||
* @param array<string, mixed> $columnData
|
||||
*/
|
||||
public function updateRelationColumns(
|
||||
Entity $entity,
|
||||
|
||||
@@ -241,7 +241,7 @@ class RDBRelation
|
||||
* * `where(array $clause)`
|
||||
* * `where(string $key, string $value)`
|
||||
*
|
||||
* @param WhereItem|array<mixed,mixed>|string $clause A key or where clause.
|
||||
* @param WhereItem|array<mixed, mixed>|string $clause A key or where clause.
|
||||
* @param mixed[]|scalar|null $value A value. Should be omitted if the first argument is not string.
|
||||
*/
|
||||
public function where($clause = [], $value = null): Builder
|
||||
@@ -257,7 +257,7 @@ class RDBRelation
|
||||
* * `having(array $clause)`
|
||||
* * `having(string $key, string $value)`
|
||||
*
|
||||
* @param WhereItem|array<mixed,mixed>|string $clause A key or where clause.
|
||||
* @param WhereItem|array<mixed, mixed>|string $clause A key or where clause.
|
||||
* @param mixed[]|string|null $value A value. Should be omitted if the first argument is not string.
|
||||
*/
|
||||
public function having($clause = [], $value = null): Builder
|
||||
|
||||
@@ -29,16 +29,16 @@
|
||||
|
||||
namespace Espo\Repositories;
|
||||
|
||||
use Espo\Core\Repositories\Database;
|
||||
use Espo\Entities\User as UserEntity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Entities\EmailAddress as EmailAddressEntity;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
/**
|
||||
* @extends \Espo\Core\Repositories\Database<\Espo\Entities\EmailAddress>
|
||||
* @extends Database<EmailAddressEntity>
|
||||
*/
|
||||
class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
class EmailAddress extends Database implements
|
||||
Di\ApplicationStateAware,
|
||||
Di\AclManagerAware
|
||||
{
|
||||
@@ -74,9 +74,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
|
||||
$eaCollection = $this
|
||||
->where([
|
||||
[
|
||||
'lower' => $lowerAddressList
|
||||
]
|
||||
['lower' => $lowerAddressList]
|
||||
])
|
||||
->find();
|
||||
|
||||
@@ -124,7 +122,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
$emailAddressList = $this
|
||||
->select(['name', 'lower', 'invalid', 'optOut', ['ee.primary', 'primary']])
|
||||
->join(
|
||||
'EntityEmailAddress',
|
||||
EmailAddressEntity::RELATION_ENTITY_EMAIL_ADDRESS,
|
||||
'ee',
|
||||
[
|
||||
'ee.emailAddressId:' => 'id',
|
||||
@@ -191,7 +189,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
|
||||
$itemList = $this->entityManager
|
||||
->getRDBRepository('EntityEmailAddress')
|
||||
->getRDBRepository(EmailAddressEntity::RELATION_ENTITY_EMAIL_ADDRESS)
|
||||
->sth()
|
||||
->select(['entityType', 'entityId'])
|
||||
->where($where)
|
||||
@@ -212,7 +210,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
if ($onlyName) {
|
||||
$select = ['id', 'name'];
|
||||
|
||||
if ($itemEntityType === 'User') {
|
||||
if ($itemEntityType === UserEntity::ENTITY_TYPE) {
|
||||
$select[] = 'isActive';
|
||||
}
|
||||
|
||||
@@ -230,7 +228,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($entity->getEntityType() === 'User' && !$entity->get('isActive')) {
|
||||
if ($entity instanceof UserEntity && !$entity->isActive()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -255,7 +253,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
|
||||
$itemList = $this->entityManager
|
||||
->getRDBRepository('EntityEmailAddress')
|
||||
->getRDBRepository(EmailAddressEntity::RELATION_ENTITY_EMAIL_ADDRESS)
|
||||
->sth()
|
||||
->select(['entityType', 'entityId'])
|
||||
->where($where)
|
||||
@@ -281,7 +279,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
if ($onlyName) {
|
||||
$select = ['id', 'name'];
|
||||
|
||||
if ($itemEntityType === 'User') {
|
||||
if ($itemEntityType === UserEntity::ENTITY_TYPE) {
|
||||
$select[] = 'isActive';
|
||||
}
|
||||
|
||||
@@ -296,8 +294,8 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
|
||||
if ($entity) {
|
||||
if ($entity->getEntityType() === 'User') {
|
||||
if (!$entity->get('isActive')) {
|
||||
if ($entity instanceof UserEntity) {
|
||||
if (!$entity->isActive()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -315,17 +313,26 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
public function getEntityByAddress(
|
||||
string $address,
|
||||
?string $entityType = null,
|
||||
array $order = ['User', 'Contact', 'Lead', 'Account']
|
||||
array $order = [
|
||||
'User',
|
||||
'Contact',
|
||||
'Lead',
|
||||
'Account',
|
||||
]
|
||||
): ?Entity {
|
||||
|
||||
$selectBuilder = $this->entityManager
|
||||
->getRDBRepository('EntityEmailAddress')
|
||||
->getRDBRepository(EmailAddressEntity::RELATION_ENTITY_EMAIL_ADDRESS)
|
||||
->select();
|
||||
|
||||
$selectBuilder
|
||||
->select(['entityType', 'entityId'])
|
||||
->sth()
|
||||
->join('EmailAddress', 'ea', ['ea.id:' => 'emailAddressId', 'ea.deleted' => 0])
|
||||
->join(
|
||||
EmailAddressEntity::ENTITY_TYPE,
|
||||
'ea',
|
||||
['ea.id:' => 'emailAddressId', 'ea.deleted' => 0]
|
||||
)
|
||||
->where('ea.lower=', strtolower($address))
|
||||
->order([
|
||||
['LIST:entityType:' . implode(',', $order)],
|
||||
@@ -351,8 +358,8 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements
|
||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
||||
|
||||
if ($entity) {
|
||||
if ($entity->getEntityType() === 'User') {
|
||||
if (!$entity->get('isActive')) {
|
||||
if ($entity instanceof UserEntity) {
|
||||
if (!$entity->isActive()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,15 @@
|
||||
|
||||
namespace Espo\Repositories;
|
||||
|
||||
use Espo\Core\Repositories\Database;
|
||||
use Espo\Entities\LayoutRecord;
|
||||
use Espo\Entities\LayoutSet as LayoutSetEntity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
/**
|
||||
* @extends \Espo\Core\Repositories\Database<\Espo\Entities\LayoutSet>
|
||||
* @extends Database<LayoutSetEntity>
|
||||
*/
|
||||
class LayoutSet extends \Espo\Core\Repositories\Database
|
||||
class LayoutSet extends Database
|
||||
{
|
||||
protected function afterSave(Entity $entity, array $options = [])
|
||||
{
|
||||
@@ -47,7 +50,7 @@ class LayoutSet extends \Espo\Core\Repositories\Database
|
||||
foreach ($listBefore as $name) {
|
||||
if (!in_array($name, $listNow)) {
|
||||
$layout = $this->entityManager
|
||||
->getRDBRepository('LayoutRecord')
|
||||
->getRDBRepository(LayoutRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'layoutSetId' => $entity->getId(),
|
||||
'name' => $name,
|
||||
@@ -67,7 +70,7 @@ class LayoutSet extends \Espo\Core\Repositories\Database
|
||||
parent::afterRemove($entity);
|
||||
|
||||
$layoutList = $this->entityManager
|
||||
->getRDBRepository('LayoutRecord')
|
||||
->getRDBRepository(LayoutRecord::ENTITY_TYPE)
|
||||
->where([
|
||||
'layoutSetId' => $entity->getId(),
|
||||
])
|
||||
|
||||
@@ -29,12 +29,10 @@
|
||||
|
||||
namespace Espo\Repositories;
|
||||
|
||||
use Espo\Entities\User as UserEntity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Entities\PhoneNumber as PhoneNumberEntity;
|
||||
|
||||
use Espo\Core\Repositories\Database;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
/**
|
||||
@@ -114,7 +112,7 @@ class PhoneNumber extends Database implements
|
||||
$numberList = $this
|
||||
->select(['name', 'type', 'invalid', 'optOut', ['en.primary', 'primary']])
|
||||
->join(
|
||||
'EntityPhoneNumber',
|
||||
PhoneNumberEntity::RELATION_ENTITY_PHONE_NUMBER,
|
||||
'en',
|
||||
[
|
||||
'en.phoneNumberId:' => 'id',
|
||||
@@ -170,7 +168,7 @@ class PhoneNumber extends Database implements
|
||||
}
|
||||
|
||||
$itemList = $this->entityManager
|
||||
->getRDBRepository('EntityPhoneNumber')
|
||||
->getRDBRepository(PhoneNumberEntity::RELATION_ENTITY_PHONE_NUMBER)
|
||||
->sth()
|
||||
->select(['entityType', 'entityId'])
|
||||
->where($where)
|
||||
@@ -211,7 +209,7 @@ class PhoneNumber extends Database implements
|
||||
}
|
||||
|
||||
$itemList = $this->entityManager
|
||||
->getRDBRepository('EntityPhoneNumber')
|
||||
->getRDBRepository(PhoneNumberEntity::RELATION_ENTITY_PHONE_NUMBER)
|
||||
->sth()
|
||||
->select(['entityType', 'entityId'])
|
||||
->where($where)
|
||||
@@ -237,8 +235,8 @@ class PhoneNumber extends Database implements
|
||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
||||
|
||||
if ($entity) {
|
||||
if ($entity->getEntityType() === 'User') {
|
||||
if (!$entity->get('isActive')) {
|
||||
if ($entity instanceof UserEntity) {
|
||||
if (!$entity->isActive()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,9 @@
|
||||
|
||||
namespace Espo\Repositories;
|
||||
|
||||
use Espo\Entities\Job as JobEntity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\Job\Job\Status;
|
||||
|
||||
use Espo\Core\Repositories\Database;
|
||||
|
||||
/**
|
||||
@@ -48,7 +47,7 @@ class ScheduledJob extends Database
|
||||
|
||||
if ($entity->isAttributeChanged('scheduling')) {
|
||||
$jobList = $this->entityManager
|
||||
->getRDBRepository('Job')
|
||||
->getRDBRepository(JobEntity::ENTITY_TYPE)
|
||||
->where([
|
||||
'scheduledJobId' => $entity->getId(),
|
||||
'status' => Status::PENDING,
|
||||
|
||||
@@ -252,7 +252,7 @@ class Note extends Record
|
||||
if ($targetType === NoteEntity::TARGET_USERS) {
|
||||
/** @var iterable<UserEntity> $targetUserList */
|
||||
$targetUserList = $this->entityManager
|
||||
->getRDBRepository('User')
|
||||
->getRDBRepository(UserEntity::ENTITY_TYPE)
|
||||
->select(['id', 'type'])
|
||||
->where([
|
||||
'id' => $userIdList,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Services;
|
||||
|
||||
use Espo\Entities\Webhook as WebhookEntity;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Di;
|
||||
@@ -38,7 +39,7 @@ use Espo\Entities\User;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @extends Record<\Espo\Entities\Webhook>
|
||||
* @extends Record<WebhookEntity>
|
||||
*/
|
||||
class Webhook extends Record implements
|
||||
Di\WebhookManagerAware
|
||||
@@ -72,8 +73,8 @@ class Webhook extends Record implements
|
||||
{
|
||||
parent::populateDefaults($entity, $data);
|
||||
|
||||
if ($this->getUser()->isApi()) {
|
||||
$entity->set('userId', $this->getUser()->id);
|
||||
if ($this->user->isApi()) {
|
||||
$entity->set('userId', $this->user->getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ class Webhook extends Record implements
|
||||
|
||||
public function filterUpdateInput(stdClass $data): void
|
||||
{
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
if (!$this->user->isAdmin()) {
|
||||
unset($data->event);
|
||||
}
|
||||
|
||||
@@ -100,19 +101,19 @@ class Webhook extends Record implements
|
||||
$this->checkEntityUserIsApi($entity);
|
||||
$this->processEntityEventData($entity);
|
||||
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
if (!$this->user->isAdmin()) {
|
||||
$this->checkMaxCount();
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkMaxCount(): void
|
||||
{
|
||||
$maxCount = $this->getConfig()->get('webhookMaxCountPerUser', self::WEBHOOK_MAX_COUNT_PER_USER);
|
||||
$maxCount = $this->config->get('webhookMaxCountPerUser', self::WEBHOOK_MAX_COUNT_PER_USER);
|
||||
|
||||
$count = $this->getEntityManager()
|
||||
->getRDBRepository('Webhook')
|
||||
$count = $this->entityManager
|
||||
->getRDBRepository(WebhookEntity::ENTITY_TYPE)
|
||||
->where([
|
||||
'userId' => $this->getUser()->id,
|
||||
'userId' => $this->user->getId(),
|
||||
])
|
||||
->count();
|
||||
|
||||
@@ -136,7 +137,7 @@ class Webhook extends Record implements
|
||||
}
|
||||
|
||||
/** @var User|null $user */
|
||||
$user = $this->getEntityManager()->getEntity('User', $userId);
|
||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
||||
|
||||
if (!$user || !$user->isApi()) {
|
||||
throw new Forbidden("User must be an API User.");
|
||||
@@ -176,15 +177,15 @@ class Webhook extends Record implements
|
||||
throw new Forbidden("Entity Type is empty.");
|
||||
}
|
||||
|
||||
if (!$this->getMetadata()->get(['scopes', $entityType, 'object'])) {
|
||||
if (!$this->metadata->get(['scopes', $entityType, 'object'])) {
|
||||
throw new Forbidden("Entity type is not available for Webhooks.");
|
||||
}
|
||||
|
||||
if (!$this->getEntityManager()->hasRepository($entityType)) {
|
||||
if (!$this->entityManager->hasRepository($entityType)) {
|
||||
throw new Forbidden("Not existing Entity Type.");
|
||||
}
|
||||
|
||||
if (!$this->getAcl()->checkScope($entityType, 'read')) {
|
||||
if (!$this->acl->checkScope($entityType, 'read')) {
|
||||
throw new Forbidden("Entity type is forbidden.");
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ class Webhook extends Record implements
|
||||
throw new Forbidden("Field is forbidden.");
|
||||
}
|
||||
|
||||
if (!$this->getMetadata()->get(['entityDefs', $entityType, 'fields', $field])) {
|
||||
if (!$this->metadata->get(['entityDefs', $entityType, 'fields', $field])) {
|
||||
throw new Forbidden("Field does not exist.");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -31,30 +31,29 @@ namespace Espo\Tools\EmailNotification;
|
||||
|
||||
use Espo\Core\Notification\EmailNotificationHandler;
|
||||
use Espo\Core\Mail\SenderParams;
|
||||
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
use Espo\Repositories\Portal as PortalRepository;
|
||||
|
||||
use Espo\{
|
||||
ORM\Entity,
|
||||
ORM\EntityManager,
|
||||
ORM\Query\SelectBuilder as SelectBuilder,
|
||||
Entities\User as UserEntity,
|
||||
Entities\Note as NoteEntity,
|
||||
};
|
||||
|
||||
use Espo\Core\{
|
||||
Htmlizer\HtmlizerFactory as HtmlizerFactory,
|
||||
Htmlizer\Htmlizer,
|
||||
Utils\Config,
|
||||
Utils\Metadata,
|
||||
Utils\Language,
|
||||
InjectableFactory,
|
||||
Utils\TemplateFileManager,
|
||||
Mail\EmailSender as EmailSender,
|
||||
Utils\Util,
|
||||
Utils\Log,
|
||||
};
|
||||
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\Note as NoteEntity;
|
||||
use Espo\Entities\Notification;
|
||||
use Espo\Entities\Portal;
|
||||
use Espo\Entities\Preferences;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Entities\User as UserEntity;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\ORM\Query\SelectBuilder as SelectBuilder;
|
||||
use Espo\Core\Htmlizer\Htmlizer;
|
||||
use Espo\Core\Htmlizer\HtmlizerFactory as HtmlizerFactory;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Mail\EmailSender as EmailSender;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Language;
|
||||
use Espo\Core\Utils\Log;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\TemplateFileManager;
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\Tools\Stream\NoteAccessControl;
|
||||
|
||||
use Michelf\Markdown;
|
||||
@@ -66,8 +65,7 @@ use Throwable;
|
||||
|
||||
class Processor
|
||||
{
|
||||
private const HOURS_THERSHOLD = 5;
|
||||
|
||||
private const HOURS_THRESHOLD = 5;
|
||||
private const PROCESS_MAX_COUNT = 200;
|
||||
|
||||
private ?Htmlizer $htmlizer = null;
|
||||
@@ -81,25 +79,15 @@ class Processor
|
||||
* @var array<string,?\Espo\Entities\Portal>
|
||||
*/
|
||||
private $userIdPortalCacheMap = [];
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $htmlizerFactory;
|
||||
|
||||
private $emailSender;
|
||||
|
||||
private $config;
|
||||
|
||||
private $injectableFactory;
|
||||
|
||||
private $templateFileManager;
|
||||
|
||||
private $metadata;
|
||||
|
||||
private $language;
|
||||
|
||||
private $log;
|
||||
|
||||
private $noteAccessControl;
|
||||
|
||||
public function __construct(
|
||||
@@ -135,11 +123,11 @@ class Processor
|
||||
$typeList = [];
|
||||
|
||||
if ($mentionEmailNotifications) {
|
||||
$typeList[] = 'MentionInPost';
|
||||
$typeList[] = Notification::TYPE_MENTION_IN_POST;
|
||||
}
|
||||
|
||||
if ($streamEmailNotifications || $portalStreamEmailNotifications) {
|
||||
$typeList[] = 'Note';
|
||||
$typeList[] = Notification::TYPE_NOTE;
|
||||
}
|
||||
|
||||
if (empty($typeList)) {
|
||||
@@ -147,10 +135,10 @@ class Processor
|
||||
}
|
||||
|
||||
$fromDt = new DateTime();
|
||||
$fromDt->modify('-' . self::HOURS_THERSHOLD . ' hours');
|
||||
$fromDt->modify('-' . self::HOURS_THRESHOLD . ' hours');
|
||||
|
||||
$where = [
|
||||
'createdAt>' => $fromDt->format('Y-m-d H:i:s'),
|
||||
'createdAt>' => $fromDt->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
|
||||
'read' => false,
|
||||
'emailIsProcessed' => false,
|
||||
];
|
||||
@@ -161,7 +149,7 @@ class Processor
|
||||
$delayDt = new DateTime();
|
||||
$delayDt->modify('-' . $delay . ' seconds');
|
||||
|
||||
$where[] = ['createdAt<' => $delayDt->format('Y-m-d H:i:s')];
|
||||
$where[] = ['createdAt<' => $delayDt->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT)];
|
||||
}
|
||||
|
||||
$queryList = [];
|
||||
@@ -191,7 +179,7 @@ class Processor
|
||||
$sql = $this->entityManager->getQueryComposer()->compose($unionQuery);
|
||||
|
||||
$notificationList = $this->entityManager
|
||||
->getRDBRepository('Notification')
|
||||
->getRDBRepository(Notification::ENTITY_TYPE)
|
||||
->findBySql($sql);
|
||||
|
||||
foreach ($notificationList as $notification) {
|
||||
@@ -222,9 +210,9 @@ class Processor
|
||||
return $this->entityManager
|
||||
->getQueryBuilder()
|
||||
->select()
|
||||
->from('Notification')
|
||||
->from(Notification::ENTITY_TYPE)
|
||||
->where([
|
||||
'type' => 'MentionInPost',
|
||||
'type' => Notification::TYPE_MENTION_IN_POST,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -235,11 +223,11 @@ class Processor
|
||||
$builder = $this->entityManager
|
||||
->getQueryBuilder()
|
||||
->select()
|
||||
->from('Notification')
|
||||
->join('Note', 'note', ['note.id:' => 'relatedId'])
|
||||
->from(Notification::ENTITY_TYPE)
|
||||
->join(Note::ENTITY_TYPE, 'note', ['note.id:' => 'relatedId'])
|
||||
->where([
|
||||
'type' => 'Note',
|
||||
'relatedType' => 'Note',
|
||||
'type' => Notification::TYPE_NOTE,
|
||||
'relatedType' => Note::ENTITY_TYPE,
|
||||
'note.type' => $noteNotificationTypeList,
|
||||
]);
|
||||
|
||||
@@ -268,12 +256,12 @@ class Processor
|
||||
|
||||
if ($forInternal && !$forPortal) {
|
||||
$builder->where([
|
||||
'user.type!=' => 'portal',
|
||||
'user.type!=' => User::TYPE_PORTAL,
|
||||
]);
|
||||
}
|
||||
else if (!$forInternal && $forPortal) {
|
||||
$builder->where([
|
||||
'user.type' => 'portal',
|
||||
'user.type' => User::TYPE_PORTAL,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -288,7 +276,7 @@ class Processor
|
||||
|
||||
$userId = $notification->get('userId');
|
||||
|
||||
$user = $this->entityManager->getEntity('User', $userId);
|
||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
||||
|
||||
if (!$user) {
|
||||
return;
|
||||
@@ -300,7 +288,7 @@ class Processor
|
||||
return;
|
||||
}
|
||||
|
||||
$preferences = $this->entityManager->getEntity('Preferences', $userId);
|
||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $userId);
|
||||
|
||||
if (!$preferences) {
|
||||
return;
|
||||
@@ -310,11 +298,11 @@ class Processor
|
||||
return;
|
||||
}
|
||||
|
||||
if ($notification->get('relatedType') !== 'Note' || !$notification->get('relatedId')) {
|
||||
if ($notification->get('relatedType') !== Note::ENTITY_TYPE || !$notification->get('relatedId')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$note = $this->entityManager->getEntity('Note', $notification->get('relatedId'));
|
||||
$note = $this->entityManager->getEntity(Note::ENTITY_TYPE, $notification->get('relatedId'));
|
||||
|
||||
if (!$note) {
|
||||
return;
|
||||
@@ -359,7 +347,7 @@ class Processor
|
||||
$subject = $this->getHtmlizer()->render($note, $subjectTpl, 'mention-email-subject', $data, true);
|
||||
$body = $this->getHtmlizer()->render($note, $bodyTpl, 'mention-email-body', $data, true);
|
||||
|
||||
$email = $this->entityManager->getNewEntity('Email');
|
||||
$email = $this->entityManager->getNewEntity(Email::ENTITY_TYPE);
|
||||
|
||||
$email->set([
|
||||
'subject' => $subject,
|
||||
@@ -400,7 +388,7 @@ class Processor
|
||||
|
||||
protected function processNotificationNote(Entity $notification): void
|
||||
{
|
||||
if ($notification->get('relatedType') !== 'Note') {
|
||||
if ($notification->get('relatedType') !== Note::ENTITY_TYPE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -408,7 +396,7 @@ class Processor
|
||||
return;
|
||||
}
|
||||
|
||||
$note = $this->entityManager->getEntity('Note', $notification->get('relatedId'));
|
||||
$note = $this->entityManager->getEntity(Note::ENTITY_TYPE, $notification->get('relatedId'));
|
||||
|
||||
if (!$note) {
|
||||
return;
|
||||
@@ -425,7 +413,7 @@ class Processor
|
||||
}
|
||||
|
||||
$userId = $notification->get('userId');
|
||||
$user = $this->entityManager->getEntity('User', $userId);
|
||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
||||
|
||||
if (!$user) {
|
||||
return;
|
||||
@@ -437,7 +425,7 @@ class Processor
|
||||
return;
|
||||
}
|
||||
|
||||
$preferences = $this->entityManager->getEntity('Preferences', $userId);
|
||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $userId);
|
||||
|
||||
if (!$preferences) {
|
||||
return;
|
||||
@@ -615,7 +603,7 @@ class Processor
|
||||
}
|
||||
|
||||
if ($portalId) {
|
||||
$portal = $this->entityManager->getEntityById('Portal', $portalId);
|
||||
$portal = $this->entityManager->getEntityById(Portal::ENTITY_TYPE, $portalId);
|
||||
}
|
||||
|
||||
if ($portal) {
|
||||
@@ -714,7 +702,7 @@ class Processor
|
||||
true
|
||||
);
|
||||
|
||||
$email = $this->entityManager->getNewEntity('Email');
|
||||
$email = $this->entityManager->getNewEntity(Email::ENTITY_TYPE);
|
||||
|
||||
$email->set([
|
||||
'subject' => $subject,
|
||||
@@ -776,13 +764,14 @@ class Processor
|
||||
return;
|
||||
}
|
||||
|
||||
$emailSubject = $this->entityManager->getEntity('Email', $noteData->emailId);
|
||||
$emailSubject = $this->entityManager->getEntity(Email::ENTITY_TYPE, $noteData->emailId);
|
||||
|
||||
if (!$emailSubject) {
|
||||
return;
|
||||
}
|
||||
|
||||
$emailRepository = $this->entityManager->getRDBRepository('Email');
|
||||
$emailRepository = $this->entityManager->getRDBRepository(Email::ENTITY_TYPE);
|
||||
|
||||
$eaList = $user->get('emailAddresses');
|
||||
|
||||
foreach ($eaList as $ea) {
|
||||
@@ -854,7 +843,7 @@ class Processor
|
||||
true
|
||||
);
|
||||
|
||||
$email = $this->entityManager->getNewEntity('Email');
|
||||
$email = $this->entityManager->getNewEntity(Email::ENTITY_TYPE);
|
||||
|
||||
$email->set([
|
||||
'subject' => $subject,
|
||||
@@ -898,6 +887,6 @@ class Processor
|
||||
private function getPortalRepository(): PortalRepository
|
||||
{
|
||||
/** @var PortalRepository */
|
||||
return $this->entityManager->getRepository('Portal');
|
||||
return $this->entityManager->getRepository(Portal::ENTITY_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Tools\FieldManager\Hooks;
|
||||
|
||||
use Espo\Core\Di;
|
||||
use Espo\Entities\NextNumber;
|
||||
|
||||
class NumberType implements Di\EntityManagerAware
|
||||
{
|
||||
@@ -42,7 +43,7 @@ class NumberType implements Di\EntityManagerAware
|
||||
public function onRead(string $scope, string $name, &$defs, $options): void
|
||||
{
|
||||
$number = $this->entityManager
|
||||
->getRDBRepository('NextNumber')
|
||||
->getRDBRepository(NextNumber::ENTITY_TYPE)
|
||||
->where([
|
||||
'entityType' => $scope,
|
||||
'fieldName' => $name,
|
||||
@@ -77,7 +78,7 @@ class NumberType implements Di\EntityManagerAware
|
||||
}
|
||||
|
||||
$number = $this->entityManager
|
||||
->getRDBRepository('NextNumber')
|
||||
->getRDBRepository(NextNumber::ENTITY_TYPE)
|
||||
->where([
|
||||
'entityType' => $scope,
|
||||
'fieldName' => $name
|
||||
@@ -85,7 +86,7 @@ class NumberType implements Di\EntityManagerAware
|
||||
->findOne();
|
||||
|
||||
if (!$number) {
|
||||
$number = $this->entityManager->getNewEntity('NextNumber');
|
||||
$number = $this->entityManager->getNewEntity(NextNumber::ENTITY_TYPE);
|
||||
|
||||
$number->set('entityType', $scope);
|
||||
$number->set('fieldName', $name);
|
||||
@@ -103,7 +104,7 @@ class NumberType implements Di\EntityManagerAware
|
||||
public function afterRemove(string $scope, string $name, $defs, $options): void
|
||||
{
|
||||
$number = $this->entityManager
|
||||
->getRDBRepository('NextNumber')
|
||||
->getRDBRepository(NextNumber::ENTITY_TYPE)
|
||||
->where([
|
||||
'entityType' => $scope,
|
||||
'fieldName' => $name
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Tools\Stream;
|
||||
|
||||
use Espo\Core\ORM\Repository\SaveOption;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\Autofollow;
|
||||
use Espo\Tools\Stream\Service as Service;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Entities\Preferences;
|
||||
@@ -316,7 +317,7 @@ class HookProcessor
|
||||
$userIdList = [];
|
||||
|
||||
$autofollowList = $this->entityManager
|
||||
->getRDBRepository('Autofollow')
|
||||
->getRDBRepository(Autofollow::ENTITY_TYPE)
|
||||
->select(['userId'])
|
||||
->where([
|
||||
'entityType' => $entityType,
|
||||
|
||||
@@ -107,7 +107,7 @@ class RecoveryService
|
||||
}
|
||||
|
||||
$request = $this->entityManager
|
||||
->getRDBRepository('PasswordChangeRequest')
|
||||
->getRDBRepository(PasswordChangeRequest::ENTITY_TYPE)
|
||||
->where([
|
||||
'requestId' => $id,
|
||||
])
|
||||
@@ -129,7 +129,7 @@ class RecoveryService
|
||||
public function removeRequest(string $id): void
|
||||
{
|
||||
$request = $this->entityManager
|
||||
->getRDBRepository('PasswordChangeRequest')
|
||||
->getRDBRepository(PasswordChangeRequest::ENTITY_TYPE)
|
||||
->where([
|
||||
'requestId' => $id,
|
||||
])
|
||||
@@ -211,7 +211,7 @@ class RecoveryService
|
||||
}
|
||||
|
||||
$existingRequest = $this->entityManager
|
||||
->getRDBRepository('PasswordChangeRequest')
|
||||
->getRDBRepository(PasswordChangeRequest::ENTITY_TYPE)
|
||||
->where([
|
||||
'userId' => $user->getId(),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user