- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblockbizprochistory.php
- Класс: CWebdavDocumentHistory
- Вызов: CWebdavDocumentHistory::OnBeforeDeleteFileFromHistory
static function OnBeforeDeleteFileFromHistory($historyId, $documentId)
{
static $arHistoryFields = array("ID", "DOCUMENT_ID", "DOCUMENT");
$history = new CBPHistoryService();
if ($documentId[0] != 'webdav')
return true;
$fileToDeleteHash = null;
$dbDoc = $history->GetHistoryList(
array("ID" => "DESC"),
array("ID" => $historyId),
false,
false,
$arHistoryFields
);
if ($dbDoc && ($arDoc = $dbDoc->Fetch()))
{
if (isset($arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH']))
$fileToDeleteHash = $arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'];
}
$result = true; // seems to be an old file without hash
if ($fileToDeleteHash != null) // if not
{
$dbDoc = $history->GetHistoryList(
array("ID" => "DESC"),
array("DOCUMENT_ID" => $documentId),
false,
false,
$arHistoryFields
);
if ($dbDoc)
{
while ($arDoc = $dbDoc->Fetch())
{
if ($arDoc['ID'] == $historyId)
continue;
if (isset($arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH']))
{
$result = !($arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'] == $fileToDeleteHash); // file used also in other historyRecord
if (!$result)
break;
}
}
}
}
return $result;
}