CCrmInvoiceRestService::externalizeUserFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmInvoiceRestService
  4. externalizeUserFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice_invoice.php
  • Класс: \CCrmInvoiceRestService
  • Вызов: CCrmInvoiceRestService::externalizeUserFields
static function externalizeUserFields(&$fields)
{
	if(!is_array($fields))
	{
		return;
	}

	$fieldsInfo = array();
	$userType = new CCrmUserType($GLOBALS['USER_FIELD_MANAGER'], CCrmInvoice::$sUFEntityID);
	$userType->PrepareFieldsInfo($fieldsInfo);

	if (empty($fieldsInfo))
		return;

	foreach($fields as $k => $v)
	{
		$info = isset($fieldsInfo[$k]) ? $fieldsInfo[$k] : null;
		if(!$info)
		{
			continue;
		}

		$attrs = isset($info['ATTRIBUTES']) ? $info['ATTRIBUTES'] : array();
		$isMultiple = in_array(CCrmFieldInfoAttr::Multiple, $attrs, true);
		$isHidden = in_array(CCrmFieldInfoAttr::Hidden, $attrs, true);
		$isDynamic = in_array(CCrmFieldInfoAttr::Dynamic, $attrs, true);

		if($isHidden)
		{
			unset($fields[$k]);
			continue;
		}

		$fieldType = isset($info['TYPE']) ? $info['TYPE'] : '';
		if($fieldType === 'date')
		{
			if(!is_array($v))
			{
				$fields[$k] = CRestUtil::ConvertDate($v);
			}
			else
			{
				$fields[$k] = array();
				foreach($v as &$value)
				{
					$fields[$k][] = CRestUtil::ConvertDate($value);
				}
				unset($value);
			}
		}
		elseif($fieldType === 'datetime')
		{
			if(!is_array($v))
			{
				$fields[$k] = CRestUtil::ConvertDateTime($v);
			}
			else
			{
				$fields[$k] = array();
				foreach($v as &$value)
				{
					$fields[$k][] = CRestUtil::ConvertDateTime($value);
				}
				unset($value);
			}
		}
		elseif($fieldType === 'file')
		{
			self::tryExternalizeFileField($fields, $k, $isMultiple, $isDynamic);
		}
		elseif($fieldType === 'webdav')
		{
			self::tryExternalizeWebDavElementField($fields, $k, $isMultiple);
		}
		elseif($fieldType === 'diskfile')
		{
			self::tryExternalizeDiskFileField($fields, $k, $isMultiple);
		}
	}
}

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