- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
- Класс: CWebDavIblock
- Вызов: CWebDavIblock::_ib_elm_update
function _ib_elm_update($id, $arFields, $workflow=false)
{
global $APPLICATION;
global $USER_FIELD_MANAGER;
if (is_string($workflow))
$workflow = ($workflow == 'workflow');
$id = intval($id);
if ($id <= 0)
return false;
$bUF = (isset($arFields['USER_FIELDS']));
if ($bUF)
{
$UF_ENTITY = $this->GetUfEntity();
if ( ! $USER_FIELD_MANAGER->CheckFields($UF_ENTITY, $id, $arFields['USER_FIELDS']))
{
if(is_object($APPLICATION) && $APPLICATION->GetException())
{
$e = $APPLICATION->GetException();
$this->LAST_ERROR .= $e->GetString();
return false;
}
}
}
$el = new CIBlockElement;
if ($workflow)
{
if ($bUF)
$handlerID = AddEventHandler('search', 'BeforeIndex', array($this, 'IndexUfValues'));
$result = $el->Update($id, $arFields, $workflow);
if ($bUF)
RemoveEventHandler('search', 'BeforeIndex', $handlerID);
if(!$result)
{
$this->LAST_ERROR = $el->LAST_ERROR;
return false;
}
else
{
if (isset($arFields['USER_FIELDS']))
{
$USER_FIELD_MANAGER->Update($UF_ENTITY, $id, $arFields['USER_FIELDS']);
}
}
}
else
{
$arFields['WF_STATUS_ID'] = 1;
$arProperties = (isset($arFields['PROPERTY_VALUES']) ? $arFields['PROPERTY_VALUES'] : false);
unset($arFields['PROPERTY_VALUES']);
if ($bUF)
$handlerID = AddEventHandler('search', 'BeforeIndex', array($this, 'IndexUfValues'));
if ($arProperties !== false)
{
if(
isset($this->arParams['element_array']['ID']) &&
isset($this->arParams['element_array']['IBLOCK_ID']) &&
$this->arParams['element_array']['ID'] == $id
)
{
$iblockId = $this->arParams['element_array']['IBLOCK_ID'];
}
else
{
$iblockId = $this->IBLOCK_ID;
}
foreach ($arProperties as $code => $value)
{
if($code === 'FILE')
{
$el->SetPropertyValuesEx($id, $iblockId, array($code => $value));
}
else
{
$el->SetPropertyValues($id, $iblockId, $value, $code);
}
}
if (! $this->ValidatePropertyValues($id, $arProperties, $iblockId)) // as SetPropertyValues doesn't handle SaveFile errors
{
$this->LAST_ERROR = GetMessage("WD_FILE_ERROR111");
return false;
}
}
if (isset($arFields['USER_FIELDS'])
&& !empty($arFields['USER_FIELDS'])
)
{
$USER_FIELD_MANAGER->Update($UF_ENTITY, $id, $arFields['USER_FIELDS']);
}
$result = $el->Update($id, $arFields, $workflow, true);
if(!$result)
{
if ($bUF)
RemoveEventHandler('search', 'BeforeIndex', $handlerID);
$this->LAST_ERROR = $el->LAST_ERROR;
return false;
}
if ($bUF)
RemoveEventHandler('search', 'BeforeIndex', $handlerID);
}
$element = CIBlockElement::GetList(array(), array('ID' => $id), false, false,
array('ID', 'IBLOCK_SECTION_ID', 'IBLOCK_CODE', 'IBLOCK_ID'))->fetch();
CWebDavDiskDispatcher::sendEventToOwners($element, null, 'update');
return $result;
}