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);
 }
Exemplo n.º 2
0
 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");
     }
 }
Exemplo n.º 4
0
 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");
     }
 }
Exemplo n.º 5
0
        $sortBy = 'ORGANIZATION';
    } else {
        $sortTypeID = Integrity\DuplicateIndexType::PERSON;
        $sortBy = 'PERSON';
    }
}
$arResult['SORT_TYPE_ID'] = $sortTypeID;
$arResult['SORT_BY'] = $sortBy;
$sortOrder = $arResult['SORT_ORDER'] = isset($_GET['sortOrder']) && strtoupper($_GET['sortOrder']) === 'DESC' ? SORT_DESC : SORT_ASC;
if (empty($selectedTypes)) {
    $arResult['ITEMS'] = array();
    $arResult['ENTITY_INFOS'] = array();
    $arResult['HAS_PREV_PAGE'] = false;
    $arResult['HAS_NEXT_PAGE'] = false;
} else {
    $list = new Integrity\DuplicateList(Integrity\DuplicateIndexType::joinType(array_keys($selectedTypes)), $entityTypeID, $userID, $enablePermissionCheck);
    $list->setSortTypeID($sortTypeID);
    $list->setSortOrder($sortOrder);
    $items = $list->getRootItems(($pageNum - 1) * $itemsPerPage, $itemsPerPage + 1);
    if (count($items) <= $itemsPerPage) {
        $arResult['HAS_NEXT_PAGE'] = false;
    } else {
        $arResult['HAS_NEXT_PAGE'] = true;
        array_pop($items);
    }
    $arResult['HAS_PREV_PAGE'] = $pageNum > 1;
    $arResult['ITEMS'] = $items;
    $entityInfos = array();
    /** @var Integrity\Duplicate $item **/
    foreach ($items as $item) {
        $entityID = $item->getRootEntityID();
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 if ($entityTypeID === CCrmOwnerType::Undefined) {
     __CrmDedupeListEndResonse(array('ERROR' => 'Entity type is not specified.'));
 }
 if ($entityTypeID !== CCrmOwnerType::Lead && $entityTypeID !== CCrmOwnerType::Contact && $entityTypeID !== CCrmOwnerType::Company) {
     __CrmDedupeListEndResonse(array('ERROR' => "Entity type '{$entityTypeName}' is not supported in current context."));
 }
 $leftEntityID = isset($_POST['LEFT_ENTITY_ID']) ? (int) $_POST['LEFT_ENTITY_ID'] : 0;
 if ($leftEntityID <= 0) {
     __CrmDedupeListEndResonse(array('ERROR' => 'Left entity ID is not is not specified.'));
 }
 $rightEntityID = isset($_POST['RIGHT_ENTITY_ID']) ? (int) $_POST['RIGHT_ENTITY_ID'] : 0;
 if ($rightEntityID <= 0) {
     __CrmDedupeListEndResonse(array('ERROR' => 'Right entity ID is not is not specified.'));
 }
 $typeID = isset($_POST['INDEX_TYPE_NAME']) ? Integrity\DuplicateIndexType::resolveID($_POST['INDEX_TYPE_NAME']) : Integrity\DuplicateIndexType::UNDEFINED;
 if (!Integrity\DuplicateIndexType::isDefined($typeID)) {
     __CrmDedupeListEndResonse(array('ERROR' => 'Index type ID is not specified or invalid.'));
 }
 $enablePermissionCheck = !CCrmPerms::IsAdmin($currentUserID);
 $merger = Merger\EntityMerger::create($entityTypeID, $currentUserID, $enablePermissionCheck);
 $leftEntityMatches = isset($_POST['LEFT_ENTITY_INDEX_MATCHES']) && is_array($_POST['LEFT_ENTITY_INDEX_MATCHES']) ? $_POST['LEFT_ENTITY_INDEX_MATCHES'] : array();
 $leftEntityCriterion = Integrity\DuplicateManager::createCriterion($typeID, $leftEntityMatches);
 $rightEntityMatches = isset($_POST['RIGHT_ENTITY_INDEX_MATCHES']) && is_array($_POST['RIGHT_ENTITY_INDEX_MATCHES']) ? $_POST['RIGHT_ENTITY_INDEX_MATCHES'] : array();
 if (empty($rightEntityMatches)) {
     $rightEntityMatches = $leftEntityMatches;
 }
 $rightEntityCriterion = Integrity\DuplicateManager::createCriterion($typeID, $rightEntityMatches);
 try {
     $merger->registerCriterionMismatch($rightEntityCriterion, $leftEntityID, $rightEntityID);
     $builder = Integrity\DuplicateManager::createIndexBuilder($typeID, $entityTypeID, $currentUserID, $enablePermissionCheck);
     $builder->processMismatchRegistration($leftEntityCriterion, $leftEntityID);
 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());
 }