- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
- Класс: CWebDavIblock
- Вызов: CWebDavIblock::_ib_elm_add
function _ib_elm_add($arFields, $bWorkFlow=false, $bUpdateSearch=true, $bResizePictures=false)
{
global $USER_FIELD_MANAGER;
global $APPLICATION;
$bUF = (isset($arFields['USER_FIELDS']));
if ($bUF)
{
$UF_ENTITY = $this->GetUfEntity();
if ( ! $USER_FIELD_MANAGER->CheckFields($UF_ENTITY, 0, $arFields['USER_FIELDS']))
{
if(is_object($APPLICATION) && $APPLICATION->GetException())
{
$e = $APPLICATION->GetException();
$this->LAST_ERROR .= $e->GetString();
return false;
}
}
$handlerID = AddEventHandler('search', 'BeforeIndex', array($this, 'IndexUfValues'));
}
if ($bUpdateSearch && $bUF)
$bUpdateSearch = false;
$el = new CIBlockElement();
$result = $el->Add($arFields, $bWorkFlow, $bUpdateSearch, $bResizePictures);
$ID = intval($result);
if ($ID <= 0)
{
$this->LAST_ERROR = $el->LAST_ERROR;
return false;
}
else
{
if (
isset($arFields['PROPERTY_VALUES'])
&& ! $this->ValidatePropertyValues($ID, $arFields['PROPERTY_VALUES'], $arFields['IBLOCK_ID']) // as SetPropertyValues doesn't handle SaveFile errors
)
{
$this->LAST_ERROR = GetMessage("WD_FILE_ERROR111");
$el->Delete($ID);
return false;
}
if ($bUF)
{
$USER_FIELD_MANAGER->Update($UF_ENTITY, $ID, $arFields['USER_FIELDS']);
$el->UpdateSearch($ID, true);
}
$this->_onEvent('Add', $ID);
}
if ($bUF)
RemoveEventHandler('search', 'BeforeIndex', $handlerID);
CWebDavDiskDispatcher::sendEventToOwners(null, array(
'IBLOCK_ID' => (int)$arFields['IBLOCK_ID'],
'ID' => (int)$arFields['IBLOCK_SECTION_ID'],
), 'add');
return (int) $result;
}