CCrmProductPropertyRestProxy::innerGet

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProductPropertyRestProxy
  4. innerGet
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmProductPropertyRestProxy
  • Вызов: CCrmProductPropertyRestProxy::innerGet
protected function innerGet($id, &$errors)
{
	if(!CModule::IncludeModule('iblock'))
	{
		throw new RestException('Could not load iblock module.');
	}

	/** @var CCrmPerms $userPerms */
	$userPerms = CCrmPerms::GetCurrentUserPermissions();
	if (!$userPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ'))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$result = false;
	$iblockId = intval(CCrmCatalog::EnsureDefaultExists());
	$userTypes = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'rest');
	$res = CIBlockProperty::GetByID($id, $iblockId);
	if (is_object($res))
		$result = $res->Fetch();
	unset($res);
	if(!is_array($result)
		|| (isset($result['USER_TYPE']) && !empty($result['USER_TYPE'])
			&& !array_key_exists($result['USER_TYPE'], $userTypes)))
	{
		$errors[] = 'Not found';
		return false;
	}

	$values = null;
	if ($result['PROPERTY_TYPE'] === 'L')
	{
		$values = array();
		$resEnum = CIBlockProperty::GetPropertyEnum($result['ID'], array('SORT' => 'ASC','ID' => 'ASC'));
		while($enumValue = $resEnum->Fetch())
		{
			$values[intval($enumValue['ID'])] = array(
				'ID' => $enumValue['ID'],
				'VALUE' => $enumValue['VALUE'],
				'XML_ID' => $enumValue['XML_ID'],
				'SORT' => $enumValue['SORT'],
				'DEF' => $enumValue['DEF']
			);
		}
	}
	$result['VALUES'] = $values;

	$userTypeSettings = array();
	if (isset($result['USER_TYPE_SETTINGS']) && is_array($result['USER_TYPE_SETTINGS']))
	{
		foreach ($result['USER_TYPE_SETTINGS'] as $key => $value)
			$userTypeSettings[mb_strtoupper($key)] = $value;
		$result['USER_TYPE_SETTINGS'] = $userTypeSettings;
	}

	return $result;
}

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