Helper::getFilterUserFields

  1. Bitrix24 API (v. 23.675.0)
  2. sender
  3. Helper
  4. getFilterUserFields
  • Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/integration/crm/connectors/helper.php
  • Класс: Bitrix\Sender\Integration\Crm\Connectors\Helper
  • Вызов: Helper::getFilterUserFields
static function getFilterUserFields(int $entityTypeId, bool $checkAccessRights = true): array
{
	$list = array();
	$ufManager = is_object($GLOBALS['USER_FIELD_MANAGER']) ? $GLOBALS['USER_FIELD_MANAGER'] : null;
	if (!$ufManager)
	{
		return $list;
	}

	$ufEntityId = \CCrmOwnerType::resolveUserFieldEntityID($entityTypeId);
	$crmUserType = new \CCrmUserType($ufManager, $ufEntityId);
	$logicFilter = array();
	$fieldsParams = [];

	if (!$checkAccessRights)
	{
		$fieldsParams = ['skipUserFieldVisibilityCheck' => true];
	}
	$crmUserType->prepareListFilterFields($list, $logicFilter, $fieldsParams);
	$originalList = $crmUserType->getFields($fieldsParams);
	$restrictedTypes = ['address', 'file', 'crm', 'resourcebooking'];

	$list = array_filter(
		$list,
		function ($field) use ($originalList, $restrictedTypes)
		{
			if (empty($originalList[$field['id']]))
			{
				return false;
			}

			$type = $originalList[$field['id']]['USER_TYPE']['USER_TYPE_ID'];
			return !in_array($type, $restrictedTypes);
		}
	);

	foreach ($list as $index => $field)
	{
		if ($field['type'] === 'date')
		{
			$list[$index]['include'] = [
				AdditionalDateType::CUSTOM_DATE,
				AdditionalDateType::PREV_DAY,
				AdditionalDateType::NEXT_DAY,
				AdditionalDateType::MORE_THAN_DAYS_AGO,
				AdditionalDateType::AFTER_DAYS,
			];
			if (!isset($list[$index]['allow_years_switcher']))
			{
				$list[$index]['allow_years_switcher'] = true;
			}
		}
		if ($originalList[$field['id']]['MULTIPLE'] == 'Y')
		{
			$list[$index]['multiple_uf'] = true;
		}
	}

	return $list;
}

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