CCrmStatusRestProxy::innerDelete

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmStatusRestProxy
  4. innerDelete
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmStatusRestProxy
  • Вызов: CCrmStatusRestProxy::innerDelete
protected function innerDelete($ID, &$errors, array $params = null)
{
	if(!CCrmStatus::CheckDeletePermission($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;
	}

	$isSystem = isset($currentFields['SYSTEM']) && $currentFields['SYSTEM'] === 'Y';
	$forced = is_array($params) && isset($params['FORCED']) && $params['FORCED'] === 'Y';

	if($isSystem && !$forced)
	{
		$errors[] = 'CRM System Status can be deleted only if parameter FORCED is specified and equal to "Y".';
		return false;
	}

	$entity = new CCrmStatus($currentFields['ENTITY_ID']);
	if(isset($currentFields['STATUS_ID']) && $entity->existsEntityWithStatus($currentFields['STATUS_ID']))
	{
		$errors[] = 'There are active items in this status.';
		return false;
	}

	$result = $entity->Delete($ID);
	if($result === false)
	{
		$errors[] = $entity->GetLastError();
	}
	return $result !== false;
}

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