CCrmLeadRestProxy::innerGet

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmLeadRestProxy
  4. innerGet
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmLeadRestProxy
  • Вызов: CCrmLeadRestProxy::innerGet
protected function innerGet($ID, &$errors)
{
	if(!CCrmLead::CheckReadPermission($ID))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$dbRes = CCrmLead::GetListEx(
		array(),
		array('=ID' => $ID),
		false,
		false,
		array(),
		array()
	);

	$result = $dbRes ? $dbRes->Fetch() : null;
	if(!is_array($result))
	{
		$errors[] = 'Not found';
		return false;
	}

	$result = \Bitrix\Crm\Entity\CommentsHelper::prepareFieldsFromCompatibleRestToRead(
		\CCrmOwnerType::Lead,
		$ID,
		$result,
	);

	$result['FM'] = array();
	$fmResult = CCrmFieldMulti::GetList(
		array('ID' => 'asc'),
		array(
			'ENTITY_ID' => CCrmOwnerType::ResolveName(CCrmOwnerType::Lead),
			'ELEMENT_ID' => $ID
		)
	);

	while($fm = $fmResult->Fetch())
	{
		$fmTypeID = $fm['TYPE_ID'];
		if(!isset($result['FM'][$fmTypeID]))
		{
			$result['FM'][$fmTypeID] = array();
		}

		$result['FM'][$fmTypeID][] = array('ID' => $fm['ID'], 'VALUE_TYPE' => $fm['VALUE_TYPE'], 'VALUE' => $fm['VALUE']);
	}

	$userFields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields(CCrmLead::$sUFEntityID, $ID, LANGUAGE_ID);
	foreach($userFields as $ufName => &$ufData)
	{
		$result[$ufName] = $ufData['VALUE'] ?? '';
	}
	unset($ufData);

	return $result;
}

Добавить комментарий