• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/classes/general/restentity.php
  • Класс: CBitrixRestEntity
  • Вызов: CBitrixRestEntity::entityItemDelete
static function entityItemDelete($params, $n, $server)
{
	if(self::checkItemParams($params))
	{
		$params['ID'] = intval($params['ID']);
		if($params['ID'] <= 0)
		{
			throw new BitrixMainArgumentNullException("ID");
		}
		else
		{
			$arIBlock = self::getIBlock(self::getEntityIBlockCode($params['ENTITY'], $server));
			if($arIBlock)
			{
				if(CIBlockRights::UserHasRightTo($arIBlock['ID'], $arIBlock['ID'], 'element_delete'))
				{
					$dbRes = CIBlockElement::GetList(array(), array(
						'ID' => $params['ID'],
						'IBLOCK_ID' => $arIBlock['ID']
					));
					$arRes = $dbRes->Fetch();
					if($arRes)
					{
						if(!CIBlockElement::Delete($params['ID']))
						{
							throw new RestException('Unable to delete item', RestException::ERROR_CORE);
						}

						return true;
					}
					else
					{
						throw new RestException('Item not found', self::ERROR_ITEM_NOT_FOUND);
					}
				}
				else
				{
					throw new AccessException();
				}
			}
			else
			{
				throw new RestException('Entity not found', self::ERROR_ENTITY_NOT_FOUND);
			}
		}
	}
}