mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
type fixes
This commit is contained in:
@@ -174,7 +174,7 @@ class Admin
|
||||
* @return array{
|
||||
* php: array<string,array<string,mixed>>,
|
||||
* database: array<string,array<string,mixed>>,
|
||||
* permission: array<string,array{type:string,acceptable:int}>,
|
||||
* permission: array<string,array<string,mixed>>,
|
||||
* }
|
||||
*/
|
||||
public function actionSystemRequirementList(): array
|
||||
|
||||
@@ -36,19 +36,18 @@ use Espo\Core\Di;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
|
||||
use StdClass;
|
||||
use Espo\Services\App as Service;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class App implements
|
||||
|
||||
Di\ServiceFactoryAware,
|
||||
Di\InjectableFactoryAware
|
||||
{
|
||||
use Di\ServiceFactorySetter;
|
||||
use Di\InjectableFactorySetter;
|
||||
|
||||
public function getActionUser(): StdClass
|
||||
public function getActionUser(): stdClass
|
||||
{
|
||||
return (object) $this->serviceFactory->create('App')->getUserData();
|
||||
return (object) $this->getService()->getUserData();
|
||||
}
|
||||
|
||||
public function postActionDestroyAuthToken(Request $request, Response $response): bool
|
||||
@@ -63,4 +62,9 @@ class App implements
|
||||
|
||||
return $auth->destroyAuthToken($data->token, $request, $response);
|
||||
}
|
||||
|
||||
private function getService(): Service
|
||||
{
|
||||
return $this->injectableFactory->create(Service::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ use Espo\Core\Api\Request;
|
||||
use Espo\Services\Email as Service;
|
||||
use Espo\Services\EmailTemplate as EmailTemplateService;
|
||||
|
||||
use Espo\Core\Utils\Crypt;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Email extends Record
|
||||
@@ -82,9 +84,7 @@ class Email extends Record
|
||||
}
|
||||
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getContainer()
|
||||
->get('crypt')
|
||||
->decrypt($preferences->get('smtpPassword'));
|
||||
$data->password = $this->getCrypt()->decrypt($preferences->get('smtpPassword'));
|
||||
}
|
||||
}
|
||||
else if ($data->type == 'emailAccount') {
|
||||
@@ -105,10 +105,9 @@ class Email extends Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getContainer()
|
||||
->get('crypt')
|
||||
->decrypt($emailAccount->get('smtpPassword'));
|
||||
$data->password = $this->getCrypt()->decrypt($emailAccount->get('smtpPassword'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,9 +124,7 @@ class Email extends Record
|
||||
}
|
||||
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getContainer()
|
||||
->get('crypt')
|
||||
->decrypt($emailAccount->get('smtpPassword'));
|
||||
$data->password = $this->getCrypt()->decrypt($emailAccount->get('smtpPassword'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,4 +329,10 @@ class Email extends Record
|
||||
/** @var EmailTemplateService */
|
||||
return $this->getServiceFactory()->create('EmailTemplate');
|
||||
}
|
||||
|
||||
private function getCrypt(): Crypt
|
||||
{
|
||||
/** @var Crypt */
|
||||
return $this->getContainer()->get('crypt');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,46 +72,62 @@ class EntityManager
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
$type = filter_var($type, \FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!is_string($name) || !is_string($type)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$params = [];
|
||||
|
||||
if (!empty($data['labelSingular'])) {
|
||||
$params['labelSingular'] = $data['labelSingular'];
|
||||
}
|
||||
|
||||
if (!empty($data['labelPlural'])) {
|
||||
$params['labelPlural'] = $data['labelPlural'];
|
||||
}
|
||||
|
||||
if (!empty($data['stream'])) {
|
||||
$params['stream'] = $data['stream'];
|
||||
}
|
||||
|
||||
if (!empty($data['disabled'])) {
|
||||
$params['disabled'] = $data['disabled'];
|
||||
}
|
||||
|
||||
if (!empty($data['sortBy'])) {
|
||||
$params['sortBy'] = $data['sortBy'];
|
||||
}
|
||||
|
||||
if (!empty($data['sortDirection'])) {
|
||||
$params['asc'] = $data['sortDirection'] === 'asc';
|
||||
}
|
||||
|
||||
if (isset($data['textFilterFields']) && is_array($data['textFilterFields'])) {
|
||||
$params['textFilterFields'] = $data['textFilterFields'];
|
||||
}
|
||||
|
||||
if (!empty($data['color'])) {
|
||||
$params['color'] = $data['color'];
|
||||
}
|
||||
|
||||
if (!empty($data['iconClass'])) {
|
||||
$params['iconClass'] = $data['iconClass'];
|
||||
}
|
||||
|
||||
if (isset($data['fullTextSearch'])) {
|
||||
$params['fullTextSearch'] = $data['fullTextSearch'];
|
||||
}
|
||||
|
||||
if (isset($data['countDisabled'])) {
|
||||
$params['countDisabled'] = $data['countDisabled'];
|
||||
}
|
||||
|
||||
if (isset($data['optimisticConcurrencyControl'])) {
|
||||
$params['optimisticConcurrencyControl'] = $data['optimisticConcurrencyControl'];
|
||||
}
|
||||
|
||||
$params['kanbanViewMode'] = !empty($data['kanbanViewMode']);
|
||||
|
||||
if (!empty($data['kanbanStatusIgnoreList'])) {
|
||||
$params['kanbanStatusIgnoreList'] = $data['kanbanStatusIgnoreList'];
|
||||
}
|
||||
@@ -135,6 +151,10 @@ class EntityManager
|
||||
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!is_string($name)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->entityManagerTool->update($name, $data);
|
||||
|
||||
return true;
|
||||
@@ -154,6 +174,10 @@ class EntityManager
|
||||
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!is_string($name)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->entityManagerTool->delete($name);
|
||||
|
||||
return true;
|
||||
@@ -198,6 +222,7 @@ class EntityManager
|
||||
if (array_key_exists('linkMultipleField', $data)) {
|
||||
$params['linkMultipleField'] = $data['linkMultipleField'];
|
||||
}
|
||||
|
||||
if (array_key_exists('linkMultipleFieldForeign', $data)) {
|
||||
$params['linkMultipleFieldForeign'] = $data['linkMultipleFieldForeign'];
|
||||
}
|
||||
@@ -205,16 +230,35 @@ class EntityManager
|
||||
if (array_key_exists('audited', $data)) {
|
||||
$params['audited'] = $data['audited'];
|
||||
}
|
||||
|
||||
if (array_key_exists('auditedForeign', $data)) {
|
||||
$params['auditedForeign'] = $data['auditedForeign'];
|
||||
}
|
||||
|
||||
if (array_key_exists('parentEntityTypeList', $data)) {
|
||||
$params['parentEntityTypeList'] = $data['parentEntityTypeList'];
|
||||
}
|
||||
|
||||
if (array_key_exists('foreignLinkEntityTypeList', $data)) {
|
||||
$params['foreignLinkEntityTypeList'] = $data['foreignLinkEntityTypeList'];
|
||||
}
|
||||
|
||||
/** @var array{
|
||||
* linkType: string,
|
||||
* entity: string,
|
||||
* link: string,
|
||||
* entityForeign: string,
|
||||
* linkForeign: string,
|
||||
* label: string,
|
||||
* labelForeign: string,
|
||||
* relationName?: ?string,
|
||||
* linkMultipleField?: bool,
|
||||
* linkMultipleFieldForeign?: bool,
|
||||
* audited?: bool,
|
||||
* auditedForeign?: bool,
|
||||
* } $params
|
||||
*/
|
||||
|
||||
$this->entityManagerTool->createLink($params);
|
||||
|
||||
return true;
|
||||
@@ -253,16 +297,36 @@ class EntityManager
|
||||
if (array_key_exists('audited', $data)) {
|
||||
$params['audited'] = $data['audited'];
|
||||
}
|
||||
|
||||
if (array_key_exists('auditedForeign', $data)) {
|
||||
$params['auditedForeign'] = $data['auditedForeign'];
|
||||
}
|
||||
|
||||
if (array_key_exists('parentEntityTypeList', $data)) {
|
||||
$params['parentEntityTypeList'] = $data['parentEntityTypeList'];
|
||||
}
|
||||
|
||||
if (array_key_exists('foreignLinkEntityTypeList', $data)) {
|
||||
$params['foreignLinkEntityTypeList'] = $data['foreignLinkEntityTypeList'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array{
|
||||
* entity: string,
|
||||
* link: string,
|
||||
* entityForeign?: ?string,
|
||||
* linkForeign?: ?string,
|
||||
* label?: string,
|
||||
* labelForeign?: string,
|
||||
* linkMultipleField?: bool,
|
||||
* linkMultipleFieldForeign?: bool,
|
||||
* audited?: bool,
|
||||
* auditedForeign?: bool,
|
||||
* parentEntityTypeList?: string[],
|
||||
* foreignLinkEntityTypeList?: string[],
|
||||
* } $params
|
||||
*/
|
||||
|
||||
$this->entityManagerTool->updateLink($params);
|
||||
|
||||
return true;
|
||||
@@ -279,13 +343,20 @@ class EntityManager
|
||||
'link',
|
||||
];
|
||||
|
||||
$d = [];
|
||||
$params = [];
|
||||
|
||||
foreach ($paramList as $item) {
|
||||
$d[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
$params[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
$this->entityManagerTool->deleteLink($d);
|
||||
/**
|
||||
* @var array{
|
||||
* entity?: string,
|
||||
* link?: string,
|
||||
* } $params
|
||||
*/
|
||||
|
||||
$this->entityManagerTool->deleteLink($params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
use Espo\Core\Utils\Json;
|
||||
|
||||
use Espo\Tools\Export\Service;
|
||||
use Espo\Tools\Export\ServiceParams;
|
||||
use Espo\Tools\Export\Params;
|
||||
@@ -112,11 +114,11 @@ class Export
|
||||
|
||||
if (!is_null($where) || !is_null($searchParams)) {
|
||||
if (!is_null($where)) {
|
||||
$params['where'] = json_decode(json_encode($where), true);
|
||||
$params['where'] = json_decode(Json::encode($where), true);
|
||||
}
|
||||
|
||||
if (!is_null($searchParams)) {
|
||||
$params['searchParams'] = json_decode(json_encode($searchParams), true);
|
||||
$params['searchParams'] = json_decode(Json::encode($searchParams), true);
|
||||
}
|
||||
}
|
||||
else if (!is_null($ids)) {
|
||||
|
||||
@@ -64,9 +64,11 @@ class ExternalAccount extends RecordBase
|
||||
$entity->get('enabled') &&
|
||||
$this->metadata->get('integrations.' . $entity->getId() .'.allowUserAccounts')
|
||||
) {
|
||||
/** @var string */
|
||||
$id = $entity->getId();
|
||||
|
||||
$userAccountAclScope = $this->metadata
|
||||
->get(['integrations', $entity->getId(), 'userAccountAclScope']);
|
||||
->get(['integrations', $id, 'userAccountAclScope']);
|
||||
|
||||
if ($userAccountAclScope) {
|
||||
if (!$this->acl->checkScope($userAccountAclScope)) {
|
||||
@@ -75,7 +77,7 @@ class ExternalAccount extends RecordBase
|
||||
}
|
||||
|
||||
$list[] = [
|
||||
'id' => $entity->getId(),
|
||||
'id' => $id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ class LastViewed
|
||||
$result = $this->service->getList($params);
|
||||
|
||||
return (object) [
|
||||
'total' => $result->total,
|
||||
'list' => $result->collection->getValueMapList(),
|
||||
'total' => $result['total'],
|
||||
'list' => $result['collection']->getValueMapList(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ use Espo\Core\MassAction\ServiceParams;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
|
||||
use Espo\Core\Utils\Json;
|
||||
|
||||
use stdClass;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -128,11 +130,11 @@ class MassAction
|
||||
$params = [];
|
||||
|
||||
if (!is_null($where)) {
|
||||
$params['where'] = json_decode(json_encode($where), true);
|
||||
$params['where'] = json_decode(Json::encode($where), true);
|
||||
}
|
||||
|
||||
if (!is_null($searchParams)) {
|
||||
$params['searchParams'] = json_decode(json_encode($searchParams), true);
|
||||
$params['searchParams'] = json_decode(Json::encode($searchParams), true);
|
||||
}
|
||||
|
||||
return $params;
|
||||
|
||||
@@ -63,6 +63,7 @@ class Metadata extends Base
|
||||
|
||||
private function getMetadataService(): Service
|
||||
{
|
||||
/** @var Service */
|
||||
return $this->getServiceFactory()->create('Metadata');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@ class User extends Record
|
||||
|
||||
private function getUserService(): Service
|
||||
{
|
||||
/** @var Service */
|
||||
return $this->getServiceFactory()->create('User');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,11 +64,15 @@ class LastViewed
|
||||
|
||||
/**
|
||||
* @param array{
|
||||
* offset: int,
|
||||
* maxSize: int,
|
||||
* offset: ?int,
|
||||
* maxSize: ?int,
|
||||
* } $params
|
||||
* @return array{
|
||||
* total: int,
|
||||
* collection: \Espo\ORM\Collection<\Espo\Entities\ActionHistoryRecord>,
|
||||
* }
|
||||
*/
|
||||
public function getList(array $params): object
|
||||
public function getList(array $params): array
|
||||
{
|
||||
$repository = $this->entityManager->getRDBRepository('ActionHistoryRecord');
|
||||
|
||||
@@ -81,9 +85,10 @@ class LastViewed
|
||||
}
|
||||
);
|
||||
|
||||
$offset = $params['offset'];
|
||||
$maxSize = $params['maxSize'];
|
||||
$offset = $params['offset'] ?? 0;
|
||||
$maxSize = $params['maxSize'] ?? 0;
|
||||
|
||||
/** @var \Espo\ORM\Collection<\Espo\Entities\ActionHistoryRecord> */
|
||||
$collection = $repository
|
||||
->where([
|
||||
'userId' => $this->user->getId(),
|
||||
@@ -121,7 +126,7 @@ class LastViewed
|
||||
$total = -2;
|
||||
}
|
||||
|
||||
return (object) [
|
||||
return [
|
||||
'total' => $total,
|
||||
'collection' => $collection,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user