...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicaterequisitecriterion.php
- Класс: Bitrix\Crm\Integrity\DuplicateRequisiteCriterion
- Вызов: DuplicateRequisiteCriterion::getRegisteredCodes
static function getRegisteredCodes($entityTypeID, $entityID, $enablePermissionCheck = false, $userID = 0, $limit = 50) { if(!is_int($entityTypeID)) { throw new Main\ArgumentTypeException('entityTypeID', 'integer'); } if(!is_int($entityID)) { throw new Main\ArgumentTypeException('entityID', 'integer'); } if(!is_int($userID)) { throw new Main\ArgumentTypeException('userID', 'integer'); } if(!is_bool($enablePermissionCheck)) { throw new Main\ArgumentTypeException('enablePermissionCheck', 'boolean'); } if(!is_int($limit)) { throw new Main\ArgumentTypeException('limit', 'integer'); } $query = new Main\Entity\Query(DuplicateRequisiteMatchCodeTable::getEntity()); $query->addSelect('RQ_COUNTRY_ID'); $query->addSelect('RQ_FIELD_NAME'); $query->addSelect('VALUE'); $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID); $query->addFilter('=ENTITY_ID', $entityID); if($enablePermissionCheck && $userID > 0) { $permissions = isset($params['PERMISSIONS']) ? $params['PERMISSIONS'] : null; if($permissions === null) { $permissions = \CCrmPerms::GetUserPermissions($userID); } $permissionSql = \CCrmPerms::BuildSql( \CCrmOwnerType::ResolveName($entityTypeID), '', 'READ', array('RAW_QUERY' => true, 'PERMS'=> $permissions) ); if($permissionSql === false) { //Access denied; return array(); } elseif($permissionSql !== '') { $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql)); } } if($limit > 0) { $query->setLimit($limit); } $dbResult = $query->exec(); $results = array(); while($fields = $dbResult->fetch()) { $countryId = isset($fields['RQ_COUNTRY_ID']) ? (int)$fields['RQ_COUNTRY_ID'] : 0; $fieldName = isset($fields['RQ_FIELD_NAME']) ? $fields['RQ_FIELD_NAME'] : ''; $value = isset($fields['VALUE']) ? $fields['VALUE'] : ''; $scope = EntityRequisite::formatDuplicateCriterionScope($countryId); if (!isset($results[$fieldName])) $results[$fieldName] = array(); if (!isset($results[$fieldName][$scope])) $results[$fieldName][$scope] = array(); $results[$fieldName][$scope][] = $value; } return $results; }