CBPAllHistoryService :: PrepareFileForHistory: Bitrix method

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

    
public static function PrepareFileForHistory($documentId$arFileId$historyIndex)
    {
        
$dest self::GenerateFilePath($documentId);

        
$fileParameterIsArray true;
        if (!
is_array($arFileId))
        {
            
$arFileId = array($arFileId);
            
$fileParameterIsArray false;
        }

        
$result = array();

        foreach (
$arFileId as $fileId)
        {
            if(
$ar CFile::GetFileArray($fileId))
            {
                
$newFilePath CFile::CopyFile($fileIdfalse$dest."/".$historyIndex."/".$ar["FILE_NAME"]);
                if (
$newFilePath)
                    
$result[] = $newFilePath;
            }
        }

        if (!
$fileParameterIsArray)
        {
            if (
count($result) > 0)
                
$result $result[0];
            else
                
$result "";
        }

        return 
$result;
    }