• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/iblockbizprochistory.php
  • Класс: CWebdavDocumentHistory
  • Вызов: CWebdavDocumentHistory::GetHistoryState
static function GetHistoryState($documentID, $historyID = null, $arDocHistory = null, $arParams = array())
{
	static $WD_HISTORYGLUE_PERIOD = null;

	static $arHistoryFields = array("ID", "DOCUMENT_ID", "MODIFIED", "DOCUMENT");

	$historyService = self::GetHistoryService();

	$result = 'N';
	if (self::IsGlueEnabled())
	{
		$result = 'Y';

		if ($WD_HISTORYGLUE_PERIOD == null)
			$WD_HISTORYGLUE_PERIOD = COption::GetOptionString('webdav', 'bp_history_glue_period', 300);

		if ($historyID == null || $arDocHistory == null)
		{
			if ($historyID == null)
			{
				$arFilter = array(
					"DOCUMENT_ID" => $documentID
				);
			}
			else
			{
				$arFilter = array(
					"ID" => $historyID
				);
			}

			$dbDoc = $historyService->GetHistoryList(
				array("ID" => "DESC"),
				$arFilter,
				false,
				false,
				$arHistoryFields
			);

			CTimeZone::Disable();
			if (!($dbDoc && $arDocHistory = $dbDoc->Fetch()))
				$result = 'N';
			if (isset($arParams['NEW']) && $arParams['NEW'] == 'Y')
			{
				$arDocHistory = $dbDoc->Fetch();
			}
			CTimeZone::Enable();
		}

		if (($result == 'Y') && isset($arDocHistory['DOCUMENT']['PROPERTIES']['FILE']['HISTORYGLUE'])) // last history record is 'glued'
		{
			$result = $arDocHistory['DOCUMENT']['PROPERTIES']['FILE']['HISTORYGLUE'];
			if (isset($arParams['CHECK_TIME']) && $arParams['CHECK_TIME'] == 'Y')
			{
				$result = "Y";
				$modifiedTS = MakeTimeStamp($arDocHistory['MODIFIED']);
				if ((time() - $modifiedTS) > $WD_HISTORYGLUE_PERIOD)
				{
					$result = 'N';
				}
			}
		}
		else
		{
			$result = 'N';
		}
	}

	return $result;
}