public function __construct($typeID, DedupeParams $params) { if ($typeID !== DuplicateIndexType::COMMUNICATION_PHONE && $typeID !== DuplicateIndexType::COMMUNICATION_EMAIL) { throw new Main\NotSupportedException("Type(s): '" . DuplicateIndexType::resolveName($typeID) . "' is not supported in current context"); } parent::__construct($typeID, $params); }
public static function getMatchHash($typeID, array $matches) { if ($typeID === DuplicateIndexType::PERSON) { return DuplicatePersonCriterion::prepareMatchHash($matches); } elseif ($typeID === DuplicateIndexType::ORGANIZATION) { return DuplicateOrganizationCriterion::prepareMatchHash($matches); } elseif ($typeID === DuplicateIndexType::COMMUNICATION_EMAIL || $typeID === DuplicateIndexType::COMMUNICATION_PHONE) { return DuplicateCommunicationCriterion::prepareMatchHash($matches); } throw new Main\NotSupportedException("Criterion type(s): '" . DuplicateIndexType::resolveName($typeID) . "' is not supported in current context"); }
public static function create($typeID, DedupeParams $params) { if ($typeID === DuplicateIndexType::PERSON) { return new PersonDedupeDataSource($params); } elseif ($typeID === DuplicateIndexType::ORGANIZATION) { return new OrganizationDedupeDataSource($params); } elseif ($typeID === DuplicateIndexType::COMMUNICATION_PHONE || $typeID === DuplicateIndexType::COMMUNICATION_EMAIL) { return new CommunicationDedupeDataSource($typeID, $params); } else { throw new Main\NotSupportedException("Type: '" . DuplicateIndexType::resolveName($typeID) . "' is not supported in current context"); } }
public function isExists() { $params = array('TYPE_ID' => $this->typeID, 'ENTITY_TYPE_ID' => $this->getEntityTypeID(), 'USER_ID' => $this->getUserID()); if ($this->typeID === DuplicateIndexType::PERSON) { return DuplicatePersonCriterion::checkIndex($params); } elseif ($this->typeID === DuplicateIndexType::ORGANIZATION) { return DuplicateOrganizationCriterion::checkIndex($params); } elseif ($this->typeID === DuplicateIndexType::COMMUNICATION_PHONE || $this->typeID === DuplicateIndexType::COMMUNICATION_EMAIL) { return DuplicateCommunicationCriterion::checkIndex($params); } else { throw new Main\NotSupportedException("Criterion type(s): '" . DuplicateIndexType::resolveName($this->typeID) . "' is not supported in current context"); } }
foreach ($supportedTypes as $typeID) { $typeLayoutID = CCrmOwnerType::Undefined; if ($typeID === Integrity\DuplicateIndexType::ORGANIZATION) { $typeLayoutID = CCrmOwnerType::Company; } elseif ($typeID === Integrity\DuplicateIndexType::PERSON) { $typeLayoutID = CCrmOwnerType::Contact; } $groupName = ''; if ($typeID === Integrity\DuplicateIndexType::PERSON || $typeID === Integrity\DuplicateIndexType::ORGANIZATION) { $groupName = 'denomination'; } elseif ($typeID === Integrity\DuplicateIndexType::COMMUNICATION_PHONE || $typeID === Integrity\DuplicateIndexType::COMMUNICATION_EMAIL) { $groupName = 'communication'; } $description = isset($typeDescriptions[$typeID]) ? $typeDescriptions[$typeID] : $typeID; $isIndexed = in_array($typeID, $indexedTypes, true); $typeInfos[$typeID] = array('ID' => $typeID, 'NAME' => Integrity\DuplicateIndexType::resolveName($typeID), 'DESCRIPTION' => $description, 'IS_INDEXED' => $isIndexed, 'IS_SELECTED' => false, 'IS_UNDERSTATED' => false, 'LAYOUT_NAME' => CCrmOwnerType::ResolveName($typeLayoutID), 'GROUP_NAME' => $groupName); if ($filterTypeID === Integrity\DuplicateIndexType::UNDEFINED || ($filterTypeID & $typeID) === $typeID) { if (!$isIndexed && $filterTypeID !== Integrity\DuplicateIndexType::UNDEFINED) { $skippedTypeIDs[] = $typeID; } if ($isIndexed && $filterTypeID === Integrity\DuplicateIndexType::UNDEFINED || ($filterTypeID & $typeID) === $typeID) { $selectedTypes[$typeID] = $typeID; $typeInfos[$typeID]['IS_SELECTED'] = true; } } } if (!empty($skippedTypeIDs)) { $skippedTypeDescriptions = array(); foreach ($skippedTypeIDs as $typeID) { $skippedTypeDescriptions[] = "'{$typeDescriptions[$typeID]}'"; }
public function setSortTypeID($typeID) { if (!is_numeric($typeID)) { throw new Main\ArgumentTypeException('typeID', 'integer'); } if (!is_int($typeID)) { $typeID = intval($typeID); } if (!DuplicateIndexType::isSigle($typeID)) { throw new Main\NotSupportedException("Criterion type(s): '" . DuplicateIndexType::resolveName($typeID) . "' is not supported in current context. Please use single type for sorting."); } $this->sortTypeID = $typeID; }
\CCrmOwnerType::PrepareEntityInfoBatch($entityTypeID, $entityInfos, $enablePermissionCheck, $entityInfoOptions); \CCrmFieldMulti::PrepareEntityInfoBatch('PHONE', $entityTypeName, $entityInfos, array('ENABLE_NORMALIZATION' => true)); \CCrmFieldMulti::PrepareEntityInfoBatch('EMAIL', $entityTypeName, $entityInfos); foreach ($entityInfos as &$entityInfo) { if (isset($entityInfo['IMAGE_FILE_ID'])) { if ($entityInfo['IMAGE_FILE_ID'] > 0) { $imageInfo = CFile::ResizeImageGet($entityInfo['IMAGE_FILE_ID'], array('width' => 34, 'height' => 50), BX_RESIZE_IMAGE_EXACT); $entityInfo['IMAGE_URL'] = $imageInfo['src']; } unset($entityInfo['IMAGE_FILE_ID']); } } unset($entityInfo); } $totalsText = $criterion->getTextTotals(count($entityInfos), 50); $result = array('INDEX_TYPE_NAME' => Integrity\DuplicateIndexType::resolveName($typeID), 'ENTITY_TYPE_NAME' => $entityTypeName, 'ENTITY_INFOS' => array_values($entityInfos), 'TEXT_TOTALS' => $totalsText); __CrmDedupeListEndResonse($result); } elseif ($action === 'GET_DUPLICATE_ENTITY_MULTI_FIELDS') { $entityTypeID = isset($_POST['ENTITY_TYPE_NAME']) ? CCrmOwnerType::ResolveID($_POST['ENTITY_TYPE_NAME']) : CCrmOwnerType::Undefined; $entityTypeName = CCrmOwnerType::ResolveName($entityTypeID); $entityID = isset($_POST['ENTITY_ID']) ? (int) $_POST['ENTITY_ID'] : 0; if (!CCrmPerms::IsAdmin($currentUserID) && !CCrmAuthorizationHelper::CheckReadPermission($entityTypeName, $entityID)) { __CrmDedupeListEndResonse(array('ERROR' => 'Access denied.')); } $result = Integrity\DuplicateCommunicationCriterion::getRegisteredCodes($entityTypeID, $entityID, false, $currentUserID, 50); __CrmDedupeListEndResonse(array('MULTI_FIELDS' => $result)); } elseif ($action === 'REBUILD_DEDUPE_INDEX') { __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); $params = isset($_POST['PARAMS']) && is_array($_POST['PARAMS']) ? $_POST['PARAMS'] : array(); $contextID = isset($params['CONTEXT_ID']) ? $params['CONTEXT_ID'] : ''; if ($contextID === '') {
public 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"); } $typeID = isset($params['TYPE_ID']) ? intval($params['TYPE_ID']) : DuplicateIndexType::UNDEFINED; if ($typeID !== DuplicateIndexType::COMMUNICATION_PHONE && $typeID !== DuplicateIndexType::COMMUNICATION_EMAIL) { throw new Main\NotSupportedException("Criterion type(s): '" . DuplicateIndexType::resolveName($typeID) . "' is not supported in current context"); } $userID = isset($params['USER_ID']) ? intval($params['USER_ID']) : 0; $listParams = array('select' => array('USER_ID', 'TYPE_ID', 'ENTITY_TYPE_ID'), 'order' => array('USER_ID' => 'ASC', 'TYPE_ID' => 'ASC', 'ENTITY_TYPE_ID' => 'ASC'), 'filter' => array('=USER_ID' => $userID, '=ENTITY_TYPE_ID' => $entityTypeID, '=TYPE_ID' => $typeID), 'limit' => 1); $dbResult = Entity\DuplicateIndexTable::getList($listParams); return is_array($dbResult->fetch()); }