CCrmActivityRestProxy::innerDelete

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmActivityRestProxy
  4. innerDelete
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmActivityRestProxy
  • Вызов: CCrmActivityRestProxy::innerDelete
protected function innerDelete($ID, &$errors, array $params = null)
{
	$currentFields = CCrmActivity::GetByID($ID);
	if(!is_array($currentFields))
	{
		$errors[] = 'Activity is not found.';
		return false;
	}

	if(!CCrmActivity::CheckDeletePermission(
		$currentFields['OWNER_TYPE_ID'], $currentFields['OWNER_ID']))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	if ($currentFields['PROVIDER_ID'] === \Bitrix\Crm\Activity\Provider\RestApp::getId())
	{
		$clientId = $this->getServer()->getClientId();
		$application = $clientId ? \Bitrix\Rest\AppTable::getByClientId($clientId) : null;

		if (!$application)
		{
			$errors[] = 'Application context required.';
			return false;
		}

		if ($currentFields['ASSOCIATED_ENTITY_ID'] !== $application['ID'])
		{
			$errors[] = 'Access denied.';
			return false;
		}
	}

	$result = CCrmActivity::Delete($ID, false, true, array());
	if($result === false)
	{
		$errors[] = CCrmActivity::GetLastErrorMessage();
	}

	return $result;
}

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