• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
  • Класс: CWebDavIblock
  • Вызов: CWebDavIblock::SendHistoryFile
function SendHistoryFile($ID, $WF_ID = 0, $NotCheckWebRights = false, $params = array()) // wrong
{
	$ID = intval($ID);
	$WF_ID = intval($WF_ID);
	if($ID <=0)
	{
		return;
	}

	list($contextType, $contextEntityId) = $this->getContextData();
	if(CWebDavSymlinkHelper::isLinkElement($contextType, $contextEntityId, $ID))
	{
		$parentSectionData = CWebDavSymlinkHelper::getLinkDataOfElement($contextType, $contextEntityId, $ID);
		if($parentSectionData)
		{
			$linkWebdav = new self($parentSectionData[self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array(
				'ROOT_SECTION_ID' => $parentSectionData[self::UF_LINK_SECTION_ID],
				'symlinkMode' => true,
				'symlinkSectionData' => $parentSectionData,
				'symlinkRealRootSectionData' => $this->arRootSection,
			));
			if($this->withoutAuthorization)
			{
				$linkWebdav->withoutAuthorization = true;
			}
			return $linkWebdav->SendHistoryFile($ID, $WF_ID, $NotCheckWebRights, $params);
		}
	}

	$io = self::GetIo();
	list($arFile, $options, $fullpath, $filename) = $this->getHistoryFileData($ID, $WF_ID, $params);

	if (empty($arFile))
	{
		return;
	}

	$options["logica_full_path"] = $fullpath;
	if (!file_exists($fullpath) && file_exists($io->GetPhysicalName($fullpath)))
		$fullpath = $io->GetPhysicalName($fullpath);

	$options["path"] = $this->_path;
	$options["mimetype"] = (
	(!empty($arFile["CONTENT_TYPE"]) && $arFile["CONTENT_TYPE"] != "unknown" && $arFile["CONTENT_TYPE"] != "application/octet-stream") ?
		$arFile["CONTENT_TYPE"] : $this->get_mime_type($filename));
	$options["size"] = !empty($arFile["FILE_SIZE"]) ? $arFile["FILE_SIZE"] : 0;
	$options["name"] = $filename;
	if(!$NotCheckWebRights)
	{
		$arElementData = $this->GetObject(array("element_id" => $ID, "check_permissions" => false), false);
		if(!$this->CheckWebRights("",  array("action" => "read", "arElement" => $arElementData), false))
		{
			return;
		}
	}
	if ($options["resized"] == "Y" || $params["cache_image"] == "Y")
	{
		CFile::ViewByUser($arFile, array("content_type" => $options["mimetype"], "cache_time" => $options["cache_time"]));
	}
	if (file_exists($fullpath))
	{
		if(empty($options['size']))
		{
			$options['size'] = filesize($fullpath);
		}
		$options["mtime"] = filemtime($fullpath);
		$options["stream"] = fopen($fullpath, "r");
	}
	$x = $this->SendFile($options); //, true
}