- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
- Класс: CWebDavIblock
- Вызов: CWebDavIblock::Undelete
function Undelete($options)
{
$this->IsDir($options);
if(!$this->CheckWebRights("UNDELETE", array('action' => 'undelete', 'arElement' => $this->arParams)))
return $this->ThrowAccessDenied(__LINE__);
$bIsDir = ($this->arParams['is_dir']);
if ($this->arParams["not_found"] === true)
return "404 Not Found";
if (!isset($options['dest_url']))
{
$arElement = $this->arParams[($this->arParams['dir_array']?'dir_array':'element_array')];
if ( $this->_parse_webdav_info($arElement) &&
isset($arElement['PROPS']['BX:']['UNDELETE']))
$options['dest_url'] = $arElement['PROPS']['BX:']['UNDELETE'];
}
if (!isset($options['dest_url']))
return "404 Not Found";
$this->events_enabled = false;
$result = $this->MOVE($options);
$this->events_enabled = true;
if (in_array(intval($result), array(201, 204))) // remove the "UNDELETE" in WEBDAV_INFO
{
$options["props"] = array(array("ns"=>"BX:","name"=>"UNDELETE"));
$this->PROPPATCH($options);
if ($bIsDir)
{
$this->_onEvent('Restore', $options["section_id"], 'FOLDER');
$arUndeleteSections = array($options["section_id"]);
reset($arUndeleteSections);
while($sectionID = current($arUndeleteSections))
{
$dbUndeleteItems = $this->_get_mixed_list($sectionID);
while ($arUndeleteItem = $dbUndeleteItems->Fetch())
{
if ($arUndeleteItem["TYPE"] == "S")
{
$arUndeleteSections[] = $arUndeleteItem["ID"];
}
$arUndeleteOptions = array("props" => array( array("ns"=>"BX:", "name"=>"UNDELETE")));
if ($arUndeleteItem["TYPE"] == "S")
$arUndeleteOptions["section_id"] = $arUndeleteItem["ID"];
else
$arUndeleteOptions["element_id"] = $arUndeleteItem["ID"];
$this->PROPPATCH($arUndeleteOptions);
if ($arUndeleteItem["TYPE"] == "S")
$this->_onEvent('Restore', $arUndeleteItem["ID"], 'FOLDER');
else
{
$this->_onEvent('Restore', $arUndeleteItem["ID"]);
$el = new CIBlockElement;
$el->Update($arUndeleteItem["ID"], array('TIMESTAMP_X' => true), false, false);
}
}
next($arUndeleteSections);
}
}
else
{
$this->_onEvent('Restore', $options['element_id']);
}
$this->ClearCache("section");
return "204 No Content";
}
else
{
return "404 Not Found";
}
}