- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblockelement.php
- Класс: CAllIBlockElement
- Вызов: CAllIBlockElement::WF_CleanUpHistory
static function WF_CleanUpHistory()
{
if (CModule::IncludeModule("workflow"))
{
global $DB;
$HISTORY_DAYS = COption::GetOptionInt("workflow", "HISTORY_DAYS", -1);
if($HISTORY_DAYS >= 0)
{
$arDate = localtime(time());
$date = mktime(0, 0, 0, $arDate[4]+1, $arDate[3]-$HISTORY_DAYS, 1900+$arDate[5]);
CTimeZone::Disable();
$strSql = "
SELECT ID, WF_PARENT_ELEMENT_ID
FROM b_iblock_element
WHERE TIMESTAMP_X <= ".$DB->CharToDateFunction(ConvertTimeStamp($date, "FULL"))."
AND WF_PARENT_ELEMENT_ID is not null
ORDER BY ID DESC
";
$rsElements = $DB->Query($strSql, false, "FILE: ".__FILE__."
LINE: ".__LINE__);
CTimeZone::Enable();
//This Fetch will keep at least one history copy
//in order to prevent files being deleted
//before they copied into working copy
if($rsElements->Fetch())
{
while($arElement = $rsElements->Fetch())
{
$LAST_ID = CIBlockElement::WF_GetLast($arElement["WF_PARENT_ELEMENT_ID"]);
if($LAST_ID != $arElement["ID"])
{
CIBlockElement::Delete($arElement["ID"]);
}
}
}
}
}
}