mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
name field consts
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Classes\Acl\Attachment;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\Settings;
|
||||
@@ -58,20 +59,18 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
|
||||
public function checkEntityRead(User $user, Entity $entity, ScopeData $data): bool
|
||||
{
|
||||
/** @var Attachment $entity */
|
||||
|
||||
if ($entity->get('parentType') === Settings::ENTITY_TYPE) {
|
||||
if ($entity->getParentType() === Settings::ENTITY_TYPE) {
|
||||
// Allow the logo.
|
||||
return true;
|
||||
}
|
||||
|
||||
$parent = null;
|
||||
|
||||
$parentType = $entity->get('parentType');
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->getParentType();
|
||||
$parentId = $entity->getParent()?->getId();
|
||||
|
||||
$relatedType = $entity->get('relatedType');
|
||||
$relatedId = $entity->get('relatedId');
|
||||
$relatedType = $entity->getRelatedType();
|
||||
$relatedId = $entity->getRelated()?->getId();
|
||||
|
||||
if ($parentId && $parentType) {
|
||||
$parent = $this->entityManager->getEntityById($parentType, $parentId);
|
||||
@@ -116,8 +115,8 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
{
|
||||
if ($note->getTargetType() === Note::TARGET_TEAMS) {
|
||||
$intersect = array_intersect(
|
||||
$note->getLinkMultipleIdList('teams'),
|
||||
$user->getLinkMultipleIdList('teams')
|
||||
$note->getLinkMultipleIdList(Field::TEAMS),
|
||||
$user->getLinkMultipleIdList(Field::TEAMS)
|
||||
);
|
||||
|
||||
if (count($intersect)) {
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Classes\Acl\Note;
|
||||
|
||||
use Espo\Core\Acl\Permission;
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
@@ -128,7 +129,7 @@ class AccessChecker implements AccessEntityCREDChecker
|
||||
}
|
||||
|
||||
if ($entity->getTargetType() === Note::TARGET_TEAMS) {
|
||||
$targetTeamIdList = $entity->getLinkMultipleIdList('teams');
|
||||
$targetTeamIdList = $entity->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
foreach ($user->getTeamIdList() as $teamId) {
|
||||
if (in_array($teamId, $targetTeamIdList)) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Classes\Acl\Team;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\Team;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
@@ -41,8 +42,7 @@ class OwnershipChecker implements OwnershipOwnChecker
|
||||
{
|
||||
public function checkOwn(User $user, Entity $entity): bool
|
||||
{
|
||||
/** @var string[] $userTeamIdList */
|
||||
$userTeamIdList = $user->getLinkMultipleIdList('teams');
|
||||
$userTeamIdList = $user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
return in_array($entity->getId(), $userTeamIdList);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Classes\Acl\User;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
@@ -51,8 +52,8 @@ class OwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker
|
||||
assert($entity instanceof CoreEntity);
|
||||
|
||||
$intersect = array_intersect(
|
||||
$user->getLinkMultipleIdList('teams'),
|
||||
$entity->getLinkMultipleIdList('teams')
|
||||
$user->getLinkMultipleIdList(Field::TEAMS),
|
||||
$entity->getLinkMultipleIdList(Field::TEAMS)
|
||||
);
|
||||
|
||||
if (count($intersect)) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Classes\DefaultLayouts;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\Team;
|
||||
@@ -58,17 +59,17 @@ class DefaultSidePanelType
|
||||
}
|
||||
|
||||
if (
|
||||
$this->metadata->get(['entityDefs', $scope, 'fields', 'teams', 'type']) === FieldType::LINK_MULTIPLE &&
|
||||
$this->metadata->get(['entityDefs', $scope, 'links', 'teams', 'entity']) === Team::ENTITY_TYPE
|
||||
$this->metadata->get(['entityDefs', $scope, 'fields', Field::TEAMS, 'type']) === FieldType::LINK_MULTIPLE &&
|
||||
$this->metadata->get(['entityDefs', $scope, 'links', Field::TEAMS, 'entity']) === Team::ENTITY_TYPE
|
||||
) {
|
||||
$list[] = (object) ['name' => 'teams'];
|
||||
$list[] = (object) ['name' => Field::TEAMS];
|
||||
}
|
||||
|
||||
if (
|
||||
$this->metadata->get("entityDefs.$scope.fields.collaborators.type") === FieldType::LINK_MULTIPLE &&
|
||||
$this->metadata->get("entityDefs.$scope.links.collaborators.entity") === User::ENTITY_TYPE
|
||||
) {
|
||||
$list[] = (object) ['name' => 'collaborators'];
|
||||
$list[] = (object) ['name' => Field::COLLABORATORS];
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Classes\RecordHooks\Email;
|
||||
|
||||
use Espo\Core\Mail\Sender;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Record\Hook\SaveHook;
|
||||
use Espo\Core\Utils\FieldUtil;
|
||||
use Espo\Core\Utils\SystemUser;
|
||||
@@ -45,9 +46,9 @@ class BeforeUpdate implements SaveHook
|
||||
{
|
||||
/** @var string[] */
|
||||
private $allowedForUpdateFieldList = [
|
||||
'parent',
|
||||
'teams',
|
||||
'assignedUser',
|
||||
Field::PARENT,
|
||||
Field::TEAMS,
|
||||
Field::ASSIGNED_USER,
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
|
||||
@@ -34,6 +34,7 @@ use Espo\Core\Acl\Permission;
|
||||
use Espo\Core\Acl\Table as AclTable;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Record\Hook\SaveHook;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\User;
|
||||
@@ -64,7 +65,7 @@ class AssignmentCheck implements SaveHook
|
||||
|
||||
$userIdList = $entity->getLinkMultipleIdList('users');
|
||||
$portalIdList = $entity->getLinkMultipleIdList('portals');
|
||||
$teamIdList = $entity->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $entity->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
/** @var iterable<User> $targetUserList */
|
||||
$targetUserList = [];
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\Acl\AccessChecker\ScopeChecker;
|
||||
use Espo\Core\Acl\AccessChecker\ScopeCheckerData;
|
||||
use Espo\Core\AclManager;
|
||||
@@ -57,9 +57,9 @@ class DefaultAccessChecker implements
|
||||
AccessEntityDeleteChecker,
|
||||
AccessEntityStreamChecker
|
||||
{
|
||||
private const ATTR_CREATED_BY_ID = 'createdById';
|
||||
private const ATTR_CREATED_AT = 'createdAt';
|
||||
private const ATTR_ASSIGNED_USER_ID = 'assignedUserId';
|
||||
private const ATTR_CREATED_BY_ID = Field::CREATED_BY . 'Id';
|
||||
private const ATTR_CREATED_AT = Field::CREATED_AT;
|
||||
private const ATTR_ASSIGNED_USER_ID = Field::ASSIGNED_USER . 'Id';
|
||||
private const ALLOW_DELETE_OWN_CREATED_PERIOD = '24 hours';
|
||||
|
||||
public function __construct(
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -44,10 +45,10 @@ use Espo\Core\AclManager;
|
||||
*/
|
||||
class DefaultAssignmentChecker implements AssignmentChecker
|
||||
{
|
||||
protected const FIELD_ASSIGNED_USERS = 'assignedUsers';
|
||||
protected const FIELD_TEAMS = 'teams';
|
||||
protected const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS;
|
||||
protected const FIELD_TEAMS = Field::TEAMS;
|
||||
protected const ATTR_ASSIGNED_USER_ID = 'assignedUserId';
|
||||
private const FIELD_COLLABORATORS = 'collaborators';
|
||||
private const FIELD_COLLABORATORS = Field::COLLABORATORS;
|
||||
|
||||
public function __construct(
|
||||
private AclManager $aclManager,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
use Espo\Entities\User;
|
||||
@@ -42,12 +43,12 @@ use Espo\Entities\User;
|
||||
*/
|
||||
class DefaultOwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker, OwnershipSharedChecker
|
||||
{
|
||||
private const ATTR_CREATED_BY_ID = 'createdById';
|
||||
private const ATTR_ASSIGNED_USER_ID = 'assignedUserId';
|
||||
private const ATTR_ASSIGNED_TEAMS_IDS = 'teamsIds';
|
||||
private const FIELD_TEAMS = 'teams';
|
||||
private const FIELD_ASSIGNED_USERS = 'assignedUsers';
|
||||
private const FIELD_COLLABORATORS = 'collaborators';
|
||||
private const ATTR_CREATED_BY_ID = Field::CREATED_BY . 'Id';
|
||||
private const ATTR_ASSIGNED_USER_ID = Field::ASSIGNED_USER . 'Id';
|
||||
private const ATTR_ASSIGNED_TEAMS_IDS = Field::TEAMS . 'Ids';
|
||||
private const FIELD_TEAMS = Field::TEAMS;
|
||||
private const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS;
|
||||
private const FIELD_COLLABORATORS = Field::COLLABORATORS;
|
||||
|
||||
public function checkOwn(User $user, Entity $entity): bool
|
||||
{
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Defs;
|
||||
|
||||
class OwnerUserFieldProvider
|
||||
{
|
||||
protected const FIELD_ASSIGNED_USERS = 'assignedUsers';
|
||||
protected const FIELD_ASSIGNED_USER = 'assignedUser';
|
||||
protected const FIELD_CREATED_BY = 'createdBy';
|
||||
protected const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS;
|
||||
protected const FIELD_ASSIGNED_USER = Field::ASSIGNED_USER;
|
||||
protected const FIELD_CREATED_BY = Field::CREATED_BY;
|
||||
|
||||
public function __construct(private Defs $ormDefs, private Metadata $metadata)
|
||||
{}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Acl\Table;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\Team;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\Entities\User;
|
||||
@@ -59,7 +60,7 @@ class DefaultRoleListProvider implements RoleListProvider
|
||||
/** @var iterable<Team> $teamList */
|
||||
$teamList = $this->entityManager
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->getRelation($this->user, 'teams')
|
||||
->getRelation($this->user, Field::TEAMS)
|
||||
->find();
|
||||
|
||||
foreach ($teamList as $team) {
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core;
|
||||
|
||||
use Espo\Core\Acl\OwnershipSharedChecker;
|
||||
use Espo\Core\Acl\Permission;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\Entities\User;
|
||||
@@ -605,7 +606,7 @@ class AclManager
|
||||
}
|
||||
|
||||
if ($permission === Table::LEVEL_TEAM) {
|
||||
$teamIdList = $user->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
/** @var \Espo\Repositories\User $userRepository */
|
||||
$userRepository = $this->entityManager->getRepository(User::ENTITY_TYPE);
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core\Authentication;
|
||||
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Language\LanguageProxy;
|
||||
use Espo\Repositories\UserData as UserDataRepository;
|
||||
use Espo\Entities\Portal;
|
||||
@@ -779,7 +780,7 @@ class Authentication
|
||||
return [null, FailReason::ANOTHER_USER_NOT_ALLOWED];
|
||||
}
|
||||
|
||||
$loggedUser->loadLinkMultipleField('teams');
|
||||
$loggedUser->loadLinkMultipleField(Field::TEAMS);
|
||||
|
||||
return [$loggedUser, null];
|
||||
}
|
||||
@@ -791,7 +792,7 @@ class Authentication
|
||||
}
|
||||
|
||||
if (!$this->isPortal()) {
|
||||
$user->loadLinkMultipleField('teams');
|
||||
$user->loadLinkMultipleField(Field::TEAMS);
|
||||
}
|
||||
|
||||
$user->set('ipAddress', $this->util->obtainIpFromRequest($request));
|
||||
|
||||
@@ -44,6 +44,7 @@ use Espo\Core\Authentication\Login\Data;
|
||||
use Espo\Core\Authentication\Logins\Espo;
|
||||
use Espo\Core\Authentication\Result;
|
||||
use Espo\Core\Authentication\Result\FailReason;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\ORM\Repository\Option\SaveOption;
|
||||
use Espo\Core\Utils\Config;
|
||||
@@ -382,7 +383,7 @@ class LdapLogin implements Login
|
||||
'skipLinkMultipleHooks' => true,
|
||||
]);
|
||||
|
||||
$this->linkMultipleSaver->process($user, 'teams', $saverParams);
|
||||
$this->linkMultipleSaver->process($user, Field::TEAMS, $saverParams);
|
||||
$this->linkMultipleSaver->process($user, 'portals', $saverParams);
|
||||
$this->linkMultipleSaver->process($user, 'portalRoles', $saverParams);
|
||||
$this->emailAddressSaver->process($user, $saverParams);
|
||||
|
||||
@@ -34,6 +34,7 @@ use Espo\Core\ApplicationState;
|
||||
use Espo\Core\Authentication\Jwt\Token\Payload;
|
||||
use Espo\Core\Authentication\Oidc\ConfigDataProvider;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\PasswordHash;
|
||||
use Espo\Core\Utils\Util;
|
||||
@@ -98,7 +99,7 @@ class Sync
|
||||
$clearAclCache = false;
|
||||
|
||||
if ($this->configDataProvider->syncTeams()) {
|
||||
$user->loadLinkMultipleField('teams');
|
||||
$user->loadLinkMultipleField(Field::TEAMS);
|
||||
|
||||
$user->set($this->getUserTeamsDataFromToken($payload));
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\FieldProcessing\EmailAddress\Saver as EmailAddressSaver;
|
||||
use Espo\Core\FieldProcessing\PhoneNumber\Saver as PhoneNumberSaver;
|
||||
use Espo\Core\FieldProcessing\Relation\LinkMultipleSaver;
|
||||
use Espo\Core\FieldProcessing\Saver\Params as SaverParams;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Repository\Option\SaveOption;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\EntityManager;
|
||||
@@ -62,7 +63,7 @@ class UserRepository
|
||||
|
||||
$saverParams = SaverParams::create()->withRawOptions(['skipLinkMultipleHooks' => true]);
|
||||
|
||||
$this->linkMultipleSaver->process($user, 'teams', $saverParams);
|
||||
$this->linkMultipleSaver->process($user, Field::TEAMS, $saverParams);
|
||||
$this->linkMultipleSaver->process($user, 'portals', $saverParams);
|
||||
$this->linkMultipleSaver->process($user, 'portalRoles', $saverParams);
|
||||
$this->emailAddressSaver->process($user, $saverParams);
|
||||
|
||||
@@ -37,6 +37,7 @@ use Espo\Core\Mail\Exceptions\NoSmtp;
|
||||
use Espo\Core\Mail\Account\ImapParams;
|
||||
use Espo\Core\Mail\Smtp\HandlerProcessor;
|
||||
use Espo\Core\Mail\SmtpParams;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Repository\Option\SaveOption;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Crypt;
|
||||
@@ -161,7 +162,7 @@ class Account implements AccountInterface
|
||||
->getRDBRepositoryByClass(User::class)
|
||||
->select(['id'])
|
||||
->distinct()
|
||||
->join('teams')
|
||||
->join(Field::TEAMS)
|
||||
->where([
|
||||
'type' => [User::TYPE_REGULAR, User::TYPE_ADMIN],
|
||||
'isActive' => true,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Mail\Account\GroupAccount\Hooks;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Laminas\Mail\Message;
|
||||
|
||||
use Espo\Core\Mail\Account\GroupAccount\AccountFactory as GroupAccountFactory;
|
||||
@@ -420,10 +421,10 @@ class AfterFetch implements AfterFetchInterface
|
||||
$email->addLinkMultipleId('users', $userId);
|
||||
}
|
||||
|
||||
$teamIdList = $case->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $case->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
foreach ($teamIdList as $teamId) {
|
||||
$email->addLinkMultipleId('teams', $teamId);
|
||||
$email->addLinkMultipleId(Field::TEAMS, $teamId);
|
||||
}
|
||||
|
||||
$this->entityManager->saveEntity($email, [
|
||||
|
||||
@@ -34,6 +34,7 @@ use Espo\Core\AclManager;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Mail\Account\GroupAccount\AccountFactory as GroupAccountFactory;
|
||||
use Espo\Core\Mail\Account\PersonalAccount\AccountFactory as PersonalAccountFactory;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Entities\EmailAccount as EmailAccountEntity;
|
||||
use Espo\Entities\InboundEmail as InboundEmailEntity;
|
||||
@@ -74,7 +75,7 @@ class SendingAccountProvider
|
||||
->getRDBRepositoryByClass(InboundEmailEntity::class)
|
||||
->select(['id'])
|
||||
->distinct()
|
||||
->join('teams')
|
||||
->join(Field::TEAMS)
|
||||
->where([
|
||||
'status' => InboundEmailEntity::STATUS_ACTIVE,
|
||||
'useSmtp' => true,
|
||||
|
||||
@@ -40,6 +40,7 @@ use Espo\Core\Mail\Message;
|
||||
use Espo\Core\Mail\MessageWrapper;
|
||||
use Espo\Core\Mail\Parser;
|
||||
use Espo\Core\Mail\ParserFactory;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Repository\Option\SaveOption;
|
||||
use Espo\Core\Notification\AssignmentNotificator;
|
||||
use Espo\Core\Notification\AssignmentNotificatorFactory;
|
||||
@@ -276,7 +277,7 @@ class DefaultImporter implements Importer
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($parent->getLinkMultipleIdList('teams') as $parentTeamId) {
|
||||
foreach ($parent->getLinkMultipleIdList(Field::TEAMS) as $parentTeamId) {
|
||||
$email->addTeamId($parentTeamId);
|
||||
}
|
||||
}
|
||||
@@ -300,8 +301,8 @@ class DefaultImporter implements Importer
|
||||
$fetchedAssignedUserIds = $email->getAssignedUsers()->getIdList();
|
||||
|
||||
$email->setLinkMultipleIdList('users', []);
|
||||
$email->setLinkMultipleIdList('teams', []);
|
||||
$email->setLinkMultipleIdList('assignedUsers', []);
|
||||
$email->setLinkMultipleIdList(Field::TEAMS, []);
|
||||
$email->setLinkMultipleIdList(Field::ASSIGNED_USERS, []);
|
||||
|
||||
$processNoteAcl = false;
|
||||
|
||||
@@ -372,7 +373,7 @@ class DefaultImporter implements Importer
|
||||
|
||||
$this->linkMultipleSaver->process($email, 'users', $saverParams);
|
||||
$this->linkMultipleSaver->process($email, 'assignedUsers', $saverParams);
|
||||
$this->linkMultipleSaver->process($email, 'teams', $saverParams);
|
||||
$this->linkMultipleSaver->process($email, Field::TEAMS, $saverParams);
|
||||
|
||||
if ($this->notificationsEnabled()) {
|
||||
$notificatorParams = AssignmentNotificatorParams::create()
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Core\Mail\Importer;
|
||||
|
||||
use Espo\Core\Mail\Message;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Templates\Entities\Company;
|
||||
use Espo\Core\Templates\Entities\Person;
|
||||
use Espo\Core\Utils\Config;
|
||||
@@ -56,7 +57,7 @@ class DefaultParentFinder implements ParentFinder
|
||||
$this->entityTypeList = $this->entityManager
|
||||
->getDefs()
|
||||
->getEntity(Email::ENTITY_TYPE)
|
||||
->getField('parent')
|
||||
->getField(Field::PARENT)
|
||||
->getParam('entityList') ?? [];
|
||||
}
|
||||
|
||||
|
||||
43
application/Espo/Core/Name/Field.php
Normal file
43
application/Espo/Core/Name/Field.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Name;
|
||||
|
||||
class Field
|
||||
{
|
||||
public const CREATED_BY = 'createdBy';
|
||||
public const CREATED_AT = 'createdAt';
|
||||
public const MODIFIED_BY = 'modifiedBy';
|
||||
public const MODIFIED_AT = 'modifiedAt';
|
||||
public const ASSIGNED_USER = 'assignedUser';
|
||||
public const ASSIGNED_USERS = 'assignedUsers';
|
||||
public const COLLABORATORS = 'collaborators';
|
||||
public const TEAMS = 'teams';
|
||||
public const PARENT = 'parent';
|
||||
}
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Portal\Acl;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\ORM\BaseEntity;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
@@ -61,7 +62,7 @@ class DefaultOwnershipChecker implements
|
||||
private const FIELD_CONTACTS = 'contacts';
|
||||
private const FIELD_ACCOUNT = 'account';
|
||||
private const FIELD_ACCOUNTS = 'accounts';
|
||||
private const FIELD_PARENT = 'parent';
|
||||
private const FIELD_PARENT = Field::PARENT;
|
||||
|
||||
public function __construct(private EntityManager $entityManager)
|
||||
{}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Core\Record\Defaults;
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Acl\Permission;
|
||||
use Espo\Core\Acl\Table as AclTable;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Config;
|
||||
@@ -70,7 +71,7 @@ class DefaultPopulator implements Populator
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
$entity->addLinkMultipleId('teams', $defaultTeamId);
|
||||
$entity->addLinkMultipleId(Field::TEAMS, $defaultTeamId);
|
||||
|
||||
$teamsNames = $entity->get('teamsNames');
|
||||
|
||||
@@ -107,7 +108,7 @@ class DefaultPopulator implements Populator
|
||||
|
||||
$defs = $this->entityManager->getDefs()->getEntity($entityType);
|
||||
|
||||
if ($defs->tryGetField('assignedUser')?->getType() !== FieldType::LINK) {
|
||||
if ($defs->tryGetField(Field::ASSIGNED_USER)?->getType() !== FieldType::LINK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ class DefaultPopulator implements Populator
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$this->acl->checkField($entityType, 'assignedUser', AclTable::ACTION_EDIT)) {
|
||||
if (!$this->acl->checkField($entityType, Field::ASSIGNED_USER, AclTable::ACTION_EDIT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -146,11 +147,11 @@ class DefaultPopulator implements Populator
|
||||
|
||||
$defs = $this->entityManager->getDefs()->getEntity($entityType);
|
||||
|
||||
if ($defs->tryGetField('teams')?->getType() !== FieldType::LINK_MULTIPLE) {
|
||||
if ($defs->tryGetField(Field::TEAMS)?->getType() !== FieldType::LINK_MULTIPLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($entity->hasLinkMultipleId('teams', $this->user->getDefaultTeam()->getId())) {
|
||||
if ($entity->hasLinkMultipleId(Field::TEAMS, $this->user->getDefaultTeam()->getId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ class DefaultPopulator implements Populator
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$this->acl->checkField($entityType, 'teams', AclTable::ACTION_EDIT)) {
|
||||
if (!$this->acl->checkField($entityType, Field::TEAMS, AclTable::ACTION_EDIT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Repositories;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Repository\Option\SaveOption;
|
||||
use Espo\Core\Utils\SystemUser;
|
||||
use Espo\ORM\BaseEntity;
|
||||
@@ -54,11 +55,11 @@ use stdClass;
|
||||
class Database extends RDBRepository
|
||||
{
|
||||
private const ATTR_ID = 'id';
|
||||
private const ATTR_CREATED_BY_ID = 'createdById';
|
||||
private const ATTR_MODIFIED_BY_ID = 'modifiedById';
|
||||
private const ATTR_MODIFIED_BY_NAME = 'modifiedByName';
|
||||
private const ATTR_CREATED_AT = 'createdAt';
|
||||
private const ATTR_MODIFIED_AT = 'modifiedAt';
|
||||
private const ATTR_CREATED_BY_ID = Field::CREATED_BY . 'Id';
|
||||
private const ATTR_MODIFIED_BY_ID = Field::MODIFIED_BY . 'Id';
|
||||
private const ATTR_MODIFIED_BY_NAME = Field::MODIFIED_BY . 'Name';
|
||||
private const ATTR_CREATED_AT = Field::CREATED_AT;
|
||||
private const ATTR_MODIFIED_AT = Field::MODIFIED_AT;
|
||||
|
||||
/**
|
||||
* Disables hook processing.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Defs;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
@@ -65,7 +66,7 @@ class ForeignOnlyOwn implements Filter
|
||||
|
||||
$foreignEntityDefs = $this->defs->getEntity($foreignEntityType);
|
||||
|
||||
if ($foreignEntityDefs->hasField('assignedUser')) {
|
||||
if ($foreignEntityDefs->hasField(Field::ASSIGNED_USER)) {
|
||||
$queryBuilder->where([
|
||||
"{$alias}.assignedUserId" => $this->user->getId(),
|
||||
]);
|
||||
@@ -73,7 +74,7 @@ class ForeignOnlyOwn implements Filter
|
||||
return;
|
||||
}
|
||||
|
||||
if ($foreignEntityDefs->hasField('createdBy')) {
|
||||
if ($foreignEntityDefs->hasField(Field::CREATED_BY)) {
|
||||
$queryBuilder->where([
|
||||
"{$alias}.createdById" => $this->user->getId(),
|
||||
]);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\Entities\Team;
|
||||
use Espo\ORM\Query\Part\Condition;
|
||||
@@ -113,11 +114,11 @@ class ForeignOnlyTeam implements Filter
|
||||
|
||||
$foreignEntityDefs = $this->defs->getEntity($foreignEntityType);
|
||||
|
||||
if ($foreignEntityDefs->hasField('assignedUser')) {
|
||||
if ($foreignEntityDefs->hasField(Field::ASSIGNED_USER)) {
|
||||
return 'assignedUserId';
|
||||
}
|
||||
|
||||
if ($foreignEntityDefs->hasField('createdBy')) {
|
||||
if ($foreignEntityDefs->hasField(Field::CREATED_BY)) {
|
||||
return 'createdById';
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\Core\Select\Helpers\FieldHelper;
|
||||
use Espo\Entities\Team;
|
||||
@@ -36,6 +37,9 @@ use Espo\Entities\User;
|
||||
use Espo\ORM\Defs;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
class OnlyTeam implements Filter
|
||||
{
|
||||
public function __construct(
|
||||
@@ -68,7 +72,7 @@ class OnlyTeam implements Filter
|
||||
if ($this->fieldHelper->hasAssignedUsersField()) {
|
||||
$relationDefs = $this->defs
|
||||
->getEntity($this->entityType)
|
||||
->getRelation('assignedUsers');
|
||||
->getRelation(Field::ASSIGNED_USERS);
|
||||
|
||||
$middleEntityType = ucfirst($relationDefs->getRelationshipName());
|
||||
$key1 = $relationDefs->getMidKey();
|
||||
@@ -89,7 +93,7 @@ class OnlyTeam implements Filter
|
||||
if ($this->fieldHelper->hasCollaboratorsField()) {
|
||||
$relationDefs = $this->defs
|
||||
->getEntity($this->entityType)
|
||||
->getRelation('collaborators');
|
||||
->getRelation(Field::COLLABORATORS);
|
||||
|
||||
$middleEntityType = ucfirst($relationDefs->getRelationshipName());
|
||||
$key1 = $relationDefs->getMidKey();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\Bool\Filters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\Bool\Filter;
|
||||
use Espo\Core\Select\Helpers\FieldHelper;
|
||||
use Espo\Entities\User;
|
||||
@@ -59,7 +60,7 @@ class Shared implements Filter
|
||||
|
||||
$relationDefs = $this->defs
|
||||
->getEntity($this->entityType)
|
||||
->getRelation('collaborators');
|
||||
->getRelation(Field::COLLABORATORS);
|
||||
|
||||
$middleEntityType = ucfirst($relationDefs->getRelationshipName());
|
||||
$key1 = $relationDefs->getMidKey();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\Helpers;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\Team;
|
||||
use Espo\Entities\User;
|
||||
@@ -51,12 +52,12 @@ class FieldHelper
|
||||
private const LINK_CONTACT = 'contact';
|
||||
private const LINK_ACCOUNTS = 'accounts';
|
||||
private const LINK_ACCOUNT = 'account';
|
||||
private const LINK_PARENT = 'parent';
|
||||
private const LINK_TEAMS = 'teams';
|
||||
private const LINK_ASSIGNED_USERS = 'assignedUsers';
|
||||
private const LINK_ASSIGNED_USER = 'assignedUser';
|
||||
private const LINK_CREATED_BY = 'createdBy';
|
||||
private const LINK_COLLABORATORS = 'collaborators';
|
||||
private const LINK_PARENT = Field::PARENT;
|
||||
private const LINK_TEAMS = Field::TEAMS;
|
||||
private const LINK_ASSIGNED_USERS = Field::ASSIGNED_USERS;
|
||||
private const LINK_ASSIGNED_USER = Field::ASSIGNED_USER;
|
||||
private const LINK_CREATED_BY = Field::CREATED_BY;
|
||||
private const LINK_COLLABORATORS = Field::COLLABORATORS;
|
||||
|
||||
public function __construct(
|
||||
private string $entityType,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\Helpers;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Defs;
|
||||
use Espo\ORM\Query\Part\Condition;
|
||||
@@ -60,7 +61,7 @@ class RelationQueryHelper
|
||||
return $this->prepareRelatedUsersWhere(
|
||||
$entityType,
|
||||
$userId,
|
||||
'collaborators',
|
||||
Field::COLLABORATORS,
|
||||
User::RELATIONSHIP_ENTITY_COLLABORATOR
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
|
||||
use Espo\Core\Field\LinkParent;
|
||||
@@ -192,12 +193,12 @@ class Attachment extends Entity
|
||||
public function setParent(LinkParent|Entity|null $parent): self
|
||||
{
|
||||
if ($parent instanceof LinkParent) {
|
||||
$this->setValueObject('parent', $parent);
|
||||
$this->setValueObject(Field::PARENT, $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('parent', $parent);
|
||||
$this->relations->set(Field::PARENT, $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\Field\DateTime;
|
||||
@@ -684,7 +685,7 @@ class Email extends Entity
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
public function getUsers(): LinkMultiple
|
||||
@@ -890,14 +891,14 @@ class Email extends Entity
|
||||
|
||||
public function addTeamId(string $teamId): self
|
||||
{
|
||||
$this->addLinkMultipleId('teams', $teamId);
|
||||
$this->addLinkMultipleId(Field::TEAMS, $teamId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\Sms\Sms as SmsInterface;
|
||||
use Espo\Core\Field\DateTime;
|
||||
@@ -158,6 +159,6 @@ class Sms extends Entity implements SmsInterface
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Field\LinkMultipleItem;
|
||||
use Espo\Core\Hook\Hook\BeforeSave;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\ORM\Entity;
|
||||
@@ -45,9 +46,9 @@ class Collaborators implements BeforeSave
|
||||
{
|
||||
public static int $order = 7;
|
||||
|
||||
private const FIELD_COLLABORATORS = 'collaborators';
|
||||
private const FIELD_ASSIGNED_USERS = 'assignedUsers';
|
||||
private const FIELD_ASSIGNED_USER = 'assignedUser';
|
||||
private const FIELD_COLLABORATORS = Field::COLLABORATORS;
|
||||
private const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS;
|
||||
private const FIELD_ASSIGNED_USER = Field::ASSIGNED_USER;
|
||||
|
||||
public function __construct(
|
||||
private Metadata $metadata,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Classes\Select\CampaignLogRecord\AccessControlFilters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
@@ -43,7 +44,7 @@ class OnlyTeam implements Filter
|
||||
{
|
||||
$queryBuilder->leftJoin('campaign', 'campaignAccess');
|
||||
|
||||
$teamIdList = $this->user->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $this->user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
if (count($teamIdList) === 0) {
|
||||
$queryBuilder->where([
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Classes\Select\CampaignTrackingUrl\AccessControlFilters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
@@ -43,7 +44,7 @@ class OnlyTeam implements Filter
|
||||
{
|
||||
$queryBuilder->leftJoin('campaign', 'campaignAccess');
|
||||
|
||||
$teamIdList = $this->user->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $this->user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
if (count($teamIdList) === 0) {
|
||||
$queryBuilder->where([
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Classes\Select\MassEmail\AccessControlFilters;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
@@ -43,7 +44,7 @@ class OnlyTeam implements Filter
|
||||
{
|
||||
$queryBuilder->leftJoin('campaign', 'campaignAccess');
|
||||
|
||||
$teamIdList = $this->user->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $this->user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
if (count($teamIdList) === 0) {
|
||||
$queryBuilder->where([
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Modules\Crm\Entities;
|
||||
use Espo\Core\Field\Date;
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Entities\User;
|
||||
|
||||
@@ -75,7 +76,7 @@ class Campaign extends Entity
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
public function setAssignedUser(Link|User|null $assignedUser): self
|
||||
@@ -85,7 +86,7 @@ class Campaign extends Entity
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Collection;
|
||||
@@ -127,7 +128,7 @@ class CaseObj extends \Espo\Core\ORM\Entity
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\User;
|
||||
@@ -80,7 +81,7 @@ class Document extends Entity
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
public function setAssignedUser(Link|User|null $assignedUser): self
|
||||
@@ -90,7 +91,7 @@ class Document extends Entity
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\User;
|
||||
@@ -62,7 +63,7 @@ class KnowledgeBaseArticle extends Entity
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Modules\Crm\Entities;
|
||||
use Espo\Core\Field\DateTime;
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\User;
|
||||
|
||||
class Lead extends \Espo\Core\Entities\Person
|
||||
@@ -111,7 +112,7 @@ class Lead extends \Espo\Core\Entities\Person
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
public function getCreatedAccount(): ?Link
|
||||
@@ -159,7 +160,7 @@ class Lead extends \Espo\Core\Entities\Person
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Field\DateTimeOptional;
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Field\LinkParent;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Entities\User;
|
||||
|
||||
@@ -113,7 +114,7 @@ class Meeting extends Entity
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
public function getUsers(): LinkMultiple
|
||||
@@ -154,7 +155,7 @@ class Meeting extends Entity
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Field\Currency;
|
||||
use Espo\Core\Field\Date;
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Entities\User;
|
||||
|
||||
@@ -136,7 +137,7 @@ class Opportunity extends Entity
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
public function setAccount(Account|Link|null $account): self
|
||||
@@ -151,7 +152,7 @@ class Opportunity extends Entity
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
$this->setValueObject(Field::TEAMS, $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Field\DateTimeOptional;
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Field\LinkParent;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\User;
|
||||
@@ -78,13 +79,13 @@ class Task extends Entity
|
||||
public function getAssignedUser(): ?Link
|
||||
{
|
||||
/** @var ?Link */
|
||||
return $this->getValueObject('assignedUser');
|
||||
return $this->getValueObject(Field::ASSIGNED_USER);
|
||||
}
|
||||
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
/** @var LinkMultiple */
|
||||
return $this->getValueObject('teams');
|
||||
return $this->getValueObject(Field::TEAMS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,12 +100,12 @@ class Task extends Entity
|
||||
public function setParent(Entity|LinkParent|null $parent): self
|
||||
{
|
||||
if ($parent instanceof LinkParent) {
|
||||
$this->setValueObject('parent', $parent);
|
||||
$this->setValueObject(Field::PARENT, $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->relations->set('parent', $parent);
|
||||
$this->relations->set(Field::PARENT, $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Field\DateTime as DateTimeField;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Select\Helpers\RelationQueryHelper;
|
||||
use Espo\Core\Select\SelectBuilderFactory;
|
||||
@@ -600,7 +601,7 @@ class Service
|
||||
}
|
||||
|
||||
if ($this->acl->getPermissionLevel(Acl\Permission::USER) === Table::LEVEL_TEAM) {
|
||||
$userTeamIdList = $this->user->getLinkMultipleIdList('teams');
|
||||
$userTeamIdList = $this->user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
foreach ($teamIdList as $teamId) {
|
||||
if (!in_array($teamId, $userTeamIdList)) {
|
||||
@@ -614,7 +615,7 @@ class Service
|
||||
$userList = $this->entityManager
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->select(['id', 'name'])
|
||||
->leftJoin('teams')
|
||||
->leftJoin(Field::TEAMS)
|
||||
->where([
|
||||
'isActive' => true,
|
||||
'teamsMiddle.teamId' => $teamIdList,
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Modules\Crm\Tools\Opportunity\Report;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\SelectBuilderFactory;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -131,7 +132,7 @@ class SalesPipeline
|
||||
->where($whereClause);
|
||||
|
||||
if ($teamId) {
|
||||
$queryBuilder->join('teams', 'teamsFilter');
|
||||
$queryBuilder->join(Field::TEAMS, 'teamsFilter');
|
||||
}
|
||||
|
||||
$this->util->handleDistinctReportQueryBuilder($queryBuilder, $whereClause);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Tools\App;
|
||||
|
||||
use Espo\Core\Authentication\Util\MethodProvider as AuthenticationMethodProvider;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\SystemUser;
|
||||
use Espo\Entities\DashboardTemplate;
|
||||
use Espo\Entities\Email;
|
||||
@@ -86,7 +87,7 @@ class AppService
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->has('teamsIds')) {
|
||||
$user->loadLinkMultipleField('teams');
|
||||
$user->loadLinkMultipleField(Field::TEAMS);
|
||||
}
|
||||
|
||||
if ($user->isPortal()) {
|
||||
@@ -344,7 +345,7 @@ class AppService
|
||||
}
|
||||
|
||||
if ($groupEmailAccountPermission === Acl\Table::LEVEL_TEAM) {
|
||||
$teamIdList = $user->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
if (!count($teamIdList)) {
|
||||
return [];
|
||||
@@ -358,7 +359,7 @@ class AppService
|
||||
'smtpIsShared' => true,
|
||||
'teamsMiddle.teamId' => $teamIdList,
|
||||
])
|
||||
->join('teams')
|
||||
->join(Field::TEAMS)
|
||||
->distinct()
|
||||
->find();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Tools\Dashboard;
|
||||
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\DashboardTemplate;
|
||||
use Espo\Entities\Preferences;
|
||||
use Espo\Entities\Team;
|
||||
@@ -106,10 +107,10 @@ class Service
|
||||
|
||||
$userList = $this->entityManager
|
||||
->getRDBRepository(User::ENTITY_TYPE)
|
||||
->join('teams')
|
||||
->join(Field::TEAMS)
|
||||
->distinct()
|
||||
->where([
|
||||
'teams.id' => $teamId,
|
||||
Field::TEAMS . '.id' => $teamId,
|
||||
])
|
||||
->find();
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error\Body;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\SelectBuilderFactory;
|
||||
use Espo\Core\Select\Where\Item as WhereItem;
|
||||
use Espo\Core\Utils\Config;
|
||||
@@ -529,7 +530,7 @@ class InboxService
|
||||
$groupFolderList = $this->entityManager
|
||||
->getRDBRepositoryByClass(GroupEmailFolder::class)
|
||||
->distinct()
|
||||
->leftJoin('teams')
|
||||
->leftJoin(Field::TEAMS)
|
||||
->where(
|
||||
$this->user->isAdmin() ?
|
||||
['id!=' => null] :
|
||||
|
||||
@@ -34,6 +34,7 @@ use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\ForbiddenSilent;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Language;
|
||||
use Espo\Entities\Email;
|
||||
@@ -107,7 +108,7 @@ class Service
|
||||
$groupFolderList = $this->entityManager
|
||||
->getRDBRepositoryByClass(GroupEmailFolder::class)
|
||||
->distinct()
|
||||
->leftJoin('teams')
|
||||
->leftJoin(Field::TEAMS)
|
||||
->where(
|
||||
$user->isAdmin() ?
|
||||
['id!=' => null] :
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Tools\EntityManager\Hook\Hooks;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Log;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -43,7 +44,7 @@ use Espo\Tools\EntityManager\Params;
|
||||
class CollaboratorsUpdateHook implements UpdateHook
|
||||
{
|
||||
private const PARAM = 'collaborators';
|
||||
private const FIELD = 'collaborators';
|
||||
private const FIELD = Field::COLLABORATORS;
|
||||
private const RELATION_NAME = 'entityCollaborator';
|
||||
|
||||
private const DEFAULT_MAX_COUNT = 30;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Tools\LeadCapture;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\PhoneNumber\Sanitizer as PhoneNumberSanitizer;
|
||||
use Espo\Core\Job\JobSchedulerFactory;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
@@ -322,7 +323,7 @@ class CaptureService
|
||||
$targetTeamId = $leadCapture->getTargetTeamId();
|
||||
|
||||
if ($targetTeamId) {
|
||||
$lead->addLinkMultipleId('teams', $targetTeamId);
|
||||
$lead->addLinkMultipleId(Field::TEAMS, $targetTeamId);
|
||||
}
|
||||
|
||||
$this->entityManager->saveEntity($lead);
|
||||
@@ -481,7 +482,7 @@ class CaptureService
|
||||
}
|
||||
|
||||
if ($leadCapture->getTargetTeamId()) {
|
||||
$lead->addLinkMultipleId('teams', $leadCapture->getTargetTeamId());
|
||||
$lead->addLinkMultipleId(Field::TEAMS, $leadCapture->getTargetTeamId());
|
||||
}
|
||||
|
||||
$validationParams = FieldValidationParams::create()->withTypeSkipFieldList('required', $fieldList);
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Tools\Notification;
|
||||
use Espo\Core\AclManager as InternalAclManager;
|
||||
use Espo\Core\Acl\Table;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Tools\Stream\Service as StreamService;
|
||||
|
||||
use Espo\ORM\EntityManager;
|
||||
@@ -128,9 +129,7 @@ class NoteHookProcessor
|
||||
$userIdList = null;
|
||||
|
||||
if (!$skipAclCheck) {
|
||||
/** @var string[] $teamIdList */
|
||||
$teamIdList = $note->getLinkMultipleIdList('teams');
|
||||
/** @var string[] $userIdList */
|
||||
$teamIdList = $note->getLinkMultipleIdList(Field::TEAMS);
|
||||
$userIdList = $note->getLinkMultipleIdList('users');
|
||||
}
|
||||
|
||||
@@ -391,8 +390,7 @@ class NoteHookProcessor
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var string[] $userTeamIdList */
|
||||
$userTeamIdList = $user->getLinkMultipleIdList('teams');
|
||||
$userTeamIdList = $user->getLinkMultipleIdList(Field::TEAMS);
|
||||
|
||||
foreach ($teamIdList as $teamId) {
|
||||
if (in_array($teamId, $userTeamIdList)) {
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Acl;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Record\Collection as RecordCollection;
|
||||
use Espo\Core\Select\SearchParams;
|
||||
use Espo\Core\Select\SelectBuilderFactory;
|
||||
@@ -299,7 +300,7 @@ class RecordService
|
||||
|
||||
if ($targetType !== Note::TARGET_USERS) {
|
||||
if (!$targetType || $targetType === Note::TARGET_TEAMS) {
|
||||
$note->loadLinkMultipleField('teams');
|
||||
$note->loadLinkMultipleField(Field::TEAMS);
|
||||
} else if ($targetType === Note::TARGET_PORTALS) {
|
||||
$note->loadLinkMultipleField('portals');
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Tools\Stream\NoteAcl;
|
||||
use DateTimeImmutable;
|
||||
use Espo\Core\AclManager;
|
||||
use Espo\Core\Field\DateTime;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Config;
|
||||
@@ -110,13 +111,13 @@ class Processor
|
||||
}
|
||||
}
|
||||
|
||||
if ($entity->hasLinkMultipleField('teams')) {
|
||||
if ($entity->isAttributeChanged('teamsIds')) {
|
||||
if ($entity->hasLinkMultipleField(Field::TEAMS)) {
|
||||
if ($entity->isAttributeChanged(Field::TEAMS)) {
|
||||
$teamsAttributeIsChanged = true;
|
||||
}
|
||||
|
||||
if ($teamsAttributeIsChanged || $notify) {
|
||||
$teamIdList = $entity->getLinkMultipleIdList('teams');
|
||||
$teamIdList = $entity->getLinkMultipleIdList(Field::TEAMS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Tools\Stream;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\SearchParams;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\ORM\Collection;
|
||||
@@ -255,7 +256,7 @@ class RecordService
|
||||
|
||||
$builder
|
||||
->distinct()
|
||||
->leftJoin('teams')
|
||||
->leftJoin(Field::TEAMS)
|
||||
->leftJoin('users');
|
||||
|
||||
$where[] = [
|
||||
@@ -432,7 +433,7 @@ class RecordService
|
||||
$note->getParentId() && $note->getParentType() &&
|
||||
($note->getParentId() !== $id || $note->getParentType() !== $scope)
|
||||
) {
|
||||
$note->loadParentNameField('parent');
|
||||
$note->loadParentNameField(Field::PARENT);
|
||||
}
|
||||
|
||||
if ($note->getRelatedId() && $note->getRelatedType()) {
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Tools\Stream;
|
||||
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
use Espo\Core\Field\LinkParent;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Repository\Option\SaveOption;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Entities\StreamSubscription;
|
||||
@@ -386,8 +387,8 @@ class Service
|
||||
$note->setAclIsProcessed();
|
||||
$note->setTeamsIds([]);
|
||||
|
||||
if ($entity->hasLinkMultipleField('teams')) {
|
||||
$note->setTeamsIds($entity->getLinkMultipleIdList('teams'));
|
||||
if ($entity->hasLinkMultipleField(Field::TEAMS)) {
|
||||
$note->setTeamsIds($entity->getLinkMultipleIdList(Field::TEAMS));
|
||||
}
|
||||
|
||||
$userIds = array_merge(
|
||||
@@ -453,7 +454,7 @@ class Service
|
||||
return [];
|
||||
}
|
||||
|
||||
$field = 'collaborators';
|
||||
$field = Field::COLLABORATORS;
|
||||
|
||||
if (!$entity->hasLinkMultipleField($field)) {
|
||||
return [];
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Tools\Stream;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\SearchParams;
|
||||
use Espo\Modules\Crm\Entities\Account;
|
||||
use Espo\ORM\EntityManager;
|
||||
@@ -92,7 +93,6 @@ class UserRecordService
|
||||
throw new NotFound("User not found.");
|
||||
}
|
||||
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
if (!$this->acl->checkUserPermission($user, 'user')) {
|
||||
throw new Forbidden("No user permission access.");
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class UserRecordService
|
||||
|
||||
$baseBuilder = $this->queryHelper->buildBaseQueryBuilder($searchParams)
|
||||
->select($this->queryHelper->getUserQuerySelect())
|
||||
->leftJoin('createdBy')
|
||||
->leftJoin(Field::CREATED_BY)
|
||||
->order('number', Order::DESC)
|
||||
->limit(0, $offset + $maxSize + 1);
|
||||
|
||||
@@ -135,7 +135,6 @@ class UserRecordService
|
||||
throw new NotFound("User not found.");
|
||||
}
|
||||
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
if (!$this->acl->checkUserPermission($user, 'user')) {
|
||||
throw new Forbidden("No user permission access.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user