chore: Update copyright year from 2025 to 2026 across core files
- Updated copyright headers in 3,055 core application files - Changed 'Copyright (C) 2014-2025' to 'Copyright (C) 2014-2026' - Added 123 new files from EspoCRM core updates - Removed 4 deprecated files - Total changes: 61,637 insertions, 54,283 deletions This is a routine maintenance update for the new year 2026.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl;
|
||||
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* An access filter.
|
||||
@@ -42,5 +42,5 @@ use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
*/
|
||||
interface Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void;
|
||||
public function apply(SelectBuilder $queryBuilder): void;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,10 +29,14 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Acl\AssignmentChecker\Helper;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Defs;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
use Espo\ORM\Query\Part\Expression as Expr;
|
||||
use Espo\ORM\Query\Part\Where\OrGroup;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\User;
|
||||
@@ -45,7 +49,8 @@ class ForeignOnlyOwn implements Filter
|
||||
private string $entityType,
|
||||
private User $user,
|
||||
private Metadata $metadata,
|
||||
private Defs $defs
|
||||
private Defs $defs,
|
||||
private Helper $helper,
|
||||
) {}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
@@ -53,7 +58,7 @@ class ForeignOnlyOwn implements Filter
|
||||
$link = $this->metadata->get(['aclDefs', $this->entityType, 'link']);
|
||||
|
||||
if (!$link) {
|
||||
throw new LogicException("No `link` in aclDefs for {$this->entityType}.");
|
||||
throw new LogicException("No `link` in aclDefs for $this->entityType.");
|
||||
}
|
||||
|
||||
$alias = $link . 'Access';
|
||||
@@ -67,18 +72,82 @@ class ForeignOnlyOwn implements Filter
|
||||
|
||||
$foreignEntityDefs = $this->defs->getEntity($foreignEntityType);
|
||||
|
||||
$orBuilder = OrGroup::createBuilder();
|
||||
|
||||
if ($this->helper->hasCollaboratorsField($foreignEntityType)) {
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias." . Attribute::ID),
|
||||
SelectBuilder::create()
|
||||
->from(User::RELATIONSHIP_ENTITY_COLLABORATOR, 's')
|
||||
->select('s.entityId')
|
||||
->where(
|
||||
Cond::and(
|
||||
Cond::equal(
|
||||
Expr::column('s.entityType'),
|
||||
$foreignEntityType,
|
||||
),
|
||||
Cond::equal(
|
||||
Expr::column('s.userId'),
|
||||
$this->user->getId(),
|
||||
)
|
||||
)
|
||||
)
|
||||
->build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->helper->hasAssignedUsersField($foreignEntityType)) {
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias." . Attribute::ID),
|
||||
SelectBuilder::create()
|
||||
->from(User::RELATIONSHIP_ENTITY_USER, 's')
|
||||
->select('s.entityId')
|
||||
->where(
|
||||
Cond::and(
|
||||
Cond::equal(
|
||||
Expr::column('s.entityType'),
|
||||
$foreignEntityType,
|
||||
),
|
||||
Cond::equal(
|
||||
Expr::column('s.userId'),
|
||||
$this->user->getId(),
|
||||
)
|
||||
)
|
||||
)
|
||||
->build()
|
||||
)
|
||||
);
|
||||
|
||||
$queryBuilder->where($orBuilder->build());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($foreignEntityDefs->hasField(Field::ASSIGNED_USER)) {
|
||||
$queryBuilder->where([
|
||||
"{$alias}.assignedUserId" => $this->user->getId(),
|
||||
]);
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias.assignedUserId"),
|
||||
$this->user->getId()
|
||||
)
|
||||
);
|
||||
|
||||
$queryBuilder->where($orBuilder->build());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($foreignEntityDefs->hasField(Field::CREATED_BY)) {
|
||||
$queryBuilder->where([
|
||||
"{$alias}.createdById" => $this->user->getId(),
|
||||
]);
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias.createdById"),
|
||||
$this->user->getId()
|
||||
)
|
||||
);
|
||||
|
||||
$queryBuilder->where($orBuilder->build());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,13 +29,15 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Acl\AssignmentChecker\Helper;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\Entities\Team;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Condition;
|
||||
use Espo\ORM\Query\Part\Expression;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
use Espo\ORM\Query\Part\Expression as Expr;
|
||||
use Espo\ORM\Query\Part\Where\OrGroup;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\ORM\Defs;
|
||||
@@ -52,7 +54,8 @@ class ForeignOnlyTeam implements Filter
|
||||
private string $entityType,
|
||||
private User $user,
|
||||
private Metadata $metadata,
|
||||
private Defs $defs
|
||||
private Defs $defs,
|
||||
private Helper $helper,
|
||||
) {}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
@@ -65,33 +68,149 @@ class ForeignOnlyTeam implements Filter
|
||||
|
||||
$alias = "{$link}Access";
|
||||
|
||||
$ownerAttribute = $this->getOwnerAttribute($link);
|
||||
$foreignEntityType = $this->getForeignEntityType($link);
|
||||
|
||||
if (!$ownerAttribute) {
|
||||
$queryBuilder->leftJoin($link, $alias);
|
||||
|
||||
$orBuilder = OrGroup::createBuilder();
|
||||
|
||||
$this->applyCollaborators($foreignEntityType, $orBuilder, $alias);
|
||||
$this->applyAssignedUsers($foreignEntityType, $orBuilder, $alias);
|
||||
$this->applyAssignedUser($foreignEntityType, $orBuilder, $alias);
|
||||
$this->applyCreatedBy($foreignEntityType, $orBuilder, $alias);
|
||||
$this->applyTeams($foreignEntityType, $orBuilder, $alias);
|
||||
|
||||
if ($orBuilder->build()->getItemCount() === 0) {
|
||||
$queryBuilder->where([Attribute::ID => null]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$teamIdList = $this->user->getTeamIdList();
|
||||
$queryBuilder
|
||||
->where($orBuilder->build())
|
||||
->where(["$alias.id!=" => null]);
|
||||
}
|
||||
|
||||
if (count($teamIdList) === 0) {
|
||||
$queryBuilder
|
||||
->leftJoin($link, $alias)
|
||||
->where(["$alias.$ownerAttribute" => $this->user->getId()]);
|
||||
private function getForeignEntityType(string $link): string
|
||||
{
|
||||
return $this->defs
|
||||
->getEntity($this->entityType)
|
||||
->getRelation($link)
|
||||
->getForeignEntityType();
|
||||
}
|
||||
|
||||
private function applyCollaborators(string $foreignEntityType, OrGroupBuilder $orBuilder, string $alias): void
|
||||
{
|
||||
if (!$this->helper->hasCollaboratorsField($foreignEntityType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$foreignEntityType = $this->getForeignEntityType($link);
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias." . Attribute::ID),
|
||||
SelectBuilder::create()
|
||||
->from(User::RELATIONSHIP_ENTITY_COLLABORATOR, 's')
|
||||
->select('s.entityId')
|
||||
->where(
|
||||
Cond::and(
|
||||
Cond::equal(
|
||||
Expr::column('s.entityType'),
|
||||
$foreignEntityType,
|
||||
),
|
||||
Cond::equal(
|
||||
Expr::column('s.userId'),
|
||||
$this->user->getId(),
|
||||
)
|
||||
)
|
||||
)
|
||||
->build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$orGroup = OrGroup::create(
|
||||
Condition::equal(
|
||||
Expression::column("$alias.$ownerAttribute"),
|
||||
private function applyAssignedUsers(
|
||||
string $foreignEntityType,
|
||||
OrGroupBuilder $orBuilder,
|
||||
string $alias,
|
||||
): void {
|
||||
|
||||
if (!$this->helper->hasAssignedUsersField($foreignEntityType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias." . Attribute::ID),
|
||||
SelectBuilder::create()
|
||||
->from(User::RELATIONSHIP_ENTITY_USER, 's')
|
||||
->select('s.entityId')
|
||||
->where(
|
||||
Cond::and(
|
||||
Cond::equal(
|
||||
Expr::column('s.entityType'),
|
||||
$foreignEntityType,
|
||||
),
|
||||
Cond::equal(
|
||||
Expr::column('s.userId'),
|
||||
$this->user->getId(),
|
||||
)
|
||||
)
|
||||
)
|
||||
->build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function applyAssignedUser(string $foreignEntityType, OrGroupBuilder $orBuilder, string $alias): void
|
||||
{
|
||||
$foreignEntityDefs = $this->defs->getEntity($foreignEntityType);
|
||||
|
||||
if (
|
||||
$this->helper->hasAssignedUsersField($foreignEntityType) ||
|
||||
!$foreignEntityDefs->hasField(Field::ASSIGNED_USER)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias.assignedUserId"),
|
||||
$this->user->getId()
|
||||
),
|
||||
Condition::in(
|
||||
Expression::column("$alias.id"),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function applyCreatedBy(string $foreignEntityType, OrGroupBuilder $orBuilder, string $alias): void
|
||||
{
|
||||
$foreignEntityDefs = $this->defs->getEntity($foreignEntityType);
|
||||
|
||||
if (
|
||||
$this->helper->hasAssignedUsersField($foreignEntityType) ||
|
||||
$foreignEntityDefs->hasField(Field::ASSIGNED_USER) ||
|
||||
!$foreignEntityDefs->hasField(Field::CREATED_BY)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orBuilder->add(
|
||||
Cond::equal(
|
||||
Expr::column("$alias.createdById"),
|
||||
$this->user->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function applyTeams(string $foreignEntityType, OrGroupBuilder $orBuilder, string $alias): void
|
||||
{
|
||||
$teamIdList = $this->user->getTeamIdList();
|
||||
|
||||
if (count($teamIdList) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orBuilder->add(
|
||||
Cond::in(
|
||||
Expr::column("$alias.id"),
|
||||
SelectBuilder::create()
|
||||
->from(Team::RELATIONSHIP_ENTITY_TEAM)
|
||||
->select('entityId')
|
||||
@@ -102,35 +221,5 @@ class ForeignOnlyTeam implements Filter
|
||||
->build()
|
||||
)
|
||||
);
|
||||
|
||||
$queryBuilder
|
||||
->leftJoin($link, $alias)
|
||||
->where($orGroup)
|
||||
->where(["$alias.id!=" => null]);
|
||||
}
|
||||
|
||||
private function getOwnerAttribute(string $link): ?string
|
||||
{
|
||||
$foreignEntityType = $this->getForeignEntityType($link);
|
||||
|
||||
$foreignEntityDefs = $this->defs->getEntity($foreignEntityType);
|
||||
|
||||
if ($foreignEntityDefs->hasField(Field::ASSIGNED_USER)) {
|
||||
return 'assignedUserId';
|
||||
}
|
||||
|
||||
if ($foreignEntityDefs->hasField(Field::CREATED_BY)) {
|
||||
return 'createdById';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getForeignEntityType(string $link): string
|
||||
{
|
||||
return $this->defs
|
||||
->getEntity($this->entityType)
|
||||
->getRelation($link)
|
||||
->getForeignEntityType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -30,10 +30,10 @@
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Mandatory implements Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -31,11 +31,11 @@ namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class No implements Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder->where([Attribute::ID => null]);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -37,7 +37,7 @@ use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Where\OrGroup;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\Part\WhereItem;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class OnlyOwn implements Filter
|
||||
{
|
||||
@@ -48,7 +48,7 @@ class OnlyOwn implements Filter
|
||||
private RelationQueryHelper $relationQueryHelper,
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$ownItem = $this->getOwnWhereItem();
|
||||
|
||||
@@ -67,7 +67,7 @@ class OnlyOwn implements Filter
|
||||
$queryBuilder->where($ownItem);
|
||||
}
|
||||
|
||||
private function applyCollaborators(QueryBuilder $queryBuilder, ?WhereItem $ownItem): void
|
||||
private function applyCollaborators(SelectBuilder $queryBuilder, ?WhereItem $ownItem): void
|
||||
{
|
||||
$sharedItem = $this->relationQueryHelper->prepareCollaboratorsWhere($this->entityType, $this->user->getId());
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -36,7 +36,7 @@ use Espo\Entities\Team;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Defs;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnused
|
||||
@@ -50,7 +50,7 @@ class OnlyTeam implements Filter
|
||||
private Defs $defs
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
if (!$this->fieldHelper->hasTeamsField()) {
|
||||
$queryBuilder->where([Attribute::ID => null]);
|
||||
@@ -58,7 +58,7 @@ class OnlyTeam implements Filter
|
||||
return;
|
||||
}
|
||||
|
||||
$subQueryBuilder = QueryBuilder::create()
|
||||
$subQueryBuilder = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin(Team::RELATIONSHIP_ENTITY_TEAM, 'entityTeam', [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -30,10 +30,10 @@
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class PortalAll implements Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -41,7 +41,7 @@ use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Where\OrGroup;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\Part\WhereItem;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class PortalOnlyAccount implements Filter
|
||||
{
|
||||
@@ -53,7 +53,7 @@ class PortalOnlyAccount implements Filter
|
||||
private RelationQueryHelper $relationQueryHelper,
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$orBuilder = OrGroup::createBuilder();
|
||||
|
||||
@@ -96,7 +96,7 @@ class PortalOnlyAccount implements Filter
|
||||
/**
|
||||
* @param string[] $ids
|
||||
*/
|
||||
private function prepareAccountWhere(QueryBuilder $queryBuilder, array $ids): ?WhereItem
|
||||
private function prepareAccountWhere(SelectBuilder $queryBuilder, array $ids): ?WhereItem
|
||||
{
|
||||
$defs = $this->metadataProvider->getAccountLink($this->entityType);
|
||||
|
||||
@@ -107,7 +107,7 @@ class PortalOnlyAccount implements Filter
|
||||
return $this->relationQueryHelper->prepareLinkWhere($defs, Account::ENTITY_TYPE, $ids, $queryBuilder);
|
||||
}
|
||||
|
||||
private function prepareContactWhere(QueryBuilder $queryBuilder, string $id): ?WhereItem
|
||||
private function prepareContactWhere(SelectBuilder $queryBuilder, string $id): ?WhereItem
|
||||
{
|
||||
$defs = $this->metadataProvider->getContactLink($this->entityType);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -40,7 +40,7 @@ use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Where\OrGroup;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\Part\WhereItem;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class PortalOnlyContact implements Filter
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class PortalOnlyContact implements Filter
|
||||
private RelationQueryHelper $relationQueryHelper,
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$orBuilder = OrGroup::createBuilder();
|
||||
|
||||
@@ -83,7 +83,7 @@ class PortalOnlyContact implements Filter
|
||||
$queryBuilder->where($orGroup);
|
||||
}
|
||||
|
||||
private function prepareContactWhere(QueryBuilder $queryBuilder, string $id): ?WhereItem
|
||||
private function prepareContactWhere(SelectBuilder $queryBuilder, string $id): ?WhereItem
|
||||
{
|
||||
$defs = $this->metadataProvider->getContactLink($this->entityType);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -33,14 +33,14 @@ use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\Core\Select\Helpers\FieldHelper;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class PortalOnlyOwn implements Filter
|
||||
{
|
||||
public function __construct(private User $user, private FieldHelper $fieldHelper)
|
||||
{}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
if ($this->fieldHelper->hasCreatedByField()) {
|
||||
$queryBuilder->where([
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -34,7 +34,7 @@ use Espo\Core\Select\OrmSelectBuilder;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
use Espo\Core\Select\Bool\FilterFactory as BoolFilterFactory;
|
||||
use Espo\ORM\Query\Select;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
|
||||
@@ -53,7 +53,7 @@ class Applier
|
||||
* @param string[] $boolFilterNameList
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function apply(QueryBuilder $queryBuilder, array $boolFilterNameList): void
|
||||
public function apply(SelectBuilder $queryBuilder, array $boolFilterNameList): void
|
||||
{
|
||||
$orGroupBuilder = new OrGroupBuilder();
|
||||
|
||||
@@ -80,7 +80,7 @@ class Applier
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function applyBoolFilter(
|
||||
QueryBuilder $queryBuilder,
|
||||
SelectBuilder $queryBuilder,
|
||||
OrGroupBuilder $orGroupBuilder,
|
||||
string $filterName
|
||||
): void {
|
||||
@@ -110,7 +110,7 @@ class Applier
|
||||
throw new BadRequest("No bool filter '$filterName' for '$this->entityType'.");
|
||||
}
|
||||
|
||||
private function handleMultiple(Select $queryBefore, QueryBuilder $queryBuilder): void
|
||||
private function handleMultiple(Select $queryBefore, SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryAfter = $queryBuilder->build();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -30,12 +30,12 @@
|
||||
namespace Espo\Core\Select\Bool;
|
||||
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* Applies a bool filter. A where item should be added to OrGroupBuilder.
|
||||
*/
|
||||
interface Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void;
|
||||
public function apply(SelectBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -35,14 +35,14 @@ use Espo\Entities\User;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Followed implements Filter
|
||||
{
|
||||
public function __construct(private string $entityType, private User $user)
|
||||
{}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
{
|
||||
$alias = 'subscriptionFollowedBoolFilter';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -37,7 +37,7 @@ use Espo\ORM\Defs;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnused
|
||||
@@ -53,7 +53,7 @@ class OnlyMy implements Filter
|
||||
private Defs $defs
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
{
|
||||
if ($this->user->isPortal()) {
|
||||
$orGroupBuilder->add(
|
||||
@@ -75,7 +75,7 @@ class OnlyMy implements Filter
|
||||
$key1 = $relationDefs->getMidKey();
|
||||
$key2 = $relationDefs->getForeignMidKey();
|
||||
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($middleEntityType, 'assignedUsersMiddle', [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -37,7 +37,7 @@ use Espo\ORM\Defs;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnused
|
||||
@@ -53,7 +53,7 @@ class Shared implements Filter
|
||||
private Defs $defs
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
public function apply(SelectBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
{
|
||||
if (!$this->fieldHelper->hasCollaboratorsField()) {
|
||||
return;
|
||||
@@ -67,7 +67,7 @@ class Shared implements Filter
|
||||
$key1 = $relationDefs->getMidKey();
|
||||
$key2 = $relationDefs->getForeignMidKey();
|
||||
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($middleEntityType, 'collaboratorsMiddle', [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -32,7 +32,7 @@ namespace Espo\Core\Select\Primary;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
use Espo\Core\Select\OrmSelectBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Entities\User;
|
||||
|
||||
class Applier
|
||||
@@ -47,7 +47,7 @@ class Applier
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function apply(QueryBuilder $queryBuilder, string $filterName): void
|
||||
public function apply(SelectBuilder $queryBuilder, string $filterName): void
|
||||
{
|
||||
if ($this->primaryFilterFactory->has($this->entityType, $filterName)) {
|
||||
$filter = $this->primaryFilterFactory->create($this->entityType, $this->user, $filterName);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
namespace Espo\Core\Select\Primary;
|
||||
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* A primary filter.
|
||||
*/
|
||||
interface Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void;
|
||||
public function apply(SelectBuilder $queryBuilder): void;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -244,7 +244,6 @@ class SearchParams
|
||||
* With a primary filter.
|
||||
*
|
||||
* @param string|null $primaryFilter
|
||||
* @return $this
|
||||
*/
|
||||
public function withPrimaryFilter(?string $primaryFilter): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -35,7 +35,7 @@ use Espo\Core\Utils\FieldUtil;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Applier
|
||||
{
|
||||
@@ -60,7 +60,7 @@ class Applier
|
||||
private MetadataProvider $metadataProvider
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder, SearchParams $searchParams): void
|
||||
public function apply(SelectBuilder $queryBuilder, SearchParams $searchParams): void
|
||||
{
|
||||
$attributeList = $this->getSelectAttributeList($searchParams);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -503,6 +503,10 @@ class SelectBuilder
|
||||
$searchParams = SearchParams::merge($searchParams, $this->searchParams);
|
||||
}
|
||||
|
||||
foreach ($this->whereItemList as $it) {
|
||||
$searchParams = $searchParams->withWhereAdded($it);
|
||||
}
|
||||
|
||||
$this->createAdditionalApplier()->apply(
|
||||
$this->additionalApplierClassNameList,
|
||||
$this->queryBuilder,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -33,7 +33,7 @@ use Espo\Core\Select\Text\FullTextSearch\Data as FullTextSearchData;
|
||||
use Espo\Core\Select\Text\FullTextSearch\DataComposerFactory as FullTextSearchDataComposerFactory;
|
||||
use Espo\Core\Select\Text\FullTextSearch\DataComposer\Params as FullTextSearchDataComposerParams;
|
||||
use Espo\Core\Select\Text\Filter\Data as FilterData;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Order as OrderExpr;
|
||||
use Espo\ORM\Query\Part\Expression as Expr;
|
||||
use Espo\ORM\Query\Part\WhereItem;
|
||||
@@ -62,8 +62,10 @@ class Applier
|
||||
private ConfigProvider $config
|
||||
) {}
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
public function apply(QueryBuilder $queryBuilder, string $filter, FilterParams $params): void
|
||||
/**
|
||||
* @noinspection PhpUnusedParameterInspection
|
||||
*/
|
||||
public function apply(SelectBuilder $queryBuilder, string $filter, FilterParams $params): void
|
||||
{
|
||||
$forceFullText = false;
|
||||
$skipFullText = false;
|
||||
@@ -97,7 +99,7 @@ class Applier
|
||||
return $composer->compose($filter, $params);
|
||||
}
|
||||
|
||||
private function processFullTextSearch(QueryBuilder $queryBuilder, FullTextSearchData $data): WhereItem
|
||||
private function processFullTextSearch(SelectBuilder $queryBuilder, FullTextSearchData $data): WhereItem
|
||||
{
|
||||
$expression = $data->getExpression();
|
||||
|
||||
@@ -203,7 +205,7 @@ class Applier
|
||||
->withFullTextSearchWhereItem($fullTextWhere);
|
||||
}
|
||||
|
||||
private function applyFilter(QueryBuilder $queryBuilder, FilterData $filterData): void
|
||||
private function applyFilter(SelectBuilder $queryBuilder, FilterData $filterData): void
|
||||
{
|
||||
$filterObj = $this->filterFactory->create($this->entityType, $this->user);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -32,7 +32,7 @@ namespace Espo\Core\Select\Text;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Select\Text\Filter\Data;
|
||||
use Espo\ORM\Name\Attribute;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Where\OrGroup;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\Part\Where\Comparison as Cmp;
|
||||
@@ -49,7 +49,7 @@ class DefaultFilter implements Filter
|
||||
private ConfigProvider $config
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder, Data $data): void
|
||||
public function apply(SelectBuilder $queryBuilder, Data $data): void
|
||||
{
|
||||
$orGroupBuilder = OrGroup::createBuilder();
|
||||
|
||||
@@ -78,7 +78,7 @@ class DefaultFilter implements Filter
|
||||
* @todo AttributeFilterFactory.
|
||||
*/
|
||||
private function applyAttribute(
|
||||
QueryBuilder $queryBuilder,
|
||||
SelectBuilder $queryBuilder,
|
||||
OrGroupBuilder $orGroupBuilder,
|
||||
string $attribute,
|
||||
Data $data
|
||||
@@ -147,7 +147,7 @@ class DefaultFilter implements Filter
|
||||
);
|
||||
}
|
||||
|
||||
private function getAttributeTypeAndApplyJoin(QueryBuilder $queryBuilder, string $attribute): string
|
||||
private function getAttributeTypeAndApplyJoin(SelectBuilder $queryBuilder, string $attribute): string
|
||||
{
|
||||
if (str_contains($attribute, '.')) {
|
||||
[$link, $foreignField] = explode('.', $attribute);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -37,7 +37,7 @@ use Espo\ORM\Query\Part\Expression as Expr;
|
||||
use Espo\ORM\Query\Part\Where\Comparison;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\Part\WhereItem;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -54,7 +54,7 @@ class Converter
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item, ?Converter\Params $params = null): WhereItem
|
||||
public function convert(SelectBuilder $queryBuilder, Item $item, ?Converter\Params $params = null): WhereItem
|
||||
{
|
||||
if ($params && $params->useSubQueryIfMany() && $this->hasRelatedMany($queryBuilder, $item)) {
|
||||
return $this->convertSubQuery($queryBuilder, $item);
|
||||
@@ -83,7 +83,7 @@ class Converter
|
||||
return WhereClause::fromRaw($whereClause);
|
||||
}
|
||||
|
||||
private function hasRelatedMany(QueryBuilder $queryBuilder, Item $item): bool
|
||||
private function hasRelatedMany(SelectBuilder $queryBuilder, Item $item): bool
|
||||
{
|
||||
$entityType = $queryBuilder->build()->getFrom();
|
||||
|
||||
@@ -119,7 +119,7 @@ class Converter
|
||||
* @return array<int|string, mixed>
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function processItem(QueryBuilder $queryBuilder, Item $item): array
|
||||
private function processItem(SelectBuilder $queryBuilder, Item $item): array
|
||||
{
|
||||
return $this->itemConverter->convert($queryBuilder, $item)->getRaw();
|
||||
}
|
||||
@@ -127,11 +127,11 @@ class Converter
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function convertSubQuery(QueryBuilder $queryBuilder, Item $item): Comparison
|
||||
private function convertSubQuery(SelectBuilder $queryBuilder, Item $item): Comparison
|
||||
{
|
||||
$entityType = $queryBuilder->build()->getFrom() ?? throw new RuntimeException();
|
||||
|
||||
$subQueryBuilder = QueryBuilder::create()
|
||||
$subQueryBuilder = SelectBuilder::create()
|
||||
->from($entityType)
|
||||
->select(Attribute::ID);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\Select\Where;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\ORM\Query\Part\WhereItem as WhereClauseItem;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
/**
|
||||
* Converts a where item to a where clause item (for ORM).
|
||||
@@ -41,5 +41,5 @@ interface ItemConverter
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item): WhereClauseItem;
|
||||
public function convert(SelectBuilder $queryBuilder, Item $item): WhereClauseItem;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -49,7 +49,7 @@ use Espo\ORM\Query\Part\Join;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\Part\WhereItem as WhereClauseItem;
|
||||
use Espo\ORM\Query\Select;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
@@ -75,7 +75,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function convert(QueryBuilder $queryBuilder, Item $item): WhereClauseItem
|
||||
public function convert(SelectBuilder $queryBuilder, Item $item): WhereClauseItem
|
||||
{
|
||||
$type = $item->getType();
|
||||
$value = $item->getValue();
|
||||
@@ -360,7 +360,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
* @return array<string|int, mixed>
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function groupProcessAndOr(QueryBuilder $queryBuilder, string $type, $value): array
|
||||
private function groupProcessAndOr(SelectBuilder $queryBuilder, string $type, $value): array
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
throw new BadRequest("Bad where item.");
|
||||
@@ -396,7 +396,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
throw new BadRequest("Bad where item.");
|
||||
}
|
||||
|
||||
$sqQueryBuilder = QueryBuilder::create()
|
||||
$sqQueryBuilder = SelectBuilder::create()
|
||||
->from($this->entityType);
|
||||
|
||||
$whereItem = Item::fromRaw([
|
||||
@@ -440,7 +440,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
throw new BadRequest("Bad where item 'column'.");
|
||||
}
|
||||
|
||||
$subQueryBuilder = QueryBuilder::create()
|
||||
$subQueryBuilder = SelectBuilder::create()
|
||||
->from($this->entityType)
|
||||
->select(Attribute::ID)
|
||||
->leftJoin($link);
|
||||
@@ -480,7 +480,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function groupProcessArray(
|
||||
QueryBuilder $queryBuilder,
|
||||
SelectBuilder $queryBuilder,
|
||||
string $type,
|
||||
string $attribute,
|
||||
$value
|
||||
@@ -540,7 +540,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
throw new BadRequest("Bad where item. No value.");
|
||||
}
|
||||
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select('entityId')
|
||||
->from(ArrayValue::ENTITY_TYPE)
|
||||
->where([
|
||||
@@ -560,7 +560,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
|
||||
return Cond::not(
|
||||
Cond::exists(
|
||||
QueryBuilder::create()
|
||||
SelectBuilder::create()
|
||||
->select('entityId')
|
||||
->from(ArrayValue::ENTITY_TYPE)
|
||||
->where([
|
||||
@@ -577,7 +577,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
if ($type === Type::ARRAY_IS_EMPTY) {
|
||||
return Cond::not(
|
||||
Cond::exists(
|
||||
QueryBuilder::create()
|
||||
SelectBuilder::create()
|
||||
->select('entityId')
|
||||
->from(ArrayValue::ENTITY_TYPE)
|
||||
->where([
|
||||
@@ -591,7 +591,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
}
|
||||
|
||||
if ($type === Type::ARRAY_IS_NOT_EMPTY) {
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select('entityId')
|
||||
->from(ArrayValue::ENTITY_TYPE)
|
||||
->where([
|
||||
@@ -616,7 +616,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
|
||||
foreach ($value as $arrayValue) {
|
||||
$whereList[] = [
|
||||
$idPart .'=s' => QueryBuilder::create()
|
||||
$idPart .'=s' => SelectBuilder::create()
|
||||
->from(ArrayValue::ENTITY_TYPE)
|
||||
->select('entityId')
|
||||
->where([
|
||||
@@ -1370,7 +1370,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
// The foreign table is not joined as it would perform much slower.
|
||||
// Trade off is that if a foreign record is deleted but the middle table
|
||||
// is not yet deleted, it will give a non-actual result.
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($middleEntityType, $alias, $conditions)
|
||||
@@ -1386,7 +1386,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
$relationType == Entity::BELONGS_TO ||
|
||||
$relationType === Entity::HAS_CHILDREN
|
||||
) {
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($link, $alias)
|
||||
@@ -1428,7 +1428,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
// The foreign table is not joined as it would perform much slower.
|
||||
// Trade off is that if a foreign record is deleted but the middle table
|
||||
// is not yet deleted, it will give a non-actual result.
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($middleEntityType, $alias, $conditions)
|
||||
@@ -1444,7 +1444,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
$relationType == Entity::BELONGS_TO ||
|
||||
$relationType == Entity::HAS_CHILDREN
|
||||
) {
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($link, $alias)
|
||||
@@ -1495,7 +1495,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
// MariaDB and PostgreSQL perform fast, MySQL – slow.
|
||||
return Cond::in(
|
||||
Cond::column(Attribute::ID),
|
||||
QueryBuilder::create()
|
||||
SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin(
|
||||
@@ -1511,7 +1511,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
$relationType == Entity::HAS_MANY ||
|
||||
$relationType == Entity::HAS_ONE
|
||||
) {
|
||||
$subQuery = QueryBuilder::create()
|
||||
$subQuery = SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType)
|
||||
->leftJoin($link, $alias)
|
||||
@@ -1565,7 +1565,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
// MariaDB and MySQL perform slow, PostgreSQL – fast.
|
||||
return Cond::not(
|
||||
Cond::exists(
|
||||
QueryBuilder::create()
|
||||
SelectBuilder::create()
|
||||
->from($this->entityType, 'sq')
|
||||
->join(
|
||||
Join::create($link, $alias)
|
||||
@@ -1589,7 +1589,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
) {
|
||||
return Cond::not(
|
||||
Cond::exists(
|
||||
QueryBuilder::create()
|
||||
SelectBuilder::create()
|
||||
->select(Attribute::ID)
|
||||
->from($this->entityType, 'sq')
|
||||
->join($link, $alias)
|
||||
@@ -1647,7 +1647,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
|
||||
foreach ($value as $targetId) {
|
||||
// Only-middle join performs slower on MariaDB.
|
||||
$sq = QueryBuilder::create()
|
||||
$sq = SelectBuilder::create()
|
||||
->from($this->entityType)
|
||||
->select(Attribute::ID)
|
||||
->leftJoin($link)
|
||||
@@ -1666,7 +1666,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
$whereList = [];
|
||||
|
||||
foreach ($value as $targetId) {
|
||||
$sq = QueryBuilder::create()
|
||||
$sq = SelectBuilder::create()
|
||||
->from($this->entityType)
|
||||
->select(Attribute::ID)
|
||||
->leftJoin($link)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user