- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicatepersoncriterion.php
- Класс: Bitrix\Crm\Integrity\DuplicatePersonCriterion
- Вызов: DuplicatePersonCriterion::checkIndex
static function checkIndex(array $params)
{
$entityTypeID = isset($params['ENTITY_TYPE_ID']) ? intval($params['ENTITY_TYPE_ID']) : \CCrmOwnerType::Undefined;
if($entityTypeID !== \CCrmOwnerType::Undefined
&& $entityTypeID !== \CCrmOwnerType::Lead
&& $entityTypeID !== \CCrmOwnerType::Contact
&& $entityTypeID !== \CCrmOwnerType::Company)
{
throw new Main\NotSupportedException("Entity type: '".\CCrmOwnerType::ResolveName($entityTypeID)."' is not supported in current context");
}
$userID = isset($params['USER_ID']) ? intval($params['USER_ID']) : 0;
$scope = null;
if (isset($params['SCOPE']))
{
$scope = $params['SCOPE'];
if (!DuplicateIndexType::checkScopeValue($scope))
{
throw new Main\ArgumentException("Parameter has invalid value", 'SCOPE');
}
}
$filter = array(
'=USER_ID' => $userID,
'=ENTITY_TYPE_ID' => $entityTypeID,
'=TYPE_ID' => DuplicateIndexType::PERSON
);
if ($scope !== null)
$filter['=SCOPE'] = $scope;
$listParams = array(
'select' => array('USER_ID', 'TYPE_ID', 'ENTITY_TYPE_ID'),
'order' => array('USER_ID'=>'ASC', 'TYPE_ID'=>'ASC', 'ENTITY_TYPE_ID'=>'ASC'),
'filter' => $filter,
'limit' => 1
);
$dbResult = Entity\DuplicateIndexTable::getList($listParams);
return is_array($dbResult->fetch());
}