- Модуль: rest
- Путь к файлу: ~/bitrix/modules/rest/classes/general/restentity.php
- Класс: CBitrixRestEntity
- Вызов: CBitrixRestEntity::entityItemPropertyUpdate
static function entityItemPropertyUpdate($params, $n, $server)
{
if(self::checkItemPropertyParams($params))
{
if(self::checkEntity($params['ENTITY'], $server))
{
$arField = self::getItemProperty($params['PROPERTY'], $params['ENTITY'], $server);
if($arField)
{
if(CIBlockRights::UserHasRightTo($arField['IBLOCK_ID'], $arField['IBLOCK_ID'], 'iblock_edit'))
{
$arPropFields = array();
if(isset($params['PROPERTY_NEW']) && $params['PROPERTY_NEW'] != $params['PROPERTY'])
{
if (self::checkItemProperty($params['PROPERTY_NEW'], $params['ENTITY'], $server))
{
throw new RestException ('Property '.$params['PROPERTY_NEW'].' already exists', self::ERROR_PROPERTY_ALREADY_EXISTS);
}
$arPropFields["CODE"] = $params['PROPERTY_NEW'];
}
if(isset($params['NAME']))
{
$arPropFields['NAME'] = trim($params['NAME']);
}
if(isset($params['SORT']))
{
$arPropFields['SORT'] = trim($params['SORT']);
}
if(isset($params['TYPE']) && $arField['PROPERTY_TYPE'] != $params['TYPE'])
{
if($params['TYPE'] == 'F')
{
throw new BitrixMainArgumentException('Cannot change property type to File', "TYPE");
}
// elseif($params['TYPE'] == 'L')
// {
// throw new BitrixMainNotSupportedException(self::ERROR_UNSUPPORTED_PROPERTY_TYPE);
// }
else
{
$arPropFields['PROPERTY_TYPE'] = $params['TYPE'];
}
}
$ibp = new CIBlockProperty;
if(!$ibp->Update($arField['ID'], $arPropFields))
{
throw new RestException($ibp->LAST_ERROR, RestException::ERROR_CORE);
}
return true;
}
else
{
throw new AccessException();
}
}
else
{
throw new RestException('Property not found', self::ERROR_PROPERTY_NOT_FOUND);
}
}
else
{
throw new RestException('Entity not found', self::ERROR_ENTITY_NOT_FOUND);
}
}
}