Initial commit

This commit is contained in:
root
2026-01-19 17:44:46 +01:00
commit 823af8b11d
8721 changed files with 1130846 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\AccessControlFilters;
use Espo\Core\Acl\Table;
use Espo\Core\AclManager;
use Espo\Core\Select\AccessControl\Filter;
use Espo\Core\Utils\Metadata;
use Espo\Entities\User;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class Mandatory implements Filter
{
public function __construct(
private User $user,
private Metadata $metadata,
private AclManager $aclManager
) {}
public function apply(QueryBuilder $queryBuilder): void
{
if (!$this->user->getPortalId()) {
$forbiddenEntityTypeList = [];
$scopes = $this->metadata->get('scopes', []);
foreach ($scopes as $scope => $defs) {
if (empty($defs['entity'])) {
continue;
}
if ($this->aclManager->checkScope($this->user, $scope, Table::ACTION_READ)) {
continue;
}
$forbiddenEntityTypeList[] = $scope;
}
if ($forbiddenEntityTypeList !== []) {
$queryBuilder->where(['entityType!=' => $forbiddenEntityTypeList]);
}
return;
}
$queryBuilder
->distinct()
->leftJoin('portals', 'portalsAccess')
->where(['portalsAccess.id' => $this->user->getPortalId()]);
}
}

View File

@@ -0,0 +1,31 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Modules\Advanced\Entities\Report;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class GridType implements Filter
{
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->where(['type' => Report::TYPE_GRID]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Modules\Advanced\Entities\Report;
use Espo\Modules\Crm\Entities\Account;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class ListAccounts implements Filter
{
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->where([
'type' => Report::TYPE_LIST,
'entityType' => Account::ENTITY_TYPE,
]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Modules\Advanced\Entities\Report;
use Espo\Modules\Crm\Entities\Contact;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class ListContacts implements Filter
{
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->where([
'type' => Report::TYPE_LIST,
'entityType' => Contact::ENTITY_TYPE,
]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Modules\Advanced\Entities\Report;
use Espo\Modules\Crm\Entities\Lead;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class ListLeads implements Filter
{
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->where([
'type' => Report::TYPE_LIST,
'entityType' => Lead::ENTITY_TYPE,
]);
}
}

View File

@@ -0,0 +1,84 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Core\Templates\Entities\Company;
use Espo\Core\Templates\Entities\Person;
use Espo\Core\Utils\Metadata;
use Espo\Entities\User;
use Espo\Modules\Advanced\Entities\Report;
use Espo\Modules\Crm\Entities\Account;
use Espo\Modules\Crm\Entities\Contact;
use Espo\Modules\Crm\Entities\Lead;
use Espo\Modules\Crm\Entities\TargetList;
use Espo\ORM\Entity;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class ListTargets implements Filter
{
private Metadata $metadata;
public function __construct(Metadata $metadata) {
$this->metadata = $metadata;
}
public function apply(QueryBuilder $queryBuilder): void
{
$entityTypeList = [
Contact::ENTITY_TYPE,
Lead::ENTITY_TYPE,
User::ENTITY_TYPE,
Account::ENTITY_TYPE,
];
foreach ($this->metadata->get(['entityDefs', TargetList::ENTITY_TYPE, 'links']) as $defs) {
$entityType = $defs['entity'] ?? null;
$type = $defs['type'] ?? null;
if ($type !== Entity::HAS_MANY) {
continue;
}
if (!$entityType) {
continue;
}
if (in_array($entityType, $entityTypeList)) {
continue;
}
$templateType = $this->metadata->get(['scopes', $entityType, 'type']);
if (
$templateType !== Person::TEMPLATE_TYPE &&
$templateType !== Company::TEMPLATE_TYPE
) {
continue;
}
$entityTypeList[] = $entityType;
}
$queryBuilder->where([
'type' => Report::TYPE_LIST,
'entityType' => $entityTypeList,
]);
}
}

View File

@@ -0,0 +1,31 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Modules\Advanced\Entities\Report;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class ListType implements Filter
{
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->where(['type' => Report::TYPE_LIST]);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/***********************************************************************************
* The contents of this file are subject to the Extension License Agreement
* ("Agreement") which can be viewed at
* https://www.espocrm.com/extension-license-agreement/.
* By copying, installing downloading, or using this file, You have unconditionally
* agreed to the terms and conditions of the Agreement, and You may not use this
* file except in compliance with the Agreement. Under the terms of the Agreement,
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
* redistribute, market, publish, commercialize, or otherwise transfer rights or
* usage to the software or any modified version or derivative work of the software
* created by or for you.
*
* Copyright (C) 2015-2025 EspoCRM, Inc.
*
* License ID: 19bc86a68a7bb01f458cb391d43a9212
************************************************************************************/
namespace Espo\Modules\Advanced\Classes\Select\Report\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\Entities\User;
use Espo\Modules\Advanced\Entities\Report;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
class ListUsers implements Filter
{
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->where([
'type' => Report::TYPE_LIST,
'entityType' => User::ENTITY_TYPE,
]);
}
}