mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
cs fix
This commit is contained in:
@@ -46,7 +46,7 @@ class Action
|
||||
$this->recordServiceContainer = $recordServiceContainer;
|
||||
}
|
||||
|
||||
public function postActionProcess(Request $request) : StdClass
|
||||
public function postActionProcess(Request $request): StdClass
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use Espo\Core\ORM\Entity;
|
||||
|
||||
class Attachment extends Entity
|
||||
{
|
||||
public function getSourceId() : ?string
|
||||
public function getSourceId(): ?string
|
||||
{
|
||||
$sourceId = $this->get('sourceId');
|
||||
|
||||
@@ -44,7 +44,7 @@ class Attachment extends Entity
|
||||
return $sourceId;
|
||||
}
|
||||
|
||||
public function getStorage() : ?string
|
||||
public function getStorage(): ?string
|
||||
{
|
||||
return $this->get('storage');
|
||||
}
|
||||
|
||||
@@ -136,12 +136,12 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
}
|
||||
}
|
||||
|
||||
public function isManuallyArchived() : bool
|
||||
public function isManuallyArchived(): bool
|
||||
{
|
||||
return $this->get('status') === 'Archived' && $this->get('createdById') !== 'system';
|
||||
}
|
||||
|
||||
public function addAttachment(Attachment $attachment) : void
|
||||
public function addAttachment(Attachment $attachment): void
|
||||
{
|
||||
if (!$this->id) {
|
||||
return;
|
||||
@@ -158,12 +158,12 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
return $this->getBodyPlain();
|
||||
}
|
||||
|
||||
public function hasBodyPlain() : bool
|
||||
public function hasBodyPlain(): bool
|
||||
{
|
||||
return $this->hasInContainer('bodyPlain') && $this->getFromContainer('bodyPlain');
|
||||
}
|
||||
|
||||
public function getBodyPlain() : ?string
|
||||
public function getBodyPlain(): ?string
|
||||
{
|
||||
if ($this->getFromContainer('bodyPlain')) {
|
||||
return $this->getFromContainer('bodyPlain');
|
||||
@@ -238,7 +238,7 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function getInlineAttachments() : array
|
||||
public function getInlineAttachments(): array
|
||||
{
|
||||
$idList = [];
|
||||
|
||||
@@ -277,7 +277,7 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
return $attachmentList;
|
||||
}
|
||||
|
||||
public function getToList() : array
|
||||
public function getToList(): array
|
||||
{
|
||||
$value = $this->get('to');
|
||||
|
||||
@@ -292,7 +292,7 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getCcList() : array
|
||||
public function getCcList(): array
|
||||
{
|
||||
$value = $this->get('cc');
|
||||
|
||||
@@ -307,7 +307,7 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getBccList() : array
|
||||
public function getBccList(): array
|
||||
{
|
||||
$value = $this->get('bcc');
|
||||
|
||||
@@ -337,7 +337,7 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
return [];
|
||||
}
|
||||
|
||||
public function setDummyMessageId() : void
|
||||
public function setDummyMessageId(): void
|
||||
{
|
||||
$this->set('messageId', 'dummy:' . Util::generateId());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a status.
|
||||
*/
|
||||
public function getStatus() : string
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->get('status');
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a job name.
|
||||
*/
|
||||
public function getJob() : ?string
|
||||
public function getJob(): ?string
|
||||
{
|
||||
return $this->get('job');
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a scheduled job name.
|
||||
*/
|
||||
public function getScheduledJobJob() : ?string
|
||||
public function getScheduledJobJob(): ?string
|
||||
{
|
||||
return $this->get('scheduledJobJob');
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a target type.
|
||||
*/
|
||||
public function getTargetType() : ?string
|
||||
public function getTargetType(): ?string
|
||||
{
|
||||
return $this->get('targetType');
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a target ID.
|
||||
*/
|
||||
public function getTargetId() : ?string
|
||||
public function getTargetId(): ?string
|
||||
{
|
||||
return $this->get('targetId');
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get data.
|
||||
*/
|
||||
public function getData() : StdClass
|
||||
public function getData(): StdClass
|
||||
{
|
||||
return $this->get('data') ?? (object) [];
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a service name.
|
||||
*/
|
||||
public function getServiceName() : ?string
|
||||
public function getServiceName(): ?string
|
||||
{
|
||||
return $this->get('serviceName');
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a method name.
|
||||
*/
|
||||
public function getMethodName() : ?string
|
||||
public function getMethodName(): ?string
|
||||
{
|
||||
return $this->get('methodName');
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a scheduled job ID.
|
||||
*/
|
||||
public function getScheduledJobId() : ?string
|
||||
public function getScheduledJobId(): ?string
|
||||
{
|
||||
return $this->get('scheduledJobId');
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class Job extends Entity
|
||||
/**
|
||||
* Get a started date-time.
|
||||
*/
|
||||
public function getStartedAt() : ?string
|
||||
public function getStartedAt(): ?string
|
||||
{
|
||||
return $this->get('startedAt');
|
||||
}
|
||||
|
||||
@@ -33,47 +33,47 @@ use Espo\Core\Entities\Person;
|
||||
|
||||
class User extends Person
|
||||
{
|
||||
public function isActive() : bool
|
||||
public function isActive(): bool
|
||||
{
|
||||
return (bool) $this->get('isActive');
|
||||
}
|
||||
|
||||
public function isAdmin() : bool
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->get('type') === 'admin' || $this->isSystem() || $this->isSuperAdmin();
|
||||
}
|
||||
|
||||
public function isPortal() : bool
|
||||
public function isPortal(): bool
|
||||
{
|
||||
return $this->get('type') === 'portal';
|
||||
}
|
||||
|
||||
public function isPortalUser() : bool
|
||||
public function isPortalUser(): bool
|
||||
{
|
||||
return $this->isPortal();
|
||||
}
|
||||
|
||||
public function isRegular() : bool
|
||||
public function isRegular(): bool
|
||||
{
|
||||
return $this->get('type') === 'regular' || ($this->has('type') && !$this->get('type'));
|
||||
}
|
||||
|
||||
public function isApi() : bool
|
||||
public function isApi(): bool
|
||||
{
|
||||
return $this->get('type') === 'api';
|
||||
}
|
||||
|
||||
public function isSystem() : bool
|
||||
public function isSystem(): bool
|
||||
{
|
||||
return $this->get('type') === 'system';
|
||||
}
|
||||
|
||||
public function isSuperAdmin() : bool
|
||||
public function isSuperAdmin(): bool
|
||||
{
|
||||
return $this->get('type') === 'super-admin';
|
||||
}
|
||||
|
||||
public function getTeamIdList() : array
|
||||
public function getTeamIdList(): array
|
||||
{
|
||||
return $this->getLinkMultipleIdList('teams');
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class Attachment implements EntryPoint
|
||||
$this->acl = $acl;
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class Avatar extends Image implements Di\MetadataAware
|
||||
return $colorList[$index];
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$userId = $request->get('id');
|
||||
|
||||
@@ -132,7 +132,7 @@ class Avatar extends Image implements Di\MetadataAware
|
||||
$response->writeBody($imgContent);
|
||||
}
|
||||
|
||||
protected function renderBlank(Response $response) : void
|
||||
protected function renderBlank(Response $response): void
|
||||
{
|
||||
ob_start();
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class ChangePassword implements EntryPoint
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$requestId = $request->getQueryParam('id');
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class ConfirmOptIn implements EntryPoint
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->get('id');
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Download implements EntryPoint
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class Image implements EntryPoint
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
$size = $request->getQueryParam('size') ?? null;
|
||||
@@ -111,7 +111,7 @@ class Image implements EntryPoint
|
||||
$this->show($response, $id, $size, false);
|
||||
}
|
||||
|
||||
protected function show(Response $response, string $id, ?string $size, bool $disableAccessCheck = false) : void
|
||||
protected function show(Response $response, string $id, ?string $size, bool $disableAccessCheck = false): void
|
||||
{
|
||||
$attachment = $this->entityManager->getEntity('Attachment', $id);
|
||||
|
||||
@@ -171,7 +171,7 @@ class Image implements EntryPoint
|
||||
->setHeader('Content-Length', (string) $fileSize);
|
||||
}
|
||||
|
||||
protected function getThumbContents(Attachment $attachment, string $size) : string
|
||||
protected function getThumbContents(Attachment $attachment, string $size): string
|
||||
{
|
||||
if (!array_key_exists($size, $this->imageSizes)) {
|
||||
throw new Error("Bad size.");
|
||||
|
||||
@@ -47,7 +47,7 @@ class LogoImage extends Image implements Di\ConfigAware
|
||||
|
||||
protected $allowedFieldList = ['companyLogo'];
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
@@ -40,7 +40,7 @@ class OauthCallback implements EntryPoint
|
||||
{
|
||||
use NoAuth;
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
echo "If this window is not closed automatically, it's probable that URL you use to access ".
|
||||
"EspoCRM doesn't match URL specified at Administration > Settings > Site URL.";
|
||||
|
||||
@@ -51,7 +51,7 @@ class Pdf implements EntryPoint
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run(Request $request, Response $response) : void
|
||||
public function run(Request $request, Response $response): void
|
||||
{
|
||||
$entityId = $request->getQueryParam('entityId');
|
||||
$entityType = $request->getQueryParam('entityType');
|
||||
|
||||
@@ -49,7 +49,7 @@ class AuthTokenControl implements Job
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
$authTokenLifetime = $this->config->get('authTokenLifetime');
|
||||
$authTokenMaxIdleTime = $this->config->get('authTokenMaxIdleTime');
|
||||
|
||||
@@ -55,7 +55,7 @@ class CheckEmailAccounts implements JobTargeted
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run(string $targetType, string $targetId, StdClass $data) : void
|
||||
public function run(string $targetType, string $targetId, StdClass $data): void
|
||||
{
|
||||
if (!$targetId) {
|
||||
throw new Error();
|
||||
@@ -81,7 +81,7 @@ class CheckEmailAccounts implements JobTargeted
|
||||
}
|
||||
}
|
||||
|
||||
public function prepare(ScheduledJob $scheduledJob, string $executeTime) : void
|
||||
public function prepare(ScheduledJob $scheduledJob, string $executeTime): void
|
||||
{
|
||||
$collection = $this->entityManager->getRepository('EmailAccount')
|
||||
->join('assignedUser', 'assignedUserAdditional')
|
||||
|
||||
@@ -55,7 +55,7 @@ class CheckInboundEmails implements JobTargeted
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run(string $targetType, string $targetId, StdClass $data) : void
|
||||
public function run(string $targetType, string $targetId, StdClass $data): void
|
||||
{
|
||||
if (!$targetId) {
|
||||
throw new Error();
|
||||
@@ -80,7 +80,7 @@ class CheckInboundEmails implements JobTargeted
|
||||
}
|
||||
}
|
||||
|
||||
public function prepare(ScheduledJob $scheduledJob, string $executeTime) : void
|
||||
public function prepare(ScheduledJob $scheduledJob, string $executeTime): void
|
||||
{
|
||||
$collection = $this->entityManager
|
||||
->getRepository('InboundEmail')
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Jobs;
|
||||
|
||||
class CheckNewExtensionVersion extends CheckNewVersion
|
||||
{
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
if (
|
||||
!$this->config->get('adminNotifications') ||
|
||||
|
||||
@@ -50,13 +50,14 @@ class CheckNewVersion implements Job
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
if (!$this->config->get('adminNotifications') || !$this->config->get('adminNotificationsNewVersion')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$job = $this->entityManager->getEntity('Job');
|
||||
|
||||
$job->set([
|
||||
'name' => 'Check for New Version (job)',
|
||||
'serviceName' => 'AdminNotifications',
|
||||
|
||||
@@ -35,7 +35,7 @@ use Espo\Core\{
|
||||
|
||||
class Dummy implements Job
|
||||
{
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class ProcessJobQueueE0 implements Job
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
$limit = $this->config->get('jobE0MaxPortion', 100);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class ProcessJobQueueQ0 implements Job
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
$limit = $this->config->get('jobQ0MaxPortion', 200);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class ProcessJobQueueQ1 implements Job
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
$limit = $this->config->get('jobQ1MaxPortion', 500);
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@ use Espo\Core\{
|
||||
class ProcessWebhookQueue implements Job
|
||||
{
|
||||
protected $config;
|
||||
|
||||
protected $entityManager;
|
||||
|
||||
protected $aclManager;
|
||||
|
||||
public function __construct(Config $config, EntityManager $entityManager, AclManager $aclManager)
|
||||
@@ -51,7 +53,7 @@ class ProcessWebhookQueue implements Job
|
||||
$this->aclManager = $aclManager;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
$sender = new Sender($this->config);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class SendEmailNotifications implements Job
|
||||
$this->processor = $processor;
|
||||
}
|
||||
|
||||
public function run() : void
|
||||
public function run(): void
|
||||
{
|
||||
$this->processor->process();
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class Attachment extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
}
|
||||
|
||||
protected function processBeforeSaveNew(Entity $entity) : void
|
||||
protected function processBeforeSaveNew(Entity $entity): void
|
||||
{
|
||||
if (!$entity->get('storage')) {
|
||||
$defaultStorage = $this->config->get('defaultFileStorage');
|
||||
@@ -152,22 +152,22 @@ class Attachment extends \Espo\Core\Repositories\Database implements
|
||||
return $attachment;
|
||||
}
|
||||
|
||||
public function getContents(AttachmentEntity $entity) : string
|
||||
public function getContents(AttachmentEntity $entity): string
|
||||
{
|
||||
return $this->fileStorageManager->getContents($entity);
|
||||
}
|
||||
|
||||
public function getStream(AttachmentEntity $entity) : StreamInterface
|
||||
public function getStream(AttachmentEntity $entity): StreamInterface
|
||||
{
|
||||
return $this->fileStorageManager->getStream($entity);
|
||||
}
|
||||
|
||||
public function getSize(AttachmentEntity $entity) : int
|
||||
public function getSize(AttachmentEntity $entity): int
|
||||
{
|
||||
return $this->fileStorageManager->getSize($entity);
|
||||
}
|
||||
|
||||
public function getFilePath(AttachmentEntity $entity) : string
|
||||
public function getFilePath(AttachmentEntity $entity): string
|
||||
{
|
||||
return $this->fileStorageManager->getLocalFilePath($entity);
|
||||
}
|
||||
|
||||
@@ -50,9 +50,12 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
$idList = [];
|
||||
|
||||
if (!empty($addressValue)) {
|
||||
$addressList = array_map(function ($item) {
|
||||
return trim($item);
|
||||
}, explode(';', $addressValue));
|
||||
$addressList = array_map(
|
||||
function ($item) {
|
||||
return trim($item);
|
||||
},
|
||||
explode(';', $addressValue)
|
||||
);
|
||||
|
||||
$addressList = array_filter($addressList, function ($item) {
|
||||
return filter_var($item, FILTER_VALIDATE_EMAIL);
|
||||
@@ -72,10 +75,13 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
|
||||
protected function addUserByEmailAddressId(Entity $entity, $emailAddressId, $addAssignedUser = false)
|
||||
{
|
||||
$userList = $this->getEntityManager()->getRepository('EmailAddress')->getEntityListByAddressId($emailAddressId, null, 'User', true);
|
||||
$userList = $this->getEntityManager()
|
||||
->getRepository('EmailAddress')
|
||||
->getEntityListByAddressId($emailAddressId, null, 'User', true);
|
||||
|
||||
foreach ($userList as $user) {
|
||||
$entity->addLinkMultipleId('users', $user->id);
|
||||
|
||||
if ($addAssignedUser) {
|
||||
$entity->addLinkMultipleId('assignedUsers', $user->id);
|
||||
}
|
||||
@@ -86,12 +92,18 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
{
|
||||
if ($entity->get('fromEmailAddressName')) {
|
||||
$entity->set('from', $entity->get('fromEmailAddressName'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($entity->get('fromEmailAddressId')) {
|
||||
$ea = $this->getEntityManager()->getRepository('EmailAddress')->get($entity->get('fromEmailAddressId'));
|
||||
$ea = $this->getEntityManager()
|
||||
->getRepository('EmailAddress')
|
||||
->get($entity->get('fromEmailAddressId'));
|
||||
|
||||
if ($ea) {
|
||||
$entity->set('from', $ea->get('name'));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -107,11 +119,14 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
{
|
||||
$entity->loadLinkMultipleField('toEmailAddresses');
|
||||
$names = $entity->get('toEmailAddressesNames');
|
||||
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
$arr = [];
|
||||
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
|
||||
$entity->set('to', implode(';', $arr));
|
||||
}
|
||||
}
|
||||
@@ -120,8 +135,10 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
{
|
||||
$entity->loadLinkMultipleField('ccEmailAddresses');
|
||||
$names = $entity->get('ccEmailAddressesNames');
|
||||
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
$arr = [];
|
||||
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
@@ -133,11 +150,14 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
{
|
||||
$entity->loadLinkMultipleField('bccEmailAddresses');
|
||||
$names = $entity->get('bccEmailAddressesNames');
|
||||
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
$arr = [];
|
||||
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
|
||||
$entity->set('bcc', implode(';', $arr));
|
||||
}
|
||||
}
|
||||
@@ -146,24 +166,29 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
{
|
||||
$entity->loadLinkMultipleField('replyToEmailAddresses');
|
||||
$names = $entity->get('replyToEmailAddressesNames');
|
||||
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
$arr = [];
|
||||
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
|
||||
$entity->set('replyTo', implode(';', $arr));
|
||||
}
|
||||
}
|
||||
|
||||
public function loadNameHash(Entity $entity, array $fieldList = ['from', 'to', 'cc', 'bcc', 'replyTo'])
|
||||
{
|
||||
$addressList = array();
|
||||
$addressList = [];
|
||||
|
||||
if (in_array('from', $fieldList) && $entity->get('from')) {
|
||||
$addressList[] = $entity->get('from');
|
||||
}
|
||||
|
||||
if (in_array('to', $fieldList)) {
|
||||
$arr = explode(';', $entity->get('to'));
|
||||
|
||||
foreach ($arr as $address) {
|
||||
if (!in_array($address, $addressList)) {
|
||||
$addressList[] = $address;
|
||||
@@ -173,6 +198,7 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
|
||||
if (in_array('cc', $fieldList)) {
|
||||
$arr = explode(';', $entity->get('cc'));
|
||||
|
||||
foreach ($arr as $address) {
|
||||
if (!in_array($address, $addressList)) {
|
||||
$addressList[] = $address;
|
||||
@@ -181,14 +207,17 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
if (in_array('bcc', $fieldList)) {
|
||||
$arr = explode(';', $entity->get('bcc'));
|
||||
|
||||
foreach ($arr as $address) {
|
||||
if (!in_array($address, $addressList)) {
|
||||
$addressList[] = $address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('replyTo', $fieldList)) {
|
||||
$arr = explode(';', $entity->get('replyTo'));
|
||||
|
||||
foreach ($arr as $address) {
|
||||
if (!in_array($address, $addressList)) {
|
||||
$addressList[] = $address;
|
||||
@@ -199,19 +228,29 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
$nameHash = (object) [];
|
||||
$typeHash = (object) [];
|
||||
$idHash = (object) [];
|
||||
|
||||
foreach ($addressList as $address) {
|
||||
$p = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddress($address);
|
||||
$p = $this->getEntityManager()
|
||||
->getRepository('EmailAddress')
|
||||
->getEntityByAddress($address);
|
||||
|
||||
if (!$p) {
|
||||
$p = $this->getEntityManager()->getRepository('InboundEmail')->where(array('emailAddress' => $address))->findOne();
|
||||
$p = $this->getEntityManager()
|
||||
->getRepository('InboundEmail')
|
||||
->where(array('emailAddress' => $address))
|
||||
->findOne();
|
||||
}
|
||||
|
||||
if ($p) {
|
||||
$nameHash->$address = $p->get('name');
|
||||
$typeHash->$address = $p->getEntityType();
|
||||
|
||||
$idHash->$address = $p->id;
|
||||
}
|
||||
}
|
||||
|
||||
$addressNameMap = $entity->get('addressNameMap');
|
||||
|
||||
if (is_object($addressNameMap)) {
|
||||
foreach (get_object_vars($addressNameMap) as $key => $value) {
|
||||
if (!isset($nameHash->$key)) {
|
||||
@@ -238,24 +277,40 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
}
|
||||
}
|
||||
|
||||
if ($entity->has('from') || $entity->has('to') || $entity->has('cc') || $entity->has('bcc') || $entity->has('replyTo')) {
|
||||
if (
|
||||
$entity->has('from') ||
|
||||
$entity->has('to') ||
|
||||
$entity->has('cc') ||
|
||||
$entity->has('bcc') ||
|
||||
$entity->has('replyTo')
|
||||
) {
|
||||
if (!$entity->has('usersIds')) {
|
||||
$entity->loadLinkMultipleField('users');
|
||||
}
|
||||
|
||||
if ($entity->has('from')) {
|
||||
$from = trim($entity->get('from'));
|
||||
|
||||
if (!empty($from)) {
|
||||
$ids = $this->getEntityManager()->getRepository('EmailAddress')->getIds([$from]);
|
||||
$ids = $this->getEntityManager()
|
||||
->getRepository('EmailAddress')
|
||||
->getIds([$from]);
|
||||
|
||||
if (!empty($ids)) {
|
||||
$entity->set('fromEmailAddressId', $ids[0]);
|
||||
$entity->set('fromEmailAddressName', $from);
|
||||
|
||||
$this->addUserByEmailAddressId($entity, $ids[0], true);
|
||||
|
||||
if (!$entity->get('sentById')) {
|
||||
$user = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddressId(
|
||||
$entity->get('fromEmailAddressId'), 'User', true
|
||||
);
|
||||
$user = $this->getEntityManager()
|
||||
->getRepository('EmailAddress')
|
||||
->getEntityByAddressId(
|
||||
$entity->get('fromEmailAddressId'),
|
||||
'User',
|
||||
true
|
||||
);
|
||||
|
||||
if ($user) {
|
||||
$entity->set('sentById', $user->id);
|
||||
}
|
||||
@@ -316,18 +371,28 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
|
||||
if ($parent) {
|
||||
$accountId = null;
|
||||
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
$accountId = $parent->id;
|
||||
}
|
||||
if (!$accountId && $parent->get('accountId') && $parent->getRelationParam('account', 'entity') == 'Account') {
|
||||
|
||||
if (
|
||||
!$accountId &&
|
||||
$parent->get('accountId') &&
|
||||
$parent->getRelationParam('account', 'entity') == 'Account'
|
||||
) {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
|
||||
if ($accountId) {
|
||||
$account = $this->getEntityManager()->getEntity('Account', $accountId);
|
||||
|
||||
if ($account) {
|
||||
$entity->set('accountId', $accountId);
|
||||
$entity->set('accountName', $account->get('name'));
|
||||
@@ -341,16 +406,22 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
{
|
||||
foreach ($entity->getLinkMultipleIdList('users') as $userId) {
|
||||
if ($entity->get('status') === 'Sent') {
|
||||
if ($entity->get('sentById') && $entity->get('sentById') === $userId) continue;
|
||||
if ($entity->get('sentById') && $entity->get('sentById') === $userId) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$filter = $this->getEmailFilterManager()->getMatchingFilter($entity, $userId);
|
||||
|
||||
if ($filter) {
|
||||
$action = $filter->get('action');
|
||||
|
||||
if ($action === 'Skip') {
|
||||
$entity->setLinkMultipleColumn('users', 'inTrash', $userId, true);
|
||||
} else if ($action === 'Move to Folder') {
|
||||
}
|
||||
else if ($action === 'Move to Folder') {
|
||||
$folderId = $filter->get('emailFolderId');
|
||||
|
||||
if ($folderId) {
|
||||
$entity->setLinkMultipleColumn('users', 'folderId', $userId, $folderId);
|
||||
}
|
||||
@@ -364,15 +435,24 @@ class Email extends \Espo\Core\Repositories\Database implements
|
||||
parent::afterSave($entity, $options);
|
||||
|
||||
if (!$entity->isNew()) {
|
||||
if ($entity->get('parentType') && $entity->get('parentId') && $entity->isAttributeChanged('parentId')) {
|
||||
if (
|
||||
$entity->get('parentType') &&
|
||||
$entity->get('parentId') &&
|
||||
$entity->isAttributeChanged('parentId')
|
||||
) {
|
||||
$replyList = $this->findRelated($entity, 'replies');
|
||||
|
||||
foreach ($replyList as $reply) {
|
||||
if ($reply->id === $entity->id) continue;
|
||||
if ($reply->id === $entity->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$reply->get('parentId')) {
|
||||
$reply->set([
|
||||
'parentId' => $entity->get('parentId'),
|
||||
'parentType' => $entity->get('parentType')
|
||||
]);
|
||||
|
||||
$this->getEntityManager()->saveEntity($reply);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,15 @@ use Espo\ORM\Entity;
|
||||
|
||||
class ExternalAccount extends \Espo\Core\Repositories\Database
|
||||
{
|
||||
public function get(?string $id = null) : ?Entity
|
||||
public function get(?string $id = null): ?Entity
|
||||
{
|
||||
$entity = parent::get($id);
|
||||
|
||||
if (empty($entity) && !empty($id)) {
|
||||
$entity = $this->get();
|
||||
$entity->id = $id;
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ use Espo\Core\Repositories\Database;
|
||||
|
||||
class Import extends Database
|
||||
{
|
||||
public function findResultRecords(Entity $entity, string $relationName, Query $query) : Collection
|
||||
public function findResultRecords(Entity $entity, string $relationName, Query $query): Collection
|
||||
{
|
||||
$entityType = $entity->get('entityType');
|
||||
|
||||
@@ -54,7 +54,7 @@ class Import extends Database
|
||||
->find();
|
||||
}
|
||||
|
||||
protected function addImportEntityJoin(Entity $entity, string $link, Query $query) : Query
|
||||
protected function addImportEntityJoin(Entity $entity, string $link, Query $query): Query
|
||||
{
|
||||
$entityType = $entity->get('entityType');
|
||||
|
||||
@@ -96,7 +96,7 @@ class Import extends Database
|
||||
return $builder->build();
|
||||
}
|
||||
|
||||
public function countResultRecords(Entity $entity, string $relationName, ?Query $query = null) : int
|
||||
public function countResultRecords(Entity $entity, string $relationName, ?Query $query = null): int
|
||||
{
|
||||
$entityType = $entity->get('entityType');
|
||||
|
||||
|
||||
@@ -33,13 +33,15 @@ use Espo\ORM\Entity;
|
||||
|
||||
class Integration extends \Espo\Core\Repositories\Database
|
||||
{
|
||||
public function get(?string $id = null) : ?Entity
|
||||
public function get(?string $id = null): ?Entity
|
||||
{
|
||||
$entity = parent::get($id);
|
||||
|
||||
if (empty($entity) && !empty($id)) {
|
||||
$entity = $this->get();
|
||||
$entity->id = $id;
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,14 @@ class LayoutSet extends \Espo\Core\Repositories\Database
|
||||
|
||||
foreach ($listBefore as $name) {
|
||||
if (!in_array($name, $listNow)) {
|
||||
$layout = $this->getEntityManager()->getRepository('LayoutRecord')->where([
|
||||
'layoutSetId' => $entity->id,
|
||||
'name' => $name,
|
||||
])->findOne();
|
||||
$layout = $this->getEntityManager()
|
||||
->getRepository('LayoutRecord')
|
||||
->where([
|
||||
'layoutSetId' => $entity->id,
|
||||
'name' => $name,
|
||||
])
|
||||
->findOne();
|
||||
|
||||
if ($layout) {
|
||||
$this->getEntityManager()->removeEntity($layout);
|
||||
}
|
||||
@@ -57,9 +61,12 @@ class LayoutSet extends \Espo\Core\Repositories\Database
|
||||
|
||||
protected function afterRemove(Entity $entity, array $options = [])
|
||||
{
|
||||
$layoutList = $this->getEntityManager()->getRepository('LayoutRecord')->where([
|
||||
'layoutSetId' => $entity->id,
|
||||
])->find();
|
||||
$layoutList = $this->getEntityManager()
|
||||
->getRepository('LayoutRecord')
|
||||
->where([
|
||||
'layoutSetId' => $entity->id,
|
||||
])
|
||||
->find();
|
||||
|
||||
foreach ($layoutList as $layout) {
|
||||
$this->getEntityManager()->removeEntity($layout);
|
||||
|
||||
@@ -49,17 +49,20 @@ class Portal extends Database implements
|
||||
|
||||
$siteUrl = $this->config->get('siteUrl');
|
||||
$siteUrl = rtrim($siteUrl , '/') . '/';
|
||||
|
||||
$url = $siteUrl . 'portal/';
|
||||
|
||||
if ($entity->id === $this->config->get('defaultPortalId')) {
|
||||
$entity->set('isDefault', true);
|
||||
$entity->setFetched('isDefault', true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ($entity->get('customId')) {
|
||||
$url .= $entity->get('customId') . '/';
|
||||
} else {
|
||||
$url .= $entity->id . '/';
|
||||
}
|
||||
|
||||
$entity->set('isDefault', false);
|
||||
$entity->setFetched('isDefault', false);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class Preferences extends Repository implements
|
||||
|
||||
protected $entityType = 'Preferences';
|
||||
|
||||
public function get(?string $id = null) : ?Entity
|
||||
public function get(?string $id = null): ?Entity
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->entityFactory->create('Preferences');
|
||||
@@ -97,11 +97,13 @@ class Preferences extends Repository implements
|
||||
|
||||
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
|
||||
$data = Json::decode($row['data']);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
$this->data[$id] = get_object_vars($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,6 +130,7 @@ class Preferences extends Repository implements
|
||||
$defaults[$field] = $d['default'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->defaultAttributeListFromSettings as $attr) {
|
||||
$defaults[$attr] = $this->config->get($attr);
|
||||
}
|
||||
@@ -141,7 +144,8 @@ class Preferences extends Repository implements
|
||||
|
||||
$autoFollowEntityTypeList = [];
|
||||
|
||||
$autofollowList = $this->entityManager->getRepository('Autofollow')
|
||||
$autofollowList = $this->entityManager
|
||||
->getRepository('Autofollow')
|
||||
->select(['entityType'])
|
||||
->where([
|
||||
'userId' => $id,
|
||||
|
||||
@@ -144,7 +144,7 @@ class User extends Database
|
||||
}
|
||||
}
|
||||
|
||||
public function checkBelongsToAnyOfTeams(string $userId, array $teamIds) : bool
|
||||
public function checkBelongsToAnyOfTeams(string $userId, array $teamIds): bool
|
||||
{
|
||||
if (empty($teamIds)) {
|
||||
return false;
|
||||
|
||||
@@ -33,17 +33,26 @@ use Espo\ORM\Entity;
|
||||
|
||||
class UserData extends \Espo\Core\Repositories\Database
|
||||
{
|
||||
public function getByUserId(string $userId) : ?Entity
|
||||
public function getByUserId(string $userId): ?Entity
|
||||
{
|
||||
$userData = $this->where(['userId' => $userId])->findOne();
|
||||
$userData = $this
|
||||
->where(['userId' => $userId])
|
||||
->findOne();
|
||||
|
||||
if ($userData) return $userData;
|
||||
if ($userData) {
|
||||
return $userData;
|
||||
}
|
||||
|
||||
$user = $this->getEntityManager()->getRepository('User')->getById($userId);
|
||||
$user = $this->getEntityManager()
|
||||
->getRepository('User')
|
||||
->getById($userId);
|
||||
|
||||
if (!$user) return null;
|
||||
if (!$user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$userData = $this->getNew();
|
||||
|
||||
$userData->set('userId', $userId);
|
||||
|
||||
$this->save($userData, [
|
||||
|
||||
@@ -58,6 +58,7 @@ class Webhook extends \Espo\Core\Repositories\Database
|
||||
protected function processSettingAdditionalFields(Entity $entity): void
|
||||
{
|
||||
$event = $entity->get('event');
|
||||
|
||||
if (!$event) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user