- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
- Класс: CWebDavIblock
- Вызов: CWebDavIblock::_move_to_trash
function _move_to_trash(&$options)
{
self::$trashCache = array();
$this->IsDir($options);
$bIsDir = $this->arParams["is_dir"];
if ($bIsDir)
$arElement = $this->arParams['dir_array'];
else
$arElement = $this->arParams['element_array'];
if ($arElement['IBLOCK_SECTION_ID'] === null)
$arElement['IBLOCK_SECTION_ID'] = 0;
$sOriginalName = str_replace(array('///', '//'), '/', $this->_get_path($arElement['IBLOCK_SECTION_ID'], false) .'/'.$arElement['NAME']); // false in _get_path - for correct ru names in trash recovery param
$arUndeleteOptions = $options;
$arUndeleteOptions["props"][] = array("ns"=>"BX:", "name"=>"UNDELETE", "val"=>$sOriginalName);
$this->PROPPATCH($arUndeleteOptions);
$this->CACHE['CWebDavIblock::GetObject'] = array();
if ($bIsDir)
{
$arDeleteSections = array($options["section_id"]);
$this->_onEvent('Trash', $arElement["ID"], 'FOLDER');
$markDeleteSection = null;
$markDeleteSection = CWebDavDiskDispatcher::addElementForDeletingMark($arElement, $arElement);
reset($arDeleteSections);
while($sectionID = current($arDeleteSections))
{
$dbDeleteItems = $this->_get_mixed_list($sectionID);
while ($arDeleteItem = $dbDeleteItems->Fetch())
{
$sOriginalName = str_replace(array('///', '//'), '/', $this->_get_path($arDeleteItem["IBLOCK_SECTION_ID"], false) .'/'.$arDeleteItem['NAME']);
$arUndeleteOptions = array("props" => array( array("ns"=>"BX:", "name"=>"UNDELETE", "val"=>$sOriginalName)));
if ($arDeleteItem["TYPE"] == "S")
{
$arUndeleteOptions["section_id"] = $arDeleteItem["ID"];
$arDeleteSections[] = $arDeleteItem["ID"];
if($markDeleteSection)
{
CWebDavDiskDispatcher::addElementForDeletingMark($arDeleteItem, $arElement);
}
$this->_onEvent('Trash', $arDeleteItem['ID'], 'FOLDER');
}
else
{
$arUndeleteOptions["element_id"] = $arDeleteItem["ID"];
if($markDeleteSection)
{
CWebDavDiskDispatcher::addElementForDeletingMark($arDeleteItem, $arElement, false);
}
$this->_onEvent('Trash', $arDeleteItem['ID']);
}
$this->PROPPATCH($arUndeleteOptions);
}
next($arDeleteSections);
}
}
else
{
CWebDavDiskDispatcher::addElementForDeletingMark($arElement, null, false);
$this->_onEvent('Trash', $this->arParams['element_id']);
}
if ($bIsDir)
{
CWebDavSymlinkHelper::setSectionOriginalName($this->arParams['dir_array']['ID'], $this->arParams['dir_array']['NAME']);
$destName = $this->arParams['dir_array']['NAME'] . " " . $this->CorrectName(ConvertTimeStamp(time(), "FULL"));
}
else
{
if (mb_strlen($this->arParams['file_extention']) > 1)
{
$destName = mb_substr($this->arParams['element_name'], 0, -mb_strlen($this->arParams['file_extention']))." " . $this->CorrectName(ConvertTimeStamp(time(), "FULL")) . $this->arParams['file_extention'];
}
else
{
$destName = $this->arParams['element_name'] . " " . $this->CorrectName(ConvertTimeStamp(time(), "FULL")) . ".noext";
}
}
$destName = str_replace("/", "_", $destName);
$options['dest_url'] = "/".$this->meta_names['TRASH']['name']."/".$destName;
$options['rename'] = true;
$this->events_enabled = false;
$status = $this->MOVE($options);
$this->events_enabled = true;
if(intval($status) > 200 && intval($status) < 300)
{
CWebDavDiskDispatcher::markDeleteBatch();
}
else
{
CWebDavDiskDispatcher::clearDeleteBatch();
}
if (intval($status) == 201)
{
return "204 No Content";
}
else
{
$GLOBALS["APPLICATION"]->ResetException();
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("WD_FILE_ERROR16"), "FILE_OR_FOLDER_TRASH_ERROR");
return $status;
}
}