122 $args = func_get_args();
124 $documentId = (int)$documentId;
125 if ($documentId <= 0)
132 $elementProperty = [];
136 $select = array_filter(
$select, fn($field) => !str_starts_with($field,
'PROPERTY_'));
139 if (in_array(
'CREATED_BY',
$select) && !in_array(
'CREATED_USER_NAME',
$select))
141 $select[] =
'CREATED_USER_NAME';
143 if (in_array(
'MODIFIED_BY',
$select) && !in_array(
'USER_NAME',
$select))
150 'CREATED_BY_PRINTABLE' =>
'CREATED_USER_NAME',
151 'MODIFIED_BY_PRINTABLE' =>
'USER_NAME',
154 $select = array_map(
static fn($selectField) => $userNameFields[$selectField] ?? $selectField,
$select);
156 $queryElement = CIBlockElement::getList(
158 [
'ID' => $documentId,
'SHOW_NEW' =>
'Y',
'SHOW_HISTORY' =>
'Y'],
161 while ($queryResult = $queryElement->fetch())
163 $element = $queryResult;
164 $queryProperty = CIBlockElement::getProperty(
165 $queryResult[
'IBLOCK_ID'],
167 [
'sort' =>
'asc',
'id' =>
'asc',
'enum_sort' =>
'asc',
'value_id' =>
'asc'],
168 [
'ACTIVE' =>
'Y',
'EMPTY' =>
'N']
170 while ($property = $queryProperty->fetch())
172 $propertyKey =
'PROPERTY_' . $property[
'ID'];
173 if ($property[
'MULTIPLE'] ==
'Y')
175 if (!array_key_exists($propertyKey, $elementProperty))
177 $elementProperty[$propertyKey] = $property;
178 $elementProperty[$propertyKey][
'VALUE'] = [];
180 $elementProperty[$propertyKey][
'VALUE'][] = $property[
'VALUE'];
184 $elementProperty[$propertyKey] = $property;
189 foreach ($element as $fieldId => $fieldValue)
191 $result[$fieldId] = $fieldValue;
192 if (in_array($fieldId, [
'MODIFIED_BY',
'CREATED_BY']))
194 $result[$fieldId] =
'user_' . $fieldValue;
195 $result[$fieldId .
'_PRINTABLE'] =
196 $element[($fieldId ==
'MODIFIED_BY')
198 :
'CREATED_USER_NAME']
201 elseif (in_array($fieldId, [
'PREVIEW_TEXT',
'DETAIL_TEXT']))
203 if ($element[$fieldId .
'_TYPE'] ==
'html')
209 foreach ($elementProperty as $propertyId => $property)
211 if (trim($property[
'CODE']) <>
'')
213 $propertyId = $property[
'CODE'];
217 $propertyId = $property[
'ID'];
220 if (!empty($property[
'USER_TYPE']))
223 $property[
'USER_TYPE'] ==
'UserID'
224 || $property[
'USER_TYPE'] ==
'employee'
225 && (COption::getOptionString(
'bizproc',
'employee_compatible_mode',
'N') !=
'Y')
228 if (empty($property[
'VALUE']))
232 if (!is_array($property[
'VALUE']))
234 $property[
'VALUE'] = [$property[
'VALUE']];
237 $listUsers = implode(
' | ', $property[
'VALUE']);
238 $userQuery = CUser::getList(
241 [
'ID' => $listUsers],
243 'FIELDS' => [
'ID',
'LOGIN',
'NAME',
'LAST_NAME'],
246 while ($user = $userQuery->fetch())
248 if ($property[
'MULTIPLE'] ==
'Y')
252 $result[
'PROPERTY_' . $propertyId][] =
'user_' . intval($user[
'ID']);
253 $result[
'PROPERTY_' . $propertyId .
'_PRINTABLE'][] =
'(' . $user[
'LOGIN'] .
')' .
254 (($user[
'NAME'] <>
'' || $user[
'LAST_NAME'] <>
'') ?
' ' :
'') . $user[
'NAME'] .
255 (($user[
'NAME'] <>
'' && $user[
'LAST_NAME'] <>
'') ?
' ' :
'') . $user[
'LAST_NAME'];
259 $result[
'PROPERTY_' . $propertyId] =
'user_' . intval($user[
'ID']);
260 $result[
'PROPERTY_' . $propertyId .
'_PRINTABLE'] =
'(' . $user[
'LOGIN'] .
')' .
261 (($user[
'NAME'] <>
'' || $user[
'LAST_NAME'] <>
'') ?
' ' :
'') . $user[
'NAME'] .
262 (($user[
'NAME'] <>
'' && $user[
'LAST_NAME'] <>
'') ?
' ' :
'') . $user[
'LAST_NAME'];
266 elseif ($property[
'USER_TYPE'] ==
'DiskFile')
268 $diskValues = is_array($property[
'VALUE']) ? current($property[
'VALUE']) :
null;
269 $userType = \CIBlockProperty::getUserType($property[
'USER_TYPE']);
270 if (is_array($diskValues))
274 foreach ($diskValues as $attachedId)
277 if (array_key_exists(
'GetObjectId', $userType))
279 $fileId = call_user_func_array($userType[
'GetObjectId'], [$attachedId]);
286 if (array_key_exists(
'GetUrlAttachedFileElement', $userType))
288 $printableUrl = call_user_func_array(
289 $userType[
'GetUrlAttachedFileElement'],
290 [$documentId, $fileId]
294 $result[
'PROPERTY_' . $propertyId][$attachedId] = $fileId;
295 $result[
'PROPERTY_' . $propertyId .
'_PRINTABLE'][$attachedId] = $printableUrl;
303 elseif ($property[
'USER_TYPE'] ==
'HTML')
305 if (\CBPHelper::isAssociativeArray($property[
'VALUE']))
307 if ($property[
'VALUE'][
'TYPE'] ==
'HTML')
313 $result[
'PROPERTY_' . $propertyId] = $property[
'VALUE'][
'TEXT'];
319 foreach ($property[
'VALUE'] as $htmlValue)
321 if ($htmlValue[
'TYPE'] ==
'HTML')
327 $result[
'PROPERTY_' . $propertyId][] = $htmlValue[
'TEXT'];
332 elseif ($property[
'USER_TYPE'] ==
'Money')
334 $userType = \CIBlockProperty::getUserType($property[
'USER_TYPE']);
335 if (is_array($property[
'VALUE']))
339 foreach ($property[
'VALUE'] as $moneyValue)
341 $result[
'PROPERTY_' . $propertyId][] = $moneyValue;
342 if (array_key_exists(
'GetPublicViewHTML', $userType))
344 $result[
'PROPERTY_' . $propertyId .
'_PRINTABLE'][] = call_user_func_array(
345 $userType[
'GetPublicViewHTML'],
346 [$property, [
'VALUE' => $moneyValue], []]
353 $result[
'PROPERTY_' . $propertyId] = $property[
'VALUE'];
354 if (array_key_exists(
'GetPublicViewHTML', $userType))
356 $result[
'PROPERTY_' . $propertyId .
'_PRINTABLE'] = call_user_func_array(
357 $userType[
'GetPublicViewHTML'],
358 [$property, [
'VALUE' => $property[
'VALUE']], []]
365 $result[
'PROPERTY_' . $propertyId] = $property[
'VALUE'];
368 elseif ($property[
'PROPERTY_TYPE'] ==
'L')
373 $propertyKeyArray = [];
374 if (!is_array($property[
'VALUE']))
376 $property[
'VALUE'] = [$property[
'VALUE']];
378 foreach ($property[
'VALUE'] as $enumId)
380 $enumsObject = CIBlockProperty::getPropertyEnum(
385 while ($enums = $enumsObject->fetch())
387 $propertyArray[] = $enums[
'VALUE'];
388 $propertyKeyArray[] = $enums[
'XML_ID'];
391 for (
$i = 0, $cnt =
count($propertyArray);
$i < $cnt;
$i++)
393 $result[
'PROPERTY_' . $propertyId][$propertyKeyArray[
$i]] = $propertyArray[
$i];
396 elseif ($property[
'PROPERTY_TYPE'] ==
'F')
400 $propertyArray = $property[
'VALUE'];
401 if (!is_array($propertyArray))
403 $propertyArray = [$propertyArray];
406 foreach ($propertyArray as $v)
408 $fileArray = \CFile::getFileArray($v);
411 $result[
'PROPERTY_' . $propertyId][] = intval($v);
412 $result[
'PROPERTY_' . $propertyId .
'_PRINTABLE'][] =
413 "[url=/bitrix/tools/bizproc_show_file.php?f=" .
414 urlencode($fileArray[
"FILE_NAME"]) .
"&i=" . $v .
"&h=" . md5($fileArray[
"SUBDIR"]) .
"]" .
421 $result[
'PROPERTY_' . $propertyId] = $property[
'VALUE'];
427 $documentFields = static::getDocumentFields(static::getDocumentType($documentId));
428 foreach ($documentFields as $fieldKey => $field)
430 if (!array_key_exists($fieldKey,
$result))
1296 $documentId = intval($documentId);
1297 if ($documentId <= 0)
1302 CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
1304 $arFieldsPropertyValues = [];
1308 [
'ID' => $documentId,
'SHOW_NEW' =>
'Y',
'SHOW_HISTORY' =>
'Y'],
1316 $complexDocumentId = [
'lists', get_called_class(), $documentId];
1320 foreach ($arKeys as
$key)
1322 if (!array_key_exists(
$key, $arDocumentFields))
1332 (mb_substr(
$key, 0, mb_strlen(
'PROPERTY_')) ==
'PROPERTY_')
1333 ? mb_substr(
$key, mb_strlen(
'PROPERTY_'))
1337 if ($arDocumentFields[
$key][
'Type'] ==
'user')
1341 elseif ($arDocumentFields[
$key][
'Type'] ==
'select')
1344 $db = CIBlockProperty::GetPropertyEnum(
1349 while (
$ar = $db->GetNext())
1351 $arV[
$ar[
'XML_ID']] =
$ar[
'ID'];
1357 if (is_array($value) && CBPHelper::isAssociativeArray($value))
1359 $listXmlId = array_keys($value);
1360 foreach ($listXmlId as $xmlId)
1362 $listValue[] = $arV[$xmlId];
1367 if (array_key_exists($value, $arV))
1369 $value = $arV[$value];
1373 if (!empty($listValue))
1378 elseif ($arDocumentFields[
$key][
'Type'] ==
'file')
1383 if (is_array($value))
1385 foreach ($value as $file)
1387 $makeFileArray = CFile::MakeFileArray($file);
1390 $files[] = $makeFileArray;
1396 $makeFileArray = CFile::MakeFileArray($value);
1399 $files[] = $makeFileArray;
1412 elseif ($arDocumentFields[
$key][
'Type'] ==
'S:DiskFile')
1418 $value =
'n' . $value;
1423 elseif ($arDocumentFields[
$key][
'Type'] ==
'S:HTML')
1427 $value = [
'VALUE' => $value];
1446 if (mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
1448 $realKey = mb_substr(
$key, mb_strlen(
"PROPERTY_"));
1449 $arFieldsPropertyValues[$realKey] = (is_array(
$arFields[
$key])
1451 if (empty($arFieldsPropertyValues[$realKey]))
1452 $arFieldsPropertyValues[$realKey] = [
null];
1462 if (
count($arFieldsPropertyValues) > 0)
1464 $arFields[
'PROPERTY_VALUES'] = $arFieldsPropertyValues;
1467 $valuesUpdated =
false;
1468 $propertyValuesUpdated =
false;
1473 $iblockElement->SetPropertyValuesEx($documentId,
$arResult[
'IBLOCK_ID'],
$arFields[
'PROPERTY_VALUES']);
1474 $propertyValuesUpdated =
true;
1481 $res = $iblockElement->Update($documentId,
$arFields,
false,
true,
true);
1487 $valuesUpdated =
true;
1491 self::publishDocument($documentId);
1495 self::unpublishDocument($documentId);
1499 if (CModule::includeModule(
'lists') && ($valuesUpdated || $propertyValuesUpdated))
1501 CLists::rebuildSeachableContentForElement(
$arResult[
'IBLOCK_ID'], $documentId);
1695 $documentId = trim($documentId);
1696 if ($documentId ==
'')
1699 if (self::isAdmin())
1704 if (!array_key_exists(
"IBlockId", $parameters)
1706 !array_key_exists(
"IBlockPermission", $parameters)
1707 || !array_key_exists(
"DocumentStates", $parameters)
1708 || !array_key_exists(
"IBlockRightsMode", $parameters)
1709 || array_key_exists(
"IBlockRightsMode", $parameters) && ($parameters[
"IBlockRightsMode"] ===
"E")
1711 || !array_key_exists(
"CreatedBy", $parameters) && !array_key_exists(
"AllUserGroups", $parameters))
1713 if (empty(self::$elements[$documentId]))
1715 $elementListQuery = CIBlockElement::getList(
1717 array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y",
"SHOW_HISTORY" =>
"Y"),
1720 array(
"ID",
"IBLOCK_ID",
"CREATED_BY")
1722 self::$elements[$documentId] = $elementListQuery->fetch();
1725 if (empty(self::$elements[$documentId]))
1728 $element = self::$elements[$documentId];
1730 $parameters[
"IBlockId"] = $element[
"IBLOCK_ID"];
1731 $parameters[
"CreatedBy"] = $element[
"CREATED_BY"];
1734 if (!array_key_exists(
"IBlockRightsMode", $parameters))
1735 $parameters[
"IBlockRightsMode"] = CIBlock::getArrayByID($parameters[
"IBlockId"],
"RIGHTS_MODE");
1737 if ($parameters[
"IBlockRightsMode"] ===
"E")
1743 return CIBlockElementRights::userHasRightTo($parameters[
"IBlockId"], $documentId,
"element_read");
1745 return CIBlockElementRights::userHasRightTo($parameters[
"IBlockId"], $documentId,
"element_edit");
1748 if (CIBlockElementRights::userHasRightTo($parameters[
"IBlockId"], $documentId,
"element_edit"))
1751 if (!array_key_exists(
"WorkflowId", $parameters))
1754 if (!CIBlockElementRights::userHasRightTo($parameters[
"IBlockId"], $documentId,
"element_read"))
1758 if (!array_key_exists(
"AllUserGroups", $parameters))
1760 if (!array_key_exists(
"UserGroups", $parameters))
1761 $parameters[
"UserGroups"] = CUser::getUserGroup(
$userId);
1763 $parameters[
"AllUserGroups"] = $parameters[
"UserGroups"];
1764 if (
$userId == $parameters[
"CreatedBy"])
1765 $parameters[
"AllUserGroups"][] =
"Author";
1768 if (!array_key_exists(
"DocumentStates", $parameters))
1771 $parameters[
"DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(
array(
'lists', get_called_class(), self::generateDocumentType($parameters[
"IBlockId"])));
1773 $parameters[
"DocumentStates"] = CBPDocument::getDocumentStates(
1774 array(
'lists', get_called_class(), self::generateDocumentType($parameters[
"IBlockId"])),
1775 array(
'lists', get_called_class(), $documentId)
1779 if (array_key_exists($parameters[
"WorkflowId"], $parameters[
"DocumentStates"]))
1780 $parameters[
"DocumentStates"] =
array($parameters[
"WorkflowId"] => $parameters[
"DocumentStates"][$parameters[
"WorkflowId"]]);
1784 $allowableOperations = CBPDocument::getAllowableOperations(
1786 $parameters[
"AllUserGroups"],
1787 $parameters[
"DocumentStates"],
1791 if (!is_array($allowableOperations))
1801 foreach ($allowableOperations as $op)
1803 if (isset($tasks[$op]))
1804 $op = $tasks[$op][
'ID'];
1805 $ar = CTask::getOperations($op,
true);
1806 if (in_array($chop,
$ar))
1812 return CBPDocument::canUserOperateDocumentType(
1815 array(
'lists', get_called_class(), $parameters[
'IBlockId']),
1823 if (!array_key_exists(
"IBlockPermission", $parameters))
1825 if (CModule::includeModule(
'lists'))
1826 $parameters[
"IBlockPermission"] = CLists::getIBlockPermission($parameters[
"IBlockId"],
$userId);
1828 $parameters[
"IBlockPermission"] = CIBlock::getPermission($parameters[
"IBlockId"],
$userId);
1831 if ($parameters[
"IBlockPermission"] <=
"R")
1833 elseif ($parameters[
"IBlockPermission"] >=
"W")
1837 if (!array_key_exists(
"AllUserGroups", $parameters))
1839 if (!array_key_exists(
"UserGroups", $parameters))
1840 $parameters[
"UserGroups"] = CUser::getUserGroup(
$userId);
1842 $parameters[
"AllUserGroups"] = $parameters[
"UserGroups"];
1843 if (
$userId == $parameters[
"CreatedBy"])
1844 $parameters[
"AllUserGroups"][] =
"Author";
1847 if (!array_key_exists(
"DocumentStates", $parameters))
1849 $parameters[
"DocumentStates"] = CBPDocument::getDocumentStates(
1850 array(
"lists", get_called_class(),
"iblock_".$parameters[
"IBlockId"]),
1851 array(
'lists', get_called_class(), $documentId)
1855 if (array_key_exists(
"WorkflowId", $parameters))
1857 if (array_key_exists($parameters[
"WorkflowId"], $parameters[
"DocumentStates"]))
1858 $parameters[
"DocumentStates"] =
array($parameters[
"WorkflowId"] => $parameters[
"DocumentStates"][$parameters[
"WorkflowId"]]);
1863 $allowableOperations = CBPDocument::getAllowableOperations(
1865 $parameters[
"AllUserGroups"],
1866 $parameters[
"DocumentStates"]
1869 if (!is_array($allowableOperations))
1876 $r = in_array(
"read", $allowableOperations);
1879 $r = in_array(
"write", $allowableOperations);
1885 $r = in_array(
"write", $allowableOperations);
1888 $r = in_array(
"read", $allowableOperations) || in_array(
"write", $allowableOperations);
1899 $documentType = trim($documentType);
1900 if ($documentType ==
'')
1903 if (self::isAdmin())
1908 if(is_numeric($documentType))
1909 $parameters[
"IBlockId"] = intval($documentType);
1911 $parameters[
"IBlockId"] = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
1912 $parameters[
'sectionId'] = !empty($parameters[
'sectionId']) ? (int)$parameters[
'sectionId'] : 0;
1914 if (!array_key_exists(
"IBlockRightsMode", $parameters))
1915 $parameters[
"IBlockRightsMode"] = CIBlock::getArrayByID($parameters[
"IBlockId"],
"RIGHTS_MODE");
1917 if ($parameters[
"IBlockRightsMode"] ===
"E")
1920 return CIBlockRights::userHasRightTo($parameters[
"IBlockId"], $parameters[
"IBlockId"],
"iblock_rights_edit");
1922 return CIBlockSectionRights::userHasRightTo($parameters[
"IBlockId"], $parameters[
"sectionId"],
"section_element_bind");
1929 CIBlockRights::userHasRightTo($parameters[
"IBlockId"], 0,
"element_read")
1930 || CIBlockRights::userHasRightTo($parameters[
"IBlockId"], $parameters[
"IBlockId"],
"iblock_rights_edit")
1935 return CIBlockSectionRights::userHasRightTo($parameters[
"IBlockId"], $parameters[
'sectionId'],
"section_element_bind");
1939 if (!array_key_exists(
"AllUserGroups", $parameters))
1941 if (!array_key_exists(
"UserGroups", $parameters))
1942 $parameters[
"UserGroups"] = CUser::getUserGroup(
$userId);
1944 $parameters[
"AllUserGroups"] = $parameters[
"UserGroups"];
1945 $parameters[
"AllUserGroups"][] =
"Author";
1948 if (!array_key_exists(
"DocumentStates", $parameters))
1951 $parameters[
"DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(
array(
"lists", get_called_class(),
"iblock_".$parameters[
"IBlockId"]));
1953 $parameters[
"DocumentStates"] = CBPDocument::getDocumentStates(
1954 array(
"lists", get_called_class(),
"iblock_".$parameters[
"IBlockId"]),
1959 if (array_key_exists($parameters[
"WorkflowId"], $parameters[
"DocumentStates"]))
1960 $parameters[
"DocumentStates"] =
array($parameters[
"WorkflowId"] => $parameters[
"DocumentStates"][$parameters[
"WorkflowId"]]);
1964 $allowableOperations = CBPDocument::getAllowableOperations(
1966 $parameters[
"AllUserGroups"],
1967 $parameters[
"DocumentStates"],
1971 if (!is_array($allowableOperations))
1981 foreach ($allowableOperations as $op)
1983 if (isset($tasks[$op]))
1984 $op = $tasks[$op][
'ID'];
1985 $ar = CTask::getOperations($op,
true);
1986 if (in_array($chop,
$ar))
1994 if (!array_key_exists(
"IBlockPermission", $parameters))
1996 if(CModule::includeModule(
'lists'))
1997 $parameters[
"IBlockPermission"] = CLists::getIBlockPermission($parameters[
"IBlockId"],
$userId);
1999 $parameters[
"IBlockPermission"] = CIBlock::getPermission($parameters[
"IBlockId"],
$userId);
2002 if ($parameters[
"IBlockPermission"] <=
"R")
2004 elseif ($parameters[
"IBlockPermission"] >=
"W")
2008 if (!array_key_exists(
"AllUserGroups", $parameters))
2010 if (!array_key_exists(
"UserGroups", $parameters))
2011 $parameters[
"UserGroups"] = CUser::getUserGroup(
$userId);
2013 $parameters[
"AllUserGroups"] = $parameters[
"UserGroups"];
2014 $parameters[
"AllUserGroups"][] =
"Author";
2017 if (!array_key_exists(
"DocumentStates", $parameters))
2019 $parameters[
"DocumentStates"] = CBPDocument::getDocumentStates(
2020 array(
"lists", get_called_class(),
"iblock_".$parameters[
"IBlockId"]),
2025 if (array_key_exists(
"WorkflowId", $parameters))
2027 if (array_key_exists($parameters[
"WorkflowId"], $parameters[
"DocumentStates"]))
2028 $parameters[
"DocumentStates"] =
array($parameters[
"WorkflowId"] => $parameters[
"DocumentStates"][$parameters[
"WorkflowId"]]);
2033 $allowableOperations = CBPDocument::getAllowableOperations(
2035 $parameters[
"AllUserGroups"],
2036 $parameters[
"DocumentStates"]
2039 if (!is_array($allowableOperations))
2046 $r = in_array(
"read", $allowableOperations);
2049 $r = in_array(
"write", $allowableOperations);
2052 $r = in_array(
"write", $allowableOperations);
2055 $r = in_array(
"write", $allowableOperations);
2088 $documentType = trim($documentType);
2089 if ($documentType ===
'')
2094 $groupsKey = $documentType . ($withExtended ?
'@withExtended' :
'');
2096 if (isset(self::$cachedGroups[$groupsKey]))
2098 return self::$cachedGroups[$groupsKey];
2101 $iblockId = (int)mb_substr($documentType, mb_strlen(
"iblock_"));
2106 $extendedGroupsCode = [];
2107 if (CIBlock::getArrayByID(
$iblockId,
"RIGHTS_MODE") ===
"E")
2110 foreach (
$rights->getGroups() as $iblockGroupCode)
2112 if (preg_match(
"/^G(\\d+)\$/", $iblockGroupCode, $match))
2114 $groupsId[] = $match[1];
2118 $extendedGroupsCode[] = $iblockGroupCode;
2124 foreach (CIBlock::getGroupPermissions(
$iblockId) as $groupId =>
$perm)
2128 $groupsId[] = $groupId;
2133 $groupsIterator = CGroup::getListEx(
array(
"NAME" =>
"ASC"),
array(
"ID" => $groupsId));
2134 while ($group = $groupsIterator->fetch())
2136 $groups[$group[
"ID"]] = $group[
"NAME"];
2139 if ($withExtended && $extendedGroupsCode)
2141 foreach ($extendedGroupsCode as $groupCode)
2143 $groups[
'group_'.$groupCode] = CBPHelper::getExtendedGroupName($groupCode);
2147 self::$cachedGroups[$groupsKey] =
$groups;
2160 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
2164 static $documentFieldTypes =
array();
2165 if (!array_key_exists($documentType, $documentFieldTypes))
2166 $documentFieldTypes[$documentType] = self::getDocumentFieldTypes($documentType);
2168 $fieldType[
"BaseType"] =
"string";
2169 $fieldType[
"Complex"] =
false;
2170 if (array_key_exists($fieldType[
"Type"], $documentFieldTypes[$documentType]))
2172 $fieldType[
"BaseType"] = $documentFieldTypes[$documentType][$fieldType[
"Type"]][
"BaseType"];
2173 $fieldType[
"Complex"] = $documentFieldTypes[$documentType][$fieldType[
"Type"]][
"Complex"];
2176 if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::isAssociativeArray($fieldValue))
2177 $fieldValue =
array($fieldValue);
2179 $customMethodName =
"";
2180 $customMethodNameMulty =
"";
2181 if (mb_strpos($fieldType[
"Type"],
":") !==
false)
2183 $ar = CIBlockProperty::getUserType(mb_substr($fieldType[
"Type"], 2));
2184 if (array_key_exists(
"GetPublicEditHTML",
$ar))
2185 $customMethodName =
$ar[
"GetPublicEditHTML"];
2186 if (array_key_exists(
"GetPublicEditHTMLMulty",
$ar))
2187 $customMethodNameMulty =
$ar[
"GetPublicEditHTMLMulty"];
2192 if ($fieldType[
"Type"] ==
"select")
2194 $fieldValueTmp = $fieldValue;
2196 <
select id=
"id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>" name=
"<?= htmlspecialcharsbx($fieldName["Field
"]).($fieldType["Multiple
"] ? "[]
" : "") ?>"<?= ($fieldType[
"Multiple"] ?
' size="5" multiple' :
'') ?>>
2198 if (!$fieldType[
"Required"])
2199 echo
'<option value="">['.GetMessage(
"BPCGHLP_NOT_SET").
']</option>';
2200 foreach ($fieldType[
"Options"] as
$k => $v)
2202 if (is_array($v) &&
count($v) == 2)
2204 $v1 = array_values($v);
2209 $ind = array_search(
$k, $fieldValueTmp);
2210 echo
'<option value="'.htmlspecialcharsbx(
$k).
'"'.($ind !==
false ?
' selected' :
'').
'>'.
htmlspecialcharsbx($v).
'</option>';
2212 unset($fieldValueTmp[$ind]);
2217 if ($allowSelection)
2220 <br /><input type=
"text" id=
"id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text" name=
"<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text" value=
"<?
2221 if (count($fieldValueTmp) > 0)
2223 $a = array_values($fieldValueTmp);
2224 echo htmlspecialcharsbx($a[0]);
2227 <input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text', 'select');">
2231 elseif ($fieldType[
"Type"] ==
"user")
2233 $fieldValue = CBPHelper::usersArrayToString($fieldValue,
null,
array(
"lists", get_called_class(), $documentType));
2234 ?><input type=
"text" size=
"40" id=
"id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>" name=
"<?= htmlspecialcharsbx($fieldName["Field
"]) ?>" value=
"<?= htmlspecialcharsbx($fieldValue) ?>"><input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>', 'user');"><?
2236 elseif ((mb_strpos($fieldType[
"Type"],
":") !==
false)
2237 && $fieldType[
"Multiple"]
2239 is_array($customMethodNameMulty) &&
count($customMethodNameMulty) > 0
2240 || !is_array($customMethodNameMulty) && $customMethodNameMulty <>
''
2244 if (!is_array($fieldValue))
2245 $fieldValue =
array();
2247 if ($allowSelection)
2249 $fieldValueTmp1 =
array();
2250 $fieldValueTmp2 =
array();
2251 foreach ($fieldValue as $v)
2254 if (\CBPDocument::IsExpression($vTrim))
2255 $fieldValueTmp1[] = $vTrim;
2257 $fieldValueTmp2[] = $v;
2262 $fieldValueTmp1 =
array();
2263 $fieldValueTmp2 = $fieldValue;
2266 if (($fieldType[
"Type"] ==
"S:employee") && COption::getOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
2267 $fieldValueTmp2 = CBPHelper::stripUserPrefix($fieldValueTmp2);
2269 foreach ($fieldValueTmp2 as &$fld)
2270 if (!isset($fld[
'VALUE']))
2271 $fld =
array(
"VALUE" => $fld);
2273 if ($fieldType[
"Type"] ==
"E:EList")
2278 if (!empty(
$_SERVER[
'HTTP_BX_AJAX']))
2279 $GLOBALS[
"APPLICATION"]->showAjaxHead();
2280 $GLOBALS[
"APPLICATION"]->addHeadScript(
'/bitrix/js/iblock/iblock_edit.js');
2284 echo call_user_func_array(
2285 $customMethodNameMulty,
2287 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
2290 "FORM_NAME" => $fieldName[
"Form"],
2297 if ($allowSelection)
2300 <br /><input type=
"text" id=
"id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text" name=
"<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text" value=
"<?
2301 if (count($fieldValueTmp1) > 0)
2303 $a = array_values($fieldValueTmp1);
2304 echo htmlspecialcharsbx($a[0]);
2307 <input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text', 'user', '<?= $fieldType["Type
"] == 'S:employee'? 'employee' : '' ?>');">
2313 if (!array_key_exists(
"CBPVirtualDocumentCloneRowPrinted",
$GLOBALS) && $fieldType[
"Multiple"])
2315 $GLOBALS[
"CBPVirtualDocumentCloneRowPrinted"] = 1;
2318 function CBPVirtualDocumentCloneRow(tableID)
2320 var tbl = document.getElementById(tableID);
2321 var cnt = tbl.rows.length;
2322 var oRow = tbl.insertRow(cnt);
2323 var oCell = oRow.insertCell(0);
2324 var sHTML = tbl.rows[cnt - 1].cells[0].innerHTML;
2328 var s = sHTML.indexOf(
'[n', p);
2331 var e = sHTML.indexOf(
']', s);
2334 var n = parseInt(sHTML.substr(s + 2, e - s));
2335 sHTML = sHTML.substr(0, s) +
'[n' + (++n) +
']' + sHTML.substr(e + 1);
2341 var s = sHTML.indexOf(
'__n', p);
2344 var e = sHTML.indexOf(
'_', s + 2);
2347 var n = parseInt(sHTML.substr(s + 3, e - s));
2348 sHTML = sHTML.substr(0, s) +
'__n' + (++n) +
'_' + sHTML.substr(e + 1);
2351 oCell.innerHTML = sHTML;
2352 var patt =
new RegExp(
'<' +
'script' +
'>[^\000]*?<' +
'\/' +
'script' +
'>',
'ig');
2353 var code = sHTML.match(patt);
2356 for (var i = 0; i < code.length; i++)
2360 var s = code[i].substring(8, code[i].length - 9);
2361 jsUtils.EvalGlobal(s);
2366 function createAdditionalHtmlEditor(tableId)
2368 var tbl = document.getElementById(tableId);
2369 var cnt = tbl.rows.length-1;
2370 var name = tableId.replace(/(?:CBPVirtualDocument_)(.*)(?:_Table)/,
'$1')
2371 var idEditor =
'id_'+name+
'__n'+cnt+
'_';
2372 var inputNameEditor = name+
'[n'+cnt+
']';
2373 window.BXHtmlEditor.Show(
2376 'inputName':inputNameEditor,
2378 'useFileDialogs':
false,
2382 'limitPhpAccess':
false,
2385 'templateParams':[],
2386 'componentFilter':
'',
2388 'placeholder':
'Text here...',
2389 'actionUrl':
'/bitrix/tools/html_editor_action.php',
2390 'cssIframePath':
'/bitrix/js/fileman/html_editor/iframe-style.css?1412693817',
2393 'spellcheck_path':
'/bitrix/js/fileman/html_editor/html-spell.js?v=1412693817',
2395 'useCustomSpell':
'Y',
2397 'askBeforeUnloadPage':
true,
2398 'settingsKey':
'user_settings_1',
2399 'showComponents':
true,
2400 'showSnippets':
true,
2402 'splitVertical':
false,
2404 'taskbarShown':
false,
2405 'taskbarWidth':
'250',
2406 'lastSpecialchars':
false,
2407 'cleanEmptySpans':
true,
2409 'showTaskbars':
false,
2410 'showNodeNavi':
false,
2412 {
'id':
'Bold',
'compact':
true,
'sort':
'80'},
2413 {
'id':
'Italic',
'compact':
true,
'sort':
'90'},
2414 {
'id':
'Underline',
'compact':
true,
'sort':
'100'},
2415 {
'id':
'Strikeout',
'compact':
true,
'sort':
'110'},
2416 {
'id':
'RemoveFormat',
'compact':
true,
'sort':
'120'},
2417 {
'id':
'Color',
'compact':
true,
'sort':
'130'},
2418 {
'id':
'FontSelector',
'compact':
false,
'sort':
'135'},
2419 {
'id':
'FontSize',
'compact':
false,
'sort':
'140'},
2420 {
'separator':
true,
'compact':
false,
'sort':
'145'},
2421 {
'id':
'OrderedList',
'compact':
true,
'sort':
'150'},
2422 {
'id':
'UnorderedList',
'compact':
true,
'sort':
'160'},
2423 {
'id':
'AlignList',
'compact':
false,
'sort':
'190'},
2424 {
'separator':
true,
'compact':
false,
'sort':
'200'},
2425 {
'id':
'InsertLink',
'compact':
true,
'sort':
'210'},
2426 {
'id':
'InsertImage',
'compact':
false,
'sort':
'220'},
2427 {
'id':
'InsertVideo',
'compact':
true,
'sort':
'230'},
2428 {
'id':
'InsertTable',
'compact':
false,
'sort':
'250'},
2429 {
'id':
'Smile',
'compact':
false,
'sort':
'280'},
2430 {
'separator':
true,
'compact':
false,
'sort':
'290'},
2431 {
'id':
'Fullscreen',
'compact':
false,
'sort':
'310'},
2432 {
'id':
'More',
'compact':
true,
'sort':
'400'}],
2434 'autoResizeOffset':
'40',
2435 'minBodyWidth':
'350',
2436 'normalBodyWidth':
'555'
2438 var htmlEditor = BX.findChildrenByClassName(BX(tableId),
'bx-html-editor');
2439 for(var k in htmlEditor)
2441 var editorId = htmlEditor[k].getAttribute(
'id');
2442 var frameArray = BX.findChildrenByClassName(BX(editorId),
'bx-editor-iframe');
2443 if(frameArray.length > 1)
2445 for(var i = 0; i < frameArray.length - 1; i++)
2447 frameArray[i].parentNode.removeChild(frameArray[i]);
2457 if ($fieldType[
"Multiple"])
2458 echo
'<table width="100%" border="0" cellpadding="2" cellspacing="2" id="CBPVirtualDocument_'.htmlspecialcharsbx($fieldName[
"Field"]).
'_Table">';
2460 $fieldValueTmp = $fieldValue;
2462 if (
sizeof($fieldValue) == 0)
2463 $fieldValue[] =
null;
2466 foreach ($fieldValue as
$key => $value)
2469 $fieldNameId =
'id_'.htmlspecialcharsbx($fieldName[
"Field"]).
'__n'.$ind.
'_';
2470 $fieldNameName =
htmlspecialcharsbx($fieldName[
"Field"]).($fieldType[
"Multiple"] ?
"[n".$ind.
"]" :
"");
2472 if ($fieldType[
"Multiple"])
2475 if (is_array($customMethodName) &&
count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <>
'')
2477 if($fieldType[
"Type"] ==
"S:HTML")
2479 if (Loader::includeModule(
"fileman"))
2484 'useFileDialogs' =>
false,
2486 'useFileDialogs' =>
false,
2487 'minBodyWidth' => 350,
2488 'normalBodyWidth' => 555,
2489 'bAllowPhp' =>
false,
2490 'limitPhpAccess' =>
false,
2491 'showTaskbars' =>
false,
2492 'showNodeNavi' =>
false,
2493 'askBeforeUnloadPage' =>
true,
2496 'autoResize' =>
true,
2497 'autoResizeOffset' => 40,
2498 'saveOnBlur' =>
true,
2499 'actionUrl' =>
'/bitrix/tools/html_editor_action.php',
2500 'controlsMap' =>
array(
2501 array(
'id' =>
'Bold',
'compact' =>
true,
'sort' => 80),
2502 array(
'id' =>
'Italic',
'compact' =>
true,
'sort' => 90),
2503 array(
'id' =>
'Underline',
'compact' =>
true,
'sort' => 100),
2504 array(
'id' =>
'Strikeout',
'compact' =>
true,
'sort' => 110),
2505 array(
'id' =>
'RemoveFormat',
'compact' =>
true,
'sort' => 120),
2506 array(
'id' =>
'Color',
'compact' =>
true,
'sort' => 130),
2507 array(
'id' =>
'FontSelector',
'compact' =>
false,
'sort' => 135),
2508 array(
'id' =>
'FontSize',
'compact' =>
false,
'sort' => 140),
2509 array(
'separator' =>
true,
'compact' =>
false,
'sort' => 145),
2510 array(
'id' =>
'OrderedList',
'compact' =>
true,
'sort' => 150),
2511 array(
'id' =>
'UnorderedList',
'compact' =>
true,
'sort' => 160),
2512 array(
'id' =>
'AlignList',
'compact' =>
false,
'sort' => 190),
2513 array(
'separator' =>
true,
'compact' =>
false,
'sort' => 200),
2514 array(
'id' =>
'InsertLink',
'compact' =>
true,
'sort' => 210,
'wrap' =>
'bx-b-link-'.$fieldNameId),
2515 array(
'id' =>
'InsertImage',
'compact' =>
false,
'sort' => 220),
2516 array(
'id' =>
'InsertVideo',
'compact' =>
true,
'sort' => 230,
'wrap' =>
'bx-b-video-'.$fieldNameId),
2517 array(
'id' =>
'InsertTable',
'compact' =>
false,
'sort' => 250),
2518 array(
'id' =>
'Code',
'compact' =>
true,
'sort' => 260),
2519 array(
'id' =>
'Quote',
'compact' =>
true,
'sort' => 270,
'wrap' =>
'bx-b-quote-'.$fieldNameId),
2520 array(
'id' =>
'Smile',
'compact' =>
false,
'sort' => 280),
2521 array(
'separator' =>
true,
'compact' =>
false,
'sort' => 290),
2522 array(
'id' =>
'Fullscreen',
'compact' =>
false,
'sort' => 310),
2523 array(
'id' =>
'BbCode',
'compact' =>
true,
'sort' => 340),
2524 array(
'id' =>
'More',
'compact' =>
true,
'sort' => 400)
2528 'name' => $fieldNameName,
2529 'inputName' => $fieldNameName,
2530 'id' => $fieldNameId,
2532 'content' => htmlspecialcharsBack($value),
2535 $editor->show(
$res);
2539 ?><textarea rows=
"5" cols=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?=
htmlspecialcharsbx($value) ?></textarea><?
2545 if ($allowSelection && \CBPDocument::IsExpression(trim($value1)))
2548 unset($fieldValueTmp[
$key]);
2550 if (($fieldType[
"Type"] ==
"S:employee") && COption::getOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
2551 $value1 = CBPHelper::stripUserPrefix($value1);
2553 echo call_user_func_array(
2556 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
2557 array(
"VALUE" => $value1),
2559 "FORM_NAME" => $fieldName[
"Form"],
2560 "VALUE" => $fieldNameName
2569 switch ($fieldType[
"Type"])
2573 unset($fieldValueTmp[
$key]);
2574 ?><input type=
"text" size=
"10" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
2580 ?><input type=
"file" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?
2584 if (in_array($value,
array(
"Y",
"N")))
2585 unset($fieldValueTmp[
$key]);
2587 <
select id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>">
2589 if (!$fieldType[
"Required"])
2590 echo
'<option value="">['.GetMessage(
"BPCGHLP_NOT_SET").
']</option>';
2592 <option value=
"Y"<?= (in_array(
"Y", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPCGHLP_YES") ?></option>
2593 <option value=
"N"<?= (in_array(
"N", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPCGHLP_NO") ?></option>
2598 unset($fieldValueTmp[
$key]);
2599 ?><textarea rows=
"5" cols=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?=
htmlspecialcharsbx($value) ?></textarea><?
2606 if (!\CBPDocument::IsExpression(trim($value)))
2609 unset($fieldValueTmp[
$key]);
2611 require_once(
$_SERVER[
"DOCUMENT_ROOT"].
BX_ROOT.
"/modules/main/interface/init_admin.php");
2612 echo CAdminCalendar::calendarDate($fieldNameName, $v, 19, ($fieldType[
"Type"] !=
"date"));
2617 if ($allowSelection && \CBPDocument::IsExpression(trim($value1)))
2620 unset($fieldValueTmp[
$key]);
2622 if($fieldType[
"Type"] ==
"date")
2626 $ar = CIBlockProperty::getUserType(
$type);
2627 echo call_user_func_array(
2628 $ar[
"GetPublicEditHTML"],
2630 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
2631 array(
"VALUE" => $value1),
2633 "FORM_NAME" => $fieldName[
"Form"],
2634 "VALUE" => $fieldNameName
2643 unset($fieldValueTmp[
$key]);
2644 ?><input type=
"text" size=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
2648 if ($allowSelection)
2650 if (!in_array($fieldType[
"Type"],
array(
"file",
"bool",
"date",
"datetime")) && (is_array($customMethodName) &&
count($customMethodName) <= 0 || !is_array($customMethodName) && $customMethodName ==
''))
2652 ?><input type=
"button" value=
"..." onclick=
"BPAShowSelector('<?= $fieldNameId ?>', '<?= htmlspecialcharsbx($fieldType["BaseType
"]) ?>');"><?
2656 if ($fieldType[
"Multiple"])
2660 if ($fieldType[
"Multiple"])
2663 if ($fieldType[
"Multiple"] && $fieldType[
"Type"] !=
"S:HTML" && (($fieldType[
"Type"] !=
"file") ||
$publicMode))
2665 echo
'<input type="button" value="'.GetMessage(
"BPCGHLP_ADD").
'" onclick="CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$fieldName[
"Field"].
'_Table\')"/><br />';
2667 elseif($fieldType[
"Multiple"] && $fieldType[
"Type"] ==
"S:HTML")
2669 $functionOnclick =
'CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$fieldName[
"Field"].
'_Table\');createAdditionalHtmlEditor(\'CBPVirtualDocument_'.$fieldName[
"Field"].
'_Table\');';
2670 echo
'<input type="button" value="'.GetMessage(
"BPCGHLP_ADD").
'" onclick="'.$functionOnclick.
'"/><br />';
2673 if ($allowSelection)
2675 if (in_array($fieldType[
"Type"],
array(
"file",
"bool",
"date",
"datetime")) || (is_array($customMethodName) &&
count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <>
''))
2678 <input type=
"text" id=
"id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text" name=
"<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text" value=
"<?
2679 if (count($fieldValueTmp) > 0)
2681 $a = array_values($fieldValueTmp);
2682 echo htmlspecialcharsbx($a[0]);
2685 <input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field
"]) ?>_text', '<?= htmlspecialcharsbx($fieldType["BaseType
"]) ?>', '<?= $fieldType["Type
"] == 'S:employee'? 'employee' : '' ?>');">
2691 $s = ob_get_contents();
2699 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
2705 if ($fieldType[
"Type"] ==
"user")
2707 $value =
$request[$fieldName[
"Field"]];
2710 $result = CBPHelper::usersStringToArray($value,
array(
"lists", get_called_class(), $documentType),
$errors);
2720 elseif (array_key_exists($fieldName[
"Field"],
$request) || array_key_exists($fieldName[
"Field"].
"_text",
$request))
2722 $valueArray =
array();
2723 if (array_key_exists($fieldName[
"Field"],
$request))
2725 $valueArray =
$request[$fieldName[
"Field"]];
2726 if (!is_array($valueArray) || is_array($valueArray) && CBPHelper::isAssociativeArray($valueArray))
2727 $valueArray =
array($valueArray);
2729 if (array_key_exists($fieldName[
"Field"].
"_text",
$request))
2730 $valueArray[] =
$request[$fieldName[
"Field"].
"_text"];
2732 foreach ($valueArray as $value)
2734 if (is_array($value) || !is_array($value) && !\CBPDocument::IsExpression(trim($value)))
2736 if ($fieldType[
"Type"] ==
"int")
2740 $value = str_replace(
" ",
"", str_replace(
",",
".", $value));
2741 if (is_numeric($value))
2743 $value = doubleval($value);
2749 "code" =>
"ErrorValue",
2750 "message" =>
GetMessage(
"LISTS_BIZPROC_INVALID_INT"),
2751 "parameter" => $fieldName[
"Field"],
2760 elseif ($fieldType[
"Type"] ==
"double")
2764 $value = str_replace(
" ",
"", str_replace(
",",
".", $value));
2765 if (is_numeric($value))
2767 $value = doubleval($value);
2773 "code" =>
"ErrorValue",
2774 "message" =>
GetMessage(
"LISTS_BIZPROC_INVALID_INT"),
2775 "parameter" => $fieldName[
"Field"],
2784 elseif ($fieldType[
"Type"] ==
"select")
2786 if (!is_array($fieldType[
"Options"]) ||
count($fieldType[
"Options"]) <= 0 || $value ==
'')
2792 $ar = array_values($fieldType[
"Options"]);
2793 if (is_array(
$ar[0]))
2798 if (
$a[0] == $value)
2808 "code" =>
"ErrorValue",
2809 "message" =>
GetMessage(
"LISTS_BIZPROC_INVALID_SELECT"),
2810 "parameter" => $fieldName[
"Field"],
2816 if (!array_key_exists($value, $fieldType[
"Options"]))
2820 "code" =>
"ErrorValue",
2821 "message" =>
GetMessage(
"LISTS_BIZPROC_INVALID_SELECT"),
2822 "parameter" => $fieldName[
"Field"],
2828 elseif ($fieldType[
"Type"] ==
"bool")
2830 if ($value !==
"Y" && $value !==
"N")
2832 if ($value ===
true)
2836 elseif ($value ===
false)
2842 $value = mb_strtolower($value);
2843 if (in_array($value,
array(
"y",
"yes",
"true",
"1")))
2847 elseif (in_array($value,
array(
"n",
"no",
"false",
"0")))
2855 "code" =>
"ErrorValue",
2856 "message" =>
GetMessage(
"BPCGWTL_INVALID45"),
2857 "parameter" => $fieldName[
"Field"],
2867 elseif ($fieldType[
"Type"] ==
"file")
2869 if (is_array($value) && array_key_exists(
"name", $value) && $value[
"name"] <>
'')
2871 if (!array_key_exists(
"MODULE_ID", $value) || $value[
"MODULE_ID"] ==
'')
2872 $value[
"MODULE_ID"] =
"bizproc";
2874 $value = CFile::saveFile($value,
"bizproc_wf",
true,
true);
2879 "code" =>
"ErrorValue",
2880 "message" =>
GetMessage(
"BPCGWTL_INVALID915"),
2881 "parameter" => $fieldName[
"Field"],
2890 elseif ($fieldType[
"Type"] ==
"date")
2898 "code" =>
"ErrorValue",
2899 "message" =>
GetMessage(
"LISTS_BIZPROC_INVALID_DATE"),
2900 "parameter" => $fieldName[
"Field"],
2910 elseif ($fieldType[
"Type"] ==
"datetime")
2914 $valueTemporary =
array();
2915 $valueTemporary[
"VALUE"] = $value;
2916 $result = CIBlockPropertyDateTime::checkFields(
'', $valueTemporary);
2925 "code" =>
"ErrorValue",
2927 "parameter" => $fieldName[
"Field"],
2936 elseif (mb_strpos($fieldType[
"Type"],
":") !==
false && $fieldType[
"Type"] !=
"S:HTML")
2938 $customType = CIBlockProperty::getUserType(mb_substr($fieldType[
"Type"], 2));
2939 if (array_key_exists(
"GetLength", $customType))
2941 if (call_user_func_array(
2942 $customType[
"GetLength"],
2944 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
2945 array(
"VALUE" => $value)
2953 if (($value !=
null) && array_key_exists(
"CheckFields", $customType))
2955 $errorsTemporary = call_user_func_array(
2956 $customType[
"CheckFields"],
2958 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
2959 array(
"VALUE" => $value)
2962 if (
count($errorsTemporary) > 0)
2965 foreach ($errorsTemporary as $e)
2967 "code" =>
"ErrorValue",
2969 "parameter" => $fieldName[
"Field"],
2973 elseif (!array_key_exists(
"GetLength", $customType) && $value ===
'')
2978 $fieldType[
"Type"] ==
"S:employee" &&
2979 COption::getOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y"
2982 $value =
"user_".$value;
2987 if (!is_array($value) && $value ==
'')
2992 if ($value !==
null)
2997 if (!$fieldType[
"Multiple"])
3012 switch ($fieldType[
'Type'])
3015 if (!is_array($fieldValue))
3016 $fieldValue =
array($fieldValue);
3018 $result = CBPHelper::usersArrayToString($fieldValue,
null,
array(
"lists", get_called_class(), $documentType));
3022 if (is_array($fieldValue))
3025 foreach ($fieldValue as $r)
3035 if (is_array($fieldValue))
3038 foreach ($fieldValue as $r)
3041 $imgQuery = CFile::getByID($r);
3042 if ($img = $imgQuery->fetch())
3043 $result[] =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($img[
"FILE_NAME"]).
"&i=".$r.
"&h=".md5($img[
"SUBDIR"]).
"]".
htmlspecialcharsbx($img[
"ORIGINAL_NAME"]).
"[/url]";
3048 $fieldValue = intval($fieldValue);
3049 $imgQuery = CFile::getByID($fieldValue);
3050 if ($img = $imgQuery->fetch())
3051 $result =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($img[
"FILE_NAME"]).
"&i=".$fieldValue.
"&h=".md5($img[
"SUBDIR"]).
"]".
htmlspecialcharsbx($img[
"ORIGINAL_NAME"]).
"[/url]";
3056 if (is_array($fieldType[
"Options"]))
3058 if (is_array($fieldValue))
3061 foreach ($fieldValue as $r)
3063 if (array_key_exists($r, $fieldType[
"Options"]))
3064 $result[] = $fieldType[
"Options"][$r];
3069 if (array_key_exists($fieldValue, $fieldType[
"Options"]))
3070 $result = $fieldType[
"Options"][$fieldValue];
3076 if (mb_strpos($fieldType[
'Type'],
":") !==
false)
3078 if ($fieldType[
"Type"] ==
"S:employee")
3079 $fieldValue = CBPHelper::stripUserPrefix($fieldValue);
3081 $customType = CIBlockProperty::getUserType(mb_substr($fieldType[
'Type'], 2));
3082 if (array_key_exists(
"GetPublicViewHTML", $customType))
3084 if (is_array($fieldValue) && !CBPHelper::isAssociativeArray($fieldValue))
3087 foreach ($fieldValue as $value)
3089 $r = call_user_func_array(
3090 $customType[
"GetPublicViewHTML"],
3092 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
3093 array(
"VALUE" => $value),
3103 $result = call_user_func_array(
3104 $customType[
"GetPublicViewHTML"],
3106 array(
"LINK_IBLOCK_ID" => $fieldType[
"Options"]),
3107 array(
"VALUE" => $fieldValue),
3163 $ID = intval($documentId);
3165 $elementQuery = CIBlockElement::getList(
array(),
array(
"ID"=>
$ID,
"SHOW_HISTORY"=>
"Y"),
false,
false,
3180 "PREVIEW_TEXT_TYPE",
3185 "WF_PARENT_ELEMENT_ID",
3195 if($element = $elementQuery->fetch())
3197 $parentId = intval($element[
"WF_PARENT_ELEMENT_ID"]);
3201 $element[
"WF_PARENT_ELEMENT_ID"] =
false;
3203 if($element[
"PREVIEW_PICTURE"])
3204 $element[
"PREVIEW_PICTURE"] = CFile::makeFileArray($element[
"PREVIEW_PICTURE"]);
3206 $element[
"PREVIEW_PICTURE"] =
array(
"tmp_name" =>
"",
"del" =>
"Y");
3208 if($element[
"DETAIL_PICTURE"])
3209 $element[
"DETAIL_PICTURE"] = CFile::makeFileArray($element[
"DETAIL_PICTURE"]);
3211 $element[
"DETAIL_PICTURE"] =
array(
"tmp_name" =>
"",
"del" =>
"Y");
3213 $element[
"IBLOCK_SECTION"] =
array();
3214 if($element[
"IN_SECTIONS"] ==
"Y")
3216 $sectionsQuery = CIBlockElement::getElementGroups($element[
"ID"],
true,
array(
'ID',
'IBLOCK_ELEMENT_ID'));
3217 while($section = $sectionsQuery->fetch())
3218 $element[
"IBLOCK_SECTION"][] = $section[
"ID"];
3221 $element[
"PROPERTY_VALUES"] =
array();
3222 $props = &$element[
"PROPERTY_VALUES"];
3225 $propsQuery = CIBlockElement::getProperty($element[
"IBLOCK_ID"], $parentId,
array(
"value_id" =>
"asc"),
array(
"PROPERTY_TYPE" =>
"F",
"EMPTY" =>
"N"));
3226 while($prop = $propsQuery->fetch())
3228 if(!array_key_exists($prop[
"ID"],
$props))
3230 $props[$prop[
"ID"]][$prop[
"PROPERTY_VALUE_ID"]] =
array(
3231 "VALUE" =>
array(
"tmp_name" =>
"",
"del" =>
"Y"),
3232 "DESCRIPTION" =>
false,
3237 $propsQuery = CIBlockElement::getProperty($element[
"IBLOCK_ID"], $element[
"ID"],
array(
"value_id" =>
"asc"));
3239 while($prop = $propsQuery->fetch())
3242 if(!array_key_exists($prop[
"ID"],
$props))
3245 if($prop[
"PROPERTY_VALUE_ID"])
3247 if($prop[
"PROPERTY_TYPE"] ==
"F")
3249 "VALUE" => CFile::makeFileArray($prop[
"VALUE"]),
3250 "DESCRIPTION" => $prop[
"DESCRIPTION"],
3254 "VALUE" => $prop[
"VALUE"],
3255 "DESCRIPTION" => $prop[
"DESCRIPTION"],
3260 $elementObject->update($parentId, $element);
3261 CBPDocument::mergeDocuments(
3262 array(
"lists", get_called_class(), $parentId),
3263 array(
"lists", get_called_class(), $documentId)
3265 CIBlockElement::delete(
$ID);
3266 CIBlockElement::wF_CleanUpHistoryCopies($parentId, 0);
3267 $strSql =
"update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=".$parentId.
" AND WF_PARENT_ELEMENT_ID IS NULL";
3268 $DB->Query($strSql);
3269 CIBlockElement::updateSearch($parentId);
3274 CIBlockElement::wF_CleanUpHistoryCopies(
$ID, 0);
3275 $strSql =
"update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=".$ID.
" AND WF_PARENT_ELEMENT_ID IS NULL";
3276 $DB->Query($strSql);
3277 CIBlockElement::updateSearch(
$ID);
3293 $documentId = intval($documentId);
3294 if ($documentId <= 0)
3299 $dbDocumentList = CIBlockElement::getList(
3301 array(
"ID" => $documentId,
"SHOW_NEW"=>
"Y",
"SHOW_HISTORY" =>
"Y")
3303 if ($objDocument = $dbDocumentList->getNextElement())
3305 $fields = $objDocument->getFields();
3306 $properties = $objDocument->getProperties();
3311 foreach (
$fields as $fieldKey => $fieldValue)
3313 if ($fieldKey ==
"~PREVIEW_PICTURE" || $fieldKey ==
"~DETAIL_PICTURE")
3315 $result[
"FIELDS"][mb_substr($fieldKey, 1)] = CBPDocument::prepareFileForHistory(
3316 array(
"lists", get_called_class(), $documentId),
3321 elseif (mb_substr($fieldKey, 0, 1) ==
"~")
3323 $result[
"FIELDS"][mb_substr($fieldKey, 1)] = $fieldValue;
3347 "VALUE" => CBPDocument::prepareFileForHistory(
3348 array(
"lists", get_called_class(), $documentId),