- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmProductPropertyRestProxy
- Вызов: CCrmProductPropertyRestProxy::innerDelete
protected function innerDelete($id, &$errors, array $params = null)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
if(!CModule::IncludeModule('iblock'))
{
throw new RestException('Could not load iblock module.');
}
/** @var CCrmPerms $userPerms */
$userPerms = CCrmPerms::GetCurrentUserPermissions();
if (!$userPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE'))
{
$errors[] = 'Access denied.';
return false;
}
$iblockId = intval(CCrmCatalog::EnsureDefaultExists());
$userTypes = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'rest');
$res = CIBlockProperty::GetByID($id, $iblockId);
$result = false;
if (is_object($res))
$result = $res->Fetch();
unset($res);
if(!is_array($result)
|| (isset($result['USER_TYPE']) && !empty($result['USER_TYPE'])
&& !array_key_exists($result['USER_TYPE'], $userTypes)))
{
$errors[] = 'Not found';
return false;
}
if(!CIBlockProperty::Delete($id))
{
if($e = $APPLICATION->GetException())
$errors[] = $e->GetString();
else
$errors[] = 'Error on deleting product property.';
return false;
}
return true;
}