CCrmComponentHelper::EnsureFormTabPresent

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmComponentHelper
  4. EnsureFormTabPresent
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
  • Класс: \CCrmComponentHelper
  • Вызов: CCrmComponentHelper::EnsureFormTabPresent
static function EnsureFormTabPresent(&$tabs, $tab, $index = -1)
{
	if(!is_array($tabs) || empty($tabs) || !is_array($tab))
	{
		return false;
	}

	$tabID = isset($tab['id']) ? $tab['id'] : '';
	if($tabID === '')
	{
		return false;
	}

	$isFound = false;
	foreach($tabs as &$curTab)
	{
		$curTabID = isset($curTab['id']) ? $curTab['id'] : '';
		if($curTabID === $tabID)
		{
			$isFound = true;
			break;
		}
	}
	unset($curTab);

	if($isFound)
	{
		return false;
	}

	foreach($tab['fields'] as &$field)
	{
		if(isset($field['value']))
		{
			unset($field['value']);
		}
	}
	unset($field);

	$index = intval($index);
	if($index < 0 || $index >= count($tabs))
	{
		$tabs[] = $tab;
	}
	else
	{
		array_splice($tabs, $index, 0, array($tab));
	}
	return true;
}

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