mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
select access all filter
This commit is contained in:
@@ -51,6 +51,10 @@ class DefaultFilterResolver implements FilterResolver
|
||||
|
||||
public function resolve(): ?string
|
||||
{
|
||||
if ($this->acl->checkReadNo($this->entityType)) {
|
||||
return 'no';
|
||||
}
|
||||
|
||||
if ($this->acl->checkReadOnlyOwn($this->entityType)) {
|
||||
return 'onlyOwn';
|
||||
}
|
||||
@@ -59,12 +63,8 @@ class DefaultFilterResolver implements FilterResolver
|
||||
return 'onlyTeam';
|
||||
}
|
||||
|
||||
if ($this->acl->checkReadNo($this->entityType)) {
|
||||
return 'no';
|
||||
}
|
||||
|
||||
if ($this->acl->checkReadAll($this->entityType)) {
|
||||
return null;
|
||||
return 'all';
|
||||
}
|
||||
|
||||
return 'no';
|
||||
|
||||
@@ -51,6 +51,10 @@ class DefaultPortalFilterResolver implements FilterResolver
|
||||
|
||||
public function resolve(): ?string
|
||||
{
|
||||
if ($this->acl->checkReadNo($this->entityType)) {
|
||||
return 'no';
|
||||
}
|
||||
|
||||
if ($this->acl->checkReadOnlyOwn($this->entityType)) {
|
||||
return 'portalOnlyOwn';
|
||||
}
|
||||
@@ -63,12 +67,8 @@ class DefaultPortalFilterResolver implements FilterResolver
|
||||
return 'portalOnlyContact';
|
||||
}
|
||||
|
||||
if ($this->acl->checkReadNo($this->entityType)) {
|
||||
return 'no';
|
||||
}
|
||||
|
||||
if ($this->acl->checkReadAll($this->entityType)) {
|
||||
return null;
|
||||
return 'portalAll';
|
||||
}
|
||||
|
||||
return 'no';
|
||||
|
||||
43
application/Espo/Core/Select/AccessControl/Filters/All.php
Normal file
43
application/Espo/Core/Select/AccessControl/Filters/All.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2021 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\{
|
||||
ORM\QueryParams\SelectBuilder as QueryBuilder,
|
||||
Core\Select\AccessControl\Filter,
|
||||
};
|
||||
|
||||
class All implements Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2021 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Select\AccessControl\Filters;
|
||||
|
||||
use Espo\{
|
||||
ORM\QueryParams\SelectBuilder as QueryBuilder,
|
||||
Core\Select\AccessControl\Filter,
|
||||
};
|
||||
|
||||
class PortalAll implements Filter
|
||||
{
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -85,9 +85,8 @@ class AccessControlFilter
|
||||
return;
|
||||
}
|
||||
|
||||
$accessControlFilterResolver = $this->accessControlFilterResolverFactory->create(
|
||||
$this->entityType, $this->user
|
||||
);
|
||||
$accessControlFilterResolver = $this->accessControlFilterResolverFactory
|
||||
->create($this->entityType, $this->user);
|
||||
|
||||
$filterName = $accessControlFilterResolver->resolve();
|
||||
|
||||
@@ -103,7 +102,8 @@ class AccessControlFilter
|
||||
}
|
||||
|
||||
if ($this->accessControlFilterFactory->has($this->entityType, $filterName)) {
|
||||
$filter = $this->accessControlFilterFactory->create($this->entityType, $this->user, $filterName);
|
||||
$filter = $this->accessControlFilterFactory
|
||||
->create($this->entityType, $this->user, $filterName);
|
||||
|
||||
$filter->apply($queryBuilder);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ use Espo\{
|
||||
|
||||
class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->acl = $this->createMock(Acl::class);
|
||||
$this->aclPortal = $this->createMock(AclPortal::class);
|
||||
@@ -55,7 +55,7 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'onlyOwn',
|
||||
$this->initResolveTest(false, false, 'checkReadOnlyOwn')
|
||||
$this->initResolveTest(false, 'checkReadOnlyOwn')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'onlyTeam',
|
||||
$this->initResolveTest(false, false, 'checkReadOnlyTeam')
|
||||
$this->initResolveTest(false, 'checkReadOnlyTeam')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'no',
|
||||
$this->initResolveTest(false, false, 'checkReadNo')
|
||||
$this->initResolveTest(false, 'checkReadNo')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'portalOnlyOwn',
|
||||
$this->initResolveTest(true, false, 'checkReadOnlyOwn')
|
||||
$this->initResolveTest(true, 'checkReadOnlyOwn')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'portalOnlyAccount',
|
||||
$this->initResolveTest(true, false, 'checkReadOnlyAccount')
|
||||
$this->initResolveTest(true, 'checkReadOnlyAccount')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'portalOnlyContact',
|
||||
$this->initResolveTest(true, false, 'checkReadOnlyContact')
|
||||
$this->initResolveTest(true, 'checkReadOnlyContact')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,19 +103,27 @@ class FilterResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
'no',
|
||||
$this->initResolveTest(true, false, 'checkReadNo')
|
||||
$this->initResolveTest(true, 'checkReadNo')
|
||||
);
|
||||
}
|
||||
|
||||
public function testResolveAll()
|
||||
{
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$this->initResolveTest(false, true, 'checkReadAll')
|
||||
'all',
|
||||
$this->initResolveTest(false, 'checkReadAll')
|
||||
);
|
||||
}
|
||||
|
||||
protected function initResolveTest(bool $isPortal = false, bool $isAdmin = false, ?string $method) : ?string
|
||||
public function testResolvePortalAll()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'portalAll',
|
||||
$this->initResolveTest(true, 'checkReadAll')
|
||||
);
|
||||
}
|
||||
|
||||
protected function initResolveTest(bool $isPortal = false, ?string $method = null): ?string
|
||||
{
|
||||
$acl = $this->acl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user