/** * Метод возвращает массив произвольной структуры, содержащий всю информацию о документе. По этому массиву документ восстановливается методом RecoverDocumentFromHistory. * * @param string $documentId - код документа. * @return array - массив документа. */ public function GetDocumentForHistory($documentId, $historyIndex, $update = false) { $documentId = intval($documentId); if ($documentId <= 0) { throw new CBPArgumentNullException("documentId"); } $diskId = self::processGetDiskIdByDocId($documentId); if ($diskId !== null) { return self::proxyToDisk(__FUNCTION__, array($diskId, $historyIndex, $update)); } $arResult = null; $dbDocumentList = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y")); if ($objDocument = $dbDocumentList->GetNextElement()) { $arDocumentFields = $objDocument->GetFields(); $arDocumentProperties = $objDocument->GetProperties(); $arResult["NAME"] = $arDocumentFields["~NAME"]; $arResult["FIELDS"] = array(); foreach ($arDocumentFields as $fieldKey => $fieldValue) { if ($fieldKey == "~PREVIEW_PICTURE" || $fieldKey == "~DETAIL_PICTURE") { $arResult["FIELDS"][substr($fieldKey, 1)] = CBPDocument::PrepareFileForHistory(array("webdav", "CIBlockDocumentWebdavSocnet", $documentId), $fieldValue, $historyIndex); } elseif (substr($fieldKey, 0, 1) == "~") { $arResult["FIELDS"][substr($fieldKey, 1)] = $fieldValue; } } $arResult["PROPERTIES"] = array(); foreach ($arDocumentProperties as $propertyKey => $propertyValue) { if (strlen($propertyValue["USER_TYPE"]) > 0) { $arResult["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } elseif ($propertyValue["PROPERTY_TYPE"] == "L") { $arResult["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE_ENUM_ID"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } elseif ($propertyValue["PROPERTY_TYPE"] == "F" && $propertyKey == 'FILE') { $arDocID = $documentId; if (!is_array($documentId)) { $arDocID = array("webdav", "CIBlockDocumentWebdavSocnet", $documentId); } $arResult['PROPERTIES'][$propertyKey] = CWebdavDocumentHistory::GetFileForHistory($arDocID, $propertyValue, $historyIndex); $arResult['OLD_FILE_ID'] = $propertyValue['VALUE']; //for historical comment. if ($update) { $historyGlueState = CWebdavDocumentHistory::GetHistoryState($arDocID, null, null, array('CHECK_TIME' => 'Y')); } else { $historyGlueState = CWebdavDocumentHistory::GetHistoryState($arDocID, null, null, array('NEW' => 'Y', 'CHECK_TIME' => 'Y')); } $arResult['PROPERTIES'][$propertyKey]['HISTORYGLUE'] = $historyGlueState; } elseif ($propertyValue["PROPERTY_TYPE"] == "F") { $arResult["PROPERTIES"][$propertyKey] = array("VALUE" => CBPDocument::PrepareFileForHistory(array("webdav", "CIBlockDocumentWebdavSocnet", $documentId), $propertyValue["VALUE"], $historyIndex), "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } else { $arResult["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]); } } } return $arResult; }