...Человеческий поиск в разработке...
- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/virtualdocument.php
- Класс: CBPVirtualDocument
- Вызов: CBPVirtualDocument::updateDocument
static function updateDocument($documentId, $arFields) { $documentId = intval($documentId); if ($documentId <= 0) throw new CBPArgumentNullException("documentId"); CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0); $arFieldsPropertyValues = array(); $dbResult = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y"), false, false, array("ID", "IBLOCK_ID")); $arResult = $dbResult->Fetch(); if (!$arResult) throw new Exception("Element is not found"); $arDocumentFields = self::GetDocumentFields("type_".$arResult["IBLOCK_ID"]); $arKeys = array_keys($arFields); foreach ($arKeys as $key) { if (!array_key_exists($key, $arDocumentFields)) continue; if ($arDocumentFields[$key]["Multiple"] && is_string($arFields[$key])) { $arFieldsTmp = explode(",", $arFields[$key]); $arFields[$key] = array(); foreach ($arFieldsTmp as $value) $arFields[$key][] = trim($value); } $arFields[$key] = (is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key])) ? $arFields[$key] : array($arFields[$key]); if ($arDocumentFields[$key]["Type"] == "S:UserID") { $ar = array(); foreach ($arFields[$key] as $v1) { if (mb_substr($v1, 0, mb_strlen("user_")) == "user_") { $ar[] = mb_substr($v1, mb_strlen("user_")); } else { $a1 = self::GetUsersFromUserGroup($v1, $documentId); foreach ($a1 as $a11) $ar[] = $a11; } } $arFields[$key] = $ar; } elseif ($arDocumentFields[$key]['Type'] == 'S:employee') { $arFields[$key] = CBPHelper::StripUserPrefix($arFields[$key]); } elseif ($arDocumentFields[$key]["Type"] == "L") { $realKey = ((mb_substr($key, 0, mb_strlen("PROPERTY_")) == "PROPERTY_")? mb_substr($key, mb_strlen("PROPERTY_")) : $key); $arV = array(); $db = CIBlockProperty::GetPropertyEnum($realKey, false, array("IBLOCK_ID" => $arResult["IBLOCK_ID"])); while ($ar = $db->GetNext()) $arV[$ar["XML_ID"]] = $ar["ID"]; foreach ($arFields[$key] as &$value) { if (array_key_exists($value, $arV)) $value = $arV[$value]; } } elseif ($arDocumentFields[$key]["Type"] == "F") { foreach ($arFields[$key] as &$value) $value = CFile::MakeFileArray($value); } elseif ($arDocumentFields[$key]["Type"] == "S:HTML") { foreach ($arFields[$key] as &$value) $value = array("VALUE" => $value); } if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) { if (count($arFields[$key]) > 0) { $a = array_values($arFields[$key]); $arFields[$key] = $a[0]; } else { $arFields[$key] = null; } } if (mb_substr($key, 0, mb_strlen("PROPERTY_")) == "PROPERTY_") { $realKey = mb_substr($key, mb_strlen("PROPERTY_")); $arFieldsPropertyValues[$realKey] = (is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key])) ? $arFields[$key] : array($arFields[$key]); unset($arFields[$key]); } } $iblockElement = new CIBlockElement(); if (count($arFieldsPropertyValues) > 0) $iblockElement->SetPropertyValuesEx($documentId, $arResult["IBLOCK_ID"], $arFieldsPropertyValues); if (count($arFields) > 0) { $res = $iblockElement->Update($documentId, $arFields, false, true, true); if (!$res) throw new Exception($iblockElement->LAST_ERROR); } }