- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/file.php
- Класс: CWebDavFile
- Вызов: CWebDavFile::Undelete
function Undelete($options)
{
$io = self::GetIo();
$options["path"] = $io->CombinePath(static::_udecode($options["path"]));
if(!$this->CheckRights("UNDELETE", true, $options["path"]))
{
$this->ThrowAccessDenied();
return "403 Forbidden";
}
if (! isset($options['dest_url']))
{
$arParams = $this->_get_props($options['path']);
$options["dest_url"] = $arParams["UNDELETEBX:"]['value'];
}
if (! isset($options['dest_url']))
return "404 Not Found";
$this->IsDir(array("path" => $options["dest_url"]), $this->replace_symbols);
$options["dest_url"] = $this->_udecode($options["dest_url"]);
$arTo = $this->arParams;
if ($arTo["not_found"])
{
do {
$this->IsDir(array('path' => rtrim($this->arParams['parent_id'], '/')));
} while (($this->arParams["parent_id"] != '') && ($this->arParams["not_found"]));
if ($this->arParams['not_found'])
{
$options['dest_url'] = $io->CombinePath("/", $arTo['base_name']);
}
else
{
$options['dest_url'] = $io->CombinePath($this->arParams["item_id"], $arTo["base_name"]);
}
}
$this->IsDir($options);
$bIsDir = ($this->arParams['is_dir']);
if ($this->arParams["not_found"] === true)
{
return "404 Not Found";
}
else
{
$result = $this->MOVE($options);
if (in_array(intval($result), array(201, 204))) // remove the "UNDELETE" in props
{
if (! $bIsDir)
{
$options["props"] = array(array("ns"=>"BX:","name"=>"UNDELETE"));
$options["path"] = $options["dest_url"];
$this->PROPPATCH($options);
}
else
{
$params = $this->GetFilesAndFolders($options['dest_url']);
if (!empty($params))
{
$tmpParams = $this->arParams;
sort($params, SORT_STRING);
foreach ($params as $file)
{
$localpath = str_replace(array($this->real_path_full, "///", "//"), "/", $file);
$arUndeleteOptions = array("props" => array( array("ns"=>"BX:", "name"=>"UNDELETE") ), "path" => $localpath);
$this->PROPPATCH($arUndeleteOptions);
}
$this->arParams = $tmpParams;
}
}
return "204 No Content";
}
else
{
return "404 Not Found";
}
}
}