select usage and refactoring
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?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\Helpers;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\Entities\Preferences;
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
class UserTimeZoneProvider
|
||||
{
|
||||
private $user;
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $config;
|
||||
|
||||
public function __construct(User $user, EntityManager $entityManager, Config $config)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function get(): string
|
||||
{
|
||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $this->user->getId());
|
||||
|
||||
if (!$preferences) {
|
||||
return 'UTC';
|
||||
}
|
||||
|
||||
if ($preferences->get('timeZone') === null || $preferences->get('timeZone') === '') {
|
||||
return $this->config->get('timeZone');
|
||||
}
|
||||
|
||||
return $preferences->get('timeZone') ?? 'UTC';
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,9 @@
|
||||
|
||||
namespace Espo\Core\Select\Where;
|
||||
|
||||
use Espo\{
|
||||
Core\Exceptions\Error,
|
||||
Entities\User,
|
||||
};
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
@@ -43,19 +42,16 @@ use DateInterval;
|
||||
*/
|
||||
class DateTimeItemTransformer
|
||||
{
|
||||
protected $entityType;
|
||||
|
||||
protected $user;
|
||||
|
||||
public function __construct(string $entityType, User $user)
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->entityType = $entityType;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function transform(Item $item): Item
|
||||
{
|
||||
$format = 'Y-m-d H:i:s';
|
||||
$format = DateTimeUtil::SYSTEM_DATE_TIME_FORMAT;
|
||||
|
||||
$type = $item->getType();
|
||||
$value = $item->getValue();
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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\Where;
|
||||
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Core\Binding\BindingContainerBuilder;
|
||||
use Espo\Core\Binding\ContextualBinder;
|
||||
|
||||
class ItemGeneralConverterFactory
|
||||
{
|
||||
private $injectableFactory;
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory)
|
||||
{
|
||||
$this->injectableFactory = $injectableFactory;
|
||||
}
|
||||
|
||||
public function create(string $entityType, User $user): ItemGeneralConverter
|
||||
{
|
||||
$container = BindingContainerBuilder::create()
|
||||
->bindInstance(User::class, $user)
|
||||
->inContext(
|
||||
ItemGeneralConverter::class,
|
||||
function (ContextualBinder $binder) use ($entityType) {
|
||||
$binder->bindValue('$entityType', $entityType);
|
||||
}
|
||||
)
|
||||
->build();
|
||||
|
||||
return $this->injectableFactory->createWithBinding(ItemGeneralConverter::class, $container);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,24 @@ class User extends Person
|
||||
{
|
||||
public const ENTITY_TYPE = 'User';
|
||||
|
||||
public const ATTRIBUTE_TYPE = 'type';
|
||||
|
||||
public const ATTRIBUTE_IS_ACTIVE = 'isActive';
|
||||
|
||||
public const LINK_ACCOUNTS = 'accounts';
|
||||
|
||||
public const LINK_CONTACT = 'contact';
|
||||
|
||||
public const LINK_PORTALS = 'portals';
|
||||
|
||||
public const LINK_TEAMS = 'teams';
|
||||
|
||||
public const LINK_DEFAULT_TEAM = 'defaultTeam';
|
||||
|
||||
public const LINK_ROLES = 'roles';
|
||||
|
||||
public const LINK_PORTAL_ROLES = 'portalRoles';
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return (bool) $this->get('isActive');
|
||||
|
||||
+24
-44
@@ -27,56 +27,36 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\SelectManagers;
|
||||
namespace Espo\Modules\Crm\Classes\Select\Account\AccessControlFilters;
|
||||
|
||||
class Account extends \Espo\Core\Select\SelectManager
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class PortalOnlyAccount implements Filter
|
||||
{
|
||||
protected function filterPartners(&$result)
|
||||
private $user;
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'type' => 'Partner'
|
||||
);
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
protected function filterCustomers(&$result)
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'type' => 'Customer'
|
||||
);
|
||||
}
|
||||
$accountIdList = $this->user->getLinkMultipleIdList(User::LINK_ACCOUNTS);
|
||||
|
||||
protected function filterResellers(&$result)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'type' => 'Reseller'
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterRecentlyCreated(&$result)
|
||||
{
|
||||
$dt = new \DateTime('now');
|
||||
$dt->modify('-7 days');
|
||||
|
||||
$result['whereClause'][] = array(
|
||||
'createdAt>=' => $dt->format('Y-m-d H:i:s')
|
||||
);
|
||||
}
|
||||
|
||||
protected function accessPortalOnlyAccount(&$result)
|
||||
{
|
||||
$d = array();
|
||||
|
||||
$accountIdList = $this->getUser()->getLinkMultipleIdList('accounts');
|
||||
|
||||
if (count($accountIdList)) {
|
||||
$result['whereClause'][] = array(
|
||||
'id' => $accountIdList
|
||||
);
|
||||
} else {
|
||||
$result['whereClause'][] = array(
|
||||
if (!count($accountIdList)) {
|
||||
$queryBuilder->where([
|
||||
'id' => null
|
||||
);
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$queryBuilder->where([
|
||||
'id' => $accountIdList
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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\Modules\Crm\Classes\Select\Account\PrimaryFilters;
|
||||
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Customers implements Filter
|
||||
{
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder->where([
|
||||
'type' => 'Customer',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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\Modules\Crm\Classes\Select\Account\PrimaryFilters;
|
||||
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Partners implements Filter
|
||||
{
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder->where([
|
||||
'type' => 'Partner',
|
||||
]);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?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\Modules\Crm\Classes\Select\Account\PrimaryFilters;
|
||||
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class RecentlyCreated implements Filter
|
||||
{
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$from = (new DateTime())
|
||||
->modify('-7 days')
|
||||
->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
|
||||
|
||||
$queryBuilder->where([
|
||||
'createdAt>=' => $from,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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\Modules\Crm\Classes\Select\Account\PrimaryFilters;
|
||||
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Resellers implements Filter
|
||||
{
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder->where([
|
||||
'type' => 'Reseller',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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\Modules\Crm\Classes\Select\Call\PrimaryFilters;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Core\Select\Helpers\UserTimeZoneProvider;
|
||||
use Espo\Core\Select\Where\DateTimeItemTransformer;
|
||||
use Espo\Core\Select\Where\ItemGeneralConverterFactory;
|
||||
use Espo\Core\Select\Where\Item;
|
||||
|
||||
class Todays implements Filter
|
||||
{
|
||||
private $user;
|
||||
|
||||
private $userTimeZoneProvider;
|
||||
|
||||
private $transformer;
|
||||
|
||||
private $itemGeneralConverterFactory;
|
||||
|
||||
public function __construct(
|
||||
User $user,
|
||||
UserTimeZoneProvider $userTimeZoneProvider,
|
||||
DateTimeItemTransformer $transformer,
|
||||
ItemGeneralConverterFactory $itemGeneralConverterFactory
|
||||
) {
|
||||
$this->user = $user;
|
||||
$this->userTimeZoneProvider = $userTimeZoneProvider;
|
||||
$this->transformer = $transformer;
|
||||
$this->itemGeneralConverterFactory = $itemGeneralConverterFactory;
|
||||
}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$item = $this->transformer->transform(
|
||||
Item::fromRaw([
|
||||
'type' => 'today',
|
||||
'attribute' => 'dateStart',
|
||||
'timeZone' => $this->userTimeZoneProvider->get(),
|
||||
'dateTime' => true,
|
||||
])
|
||||
);
|
||||
|
||||
$whereItem = $this->itemGeneralConverterFactory
|
||||
->create('Call', $this->user)
|
||||
->convert($queryBuilder, $item);
|
||||
|
||||
$queryBuilder->where($whereItem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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\Modules\Crm\Classes\Select\Meeting\AccessControlFilters;
|
||||
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class OnlyOwn implements Filter
|
||||
{
|
||||
private $user;
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder
|
||||
->distinct()
|
||||
->leftJoin('users', 'usersAccess')
|
||||
->where(
|
||||
Cond::or(
|
||||
Cond::equal(
|
||||
Cond::column('usersAccessMiddle.userId'),
|
||||
$this->user->getId()
|
||||
),
|
||||
Cond::equal(
|
||||
Cond::column('assignedUserId'),
|
||||
$this->user->getId()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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\Modules\Crm\Classes\Select\Meeting\AccessControlFilters;
|
||||
|
||||
use Espo\Core\Select\AccessControl\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class OnlyTeam implements Filter
|
||||
{
|
||||
private $user;
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder
|
||||
->distinct()
|
||||
->leftJoin('teams', 'teamsAccess')
|
||||
->leftJoin('users', 'usersAccess')
|
||||
->where(
|
||||
Cond::or(
|
||||
Cond::in(
|
||||
Cond::column('teamsAccessMiddle.teamId'),
|
||||
$this->user->getLinkMultipleIdList(User::LINK_TEAMS)
|
||||
),
|
||||
Cond::equal(
|
||||
Cond::column('usersAccessMiddle.userId'),
|
||||
$this->user->getId()
|
||||
),
|
||||
Cond::equal(
|
||||
Cond::column('assignedUserId'),
|
||||
$this->user->getId()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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\Modules\Crm\Classes\Select\Meeting\BoolFilters;
|
||||
|
||||
use Espo\Core\Select\Boolean\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class OnlyMy implements Filter
|
||||
{
|
||||
private $user;
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder, OrGroupBuilder $orGroupBuilder): void
|
||||
{
|
||||
$queryBuilder
|
||||
->leftJoin('users', 'usersFilterOnlyMy');
|
||||
|
||||
$orGroupBuilder
|
||||
->add(
|
||||
Cond::and(
|
||||
Cond::equal(
|
||||
Cond::column('usersFilterOnlyMyMiddle.userId'),
|
||||
$this->user->getId()
|
||||
),
|
||||
Cond::or(
|
||||
Cond::notEqual(
|
||||
Cond::column('usersFilterOnlyMyMiddle.status'),
|
||||
'Declined'
|
||||
),
|
||||
Cond::equal(
|
||||
Cond::column('usersFilterOnlyMyMiddle.status'),
|
||||
null
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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\Modules\Crm\Classes\Select\Meeting\PrimaryFilters;
|
||||
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Held implements Filter
|
||||
{
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder->where([
|
||||
'status' => 'Held',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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\Modules\Crm\Classes\Select\Meeting\PrimaryFilters;
|
||||
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
class Planned implements Filter
|
||||
{
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder->where([
|
||||
'status' => 'Planned',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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\Modules\Crm\Classes\Select\Meeting\PrimaryFilters;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\Core\Select\Primary\Filter;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Core\Select\Helpers\UserTimeZoneProvider;
|
||||
use Espo\Modules\Crm\Classes\Select\Meeting\Where\DateTimeItemTransformer;
|
||||
use Espo\Core\Select\Where\ItemGeneralConverterFactory;
|
||||
use Espo\Core\Select\Where\Item;
|
||||
|
||||
class Todays implements Filter
|
||||
{
|
||||
private $user;
|
||||
|
||||
private $userTimeZoneProvider;
|
||||
|
||||
private $transformer;
|
||||
|
||||
private $itemGeneralConverterFactory;
|
||||
|
||||
public function __construct(
|
||||
User $user,
|
||||
UserTimeZoneProvider $userTimeZoneProvider,
|
||||
DateTimeItemTransformer $transformer,
|
||||
ItemGeneralConverterFactory $itemGeneralConverterFactory
|
||||
) {
|
||||
$this->user = $user;
|
||||
$this->userTimeZoneProvider = $userTimeZoneProvider;
|
||||
$this->transformer = $transformer;
|
||||
$this->itemGeneralConverterFactory = $itemGeneralConverterFactory;
|
||||
}
|
||||
|
||||
public function apply(SelectBuilder $queryBuilder): void
|
||||
{
|
||||
$item = $this->transformer->transform(
|
||||
Item::fromRaw([
|
||||
'type' => 'today',
|
||||
'attribute' => 'dateStart',
|
||||
'timeZone' => $this->userTimeZoneProvider->get(),
|
||||
'dateTime' => true,
|
||||
])
|
||||
);
|
||||
|
||||
$whereItem = $this->itemGeneralConverterFactory
|
||||
->create('Meeting', $this->user)
|
||||
->convert($queryBuilder, $item);
|
||||
|
||||
$queryBuilder->where($whereItem);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"primaryFilterClassNameMap": {
|
||||
"customers": "Espo\\Modules\\Crm\\Classes\\Select\\Account\\PrimaryFilters\\Customers",
|
||||
"resellers": "Espo\\Modules\\Crm\\Classes\\Select\\Account\\PrimaryFilters\\Resellers",
|
||||
"partners": "Espo\\Modules\\Crm\\Classes\\Select\\Account\\PrimaryFilters\\Partners",
|
||||
"recentlyCreated": "Espo\\Modules\\Crm\\Classes\\Select\\Account\\PrimaryFilters\\RecentlyCreated"
|
||||
},
|
||||
"accessControlFilterClassNameMap": {
|
||||
"portalOnlyAccount": "Espo\\Modules\\Crm\\Classes\\Select\\Account\\AccessControlFilters\\PortalOnlyAccount"
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,17 @@
|
||||
"dateStart",
|
||||
"dateEnd"
|
||||
]
|
||||
},
|
||||
"primaryFilterClassNameMap": {
|
||||
"planned": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\PrimaryFilters\\Planned",
|
||||
"held": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\PrimaryFilters\\Held",
|
||||
"todays": "Espo\\Modules\\Crm\\Classes\\Select\\Call\\PrimaryFilters\\Todays"
|
||||
},
|
||||
"boolFilterClassNameMap": {
|
||||
"onlyMy": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\BoolFilters\\OnlyMy"
|
||||
},
|
||||
"accessControlFilterClassNameMap": {
|
||||
"onlyOwn": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\AccessControlFilters\\OnlyOwn",
|
||||
"onlyTeam": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\AccessControlFilters\\OnlyTeam"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,17 @@
|
||||
"dateStart",
|
||||
"dateEnd"
|
||||
]
|
||||
},
|
||||
"primaryFilterClassNameMap": {
|
||||
"planned": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\PrimaryFilters\\Planned",
|
||||
"held": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\PrimaryFilters\\Held",
|
||||
"todays": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\PrimaryFilters\\Todays"
|
||||
},
|
||||
"boolFilterClassNameMap": {
|
||||
"onlyMy": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\BoolFilters\\OnlyMy"
|
||||
},
|
||||
"accessControlFilterClassNameMap": {
|
||||
"onlyOwn": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\AccessControlFilters\\OnlyOwn",
|
||||
"onlyTeam": "Espo\\Modules\\Crm\\Classes\\Select\\Meeting\\AccessControlFilters\\OnlyTeam"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
<?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\Modules\Crm\SelectManagers;
|
||||
|
||||
class Call extends \Espo\Core\Select\SelectManager
|
||||
{
|
||||
protected $selectAttributesDependancyMap = [
|
||||
'duration' => [
|
||||
'dateStart',
|
||||
'dateEnd',
|
||||
],
|
||||
];
|
||||
|
||||
protected function accessOnlyOwn(&$result)
|
||||
{
|
||||
$this->setDistinct(true, $result);
|
||||
$this->addJoin(['users', 'usersAccess'], $result);
|
||||
$result['whereClause'][] = [
|
||||
'OR' => [
|
||||
'usersAccessMiddle.userId' => $this->getUser()->id,
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function accessOnlyTeam(&$result)
|
||||
{
|
||||
$this->setDistinct(true, $result);
|
||||
$this->addLeftJoin(['teams', 'teamsAccess'], $result);
|
||||
$this->addLeftJoin(['users', 'usersAccess'], $result);
|
||||
|
||||
$result['whereClause'][] = [
|
||||
'OR' => [
|
||||
'teamsAccessMiddle.teamId' => $this->getUser()->getLinkMultipleIdList('teams'),
|
||||
'usersAccessMiddle.userId' => $this->getUser()->id,
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function boolFilterOnlyMy(&$result)
|
||||
{
|
||||
$this->addLeftJoin(['users', 'usersFilterOnlyMy'], $result);
|
||||
return [
|
||||
'usersFilterOnlyMyMiddle.userId' => $this->getUser()->id,
|
||||
'OR' => [
|
||||
'usersFilterOnlyMyMiddle.status!=' => 'Declined',
|
||||
'usersFilterOnlyMyMiddle.status=' => null
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function filterPlanned(&$result)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'status' => 'Planned'
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterHeld(&$result)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'status' => 'Held'
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterTodays(&$result)
|
||||
{
|
||||
$result['whereClause'][] = $this->convertDateTimeWhere(array(
|
||||
'type' => 'today',
|
||||
'field' => 'dateStart',
|
||||
'timeZone' => $this->getUserTimeZone()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
<?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\Modules\Crm\SelectManagers;
|
||||
|
||||
class Meeting extends \Espo\Core\Select\SelectManager
|
||||
{
|
||||
protected $selectAttributesDependancyMap = [
|
||||
'duration' => [
|
||||
'dateStart',
|
||||
'dateEnd',
|
||||
],
|
||||
];
|
||||
|
||||
protected function accessOnlyOwn(&$result)
|
||||
{
|
||||
$this->setDistinct(true, $result);
|
||||
$this->addJoin(['users', 'usersAccess'], $result);
|
||||
$result['whereClause'][] = [
|
||||
'OR' => [
|
||||
'usersAccessMiddle.userId' => $this->getUser()->id,
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function accessOnlyTeam(&$result)
|
||||
{
|
||||
$this->setDistinct(true, $result);
|
||||
$this->addLeftJoin(['teams', 'teamsAccess'], $result);
|
||||
$this->addLeftJoin(['users', 'usersAccess'], $result);
|
||||
|
||||
$result['whereClause'][] = [
|
||||
'OR' => [
|
||||
'teamsAccessMiddle.teamId' => $this->getUser()->getLinkMultipleIdList('teams'),
|
||||
'usersAccessMiddle.userId' => $this->getUser()->id,
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function boolFilterOnlyMy(&$result)
|
||||
{
|
||||
$this->addLeftJoin(['users', 'usersFilterOnlyMy'], $result);
|
||||
return [
|
||||
'usersFilterOnlyMyMiddle.userId' => $this->getUser()->id,
|
||||
'OR' => [
|
||||
'usersFilterOnlyMyMiddle.status!=' => 'Declined',
|
||||
'usersFilterOnlyMyMiddle.status=' => null
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function filterPlanned(&$result)
|
||||
{
|
||||
$result['whereClause'][] = [
|
||||
'status' => 'Planned'
|
||||
];
|
||||
}
|
||||
|
||||
protected function filterHeld(&$result)
|
||||
{
|
||||
$result['whereClause'][] = [
|
||||
'status' => 'Held'
|
||||
];
|
||||
}
|
||||
|
||||
protected function filterTodays(&$result)
|
||||
{
|
||||
$result['whereClause'][] = $this->convertDateTimeWhere([
|
||||
'type' => 'today',
|
||||
'attribute' => 'dateStart',
|
||||
'timeZone' => $this->getUserTimeZone()
|
||||
]);
|
||||
}
|
||||
|
||||
public function transformDateTimeWhereItem(array $item) : array
|
||||
{
|
||||
$where = parent::transformDateTimeWhereItem($item);
|
||||
|
||||
if (empty($where)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$attribute = null;
|
||||
if (!empty($item['attribute'])) {
|
||||
$attribute = $item['attribute'];
|
||||
}
|
||||
|
||||
if ($attribute != 'dateStart' && $attribute != 'dateEnd') return $where;
|
||||
if (!$this->getSeed()->hasAttribute('dateStartDate')) return $where;
|
||||
|
||||
$type = $item['type'] ?? null;
|
||||
|
||||
if ($type === 'isNull') return $where;
|
||||
if ($type === 'ever') return $where;
|
||||
if ($type === 'isNotNull') return $where;
|
||||
|
||||
$attributeDate = $attribute . 'Date';
|
||||
|
||||
$value = null;
|
||||
if (array_key_exists('value', $item)) {
|
||||
$value = $item['value'];
|
||||
if (is_string($value)) {
|
||||
if (strlen($value) > 11) {
|
||||
return $where;
|
||||
}
|
||||
} else if (is_array($value)) {
|
||||
foreach ($value as $valueItem) {
|
||||
if (strlen($valueItem) > 11) {
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dateItem = [
|
||||
'attribute' => $attributeDate,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
if (array_key_exists('value', $item)) {
|
||||
$dateItem['value'] = $value;
|
||||
}
|
||||
|
||||
$where = [
|
||||
'type' => 'or',
|
||||
'value' => [
|
||||
$dateItem,
|
||||
[
|
||||
'type' => 'and',
|
||||
'value' => [
|
||||
$where,
|
||||
[
|
||||
'type' => 'isNull',
|
||||
'attribute' => $attributeDate
|
||||
]
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,6 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
|
||||
->willReturn('Random');
|
||||
|
||||
$this->dateTimeItemTransformer = new DateTimeItemTransformer(
|
||||
$this->entityType,
|
||||
$this->user
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user