...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/tracking/rest.php
- Класс: Bitrix\Crm\Tracking\Rest
- Вызов: Rest::addTrace
static function addTrace($query, $nav = 0, \CRestServer $server) { $trace = empty($query['TRACE']) ? null : $query['TRACE']; if (!$trace) { self::printErrors(["Parameter `TRACE` required."]); } try { $traceString = Encoding::convertEncoding($trace, SITE_CHARSET, 'UTF-8'); Json::decode($traceString); } catch (\Exception $exception) { self::printErrors(["Can not parse JSON in parameter `TRACE`."]); } $entities = isset($query['ENTITIES']) ? $query['ENTITIES'] : []; $entities = is_array($entities) ? $entities : []; $allowedEntityTypes = [ \CCrmOwnerType::CompanyName, \CCrmOwnerType::ContactName, \CCrmOwnerType::DealName, \CCrmOwnerType::LeadName, \CCrmOwnerType::QuoteName, ]; foreach ($entities as $entity) { if (!isset($entity['TYPE']) || !in_array($entity['TYPE'], $allowedEntityTypes, true)) { self::printErrors(["Wrong TYPE in parameter `ENTITIES`. Allowed types: " . implode(',', $allowedEntityTypes)]); } if (!isset($entity['ID']) || !is_numeric($entity['ID']) || $entity['ID'] <= 0) { self::printErrors(["Wrong ID in parameter `ENTITIES`."]); } if (!\CCrmAuthorizationHelper::CheckUpdatePermission($entity['TYPE'], $entity['ID'])) { self::printErrors(["You have no access to entity `{$entity['TYPE']}` with ID `{$entity['ID']}`."]); } } $traceId = Trace::create($trace)->save(); foreach ($entities as $entity) { $entityId = (int) $entity['ID']; $entityTypeId = \CCrmOwnerType::ResolveID($entity['TYPE']); Trace::appendEntity($traceId, $entityTypeId, $entityId); } return $traceId; }