type fixes
This commit is contained in:
@@ -32,4 +32,19 @@ namespace Espo\Modules\Crm\Entities;
|
||||
class Reminder extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Reminder';
|
||||
|
||||
public function getUserId(): ?string
|
||||
{
|
||||
return $this->get('userId');
|
||||
}
|
||||
|
||||
public function getTargetEntityId(): ?string
|
||||
{
|
||||
return $this->get('entityId');
|
||||
}
|
||||
|
||||
public function getTargetEntityType(): ?string
|
||||
{
|
||||
return $this->get('entityType');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class CampaignTrackOpened implements EntryPoint
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
|
||||
if (!$id) {
|
||||
if (!$id || !is_string($id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class CampaignUrl implements EntryPoint
|
||||
$hash = $request->getQueryParam('hash') ?? null;
|
||||
$uid = $request->getQueryParam('uid') ?? null;
|
||||
|
||||
if (!$trackingUrlId) {
|
||||
if (!$trackingUrlId || !is_string($trackingUrlId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
@@ -120,13 +120,21 @@ class CampaignUrl implements EntryPoint
|
||||
}
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
if (!is_string($emailAddress) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithHash($trackingUrl, $emailAddress, $hash);
|
||||
}
|
||||
else if ($uid && $hash) {
|
||||
if (!is_string($uid) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithUniqueId($trackingUrl, $uid, $hash);
|
||||
}
|
||||
else {
|
||||
if (!$queueItemId) {
|
||||
if (!$queueItemId || !is_string($queueItemId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,12 +91,16 @@ class SubscribeAgain implements EntryPoint
|
||||
$hash = $request->getQueryParam('hash') ?? null;
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
if (!is_string($emailAddress) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithHash($emailAddress, $hash);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (!$id || !is_string($id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,12 +96,16 @@ class Unsubscribe implements EntryPoint
|
||||
$hash = $request->getQueryParam('hash') ?? null;
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
if (!is_string($emailAddress) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithHash($emailAddress, $hash);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (!$id || !is_string($id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
@@ -95,9 +95,9 @@ class SubmitPopupReminders implements JobDataLess
|
||||
$submitData = [];
|
||||
|
||||
foreach ($reminderList as $reminder) {
|
||||
$userId = $reminder->get('userId');
|
||||
$entityType = $reminder->get('entityType');
|
||||
$entityId = $reminder->get('entityId');
|
||||
$userId = $reminder->getUserId();
|
||||
$entityType = $reminder->getTargetEntityId();
|
||||
$entityId = $reminder->getTargetEntityId();
|
||||
|
||||
if (!$userId || !$entityType || !$entityId) {
|
||||
$this->deleteReminder($reminder);
|
||||
@@ -160,7 +160,8 @@ class SubmitPopupReminders implements JobDataLess
|
||||
$this->webSocketSubmission->submit('popupNotifications.event', $userId, (object) [
|
||||
'list' => $list
|
||||
]);
|
||||
} catch (Throwable $e) {
|
||||
}
|
||||
catch (Throwable $e) {
|
||||
$this->log->error('Job SubmitPopupReminders: [' . $e->getCode() . '] ' .$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,12 @@ class CaseObj extends \Espo\Core\Repositories\Database implements
|
||||
|
||||
protected function getStreamService(): StreamService
|
||||
{
|
||||
$this->streamService = $this->streamService ?? $this->serviceFactory->create('Stream');
|
||||
if (!$this->streamService) {
|
||||
/** @var StreamService */
|
||||
$service = $this->serviceFactory->create('Stream');
|
||||
|
||||
$this->streamService = $service;
|
||||
}
|
||||
|
||||
return $this->streamService;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class Opportunity extends Database
|
||||
}
|
||||
|
||||
$probability = $this->metadata
|
||||
->get(['entityDefs', 'Opportunity', 'fields', 'stage', 'probabilityMap', $entity->getStage()]) ?? 0;
|
||||
->get(['entityDefs', 'Opportunity', 'fields', 'stage', 'probabilityMap', $entity->getStage() ?? '']) ?? 0;
|
||||
|
||||
if ($probability) {
|
||||
$entity->set('lastStage', $entity->getStage());
|
||||
|
||||
@@ -728,7 +728,7 @@ class Activities implements
|
||||
|
||||
$sth = $this->entityManager->getQueryExecutor()->execute($unionQuery);
|
||||
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
$boolAttributeList = ['hasAttachment'];
|
||||
|
||||
@@ -942,20 +942,23 @@ class Activities implements
|
||||
|
||||
$this->accessCheck($entity);
|
||||
|
||||
$fetchAll = empty($params['scope']);
|
||||
$targetScope = $params['scope'] ?? null;
|
||||
|
||||
if (!$fetchAll) {
|
||||
if (!$this->metadata->get(['scopes', $params['scope'], 'activity'])) {
|
||||
throw new Error('Entity \'' . $params['scope'] . '\' is not an activity');
|
||||
$fetchAll = empty($targetScope);
|
||||
|
||||
if ($targetScope) {
|
||||
if (!$this->metadata->get(['scopes', $targetScope, 'activity'])) {
|
||||
throw new Error('Entity \'' . $targetScope . '\' is not an activity');
|
||||
}
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
|
||||
/** @var string[] */
|
||||
$entityTypeList = $this->config->get('activitiesEntityList', ['Meeting', 'Call']);
|
||||
|
||||
foreach ($entityTypeList as $entityType) {
|
||||
if (!$fetchAll && $params['scope'] !== $entityType) {
|
||||
if (!$fetchAll && $targetScope !== $entityType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -997,19 +1000,23 @@ class Activities implements
|
||||
|
||||
$this->accessCheck($entity);
|
||||
|
||||
$fetchAll = empty($params['scope']);
|
||||
$targetScope = $params['scope'] ?? null;
|
||||
|
||||
if (!$fetchAll) {
|
||||
if (!$this->metadata->get(['scopes', $params['scope'], 'activity'])) {
|
||||
throw new Error('Entity \'' . $params['scope'] . '\' is not an activity');
|
||||
$fetchAll = empty($targetScope);
|
||||
|
||||
if ($targetScope) {
|
||||
if (!$this->metadata->get(['scopes', $targetScope, 'activity'])) {
|
||||
throw new Error('Entity \'' . $targetScope . '\' is not an activity');
|
||||
}
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
|
||||
/** @var string[] */
|
||||
$entityTypeList = $this->config->get('historyEntityList', ['Meeting', 'Call', 'Email']);
|
||||
|
||||
foreach ($entityTypeList as $entityType) {
|
||||
if (!$fetchAll && $params['scope'] !== $entityType) {
|
||||
if (!$fetchAll && $targetScope !== $entityType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1878,7 +1885,7 @@ class Activities implements
|
||||
|
||||
$sth = $this->entityManager->getQueryExecutor()->execute($unionQuery);
|
||||
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
return $rowList;
|
||||
}
|
||||
@@ -2060,7 +2067,8 @@ class Activities implements
|
||||
];
|
||||
}
|
||||
|
||||
$builder = $this->entityManager->getQueryBuilder()
|
||||
$builder = $this->entityManager
|
||||
->getQueryBuilder()
|
||||
->union();
|
||||
|
||||
foreach ($queryList as $query) {
|
||||
@@ -2081,8 +2089,8 @@ class Activities implements
|
||||
|
||||
$totalCount = $row['count'];
|
||||
|
||||
$offset = intval($params['offset']);
|
||||
$maxSize = intval($params['maxSize']);
|
||||
$offset = intval($params['offset'] ?? 0);
|
||||
$maxSize = intval($params['maxSize'] ?? 0);
|
||||
|
||||
$unionQuery = $builder
|
||||
->order('dateStart')
|
||||
@@ -2093,7 +2101,7 @@ class Activities implements
|
||||
|
||||
$sth = $this->entityManager->getQueryExecutor()->execute($unionQuery);
|
||||
|
||||
$rows = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rows = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
$entityDataList = [];
|
||||
|
||||
|
||||
@@ -502,7 +502,7 @@ class Campaign extends Record implements
|
||||
}
|
||||
|
||||
$filename = $campaign->get('name') . ' - ' .
|
||||
$this->defaultLanguage->translate($targetEntityType, 'scopeNamesPlural');
|
||||
$this->defaultLanguage->translateLabel($targetEntityType, 'scopeNamesPlural');
|
||||
|
||||
return $this->getPdfService()->generateMailMerge(
|
||||
$targetEntityType,
|
||||
|
||||
@@ -67,7 +67,7 @@ class Document extends Record
|
||||
|
||||
$attachment = $this->getAttachmentRepository()->getCopiedAttachment($file, 'Attachment');
|
||||
|
||||
/** @var \Espo\ORM\Collection<Attachment> $attachmentList */
|
||||
/** @var \Espo\ORM\EntityCollection<Attachment> $attachmentList */
|
||||
$attachmentList = $this->entityManager
|
||||
->getCollectionFactory()
|
||||
->create('Attachment');
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Espo\Modules\Crm\Services;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\ConflictSilent;
|
||||
|
||||
use Espo\Core\Utils\Json;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Modules\Crm\Entities\Lead as LeadEntity;
|
||||
@@ -109,11 +111,13 @@ class Lead extends Record implements
|
||||
|
||||
$data = [];
|
||||
|
||||
$entityList = $this->getMetadata()->get('entityDefs.Lead.convertEntityList', []);
|
||||
/** @var string[] */
|
||||
$entityList = $this->metadata->get('entityDefs.Lead.convertEntityList', []);
|
||||
|
||||
$ignoreAttributeList = ['createdAt', 'modifiedAt', 'modifiedById', 'modifiedByName', 'createdById', 'createdByName'];
|
||||
|
||||
$convertFieldsDefs = $this->getMetadata()->get('entityDefs.Lead.convertFields', []);
|
||||
/** @var array<string,array<string,string>> */
|
||||
$convertFieldsDefs = $this->metadata->get('entityDefs.Lead.convertFields', []);
|
||||
|
||||
foreach ($entityList as $entityType) {
|
||||
if (!$this->getAcl()->checkScope($entityType, 'edit')) {
|
||||
@@ -121,26 +125,27 @@ class Lead extends Record implements
|
||||
}
|
||||
|
||||
$attributes = [];
|
||||
|
||||
$fieldMap = [];
|
||||
|
||||
$fieldList = array_keys($this->getMetadata()->get('entityDefs.Lead.fields', []));
|
||||
/** @var string[] */
|
||||
$fieldList = array_keys($this->metadata->get('entityDefs.Lead.fields', []));
|
||||
|
||||
foreach ($fieldList as $field) {
|
||||
if (!$this->getMetadata()->get('entityDefs.'.$entityType.'.fields.' . $field)) {
|
||||
if (!$this->metadata->get('entityDefs.'.$entityType.'.fields.' . $field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
$this->getMetadata()->get(['entityDefs', $entityType, 'fields', $field, 'type'])
|
||||
$this->metadata->get(['entityDefs', $entityType, 'fields', $field, 'type'])
|
||||
!==
|
||||
$this->getMetadata()->get(['entityDefs', 'Lead', 'fields', $field, 'type'])
|
||||
$this->metadata->get(['entityDefs', 'Lead', 'fields', $field, 'type'])
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fieldMap[$field] = $field;
|
||||
}
|
||||
|
||||
if (array_key_exists($entityType, $convertFieldsDefs)) {
|
||||
foreach ($convertFieldsDefs[$entityType] as $field => $leadField) {
|
||||
$fieldMap[$field] = $leadField;
|
||||
@@ -148,7 +153,7 @@ class Lead extends Record implements
|
||||
}
|
||||
|
||||
foreach ($fieldMap as $field => $leadField) {
|
||||
$type = $this->getMetadata()->get(['entityDefs', 'Lead', 'fields', $field, 'type']);
|
||||
$type = $this->metadata->get(['entityDefs', 'Lead', 'fields', $field, 'type']);
|
||||
|
||||
if (in_array($type, ['file', 'image'])) {
|
||||
$attachment = $lead->get($field);
|
||||
@@ -355,7 +360,7 @@ class Lead extends Record implements
|
||||
'duplicates' => $duplicateList,
|
||||
];
|
||||
|
||||
throw new ConflictSilent(json_encode($reason));
|
||||
throw new ConflictSilent(Json::encode($reason));
|
||||
}
|
||||
|
||||
$lead->set('status', 'Converted');
|
||||
|
||||
@@ -243,7 +243,9 @@ class Meeting extends Record implements
|
||||
{
|
||||
$userId = $userId ?? $this->getUser()->getId();
|
||||
|
||||
$statusList = $this->getMetadata()
|
||||
assert(is_string($this->entityType));
|
||||
|
||||
$statusList = $this->metadata
|
||||
->get(['entityDefs', $this->entityType, 'fields', 'acceptanceStatus', 'options'], []);
|
||||
|
||||
if (!in_array($status, $statusList)) {
|
||||
|
||||
@@ -75,7 +75,7 @@ class Opportunity extends Record
|
||||
|
||||
$lostStageList = $this->getLostStageList();
|
||||
|
||||
$options = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
$options = $this->metadata->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
|
||||
$queryBuilder = $this->selectBuilderFactory
|
||||
->create()
|
||||
@@ -126,7 +126,7 @@ class Opportunity extends Record
|
||||
->getQueryExecutor()
|
||||
->execute($queryBuilder->build());
|
||||
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
$data = [];
|
||||
|
||||
@@ -138,7 +138,7 @@ class Opportunity extends Record
|
||||
|
||||
$dataList = [];
|
||||
|
||||
$stageList = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
$stageList = $this->metadata->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
|
||||
foreach ($stageList as $stage) {
|
||||
if (in_array($stage, $lostStageList)) {
|
||||
@@ -178,7 +178,7 @@ class Opportunity extends Record
|
||||
list($dateFrom, $dateTo) = $this->getDateRangeByFilter($dateFilter);
|
||||
}
|
||||
|
||||
$options = $this->getMetadata()->get('entityDefs.Lead.fields.source.options', []);
|
||||
$options = $this->metadata->get('entityDefs.Lead.fields.source.options', []);
|
||||
|
||||
$queryBuilder = $this->selectBuilderFactory
|
||||
->create()
|
||||
@@ -214,7 +214,7 @@ class Opportunity extends Record
|
||||
->getQueryExecutor()
|
||||
->execute($queryBuilder->build());
|
||||
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
$result = [];
|
||||
|
||||
@@ -241,7 +241,7 @@ class Opportunity extends Record
|
||||
list($dateFrom, $dateTo) = $this->getDateRangeByFilter($dateFilter);
|
||||
}
|
||||
|
||||
$options = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
$options = $this->metadata->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
|
||||
$queryBuilder = $this->selectBuilderFactory
|
||||
->create()
|
||||
@@ -278,7 +278,7 @@ class Opportunity extends Record
|
||||
->getQueryExecutor()
|
||||
->execute($queryBuilder->build());
|
||||
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
$result = [];
|
||||
|
||||
@@ -355,7 +355,7 @@ class Opportunity extends Record
|
||||
|
||||
$result = [];
|
||||
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rowList = $sth->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
foreach ($rowList as $row) {
|
||||
$month = $row['month'];
|
||||
@@ -536,11 +536,11 @@ class Opportunity extends Record
|
||||
{
|
||||
$lostStageList = [];
|
||||
|
||||
$probabilityMap = $this->getMetadata()->get(
|
||||
$probabilityMap = $this->metadata->get(
|
||||
['entityDefs', OpportunityEntity::ENTITY_TYPE, 'fields', 'stage', 'probabilityMap'], []
|
||||
);
|
||||
|
||||
$stageList = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
$stageList = $this->metadata->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
|
||||
foreach ($stageList as $stage) {
|
||||
if (empty($probabilityMap[$stage])) {
|
||||
@@ -558,11 +558,11 @@ class Opportunity extends Record
|
||||
{
|
||||
$wonStageList = [];
|
||||
|
||||
$probabilityMap = $this->getMetadata()->get(
|
||||
$probabilityMap = $this->metadata->get(
|
||||
['entityDefs', OpportunityEntity::ENTITY_TYPE, 'fields', 'stage', 'probabilityMap'], []
|
||||
);
|
||||
|
||||
$stageList = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
$stageList = $this->metadata->get('entityDefs.Opportunity.fields.stage.options', []);
|
||||
|
||||
foreach ($stageList as $stage) {
|
||||
if (!empty($probabilityMap[$stage]) && $probabilityMap[$stage] == 100) {
|
||||
|
||||
Reference in New Issue
Block a user