• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/userfieldproxy.php
  • Класс: BitrixRestUserFieldProxy
  • Вызов: UserFieldProxy::delete
public function delete($ID)
{
	global $APPLICATION;

	if(!is_int($ID))
	{
		$ID = (int)$ID;
	}

	if($ID <= 0)
	{
		throw new RestException('ID is not defined or invalid.');
	}

	if(!$this->checkDeletePermission())
	{
		throw new RestException('Access denied.');
	}

	$entity = new CUserTypeEntity();
	$dbResult = $entity->GetList(array(), array('ID' => $ID));
	$persistedFields = is_object($dbResult) ? $dbResult->Fetch() : null;
	if(!is_array($persistedFields))
	{
		throw new RestException("The entity with ID '{$ID}' is not found.", RestException::ERROR_NOT_FOUND);
	}

	$entityID = isset($persistedFields['ENTITY_ID']) ? $persistedFields['ENTITY_ID'] : '';
	if($entityID !== $this->entityID)
	{
		throw new RestException('Access denied.');
	}

	if($entity->Delete($ID) === false)
	{
		$exc = $APPLICATION->GetException();
		throw new RestException(
			$exc !== false ? $exc->GetString() : 'Fail to delete user field.',
			RestException::ERROR_CORE
		);
	}
	return true;
}