CCrmStatusRestProxy::innerAdd

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmStatusRestProxy
  4. innerAdd
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmStatusRestProxy
  • Вызов: CCrmStatusRestProxy::innerAdd
protected function innerAdd(&$fields, &$errors, array $params = null)
{
	if(!CCrmStatus::CheckCreatePermission())
	{
		$errors[] = 'Access denied.';
		return false;
	}

	$entityID = $fields['ENTITY_ID'] ?? '';
	$statusID = $fields['STATUS_ID'] ?? '';
	$color = $fields['COLOR'] ?? $fields['EXTRA']['COLOR'] ?? '';
	if($entityID === '' || $statusID === '')
	{
		if($entityID === '')
		{
			$errors[] = 'The field ENTITY_ID is required.';
		}

		if($statusID === '')
		{
			$errors[] = 'The field STATUS_ID is required.';
		}

		return false;
	}

	$entityTypes = self::prepareEntityTypes();
	if(!isset($entityTypes[$entityID]))
	{
		$errors[] = 'Specified entity type is not supported.';
		return false;
	}

	$fields['SYSTEM'] = 'N';
	$fields['COLOR'] = $color;
	$entity = new CCrmStatus($entityID);
	$result = $entity->Add($fields, true);
	if($result === false)
	{
		$errors[] = $entity->GetLastError();
	}
	return $result;
}

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