- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
- Класс: CWebDavIblock
- Вызов: CWebDavIblock::getHistoryFileData
public function getHistoryFileData($id, $wfId, &$params)
{
$fullpath = '';
$options = $arFile = $arr = array();
$io = self::GetIo();
$arFilter = array(
"IBLOCK_ID" => (isset($this->arParams['element_array']['ID']) && $this->arParams['element_array']['ID'] == $id)? $this->arParams['element_array']['IBLOCK_ID'] : $this->IBLOCK_ID,
"ID" => $id,
"SHOW_HISTORY" => "Y",
"CHECK_PERMISSIONS" => "Y"
);
if ($this->permission < "U")
{
$arFilter["SHOW_HISTORY"] = "N";
}
if (($this->workflow == 'bizproc' || $this->workflow == 'bizproc_limited') && $wfId > 0)
{
$history = new CBPHistoryService();
$db_res = $history->GetHistoryList(array("ID" => "DESC"),
array(
"DOCUMENT_ID" => array(
$this->wfParams['DOCUMENT_TYPE'][0],
$this->wfParams['DOCUMENT_TYPE'][1],
$id
),
"ID" => $wfId
), false, false, array("ID", "DOCUMENT", "NAME"));
if ($db_res && $arr = $db_res->Fetch())
{
$arFile = array(
"SRC" => $arr["DOCUMENT"]["PROPERTIES"][$this->file_prop]["VALUE"],
"NAME" => $arr["DOCUMENT"]["NAME"]
);
$arr["NAME"] = $arr["DOCUMENT"]["NAME"];
$fullpath = urldecode($arFile["SRC"]);
if (mb_substr($fullpath, 0, 4) != "http")
{
$fullpath = $io->GetPhysicalName($_SERVER['DOCUMENT_ROOT'] . $arFile["SRC"]);
}
else
{
$fullpath = CWebDavTools::urlEncode($fullpath);
}
$arTmpFile = CFile::MakeFileArray($fullpath);
$fullpath = $arTmpFile['tmp_name'];
$arFile["FILE_SIZE"] = $arTmpFile["size"];
}
}
else
{
$arFilter['CHECK_PERMISSIONS'] = 'N'; //check permissions manual! While infoblock perm's check by every section's (in dropped - we have error).
$rs = CIBlockElement::GetList(array(), $arFilter, false, array("nTopCount" => 1), array(
"ID",
"NAME",
"TIMESTAMP_X",
"IBLOCK_ID",
"PROPERTY_" . $this->file_prop
));
if ($rs && $arr = $rs->Fetch())
{
if (empty($this->arParams["element_array"]))
$this->arParams["element_array"] = $arr;
$arFile = CFile::GetFileArray($arr["PROPERTY_FILE_VALUE"]);
$options["from_cloud"] = (intval($arFile['HANDLER_ID']) > 0 ? "Y" : "N");
$arTmpFile = array();
if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"]))
{
if ($params["width"] > 0 || $params["height"] > 0)
{
$arTmpFile = CFile::ResizeImageGet($arFile, array(
"width" => $params["width"],
"height" => $params["height"]
), ($params["exact"] == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL), true, false, true);
$arTmpFile['tmp_name'] = ($options["from_cloud"] == "Y" ? "" : $_SERVER["DOCUMENT_ROOT"]) . $arTmpFile["src"];
$options["resized"] = "Y";
$arFile["FILE_SIZE"] = $arTmpFile["size"];
$arFile["SRC"] = $arTmpFile["src"];
}
if ($params["cache_image"] == "Y")
{
$options["cache_time"] = 86400;
}
}
else
{
$params["cache_image"] = "N";
}
if (empty($arTmpFile))
{
$arTmpFile = CFile::MakeFileArray($arr["PROPERTY_FILE_VALUE"]);
}
$fullpath = $arTmpFile['tmp_name'];
}
}
$elementName = $arr['NAME'];
return array($arFile, $options, $fullpath, $elementName);
}