- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblockbizprochistory.php
- Класс: CWebdavDocumentHistory
- Вызов: CWebdavDocumentHistory::GetFileForHistory
static function GetFileForHistory($documentId, $propertyValue, $historyIndex)
{
$newFileID = $propertyValue['VALUE'];
$bNewFile = true;
$history = self::GetHistoryService();
$dbDoc = $history->GetHistoryList(
array("ID" => "DESC"),
array("DOCUMENT_ID" => $documentId),
false,
false,
array("ID", "DOCUMENT_ID", "NAME", "MODIFIED", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "DOCUMENT")
);
$newFileHash = CWebDavBase::_get_file_hash($newFileID);
$oldFileHash = null;
if ($newFileHash !== null)
{
if ($dbDoc && ($arTmpDoc = $dbDoc->Fetch())) // skip current saving copy
{
while ($arDoc = $dbDoc->Fetch())
{
$oldFileHash = $arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'];
if ($oldFileHash == $newFileHash)
{
$bNewFile = false;
$result = $arDoc['DOCUMENT']['PROPERTIES']['FILE'];
break;
}
}
}
}
if ($oldFileHash == null || $newFileHash == null)
$bNewFile = true; // add new copy to history
if ($bNewFile)
{
$result = array(
"VALUE" => CBPDocument::PrepareFileForHistory(
$documentId,
$propertyValue["VALUE"],
$historyIndex
),
"DESCRIPTION" => $propertyValue["DESCRIPTION"],
"HASH" => $newFileHash
);
}
return $result;
}