CCrmUserType::AddWebserviceFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmUserType
  4. AddWebserviceFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_usertype.php
  • Класс: \CCrmUserType
  • Вызов: CCrmUserType::AddWebserviceFields
public function AddWebserviceFields(&$obFields)
{
	$arUserFields = $this->GetAbstractFields();
	foreach($arUserFields as $FIELD_NAME => $arUserField)
	{
		$defVal = '';
		if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'employee')
			continue;
		if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'enum')
		{
			$sType = 'int';
			if (is_callable(array($arUserField['USER_TYPE']['CLASS_NAME'], 'GetList')))
			{
				$rsEnum = call_user_func_array(array($arUserField['USER_TYPE']['CLASS_NAME'], 'GetList'), array($arUserField));
				$obFieldValues = new CXMLCreator('CHOISES');
				while($ar = $rsEnum->GetNext())
				{
					$obFieldValue = new CXMLCreator('CHOISE', true);
					$obFieldValue->setAttribute('id', $ar['ID']);
					$obFieldValue->setData(htmlspecialcharsbx($ar['VALUE']));
					$obFieldValues->addChild($obFieldValue);
				}
			}
		}
		else if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'file')
			$sType = 'file';
		else if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'boolean')
			$sType = 'boolean';
		else if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'double' || $arUserField['USER_TYPE']['USER_TYPE_ID'] == 'integer')
			$sType = 'int';
		else if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'datetime')
		{
			$defVal = $arUserField['SETTINGS']['DEFAULT_VALUE']['VALUE'];
			$sType = 'datetime';
		}
		else if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'string')
			$sType = 'string';
		else
			$sType = 'string';

		if (empty($defVal) && isset($arUserField['SETTINGS']['DEFAULT_VALUE']) && !is_array($arUserField['SETTINGS']['DEFAULT_VALUE']))
			$defVal = $arUserField['SETTINGS']['DEFAULT_VALUE'];

		$obField = CXMLCreator::createTagAttributed('Field id="'.$FIELD_NAME.'" name="'.htmlspecialcharsbx($arUserField['EDIT_FORM_LABEL']).'" type="'.$sType.'" default="'.$defVal.'" require="'.($arUserField['MANDATORY'] == 'Y' ? 'true' : 'false').'" multy="'.($arUserField['MULTIPLE'] == 'Y' ? 'true' : 'false').'"', '');
		if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'enum' && $obFieldValues instanceof CXMLCreator)
		{
			$obField->addChild($obFieldValues);
			unset($obFieldValues);
		}
		$obFields->addChild($obField);
	}
}

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