CCrmStatusRestProxy::innerUpdate

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

	$dbResult = CCrmStatus::GetList(array(), array('ID' => $ID));
	$currentFields = $dbResult ? $dbResult->Fetch() : null;
	if(!is_array($currentFields))
	{
		$errors[] = 'Status is not found.';
		return false;
	}

	if(!isset($fields['COLOR']) && isset($fields['EXTRA']['COLOR']))
	{
		$fields['COLOR'] = $fields['EXTRA']['COLOR'];
	}
	$result = true;
	if(isset($fields['NAME']) || isset($fields['SORT']) || isset($fields['STATUS_ID']) || isset($fields['COLOR']))
	{
		if(!isset($fields['NAME']))
		{
			$fields['NAME'] = $currentFields['NAME'];
		}

		if(!isset($fields['SORT']))
		{
			$fields['SORT'] = $currentFields['SORT'];
		}
		$entity = new CCrmStatus($currentFields['ENTITY_ID']);
		$result = $entity->Update($ID, $fields);
		if($result === false)
		{
			$errors[] = $entity->GetLastError();
		}
	}

	return $result !== false;

}

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