CBPAllHistoryService :: DeleteHistory: Bitrix method

      
<?php 
//  CBPAllHistoryService :: DeleteHistory()
//  /dist/bitrix/modules/bizproc/classes/general/historyservice.php:101

    
public function DeleteHistory($id$documentId null)
    {
        global 
$DB;

        
$id intval($id);
        if (
$id <= 0)
            throw new 
Exception("id");

        
$arFilter = array("ID" => $id);
        if (
$documentId != null)
            
$arFilter["DOCUMENT_ID"] = $documentId;

        
$db $this->GetHistoryList(
            array(),
            
$arFilter,
            
false,
            
false,
            array(
"ID""MODULE_ID""ENTITY""DOCUMENT_ID")
        );
        if (
$ar $db->Fetch())
        {
            
$deleteFile true;
            foreach(
GetModuleEvents("bizproc""OnBeforeDeleteFileFromHistory"true) as $event)
            {
                if(
ExecuteModuleEventEx($event, array($id$documentId)) !== true)
                {
                    
$deleteFile false;
                    break;
                }
            }

            if (
$deleteFile)
            {
                
$dest self::GenerateFilePath($ar["DOCUMENT_ID"]);
                
DeleteDirFilesEx("/".(COption::GetOptionString("main""upload_dir""upload")).$dest."/".$ar["ID"]);
                if(
CModule::IncludeModule('clouds'))
                    
CCloudStorage::DeleteDirFilesEx($dest."/".$ar["ID"]);
            }

            
$DB->Query("DELETE FROM b_bp_history WHERE ID = ".intval($id)." "true);
        }
    }