5if (!CModule::IncludeModule(
"bizproc"))
17 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
25 static $arDocumentFieldTypes =
array();
26 if (!array_key_exists($documentType, $arDocumentFieldTypes))
29 $arFieldType[
"BaseType"] =
"string";
30 $arFieldType[
"Complex"] =
false;
31 if (array_key_exists($arFieldType[
"Type"], $arDocumentFieldTypes[$documentType]))
33 $arFieldType[
"BaseType"] = $arDocumentFieldTypes[$documentType][$arFieldType[
"Type"]][
"BaseType"];
34 $arFieldType[
"Complex"] = $arDocumentFieldTypes[$documentType][$arFieldType[
"Type"]][
"Complex"];
37 if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::IsAssociativeArray($fieldValue))
38 $fieldValue =
array($fieldValue);
40 $customMethodName =
"";
41 $customMethodNameMulty =
"";
42 if (mb_strpos($arFieldType[
"Type"],
":") !==
false)
44 $ar = CIBlockProperty::GetUserType(mb_substr($arFieldType[
"Type"], 2));
45 if (array_key_exists(
"GetPublicEditHTML",
$ar))
46 $customMethodName =
$ar[
"GetPublicEditHTML"];
47 if (array_key_exists(
"GetPublicEditHTMLMulty",
$ar))
48 $customMethodNameMulty =
$ar[
"GetPublicEditHTMLMulty"];
53 if ($arFieldType[
"Type"] ==
"select")
55 $fieldValueTmp = $fieldValue;
57 <
select id=
"id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>" name=
"<?= htmlspecialcharsbx($arFieldName["Field
"]).($arFieldType["Multiple
"] ? "[]
" : "") ?>"<?= ($arFieldType[
"Multiple"] ?
' size="5" multiple' :
'') ?>>
59 if (!$arFieldType[
"Required"])
60 echo
'<option value="">['.GetMessage(
"BPCGHLP_NOT_SET").
']</option>';
61 if(!empty($arFieldType[
"Options"]))
63 foreach ($arFieldType[
"Options"] as
$k => $v)
65 if (is_array($v) &&
count($v) == 2)
67 $v1 = array_values($v);
72 $ind = array_search(
$k, $fieldValueTmp);
73 echo
'<option value="'.htmlspecialcharsbx(
$k).
'"'.($ind !==
false ?
' selected' :
'').
'>'.
htmlspecialcharsbx($v).
'</option>';
75 unset($fieldValueTmp[$ind]);
84 <br /><input type=
"text" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text" name=
"<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text" value=
"<?
85 if (count($fieldValueTmp) > 0)
87 $a = array_values($fieldValueTmp);
88 echo htmlspecialcharsbx($a[0]);
91 <input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text', 'select');">
95 elseif ($arFieldType[
"Type"] ==
"user")
97 $fieldValue = CBPHelper::UsersArrayToString($fieldValue,
null,
array(
"iblock",
"CIBlockDocument", $documentType));
98 ?><input type=
"text" size=
"40" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>" name=
"<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>" value=
"<?= htmlspecialcharsbx($fieldValue) ?>"><input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>', 'user');"><?
100 elseif ((mb_strpos($arFieldType[
"Type"],
":") !==
false)
101 && $arFieldType[
"Multiple"]
103 is_array($customMethodNameMulty) &&
count($customMethodNameMulty) > 0
104 || !is_array($customMethodNameMulty) && $customMethodNameMulty <>
''
108 if (!is_array($fieldValue))
109 $fieldValue =
array();
111 if ($bAllowSelection)
113 $fieldValueTmp1 =
array();
114 $fieldValueTmp2 =
array();
115 foreach ($fieldValue as $v)
118 if (CBPDocument::IsExpression($vTrim))
119 $fieldValueTmp1[] = $vTrim;
121 $fieldValueTmp2[] = $v;
126 $fieldValueTmp1 =
array();
127 $fieldValueTmp2 = $fieldValue;
130 if (($arFieldType[
"Type"] ==
"S:employee") && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
131 $fieldValueTmp2 = CBPHelper::StripUserPrefix($fieldValueTmp2);
133 foreach ($fieldValueTmp2 as &$fld)
134 if (!isset($fld[
'VALUE']))
135 $fld =
array(
"VALUE" => $fld);
137 if ($arFieldType[
"Type"] ==
"E:EList")
142 if (!empty(
$_SERVER[
'HTTP_BX_AJAX']))
143 $GLOBALS[
"APPLICATION"]->ShowAjaxHead();
144 $GLOBALS[
"APPLICATION"]->AddHeadScript(
'/bitrix/js/iblock/iblock_edit.js');
148 echo call_user_func_array(
149 $customMethodNameMulty,
151 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
154 "FORM_NAME" => $arFieldName[
"Form"],
161 if ($bAllowSelection)
164 <br /><input type=
"text" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text" name=
"<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text" value=
"<?
165 if (count($fieldValueTmp1) > 0)
167 $a = array_values($fieldValueTmp1);
168 echo htmlspecialcharsbx($a[0]);
171 <input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text', 'user', '<?= $arFieldType["Type
"] == 'S:employee'? 'employee' : '' ?>');">
177 if (!array_key_exists(
"CBPVirtualDocumentCloneRowPrinted",
$GLOBALS) && $arFieldType[
"Multiple"])
179 $GLOBALS[
"CBPVirtualDocumentCloneRowPrinted"] = 1;
182 function CBPVirtualDocumentCloneRow(tableID)
184 var tbl = document.getElementById(tableID);
185 var cnt = tbl.rows.length;
186 var oRow = tbl.insertRow(cnt);
187 var oCell = oRow.insertCell(0);
188 var sHTML = tbl.rows[cnt - 1].cells[0].innerHTML;
192 var s = sHTML.indexOf(
'[n', p);
195 var e = sHTML.indexOf(
']', s);
198 var n = parseInt(sHTML.substr(s + 2, e - s));
199 sHTML = sHTML.substr(0, s) +
'[n' + (++n) +
']' + sHTML.substr(e + 1);
205 var s = sHTML.indexOf(
'__n', p);
208 var e = sHTML.indexOf(
'_', s + 2);
211 var n = parseInt(sHTML.substr(s + 3, e - s));
212 sHTML = sHTML.substr(0, s) +
'__n' + (++n) +
'_' + sHTML.substr(e + 1);
215 oCell.innerHTML = sHTML;
216 var patt =
new RegExp(
'<' +
'script' +
'>[^\000]*?<' +
'\/' +
'script' +
'>',
'ig');
217 var code = sHTML.match(patt);
220 for (var i = 0; i < code.length; i++)
224 var s = code[i].substring(8, code[i].length - 9);
225 jsUtils.EvalGlobal(s);
230 function createAdditionalHtmlEditor(tableId)
232 var tbl = document.getElementById(tableId);
233 var cnt = tbl.rows.length-1;
234 var name = tableId.replace(/(?:CBPVirtualDocument_)(.*)(?:_Table)/,
'$1')
235 var idEditor =
'id_'+name+
'__n'+cnt+
'_';
236 var inputNameEditor = name+
'[n'+cnt+
']';
237 window.BXHtmlEditor.Show(
240 'inputName':inputNameEditor,
242 'useFileDialogs':
false,
246 'limitPhpAccess':
false,
250 'componentFilter':
'',
252 'placeholder':
'Text here...',
253 'actionUrl':
'/bitrix/tools/html_editor_action.php',
254 'cssIframePath':
'/bitrix/js/fileman/html_editor/iframe-style.css?1412693817',
257 'spellcheck_path':
'/bitrix/js/fileman/html_editor/html-spell.js?v=1412693817',
259 'useCustomSpell':
'Y',
261 'askBeforeUnloadPage':
true,
262 'settingsKey':
'user_settings_1',
263 'showComponents':
true,
266 'splitVertical':
false,
268 'taskbarShown':
false,
269 'taskbarWidth':
'250',
270 'lastSpecialchars':
false,
271 'cleanEmptySpans':
true,
273 'showTaskbars':
false,
274 'showNodeNavi':
false,
276 {
'id':
'Bold',
'compact':
true,
'sort':
'80'},
277 {
'id':
'Italic',
'compact':
true,
'sort':
'90'},
278 {
'id':
'Underline',
'compact':
true,
'sort':
'100'},
279 {
'id':
'Strikeout',
'compact':
true,
'sort':
'110'},
280 {
'id':
'RemoveFormat',
'compact':
true,
'sort':
'120'},
281 {
'id':
'Color',
'compact':
true,
'sort':
'130'},
282 {
'id':
'FontSelector',
'compact':
false,
'sort':
'135'},
283 {
'id':
'FontSize',
'compact':
false,
'sort':
'140'},
284 {
'separator':
true,
'compact':
false,
'sort':
'145'},
285 {
'id':
'OrderedList',
'compact':
true,
'sort':
'150'},
286 {
'id':
'UnorderedList',
'compact':
true,
'sort':
'160'},
287 {
'id':
'AlignList',
'compact':
false,
'sort':
'190'},
288 {
'separator':
true,
'compact':
false,
'sort':
'200'},
289 {
'id':
'InsertLink',
'compact':
true,
'sort':
'210',
'wrap':
'bx-b-link-'+idEditor},
290 {
'id':
'InsertImage',
'compact':
false,
'sort':
'220'},
291 {
'id':
'InsertVideo',
'compact':
true,
'sort':
'230',
'wrap':
'bx-b-video-'+idEditor},
292 {
'id':
'InsertTable',
'compact':
false,
'sort':
'250'},
293 {
'id':
'Code',
'compact':
true,
'sort':
'260'},
294 {
'id':
'Quote',
'compact':
true,
'sort':
'270',
'wrap':
'bx-b-quote-'+idEditor},
295 {
'id':
'Smile',
'compact':
false,
'sort':
'280'},
296 {
'separator':
true,
'compact':
false,
'sort':
'290'},
297 {
'id':
'Fullscreen',
'compact':
false,
'sort':
'310'},
298 {
'id':
'BbCode',
'compact':
true,
'sort':
'340'},
299 {
'id':
'More',
'compact':
true,
'sort':
'400'}],
301 'autoResizeOffset':
'40',
302 'minBodyWidth':
'350',
303 'normalBodyWidth':
'555'
305 var htmlEditor = BX.findChildrenByClassName(BX(tableId),
'bx-html-editor');
306 for(var k in htmlEditor)
308 var editorId = htmlEditor[k].getAttribute(
'id');
309 var frameArray = BX.findChildrenByClassName(BX(editorId),
'bx-editor-iframe');
310 if(frameArray.length > 1)
312 for(var i = 0; i < frameArray.length - 1; i++)
314 frameArray[i].parentNode.removeChild(frameArray[i]);
324 if ($arFieldType[
"Multiple"])
325 echo
'<table width="100%" border="0" cellpadding="2" cellspacing="2" id="CBPVirtualDocument_'.htmlspecialcharsbx($arFieldName[
"Field"]).
'_Table">';
327 $fieldValueTmp = $fieldValue;
329 if (
sizeof($fieldValue) == 0)
330 $fieldValue[] =
null;
333 foreach ($fieldValue as
$key => $value)
336 $fieldNameId =
'id_'.htmlspecialcharsbx($arFieldName[
"Field"]).
'__n'.$ind.
'_';
337 $fieldNameName =
htmlspecialcharsbx($arFieldName[
"Field"]).($arFieldType[
"Multiple"] ?
"[n".$ind.
"]" :
"");
339 if ($arFieldType[
"Multiple"])
342 if (is_array($customMethodName) &&
count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <>
'')
344 if($arFieldType[
"Type"] ==
"S:HTML")
346 if (CModule::includeModule(
"fileman"))
348 $editor = new \CHTMLEditor;
351 'useFileDialogs' =>
false,
353 'useFileDialogs' =>
false,
354 'minBodyWidth' => 350,
355 'normalBodyWidth' => 555,
356 'bAllowPhp' =>
false,
357 'limitPhpAccess' =>
false,
358 'showTaskbars' =>
false,
359 'showNodeNavi' =>
false,
360 'askBeforeUnloadPage' =>
true,
363 'autoResize' =>
true,
364 'autoResizeOffset' => 40,
365 'saveOnBlur' =>
true,
366 'controlsMap' =>
array(
367 array(
'id' =>
'Bold',
'compact' =>
true,
'sort' => 80),
368 array(
'id' =>
'Italic',
'compact' =>
true,
'sort' => 90),
369 array(
'id' =>
'Underline',
'compact' =>
true,
'sort' => 100),
370 array(
'id' =>
'Strikeout',
'compact' =>
true,
'sort' => 110),
371 array(
'id' =>
'RemoveFormat',
'compact' =>
true,
'sort' => 120),
372 array(
'id' =>
'Color',
'compact' =>
true,
'sort' => 130),
373 array(
'id' =>
'FontSelector',
'compact' =>
false,
'sort' => 135),
374 array(
'id' =>
'FontSize',
'compact' =>
false,
'sort' => 140),
375 array(
'separator' =>
true,
'compact' =>
false,
'sort' => 145),
376 array(
'id' =>
'OrderedList',
'compact' =>
true,
'sort' => 150),
377 array(
'id' =>
'UnorderedList',
'compact' =>
true,
'sort' => 160),
378 array(
'id' =>
'AlignList',
'compact' =>
false,
'sort' => 190),
379 array(
'separator' =>
true,
'compact' =>
false,
'sort' => 200),
380 array(
'id' =>
'InsertLink',
'compact' =>
true,
'sort' => 210,
'wrap' =>
'bx-b-link-'.$fieldNameId),
381 array(
'id' =>
'InsertImage',
'compact' =>
false,
'sort' => 220),
382 array(
'id' =>
'InsertVideo',
'compact' =>
true,
'sort' => 230,
'wrap' =>
'bx-b-video-'.$fieldNameId),
383 array(
'id' =>
'InsertTable',
'compact' =>
false,
'sort' => 250),
384 array(
'id' =>
'Code',
'compact' =>
true,
'sort' => 260),
385 array(
'id' =>
'Quote',
'compact' =>
true,
'sort' => 270,
'wrap' =>
'bx-b-quote-'.$fieldNameId),
386 array(
'id' =>
'Smile',
'compact' =>
false,
'sort' => 280),
387 array(
'separator' =>
true,
'compact' =>
false,
'sort' => 290),
388 array(
'id' =>
'Fullscreen',
'compact' =>
false,
'sort' => 310),
389 array(
'id' =>
'BbCode',
'compact' =>
true,
'sort' => 340),
390 array(
'id' =>
'More',
'compact' =>
true,
'sort' => 400)
394 'name' => $fieldNameName,
395 'inputName' => $fieldNameName,
396 'id' => $fieldNameId,
398 'content' => htmlspecialcharsBack($value),
405 ?><textarea rows=
"5" cols=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?=
htmlspecialcharsbx($value) ?></textarea><?
411 if ($bAllowSelection && CBPDocument::IsExpression(trim($value1)))
414 unset($fieldValueTmp[
$key]);
416 if (($arFieldType[
"Type"] ==
"S:employee") && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
417 $value1 = CBPHelper::StripUserPrefix($value1);
419 echo call_user_func_array(
422 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
423 array(
"VALUE" => $value1),
425 "FORM_NAME" => $arFieldName[
"Form"],
426 "VALUE" => $fieldNameName
435 switch ($arFieldType[
"Type"])
439 unset($fieldValueTmp[
$key]);
440 ?><input type=
"text" size=
"10" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
446 ?><input type=
"file" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?
450 if (in_array($value,
array(
"Y",
"N")))
451 unset($fieldValueTmp[
$key]);
453 <
select id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>">
455 if (!$arFieldType[
"Required"])
456 echo
'<option value="">['.GetMessage(
"BPCGHLP_NOT_SET").
']</option>';
458 <option value=
"Y"<?= (in_array(
"Y", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPCGHLP_YES") ?></option>
459 <option value=
"N"<?= (in_array(
"N", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPCGHLP_NO") ?></option>
464 unset($fieldValueTmp[
$key]);
465 ?><textarea rows=
"5" cols=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?=
htmlspecialcharsbx($value) ?></textarea><?
473 if (!CBPDocument::IsExpression(trim($value)))
476 unset($fieldValueTmp[
$key]);
478 require_once(
$_SERVER[
"DOCUMENT_ROOT"].
BX_ROOT.
"/modules/main/interface/init_admin.php");
484 if ($bAllowSelection && CBPDocument::IsExpression(trim($value1)))
487 unset($fieldValueTmp[
$key]);
489 if($arFieldType[
"Type"] ==
"date")
493 $ar = CIBlockProperty::GetUserType(
$type);
494 echo call_user_func_array(
495 $ar[
"GetPublicEditHTML"],
497 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
498 array(
"VALUE" => $value1),
500 "FORM_NAME" => $arFieldName[
"Form"],
501 "VALUE" => $fieldNameName
510 unset($fieldValueTmp[
$key]);
511 ?><input type=
"text" size=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
515 if ($bAllowSelection)
517 if (!in_array($arFieldType[
"Type"],
array(
"file",
"bool",
"date",
"datetime")) && (is_array($customMethodName) &&
count($customMethodName) <= 0 || !is_array($customMethodName) && $customMethodName ==
''))
519 ?><input type=
"button" value=
"..." onclick=
"BPAShowSelector('<?= $fieldNameId ?>', '<?= htmlspecialcharsbx($arFieldType["BaseType
"]) ?>');"><?
523 if ($arFieldType[
"Multiple"])
527 if ($arFieldType[
"Multiple"])
530 if ($arFieldType[
"Multiple"] && $arFieldType[
"Type"] !=
"S:HTML" && (($arFieldType[
"Type"] !=
"file") ||
$publicMode))
532 echo
'<input type="button" value="'.GetMessage(
"BPCGHLP_ADD").
'" onclick="CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$arFieldName[
"Field"].
'_Table\')"/><br />';
534 elseif($arFieldType[
"Multiple"] && $arFieldType[
"Type"] ==
"S:HTML")
536 $functionOnclick =
'CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$arFieldName[
"Field"].
'_Table\');createAdditionalHtmlEditor(\'CBPVirtualDocument_'.$arFieldName[
"Field"].
'_Table\');';
537 echo
'<input type="button" value="'.GetMessage(
"BPCGHLP_ADD").
'" onclick="'.$functionOnclick.
'"/><br />';
540 if ($bAllowSelection)
542 if (in_array($arFieldType[
"Type"],
array(
"file",
"bool",
"date",
"datetime")) || (is_array($customMethodName) &&
count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <>
''))
545 <input type=
"text" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text" name=
"<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text" value=
"<?
546 if (count($fieldValueTmp) > 0)
548 $a = array_values($fieldValueTmp);
549 echo htmlspecialcharsbx($a[0]);
552 <input type=
"button" value=
"..." onclick=
"BPAShowSelector('id_<?= htmlspecialcharsbx($arFieldName["Field
"]) ?>_text', '<?= htmlspecialcharsbx($arFieldType["BaseType
"]) ?>', '<?= $arFieldType["Type
"] == 'S:employee'? 'employee' : '' ?>');">
558 $s = ob_get_contents();
564 public static function GetFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors)
567 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
573 if ($arFieldType[
"Type"] ==
"user")
575 $value = $arRequest[$arFieldName[
"Field"]];
578 $result = CBPHelper::UsersStringToArray($value,
array(
"iblock",
"CIBlockDocument", $documentType), $arErrors);
579 if (
count($arErrors) > 0)
581 foreach ($arErrors as $e)
586 elseif (array_key_exists($arFieldName[
"Field"], $arRequest) || array_key_exists($arFieldName[
"Field"].
"_text", $arRequest))
589 if (array_key_exists($arFieldName[
"Field"], $arRequest))
591 $arValue = $arRequest[$arFieldName[
"Field"]];
592 if (!is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue))
593 $arValue =
array($arValue);
595 if (array_key_exists($arFieldName[
"Field"].
"_text", $arRequest))
596 $arValue[] = $arRequest[$arFieldName[
"Field"].
"_text"];
598 foreach ($arValue as $value)
600 if (is_array($value) || !is_array($value) && !CBPDocument::IsExpression(trim($value)))
602 if ($arFieldType[
"Type"] ==
"int")
606 $value = str_replace(
" ",
"", $value);
607 if ($value.
"|" == intval($value).
"|")
609 $value = intval($value);
615 "code" =>
"ErrorValue",
617 "parameter" => $arFieldName[
"Field"],
626 elseif ($arFieldType[
"Type"] ==
"double")
630 $value = str_replace(
" ",
"", str_replace(
",",
".", $value));
631 if (is_numeric($value))
633 $value = doubleval($value);
639 "code" =>
"ErrorValue",
641 "parameter" => $arFieldName[
"Field"],
650 elseif ($arFieldType[
"Type"] ==
"select")
652 if (!is_array($arFieldType[
"Options"]) ||
count($arFieldType[
"Options"]) <= 0 || $value ==
'')
658 $ar = array_values($arFieldType[
"Options"]);
659 if (is_array(
$ar[0]))
674 "code" =>
"ErrorValue",
676 "parameter" => $arFieldName[
"Field"],
682 if (!array_key_exists($value, $arFieldType[
"Options"]))
686 "code" =>
"ErrorValue",
688 "parameter" => $arFieldName[
"Field"],
694 elseif ($arFieldType[
"Type"] ==
"bool")
696 if ($value !==
"Y" && $value !==
"N")
708 $value = mb_strtolower($value);
709 if (in_array($value,
array(
"y",
"yes",
"true",
"1")))
713 elseif (in_array($value,
array(
"n",
"no",
"false",
"0")))
721 "code" =>
"ErrorValue",
723 "parameter" => $arFieldName[
"Field"],
733 elseif ($arFieldType[
"Type"] ==
"file")
735 if (is_array($value) && array_key_exists(
"name", $value) && $value[
"name"] <>
'')
737 if (!array_key_exists(
"MODULE_ID", $value) || $value[
"MODULE_ID"] ==
'')
738 $value[
"MODULE_ID"] =
"bizproc";
740 $value = CFile::SaveFile($value,
"bizproc_wf",
true,
true);
745 "code" =>
"ErrorValue",
746 "message" =>
GetMessage(
"BPCGWTL_INVALID915"),
747 "parameter" => $arFieldName[
"Field"],
756 elseif (mb_strpos($arFieldType[
"Type"],
":") !==
false)
758 $arCustomType = CIBlockProperty::GetUserType(mb_substr($arFieldType[
"Type"], 2));
759 if (array_key_exists(
"GetLength", $arCustomType))
761 if (call_user_func_array(
762 $arCustomType[
"GetLength"],
764 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
765 array(
"VALUE" => $value)
773 if (($value !=
null) && array_key_exists(
"CheckFields", $arCustomType))
775 $arErrorsTmp1 = call_user_func_array(
776 $arCustomType[
"CheckFields"],
778 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
779 array(
"VALUE" => $value)
782 if (
count($arErrorsTmp1) > 0)
785 foreach ($arErrorsTmp1 as $e)
787 "code" =>
"ErrorValue",
789 "parameter" => $arFieldName[
"Field"],
793 elseif (!array_key_exists(
"GetLength", $arCustomType) && $value ===
'')
796 if (($value !==
null)
797 && ($arFieldType[
"Type"] ==
"S:employee")
798 && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
800 $value =
"user_".$value;
805 if (!is_array($value) && $value ==
'')
815 if (!$arFieldType[
"Multiple"])
830 switch ($arFieldType[
'Type'])
833 if (!is_array($fieldValue))
834 $fieldValue =
array($fieldValue);
836 $result = CBPHelper::UsersArrayToString($fieldValue,
null,
array(
"iblock",
"CIBlockDocument", $documentType));
840 if (is_array($fieldValue))
843 foreach ($fieldValue as $r)
853 if (is_array($fieldValue))
856 foreach ($fieldValue as $r)
859 $dbImg = CFile::GetByID($r);
860 if ($arImg = $dbImg->Fetch())
861 $result[] =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$r.
"&h=".md5($arImg[
"SUBDIR"]).
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
866 $fieldValue = intval($fieldValue);
867 $dbImg = CFile::GetByID($fieldValue);
868 if ($arImg = $dbImg->Fetch())
869 $result =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$fieldValue.
"&h=".md5($arImg[
"SUBDIR"]).
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
874 if (is_array($arFieldType[
"Options"]))
876 if (is_array($fieldValue))
879 foreach ($fieldValue as $r)
881 if (array_key_exists($r, $arFieldType[
"Options"]))
882 $result[] = $arFieldType[
"Options"][$r];
887 if (array_key_exists($fieldValue, $arFieldType[
"Options"]))
888 $result = $arFieldType[
"Options"][$fieldValue];
894 if (mb_strpos($arFieldType[
'Type'],
":") !==
false)
896 if ($arFieldType[
"Type"] ==
"S:employee")
897 $fieldValue = CBPHelper::StripUserPrefix($fieldValue);
899 $arCustomType = CIBlockProperty::GetUserType(mb_substr($arFieldType[
'Type'], 2));
900 if (array_key_exists(
"GetPublicViewHTML", $arCustomType))
902 if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue))
905 foreach ($fieldValue as $value)
907 $r = call_user_func_array(
908 $arCustomType[
"GetPublicViewHTML"],
910 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
911 array(
"VALUE" => $value),
921 $result = call_user_func_array(
922 $arCustomType[
"GetPublicViewHTML"],
924 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
925 array(
"VALUE" => $fieldValue),
940 $documentType =
null;
942 if ($fieldType ==
"user")
944 static $arCache =
array();
945 if (!array_key_exists($documentId, $arCache))
947 if (mb_substr($documentId, 0, mb_strlen(
"iblock_")) ==
"iblock_")
948 $arCache[$documentId] = $documentId;
952 $documentType = $arCache[$documentId];
955 if (is_null($arFieldType) || !is_array($arFieldType) ||
count($arFieldType) <= 0)
956 $arFieldType =
array();
957 $arFieldType[
"Type"] = $fieldType;
966 $v = intval(COption::GetOptionString(
"iblock",
"~iblock_document_version", 2));
976 $documentId = intval($documentId);
977 if ($documentId <= 0)
980 $db = CIBlockElement::GetList(
982 array(
"ID" => $documentId,
"SHOW_NEW"=>
"Y",
"SHOW_HISTORY" =>
"Y"),
985 array(
"ID",
"IBLOCK_ID",
"IBLOCK_TYPE_ID",
"DETAIL_PAGE_URL")
987 if (
$ar = $db->Fetch())
989 foreach(
GetModuleEvents(
"iblock",
"CIBlockDocument_OnGetDocumentAdminPage",
true) as $arEvent)
995 return "/bitrix/admin/iblock_element_edit.php?view=Y&ID=".$documentId.
"&IBLOCK_ID=".
$ar[
"IBLOCK_ID"].
"&type=".
$ar[
"IBLOCK_TYPE_ID"];
1009 $documentId = intval($documentId);
1010 if ($documentId <= 0)
1013 $db = CIBlockElement::GetList(
1015 array(
"ID" => $documentId,
"SHOW_NEW"=>
"Y",
"SHOW_HISTORY" =>
"Y"),
1020 if (
$ar = $db->fetch())
1030 if (mb_strpos($documentType,
'iblock_') !== 0)
1032 return $documentType;
1035 $id = (int)mb_substr($documentType, 7);
1041 return $documentType;
1044 return '['.$result[
'IBLOCK_TYPE_ID'].
'] '.
$result[
'NAME'];
1049 if (mb_strpos($documentType,
'iblock_') !== 0)
1051 return $documentType;
1054 $id = (int)mb_substr($documentType, 7);
1060 'CHECK_PERMISSIONS' =>
'N'
1065 return $documentType;
1079 [
"ID" => $documentId,
"SHOW_NEW" =>
"Y",
"SHOW_HISTORY" =>
"Y"],
1082 [
"ID",
"IBLOCK_ID"],
1096 $args = func_get_args();
1098 $documentId = (int)$documentId;
1099 if ($documentId <= 0)
1111 'CREATED_BY_PRINTABLE' =>
'CREATED_USER_NAME',
1112 'MODIFIED_BY_PRINTABLE' =>
'USER_NAME',
1115 $select = array_map(
static fn($selectField) => $userNameFields[$selectField] ?? $selectField,
$select);
1119 [
'ID' => $documentId,
'SHOW_NEW' =>
'Y',
'SHOW_HISTORY' =>
'Y'],
1122 if ($objDocument =
$iterator->GetNextElement(
false,
true))
1124 $arDocumentFields = $objDocument->GetFields();
1125 $arDocumentProperties = $objDocument->GetProperties();
1127 foreach ($arDocumentFields as $fieldKey => $fieldValue)
1129 if (mb_substr($fieldKey, 0, 1) ==
"~")
1133 if (in_array($fieldKey,
array(
"MODIFIED_BY",
"CREATED_BY")))
1135 $arResult[$fieldKey] =
"user_".$fieldValue;
1136 $arResult[$fieldKey.
"_PRINTABLE"] = $arDocumentFields[($fieldKey ==
"MODIFIED_BY") ?
"USER_NAME" :
"CREATED_USER_NAME"];
1138 elseif (in_array($fieldKey,
array(
"PREVIEW_TEXT",
"DETAIL_TEXT")))
1140 if ($arDocumentFields[$fieldKey.
"_TYPE"] ==
"html")
1145 foreach ($arDocumentProperties as $propertyKey =>
$propertyValue)
1150 (COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y"))
1161 $userQuery = CUser::getList(
'ID',
'ASC',
1162 array(
'ID' => $listUsers) ,
1163 array(
'FIELDS' =>
array(
'ID' ,
'LOGIN',
'NAME',
'LAST_NAME')));
1164 while($user = $userQuery->fetch())
1168 $arResult[
"PROPERTY_".$propertyKey][] =
"user_".intval($user[
'ID']);
1169 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"][] =
"(".$user[
"LOGIN"].
")".
1170 (($user[
"NAME"] <>
'' || $user[
"LAST_NAME"] <>
'') ?
" " :
"").$user[
"NAME"].
1171 (($user[
"NAME"] <>
'' && $user[
"LAST_NAME"] <>
'') ?
" " :
"").$user[
"LAST_NAME"];
1175 $arResult[
"PROPERTY_".$propertyKey] =
"user_".intval($user[
'ID']);
1176 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"] =
"(".$user[
"LOGIN"].
")".
1177 (($user[
"NAME"] <>
'' || $user[
"LAST_NAME"] <>
'') ?
" " :
"").$user[
"NAME"].
1178 (($user[
"NAME"] <>
'' && $user[
"LAST_NAME"] <>
'') ?
" " :
"").$user[
"LAST_NAME"];
1198 $userType = \CIBlockProperty::getUserType(
$propertyValue[
'USER_TYPE']);
1200 if (array_key_exists(
'GetObjectId', $userType))
1202 $fileId = call_user_func_array($userType[
'GetObjectId'],
array($attachedId));
1209 if (array_key_exists(
'GetUrlAttachedFileElement', $userType))
1211 $printableUrl = call_user_func_array($userType[
'GetUrlAttachedFileElement'],
array($documentId, $fileId));
1214 $arResult[
"PROPERTY_".$propertyKey][$attachedId] = $fileId;
1215 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"][$attachedId] = $printableUrl;
1232 if (!is_array($arPropertyValue))
1234 $arPropertyValue =
array($arPropertyValue);
1235 $arPropertyKey =
array($arPropertyKey);
1238 for (
$i = 0, $cnt =
count($arPropertyValue);
$i < $cnt;
$i++)
1239 $arResult[
"PROPERTY_".$propertyKey][$arPropertyKey[
$i]] = $arPropertyValue[
$i];
1244 if (!is_array($arPropertyValue))
1245 $arPropertyValue =
array($arPropertyValue);
1247 foreach ($arPropertyValue as $v)
1249 $ar = CFile::GetFileArray($v);
1252 $arResult[
"PROPERTY_".$propertyKey][intval($v)] =
$ar[
"SRC"];
1253 $arResult[
"PROPERTY_".$propertyKey.
"_printable"][intval($v)] =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode(
$ar[
"FILE_NAME"]).
"&i=".$v.
"&h=".md5(
$ar[
"SUBDIR"]).
"]".
htmlspecialcharsbx(
$ar[
"ORIGINAL_NAME"]).
"[/url]";
1263 $documentFields = static::GetDocumentFields(static::GetDocumentType($documentId));
1264 foreach ($documentFields as $fieldKey => $field)
1266 if (!array_key_exists($fieldKey,
$arResult))
1276 if (mb_substr($documentId, 0, mb_strlen(
"iblock_")) ==
"iblock_")
1281 $documentId = (int)$documentId;
1282 $iblockId = CIBlockElement::GetIBlockByID($documentId);
1288 return "iblock_$iblockId";
1293 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
1303 "Filterable" =>
true,
1304 "Editable" =>
false,
1305 "Required" =>
false,
1307 "TIMESTAMP_X" =>
array(
1308 "Name" =>
GetMessage(
"IBD_FIELD_TIMESTAMP_X"),
1309 "Type" =>
"datetime",
1310 "Filterable" =>
true,
1312 "Required" =>
false,
1314 "MODIFIED_BY" =>
array(
1317 "Filterable" =>
true,
1319 "Required" =>
false,
1321 "MODIFIED_BY_PRINTABLE" =>
array(
1322 "Name" =>
GetMessage(
"IBD_FIELD_MODIFIED_BY_USER_PRINTABLE"),
1324 "Filterable" =>
false,
1325 "Editable" =>
false,
1326 "Required" =>
false,
1328 "DATE_CREATE" =>
array(
1329 "Name" =>
GetMessage(
"IBD_FIELD_DATE_CREATE"),
1330 "Type" =>
"datetime",
1331 "Filterable" =>
true,
1333 "Required" =>
false,
1335 "CREATED_BY" =>
array(
1338 "Filterable" =>
true,
1339 "Editable" =>
false,
1340 "Required" =>
false,
1342 "CREATED_BY_PRINTABLE" =>
array(
1343 "Name" =>
GetMessage(
"IBD_FIELD_CREATED_BY_USER_PRINTABLE"),
1345 "Filterable" =>
false,
1346 "Editable" =>
false,
1347 "Required" =>
false,
1349 "IBLOCK_ID" =>
array(
1352 "Filterable" =>
true,
1359 "Filterable" =>
true,
1361 "Required" =>
false,
1363 "BP_PUBLISHED" =>
array(
1364 "Name" =>
GetMessage(
"IBD_FIELD_BP_PUBLISHED"),
1366 "Filterable" =>
false,
1368 "Required" =>
false,
1370 "ACTIVE_FROM" =>
array(
1371 "Name" =>
GetMessage(
"IBD_FIELD_DATE_ACTIVE_FROM"),
1372 "Type" =>
"datetime",
1373 "Filterable" =>
true,
1375 "Required" =>
false,
1377 "ACTIVE_TO" =>
array(
1378 "Name" =>
GetMessage(
"IBD_FIELD_DATE_ACTIVE_TO"),
1379 "Type" =>
"datetime",
1380 "Filterable" =>
true,
1382 "Required" =>
false,
1387 "Filterable" =>
true,
1389 "Required" =>
false,
1394 "Filterable" =>
true,
1398 "PREVIEW_PICTURE" =>
array(
1399 "Name" =>
GetMessage(
"IBD_FIELD_PREVIEW_PICTURE"),
1401 "Filterable" =>
false,
1403 "Required" =>
false,
1405 "PREVIEW_TEXT" =>
array(
1406 "Name" =>
GetMessage(
"IBD_FIELD_PREVIEW_TEXT"),
1408 "Filterable" =>
false,
1410 "Required" =>
false,
1412 "PREVIEW_TEXT_TYPE" =>
array(
1413 "Name" =>
GetMessage(
"IBD_FIELD_PREVIEW_TEXT_TYPE"),
1419 "Filterable" =>
false,
1421 "Required" =>
false,
1423 "DETAIL_PICTURE" =>
array(
1424 "Name" =>
GetMessage(
"IBD_FIELD_DETAIL_PICTURE"),
1426 "Filterable" =>
false,
1428 "Required" =>
false,
1430 "DETAIL_TEXT" =>
array(
1431 "Name" =>
GetMessage(
"IBD_FIELD_DETAIL_TEXT"),
1433 "Filterable" =>
false,
1435 "Required" =>
false,
1437 "DETAIL_TEXT_TYPE" =>
array(
1438 "Name" =>
GetMessage(
"IBD_FIELD_DETAIL_TEXT_TYPE"),
1444 "Filterable" =>
false,
1446 "Required" =>
false,
1451 "Filterable" =>
true,
1453 "Required" =>
false,
1458 "Filterable" =>
true,
1460 "Required" =>
false,
1465 foreach ($arKeys as
$key)
1468 $dbProperties = CIBlockProperty::GetList(
1469 array(
"sort" =>
"asc",
"name" =>
"asc"),
1472 while ($arProperty = $dbProperties->Fetch())
1474 if (trim($arProperty[
"CODE"]) <>
'')
1475 $key =
"PROPERTY_".$arProperty[
"CODE"];
1477 $key =
"PROPERTY_".$arProperty[
"ID"];
1480 "Name" => $arProperty[
"NAME"],
1481 "Filterable" => ($arProperty[
"FILTRABLE"] ==
"Y"),
1483 "Required" => ($arProperty[
"IS_REQUIRED"] ==
"Y"),
1484 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1487 if(trim($arProperty[
"CODE"]) <>
'')
1490 if ($arProperty[
"USER_TYPE"] <>
'')
1492 if ($arProperty[
"USER_TYPE"] ==
"UserID"
1493 || $arProperty[
"USER_TYPE"] ==
"employee" && (COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y"))
1497 "Name" => $arProperty[
"NAME"].
GetMessage(
"IBD_FIELD_USERNAME_PROPERTY"),
1498 "Filterable" =>
false,
1499 "Editable" =>
false,
1500 "Required" =>
false,
1501 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1505 elseif ($arProperty[
"USER_TYPE"] ==
"DateTime")
1509 elseif ($arProperty[
"USER_TYPE"] ==
"Date")
1513 elseif ($arProperty[
"USER_TYPE"] ==
"EList")
1518 elseif($arProperty[
"USER_TYPE"] ==
"DiskFile")
1522 "Name" => $arProperty[
"NAME"].
GetMessage(
"IBD_FIELD_USERNAME_PROPERTY"),
1523 "Filterable" =>
false,
1524 "Editable" =>
false,
1525 "Required" =>
false,
1526 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1530 elseif ($arProperty[
"USER_TYPE"] ==
"HTML")
1539 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"L")
1544 $dbPropertyEnums = CIBlockProperty::GetPropertyEnum($arProperty[
"ID"]);
1545 while ($arPropertyEnum = $dbPropertyEnums->GetNext())
1548 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"N")
1552 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"F")
1556 "Name" => $arProperty[
"NAME"].
GetMessage(
"IBD_FIELD_USERNAME_PROPERTY"),
1557 "Filterable" =>
false,
1558 "Editable" =>
false,
1559 "Required" =>
false,
1560 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1564 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"S")
1575 foreach ($arKeys as
$k)
1586 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
1591 "string" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_STRING"),
"BaseType" =>
"string"),
1592 "text" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_TEXT"),
"BaseType" =>
"text"),
1593 "int" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_INT"),
"BaseType" =>
"int"),
1594 "double" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_DOUBLE"),
"BaseType" =>
"double"),
1595 "select" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_SELECT"),
"BaseType" =>
"select",
"Complex" =>
true),
1596 "bool" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_BOOL"),
"BaseType" =>
"bool"),
1597 "date" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_DATA"),
"BaseType" =>
"date"),
1598 "datetime" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_DATETIME"),
"BaseType" =>
"datetime"),
1599 "user" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_USER"),
"BaseType" =>
"user"),
1600 "file" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_FILE"),
"BaseType" =>
"file"),
1603 $ignoredTypes =
array(
'map_yandex',
'directory',
'SectionAuto',
'SKU',
'EAutocomplete');
1606 "Name" =>
GetMessage(
"BPCGHLP_PROP_SELECT_INTERNAL"),
1607 "BaseType" =>
"string",
1611 foreach (CIBlockProperty::GetUserType() as
$ar)
1613 if(in_array(
$ar[
"USER_TYPE"], $ignoredTypes))
1618 $t =
$ar[
"PROPERTY_TYPE"].
":".
$ar[
"USER_TYPE"];
1625 if (COption::GetOptionString(
"bizproc",
"SkipNonPublicCustomTypes",
"N") ==
"Y"
1626 && !array_key_exists(
"GetPublicEditHTML",
$ar) || $t ==
"S:UserID" || $t ==
"S:DateTime" || $t ==
"S:Date")
1629 $arResult[$t] =
array(
"Name" =>
$ar[
"DESCRIPTION"],
"BaseType" =>
"string",
'typeClass' =>
'\Bitrix\Iblock\BizprocType\UserTypeProperty');
1630 if ($t ==
"S:employee")
1632 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\UserTypePropertyEmployee';
1633 if (COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
1636 $arResult[$t][
'typeClass'] = \Bitrix\Bizproc\BaseType\User::class;
1643 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\UserTypePropertyElist';
1647 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\UserTypePropertyHtml';
1649 elseif($t ==
'S:DiskFile')
1652 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\UserTypePropertyDiskFile';
1658 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\ECrm';
1663 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\Money';
1665 elseif($t ==
'N:Sequence')
1668 $arResult[$t][
'typeClass'] =
'\Bitrix\Iblock\BizprocType\Sequence';
1678 $integerCode = time();
1681 for (
$i = 1; $integerCode >= 0 &&
$i < 10;
$i++)
1683 $code = chr(0x41 + ($integerCode % pow(26,
$i) / pow(26,
$i - 1))) .
$code;
1684 $integerCode -= pow(26,
$i);
1691 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
1695 if (mb_substr(
$arFields[
"code"], 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
1698 $arFieldsTmp =
array(
1703 'MULTIPLE' =>
$arFields[
'multiple'] ==
'Y' || (
string)
$arFields[
'multiple'] ===
'1' ?
'Y' :
'N',
1704 'IS_REQUIRED' =>
$arFields[
'required'] ==
'Y' || (
string)
$arFields[
'required'] ===
'1' ?
'Y' :
'N',
1709 if (mb_strpos(
"0123456789", mb_substr($arFieldsTmp[
"CODE"], 0, 1)) !==
false)
1712 if (array_key_exists(
"additional_type_info",
$arFields))
1713 $arFieldsTmp[
"LINK_IBLOCK_ID"] = intval(
$arFields[
"additional_type_info"]);
1715 if (mb_strstr(
$arFields[
"type"],
":") !==
false)
1719 $arFieldsTmp[
"TYPE"] =
$arFields[
"type"];
1723 [$arFieldsTmp[
"PROPERTY_TYPE"], $arFieldsTmp[
"USER_TYPE"]] = explode(
":",
$arFields[
"type"], 2);
1725 $arFieldsTmp[
"LINK_IBLOCK_ID"] =
$arFields[
"options"];
1730 $arFieldsTmp[
"PROPERTY_TYPE"] =
"S";
1731 $arFieldsTmp[
"USER_TYPE"]=
"UserID";
1735 $arFieldsTmp[
"PROPERTY_TYPE"] =
"S";
1736 $arFieldsTmp[
"USER_TYPE"]=
"Date";
1740 $arFieldsTmp[
"PROPERTY_TYPE"] =
"S";
1741 $arFieldsTmp[
"USER_TYPE"]=
"DateTime";
1745 $arFieldsTmp[
"PROPERTY_TYPE"] =
"F";
1746 $arFieldsTmp[
"USER_TYPE"]=
"";
1750 $arFieldsTmp[
"PROPERTY_TYPE"] =
"L";
1751 $arFieldsTmp[
"USER_TYPE"]=
false;
1758 $arFieldsTmp[
"VALUES"][] =
array(
"XML_ID" =>
$k,
"VALUE" => $v,
"DEF" =>
"N",
"SORT" =>
$i);
1768 $v = trim(trim($v),
"\r\n");
1772 if (mb_substr($v, 0, 1) ==
"[" && mb_strpos($v,
"]") !==
false)
1774 $v1 = mb_substr($v, 1, mb_strpos($v,
"]") - 1);
1775 $v2 = trim(mb_substr($v, mb_strpos($v,
"]") + 1));
1777 $arFieldsTmp[
"VALUES"][] =
array(
"XML_ID" => $v1,
"VALUE" => $v2,
"DEF" =>
"N",
"SORT" =>
$i);
1784 $arFieldsTmp[
"TYPE"] =
"L";
1785 $arFieldsTmp[
"VALUES"][] =
array(
1791 $arFieldsTmp[
"VALUES"][] =
array(
1800 $arFieldsTmp[
"PROPERTY_TYPE"] =
$arFields[
"type"];
1801 $arFieldsTmp[
"USER_TYPE"] =
false;
1804 if ($arFieldsTmp[
"PROPERTY_TYPE"] ==
"T")
1806 $arFieldsTmp[
"PROPERTY_TYPE"] =
"S";
1807 $arFieldsTmp[
"ROW_COUNT"] = 5;
1810 $properties = CIBlockProperty::getList(
1812 array(
"IBLOCK_ID" => $arFieldsTmp[
"IBLOCK_ID"],
"CODE" => $arFieldsTmp[
"CODE"])
1814 if(!$properties->fetch())
1816 $ibp =
new CIBlockProperty;
1817 $propId = $ibp->Add($arFieldsTmp);
1818 if (intval($propId) <= 0)
1819 throw new Exception($ibp->LAST_ERROR);
1822 return "PROPERTY_".$arFields[
"code"];
1827 $documentId = intval($documentId);
1828 if ($documentId <= 0)
1831 CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
1833 $arFieldsPropertyValues =
array();
1834 $complexDocumentId = [
'iblock', get_called_class(), $documentId];
1838 array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y",
"SHOW_HISTORY" =>
"Y"),
1840 array(
"ID",
"IBLOCK_ID")
1844 throw new Exception(
"Element is not found");
1849 foreach ($arKeys as
$key)
1851 if (!array_key_exists(
$key, $arDocumentFields))
1856 $realKey = ((mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")?
1857 mb_substr(
$key, mb_strlen(
"PROPERTY_")) :
$key);
1859 if ($arDocumentFields[
$key][
"Type"] ==
"user")
1863 elseif ($arDocumentFields[
$key][
"Type"] ==
"select")
1866 $db = CIBlockProperty::GetPropertyEnum(
1871 while (
$ar = $db->GetNext())
1872 $arV[
$ar[
"XML_ID"]] =
$ar[
"ID"];
1874 $listValue =
array();
1877 if(is_array($value) && CBPHelper::isAssociativeArray($value))
1879 $listXmlId = array_keys($value);
1880 foreach($listXmlId as $xmlId)
1882 $listValue[] = $arV[$xmlId];
1887 if (array_key_exists($value, $arV))
1888 $value = $arV[$value];
1891 if(!empty($listValue))
1896 elseif ($arDocumentFields[
$key][
"Type"] ==
"file")
1901 if (is_array($value))
1903 foreach($value as $file)
1905 $makeFileArray = CFile::MakeFileArray($file);
1907 $files[] = $makeFileArray;
1912 $makeFileArray = CFile::MakeFileArray($value);
1914 $files[] = $makeFileArray;
1922 elseif($arDocumentFields[
$key][
"Type"] ==
"S:DiskFile")
1928 $value =
"n".$value;
1933 elseif ($arDocumentFields[
$key][
"Type"] ==
"S:HTML")
1936 $value =
array(
"VALUE" => $value);
1954 if (mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
1956 $realKey = mb_substr(
$key, mb_strlen(
"PROPERTY_"));
1957 $arFieldsPropertyValues[$realKey] = (is_array(
$arFields[
$key]) &&
1959 if(empty($arFieldsPropertyValues[$realKey]))
1960 $arFieldsPropertyValues[$realKey] =
array(
null);
1965 $iblockElement =
new CIBlockElement();
1966 if (!empty($arFieldsPropertyValues))
1968 $iblockElement->SetPropertyValuesEx($documentId,
$arResult[
"IBLOCK_ID"], $arFieldsPropertyValues);
1971 $res = $iblockElement->Update($documentId,
$arFields,
false,
true,
true);
1973 throw new Exception($iblockElement->LAST_ERROR);
1980 SELECT * FROM b_iblock_element_lock
1981 WHERE IBLOCK_ELEMENT_ID = ".intval($documentId).
"
1982 AND LOCKED_BY = '".
$DB->ForSQL($workflowId, 32).
"'
1984 $z =
$DB->Query($strSql);
1993 INSERT INTO b_iblock_element_lock (IBLOCK_ELEMENT_ID, DATE_LOCK, LOCKED_BY)
1994 SELECT E.ID, ".$DB->GetNowFunction().
", '".
$DB->ForSQL($workflowId, 32).
"'
1995 FROM b_iblock_element E
1996 LEFT JOIN b_iblock_element_lock EL on EL.IBLOCK_ELEMENT_ID = E.ID
1997 WHERE ID = ".intval($documentId).
"
1998 AND EL.IBLOCK_ELEMENT_ID IS NULL
2000 $z =
$DB->Query($strSql);
2001 return $z->AffectedRowsCount() > 0;
2010 SELECT * FROM b_iblock_element_lock
2011 WHERE IBLOCK_ELEMENT_ID = ".intval($documentId).
"
2013 $z =
$DB->Query($strSql);
2017 DELETE FROM b_iblock_element_lock
2018 WHERE IBLOCK_ELEMENT_ID = ".intval($documentId).
"
2019 AND (LOCKED_BY = '".
$DB->ForSQL($workflowId, 32).
"' OR '".
$DB->ForSQL($workflowId, 32).
"' = '')
2021 $z =
$DB->Query($strSql);
2031 foreach (
GetModuleEvents(
"iblock",
"CIBlockDocument_OnUnlockDocument",
true) as $arEvent)
2044 SELECT * FROM b_iblock_element_lock
2045 WHERE IBLOCK_ELEMENT_ID = ".intval($documentId).
"
2046 AND LOCKED_BY <> '".
$DB->ForSQL($workflowId, 32).
"'
2048 $z =
$DB->Query($strSql);
2057 $documentId = trim($documentId);
2058 if ($documentId ==
'')
2061 if (!array_key_exists(
"IBlockId", $arParameters)
2063 !array_key_exists(
"IBlockPermission", $arParameters)
2064 || !array_key_exists(
"DocumentStates", $arParameters)
2065 || !array_key_exists(
"IBlockRightsMode", $arParameters)
2066 || array_key_exists(
"IBlockRightsMode", $arParameters) && ($arParameters[
"IBlockRightsMode"] ===
"E")
2068 || !array_key_exists(
"CreatedBy", $arParameters) && !array_key_exists(
"AllUserGroups", $arParameters))
2070 $dbElementList = CIBlockElement::GetList(
2072 array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y",
"SHOW_HISTORY" =>
"Y"),
2075 array(
"ID",
"IBLOCK_ID",
"CREATED_BY")
2077 $arElement = $dbElementList->Fetch();
2082 $arParameters[
"IBlockId"] = $arElement[
"IBLOCK_ID"];
2083 $arParameters[
"CreatedBy"] = $arElement[
"CREATED_BY"];
2086 if (!array_key_exists(
"IBlockRightsMode", $arParameters))
2087 $arParameters[
"IBlockRightsMode"] = CIBlock::GetArrayByID($arParameters[
"IBlockId"],
"RIGHTS_MODE");
2089 if ($arParameters[
"IBlockRightsMode"] ===
"E")
2092 return CIBlockElementRights::UserHasRightTo($arParameters[
"IBlockId"], $documentId,
"element_read");
2094 return CIBlockElementRights::UserHasRightTo($arParameters[
"IBlockId"], $documentId,
"element_edit");
2100 if (CIBlockElementRights::UserHasRightTo($arParameters[
"IBlockId"], $documentId,
"element_edit"))
2103 if (!array_key_exists(
"WorkflowId", $arParameters))
2106 if (!CIBlockElementRights::UserHasRightTo($arParameters[
"IBlockId"], $documentId,
"element_read"))
2110 if (!array_key_exists(
"AllUserGroups", $arParameters))
2112 if (!array_key_exists(
"UserGroups", $arParameters))
2113 $arParameters[
"UserGroups"] = CUser::GetUserGroup(
$userId);
2115 $arParameters[
"AllUserGroups"] = $arParameters[
"UserGroups"];
2116 if (
$userId == $arParameters[
"CreatedBy"])
2117 $arParameters[
"AllUserGroups"][] =
"Author";
2120 if (!array_key_exists(
"DocumentStates", $arParameters))
2123 $arParameters[
"DocumentStates"] = CBPWorkflowTemplateLoader::GetDocumentTypeStates(
array(
"iblock",
"CIBlockDocument",
"iblock_".$arParameters[
"IBlockId"]));
2125 $arParameters[
"DocumentStates"] = CBPDocument::GetDocumentStates(
2126 array(
"iblock",
"CIBlockDocument",
"iblock_".$arParameters[
"IBlockId"]),
2127 array(
"iblock",
"CIBlockDocument", $documentId)
2131 if (array_key_exists($arParameters[
"WorkflowId"], $arParameters[
"DocumentStates"]))
2132 $arParameters[
"DocumentStates"] =
array($arParameters[
"WorkflowId"] => $arParameters[
"DocumentStates"][$arParameters[
"WorkflowId"]]);
2136 $arAllowableOperations = CBPDocument::GetAllowableOperations(
2138 $arParameters[
"AllUserGroups"],
2139 $arParameters[
"DocumentStates"],
2143 if (!is_array($arAllowableOperations))
2152 foreach ($arAllowableOperations as $op)
2155 if (in_array($chop,
$ar))
2163 return CBPDocument::CanUserOperateDocumentType(
2166 array(
"iblock",
"CIBlockDocument", $documentId),
2174 if (!array_key_exists(
"IBlockPermission", $arParameters))
2176 if (CModule::IncludeModule(
'lists'))
2177 $arParameters[
"IBlockPermission"] = CLists::GetIBlockPermission($arParameters[
"IBlockId"],
$userId);
2179 $arParameters[
"IBlockPermission"] = CIBlock::GetPermission($arParameters[
"IBlockId"],
$userId);
2182 if ($arParameters[
"IBlockPermission"] <=
"R")
2184 elseif ($arParameters[
"IBlockPermission"] >=
"W")
2188 if (!array_key_exists(
"AllUserGroups", $arParameters))
2190 if (!array_key_exists(
"UserGroups", $arParameters))
2191 $arParameters[
"UserGroups"] = CUser::GetUserGroup(
$userId);
2193 $arParameters[
"AllUserGroups"] = $arParameters[
"UserGroups"];
2194 if (
$userId == $arParameters[
"CreatedBy"])
2195 $arParameters[
"AllUserGroups"][] =
"Author";
2198 if (!array_key_exists(
"DocumentStates", $arParameters))
2200 $arParameters[
"DocumentStates"] = CBPDocument::GetDocumentStates(
2201 array(
"iblock",
"CIBlockDocument",
"iblock_".$arParameters[
"IBlockId"]),
2202 array(
"iblock",
"CIBlockDocument", $documentId)
2206 if (array_key_exists(
"WorkflowId", $arParameters))
2208 if (array_key_exists($arParameters[
"WorkflowId"], $arParameters[
"DocumentStates"]))
2209 $arParameters[
"DocumentStates"] =
array($arParameters[
"WorkflowId"] => $arParameters[
"DocumentStates"][$arParameters[
"WorkflowId"]]);
2214 $arAllowableOperations = CBPDocument::GetAllowableOperations(
2216 $arParameters[
"AllUserGroups"],
2217 $arParameters[
"DocumentStates"]
2220 if (!is_array($arAllowableOperations))
2227 $r = in_array(
"read", $arAllowableOperations);
2230 $r = in_array(
"write", $arAllowableOperations);
2236 $r = in_array(
"write", $arAllowableOperations);
2239 $r = in_array(
"read", $arAllowableOperations) || in_array(
"write", $arAllowableOperations);
2250 $documentType = trim($documentType);
2251 if ($documentType ==
'')
2254 $arParameters[
"IBlockId"] = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
2255 $arParameters[
'sectionId'] = !empty($arParameters[
'sectionId']) ? (int)$arParameters[
'sectionId'] : 0;
2257 if (!array_key_exists(
"IBlockRightsMode", $arParameters))
2258 $arParameters[
"IBlockRightsMode"] = CIBlock::GetArrayByID($arParameters[
"IBlockId"],
"RIGHTS_MODE");
2260 if ($arParameters[
"IBlockRightsMode"] ===
"E")
2263 return CIBlockRights::UserHasRightTo($arParameters[
"IBlockId"], $arParameters[
"IBlockId"],
"iblock_rights_edit");
2265 return CIBlockSectionRights::UserHasRightTo($arParameters[
"IBlockId"], $arParameters[
"sectionId"],
"section_element_bind");
2269 if (!array_key_exists(
"WorkflowId", $arParameters))
2273 return CIBlockRights::UserHasRightTo($arParameters[
"IBlockId"], 0,
"element_read");
2276 return CIBlockSectionRights::UserHasRightTo($arParameters[
"IBlockId"], $arParameters[
'sectionId'],
"section_element_bind");
2279 if (!array_key_exists(
"AllUserGroups", $arParameters))
2281 if (!array_key_exists(
"UserGroups", $arParameters))
2282 $arParameters[
"UserGroups"] = CUser::GetUserGroup(
$userId);
2284 $arParameters[
"AllUserGroups"] = $arParameters[
"UserGroups"];
2285 $arParameters[
"AllUserGroups"][] =
"Author";
2288 if (!array_key_exists(
"DocumentStates", $arParameters))
2291 $arParameters[
"DocumentStates"] = CBPWorkflowTemplateLoader::GetDocumentTypeStates(
array(
"iblock",
"CIBlockDocument",
"iblock_".$arParameters[
"IBlockId"]));
2293 $arParameters[
"DocumentStates"] = CBPDocument::GetDocumentStates(
2294 array(
"iblock",
"CIBlockDocument",
"iblock_".$arParameters[
"IBlockId"]),
2299 if (array_key_exists($arParameters[
"WorkflowId"], $arParameters[
"DocumentStates"]))
2300 $arParameters[
"DocumentStates"] =
array($arParameters[
"WorkflowId"] => $arParameters[
"DocumentStates"][$arParameters[
"WorkflowId"]]);
2304 $arAllowableOperations = CBPDocument::GetAllowableOperations(
2306 $arParameters[
"AllUserGroups"],
2307 $arParameters[
"DocumentStates"],
2311 if (!is_array($arAllowableOperations))
2320 foreach ($arAllowableOperations as $op)
2323 if (in_array($chop,
$ar))
2331 if (!array_key_exists(
"IBlockPermission", $arParameters))
2333 if(CModule::IncludeModule(
'lists'))
2334 $arParameters[
"IBlockPermission"] = CLists::GetIBlockPermission($arParameters[
"IBlockId"],
$userId);
2336 $arParameters[
"IBlockPermission"] = CIBlock::GetPermission($arParameters[
"IBlockId"],
$userId);
2339 if ($arParameters[
"IBlockPermission"] <=
"R")
2341 elseif ($arParameters[
"IBlockPermission"] >=
"W")
2345 if (!array_key_exists(
"AllUserGroups", $arParameters))
2347 if (!array_key_exists(
"UserGroups", $arParameters))
2348 $arParameters[
"UserGroups"] = CUser::GetUserGroup(
$userId);
2350 $arParameters[
"AllUserGroups"] = $arParameters[
"UserGroups"];
2351 $arParameters[
"AllUserGroups"][] =
"Author";
2354 if (!array_key_exists(
"DocumentStates", $arParameters))
2356 $arParameters[
"DocumentStates"] = CBPDocument::GetDocumentStates(
2357 array(
"iblock",
"CIBlockDocument",
"iblock_".$arParameters[
"IBlockId"]),
2362 if (array_key_exists(
"WorkflowId", $arParameters))
2364 if (array_key_exists($arParameters[
"WorkflowId"], $arParameters[
"DocumentStates"]))
2365 $arParameters[
"DocumentStates"] =
array($arParameters[
"WorkflowId"] => $arParameters[
"DocumentStates"][$arParameters[
"WorkflowId"]]);
2370 $arAllowableOperations = CBPDocument::GetAllowableOperations(
2372 $arParameters[
"AllUserGroups"],
2373 $arParameters[
"DocumentStates"]
2376 if (!is_array($arAllowableOperations))
2383 $r = in_array(
"read", $arAllowableOperations);
2386 $r = in_array(
"write", $arAllowableOperations);
2389 $r = in_array(
"write", $arAllowableOperations);
2392 $r = in_array(
"write", $arAllowableOperations);
2412 if (!array_key_exists(
"IBLOCK_ID",
$arFields) || intval(
$arFields[
"IBLOCK_ID"]) <= 0)
2413 throw new Exception(
"IBlock ID is not found");
2415 $arFieldsPropertyValues =
array();
2416 $complexDocumentId = [
'iblock', get_called_class(), $parentDocumentId];
2418 $arDocumentFields = static::GetDocumentFields(
"iblock_".
$arFields[
"IBLOCK_ID"]);
2421 foreach ($arKeys as
$key)
2423 if (!array_key_exists(
$key, $arDocumentFields))
2428 $realKey = ((mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")? mb_substr(
$key, mb_strlen(
"PROPERTY_")) :
$key);
2430 if ($arDocumentFields[
$key][
"Type"] ==
"user")
2434 elseif ($arDocumentFields[
$key][
"Type"] ==
"select")
2437 $db = CIBlockProperty::GetPropertyEnum($realKey,
false,
array(
"IBLOCK_ID" =>
$arFields[
"IBLOCK_ID"]));
2438 while (
$ar = $db->GetNext())
2439 $arV[
$ar[
"XML_ID"]] =
$ar[
"ID"];
2441 $listValue =
array();
2444 if(CBPHelper::isAssociativeArray($value))
2446 $listXmlId = array_keys($value);
2447 foreach($listXmlId as $xmlId)
2449 $listValue[] = $arV[$xmlId];
2454 if (array_key_exists($value, $arV))
2455 $value = $arV[$value];
2458 if(!empty($listValue))
2463 elseif ($arDocumentFields[
$key][
"Type"] ==
"file")
2468 if (is_array($value))
2470 foreach($value as $file)
2472 $files[] = CFile::MakeFileArray($file);
2476 $files[] = CFile::MakeFileArray($value);
2480 elseif ($arDocumentFields[
$key][
"Type"] ==
"S:DiskFile")
2486 $value =
"n".$value;
2491 elseif ($arDocumentFields[
$key][
"Type"] ==
"N:Sequence")
2493 $queryObject = \CIBlockProperty::getByID($realKey,
$arFields[
"IBLOCK_ID"]);
2494 if ($property = $queryObject->fetch())
2496 $propertyId = $property[
"ID"];
2497 $sequence = new \CIBlockSequence(
$arFields[
"IBLOCK_ID"], $propertyId);
2500 $value = [
"VALUE" => $value];
2502 $value = [
"VALUE" => $sequence->getNext()];
2505 elseif ($arDocumentFields[
$key][
"Type"] ==
"S:HTML")
2508 $value =
array(
"VALUE" => $value);
2526 if (mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
2528 $realKey = mb_substr(
$key, mb_strlen(
"PROPERTY_"));
2529 $arFieldsPropertyValues[$realKey] = (is_array(
$arFields[
$key]) &&
2535 if (
count($arFieldsPropertyValues) > 0)
2536 $arFields[
"PROPERTY_VALUES"] = $arFieldsPropertyValues;
2543 $iblockElement =
new CIBlockElement();
2544 $id = $iblockElement->Add(
$arFields,
false,
true,
true);
2545 if (!$id || $id <= 0)
2546 throw new Exception($iblockElement->LAST_ERROR);
2558 $documentId = intval($documentId);
2559 if ($documentId <= 0)
2562 CIBlockElement::Delete($documentId);
2573 $ID = intval($documentId);
2575 $db_element = CIBlockElement::GetList(
array(),
array(
"ID"=>
$ID,
"SHOW_HISTORY"=>
"Y"),
false,
false,
2590 "PREVIEW_TEXT_TYPE",
2595 "WF_PARENT_ELEMENT_ID",
2605 if($ar_element = $db_element->Fetch())
2607 $PARENT_ID = intval($ar_element[
"WF_PARENT_ELEMENT_ID"]);
2610 $obElement =
new CIBlockElement;
2611 $ar_element[
"WF_PARENT_ELEMENT_ID"] =
false;
2613 if($ar_element[
"PREVIEW_PICTURE"])
2614 $ar_element[
"PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element[
"PREVIEW_PICTURE"]);
2616 $ar_element[
"PREVIEW_PICTURE"] =
array(
"tmp_name" =>
"",
"del" =>
"Y");
2618 if($ar_element[
"DETAIL_PICTURE"])
2619 $ar_element[
"DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element[
"DETAIL_PICTURE"]);
2621 $ar_element[
"DETAIL_PICTURE"] =
array(
"tmp_name" =>
"",
"del" =>
"Y");
2623 $ar_element[
"IBLOCK_SECTION"] =
array();
2624 if($ar_element[
"IN_SECTIONS"] ==
"Y")
2626 $rsSections = CIBlockElement::GetElementGroups($ar_element[
"ID"],
true,
array(
'ID',
'IBLOCK_ELEMENT_ID'));
2627 while($arSection = $rsSections->Fetch())
2628 $ar_element[
"IBLOCK_SECTION"][] = $arSection[
"ID"];
2631 $ar_element[
"PROPERTY_VALUES"] =
array();
2632 $arProps = &$ar_element[
"PROPERTY_VALUES"];
2635 $rsProps = CIBlockElement::GetProperty($ar_element[
"IBLOCK_ID"], $PARENT_ID,
array(
"value_id" =>
"asc"),
array(
"PROPERTY_TYPE" =>
"F",
"EMPTY" =>
"N"));
2638 if(!array_key_exists($arProp[
"ID"], $arProps))
2639 $arProps[$arProp[
"ID"]] =
array();
2640 $arProps[$arProp[
"ID"]][$arProp[
"PROPERTY_VALUE_ID"]] =
array(
2641 "VALUE" =>
array(
"tmp_name" =>
"",
"del" =>
"Y"),
2642 "DESCRIPTION" =>
false,
2647 $rsProps = CIBlockElement::GetProperty($ar_element[
"IBLOCK_ID"], $ar_element[
"ID"],
array(
"value_id" =>
"asc"));
2652 if(!array_key_exists($arProp[
"ID"], $arProps))
2653 $arProps[$arProp[
"ID"]] =
array();
2655 if($arProp[
"PROPERTY_VALUE_ID"])
2657 if($arProp[
"PROPERTY_TYPE"] ==
"F")
2658 $arProps[$arProp[
"ID"]][
"n".$i] =
array(
2659 "VALUE" => CFile::MakeFileArray($arProp[
"VALUE"]),
2660 "DESCRIPTION" => $arProp[
"DESCRIPTION"],
2663 $arProps[$arProp[
"ID"]][
"n".$i] =
array(
2664 "VALUE" => $arProp[
"VALUE"],
2665 "DESCRIPTION" => $arProp[
"DESCRIPTION"],
2670 $obElement->Update($PARENT_ID, $ar_element);
2672 CBPDocument::MergeDocuments(
2673 array(
"iblock",
"CIBlockDocument", $PARENT_ID),
2674 array(
"iblock",
"CIBlockDocument", $documentId)
2677 CIBlockElement::Delete(
$ID);
2679 CIBlockElement::WF_CleanUpHistoryCopies($PARENT_ID, 0);
2680 $strSql =
"update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=".$PARENT_ID.
" AND WF_PARENT_ELEMENT_ID IS NULL";
2681 $DB->Query($strSql);
2682 CIBlockElement::UpdateSearch($PARENT_ID);
2689 CIBlockElement::WF_CleanUpHistoryCopies(
$ID, 0);
2690 $strSql =
"update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=".$ID.
" AND WF_PARENT_ELEMENT_ID IS NULL";
2691 $DB->Query($strSql);
2692 CIBlockElement::UpdateSearch(
$ID);
2706 $db_element = CIBlockElement::GetList(
array(),
array(
"ID"=>
$ID,
"SHOW_HISTORY"=>
"Y"),
false,
false,
2720 "PREVIEW_TEXT_TYPE",
2725 "WF_PARENT_ELEMENT_ID",
2734 if($ar_element = $db_element->Fetch())
2737 if($ar_element[
"WF_PARENT_ELEMENT_ID"] > 0)
2739 throw new Exception(
GetMessage(
"IBD_ELEMENT_NOT_FOUND"));
2743 if($ar_element[
"PREVIEW_PICTURE"])
2744 $ar_element[
"PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element[
"PREVIEW_PICTURE"]);
2746 if($ar_element[
"DETAIL_PICTURE"])
2747 $ar_element[
"DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element[
"DETAIL_PICTURE"]);
2749 $ar_element[
"IBLOCK_SECTION"] =
array();
2750 if($ar_element[
"IN_SECTIONS"] ==
"Y")
2752 $rsSections = CIBlockElement::GetElementGroups($ar_element[
"ID"],
true,
array(
'ID',
'IBLOCK_ELEMENT_ID'));
2753 while($arSection = $rsSections->Fetch())
2754 $ar_element[
"IBLOCK_SECTION"][] = $arSection[
"ID"];
2757 $ar_element[
"PROPERTY_VALUES"] =
array();
2759 foreach(
$arFields as $field_id => $value)
2760 if(array_key_exists($field_id, $ar_element))
2761 $ar_element[$field_id] = $value;
2763 $ar_element[
"WF_PARENT_ELEMENT_ID"] =
$ID;
2766 $arProps = &$ar_element[
"PROPERTY_VALUES"];
2769 $rsProps = CIBlockElement::GetProperty($ar_element[
"IBLOCK_ID"], $ar_element[
"ID"],
array(
"value_id" =>
"asc"));
2773 if(array_key_exists($arProp[
"CODE"], $ar_element[
"PROPERTY_VALUES"]))
2777 if(!array_key_exists($arProp[
"ID"], $arProps))
2778 $arProps[$arProp[
"ID"]] =
array();
2780 if($arProp[
"PROPERTY_VALUE_ID"])
2782 if($arProp[
"PROPERTY_TYPE"] ==
"F")
2783 $arProps[$arProp[
"ID"]][
"n".$i] =
array(
2784 "VALUE" => CFile::MakeFileArray($arProp[
"VALUE"]),
2785 "DESCRIPTION" => $arProp[
"DESCRIPTION"],
2788 $arProps[$arProp[
"ID"]][
"n".$i] =
array(
2789 "VALUE" => $arProp[
"VALUE"],
2790 "DESCRIPTION" => $arProp[
"DESCRIPTION"],
2795 if (CIBlock::GetArrayByID(
$IBLOCK_ID,
"RIGHTS_MODE") ===
"E")
2797 $ibRights =
new CIBlockElementRights(intval(
$IBLOCK_ID),
$ID);
2798 $arRights = $ibRights->GetRights();
2799 $arNewRights =
array();
2801 foreach($arRights as $rightID=>
$right)
2803 if (
$right[
'IS_INHERITED'] !==
'Y')
2804 $arNewRights[
'n'.$rightIndex++] =
$right;
2806 $ar_element[
'RIGHTS'] = $arNewRights;
2809 $obElement =
new CIBlockElement;
2810 $NEW_ID = $obElement->Add($ar_element);
2812 throw new Exception($obElement->LAST_ERROR);
2819 throw new Exception(
GetMessage(
"IBD_ELEMENT_NOT_FOUND"));
2831 CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
2832 $strSql =
"update b_iblock_element set WF_STATUS_ID='2', WF_NEW='Y' WHERE ID=".intval($documentId).
" AND WF_PARENT_ELEMENT_ID IS NULL";
2833 $z =
$DB->Query($strSql);
2834 CIBlockElement::UpdateSearch($documentId);
2840 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
2844 if (CIBlock::GetArrayByID(
$iblockId,
"RIGHTS_MODE") ===
"E")
2847 return $ob->GetRightsList();
2862 static $arDocumentFieldTypes =
array();
2863 if (!array_key_exists($documentType, $arDocumentFieldTypes))
2866 if (!array_key_exists($arFieldType[
"Type"], $arDocumentFieldTypes[$documentType])
2867 || !$arDocumentFieldTypes[$documentType][$arFieldType[
"Type"]][
"Complex"])
2872 if ($arFieldType[
"Type"] ==
"E:EList")
2874 if (is_array($value))
2877 $valueTmp = intval(current($value));
2881 $valueTmp = intval($value);
2891 if (
$iblockId <= 0 && intval($arFieldType[
"Options"]) > 0)
2892 $iblockId = intval($arFieldType[
"Options"]);
2894 $defaultIBlockId = 0;
2896 $result .=
'<select id="WFSFormOptionsX" onchange="'.htmlspecialcharsbx($jsFunctionName).
'(this.options[this.selectedIndex].value)">';
2900 $result .=
'<optgroup label="'.$iblockTypeName.
'">';
2912 $result .=
'</select><!--__defaultOptionsValue:'.$defaultIBlockId.
'--><!--__modifyOptionsPromt:'.
GetMessage(
"IBD_DOCUMENT_MOPROMT").
'-->';
2914 $arFieldType[
"Options"] = $defaultIBlockId;
2916 elseif ($arFieldType[
"Type"] ==
"select")
2918 $valueTmp = $arFieldType[
"Options"];
2919 if (!is_array($valueTmp))
2920 $valueTmp =
array($valueTmp => $valueTmp);
2923 foreach ($valueTmp as
$k => $v)
2925 if (is_array($v) &&
count($v) == 2)
2927 $v1 = array_values($v);
2933 $str .=
'['.$k.
']'.$v;
2939 $result .=
'<textarea id="WFSFormOptionsX" rows="5" cols="30">'.htmlspecialcharsbx(
$str).
'</textarea><br />';
2943 function WFSFormOptionsXFunction()
2946 var i, id, val, str = document.getElementById("WFSFormOptionsX").value;
2948 var arr = str.split(/[\r\n]+/);
2949 var p, re = /\[([^\]]+)\].+/;
2952 str = arr[i].replace(/^\s+|\s+$/g, \'\');
2958 p = str.indexOf(\']\');
2960 val = str.substr(p + 1);
2974 $result .=
'<input type="button" onclick="'.htmlspecialcharsbx($jsFunctionName).
'(WFSFormOptionsXFunction())" value="'.
GetMessage(
"IBD_DOCUMENT_XFORMOPTIONS3").
'">';
2982 $documentType = trim($documentType);
2983 if ($documentType ==
'')
2986 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
2990 $groupsId =
array(1);
2991 $extendedGroupsCode =
array();
2992 if(CIBlock::GetArrayByID(
$iblockId,
"RIGHTS_MODE") ===
"E")
2994 $obRights =
new CIBlockRights(
$iblockId);
2995 foreach($obRights->GetGroups() as $GROUP_CODE)
2996 if(preg_match(
"/^G(\\d+)\$/", $GROUP_CODE, $match))
2997 $groupsId[] = $match[1];
2999 $extendedGroupsCode[] = $GROUP_CODE;
3003 foreach(CIBlock::GetGroupPermissions(
$iblockId) as $groupId =>
$perm)
3006 $groupsId[] = $groupId;
3011 while ($arGroup = $dbGroupsList->Fetch())
3012 $result[$arGroup[
"ID"]] = $arGroup[
"NAME"];
3014 if ($withExtended && $extendedGroupsCode)
3016 foreach ($extendedGroupsCode as $groupCode)
3018 $result[
'group_'.$groupCode] = CBPHelper::getExtendedGroupName($groupCode);
3027 $group = mb_strtolower($group);
3028 if ($group ==
'author')
3030 $documentId = (int)$documentId;
3031 if ($documentId <= 0)
3034 $db = CIBlockElement::GetList(
array(),
array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y",
"SHOW_HISTORY" =>
"Y"),
false,
false,
array(
"ID",
"IBLOCK_ID",
"CREATED_BY"));
3035 if (
$ar = $db->Fetch())
3040 if ((
string)intval($group) !== (
string)$group)
3043 $group = (int)$group;
3049 $arFilter = [
'ACTIVE' =>
'Y',
'IS_REAL_USER' =>
true];
3055 $dbUsersList = CUser::GetList(
"ID",
"ASC",
$arFilter, [
'FIELDS' => [
'ID']]);
3056 while ($arUser = $dbUsersList->Fetch())
3064 public static function SetPermissions($documentId, $workflowId, $arPermissions, $bRewrite =
true)
3066 $documentId = intval($documentId);
3067 if ($documentId <= 0)
3071 $iblockId = intval(mb_substr($documentType, mb_strlen(
"iblock_")));
3075 if (CIBlock::GetArrayByID(
$iblockId,
"RIGHTS_MODE") !==
"E")
3078 $ob =
new CIBlockElementRights(
$iblockId, $documentId);
3079 $documentRights = $ob->GetRights();
3082 $scope =
'ScopeWorkflow';
3084 if (is_array($bRewrite) && class_exists(
'CBPSetPermissionsMode'))
3086 if (isset($bRewrite[
'setMode']))
3088 if (isset($bRewrite[
'setScope']))
3091 elseif ($bRewrite ==
true)
3096 $overrideCodes =
array();
3097 if ($mode ==
'Clear' || $mode ==
'Rewrite')
3099 foreach ($documentRights as
$i => $arRight)
3101 if ($scope ==
'ScopeDocument' || $scope ==
'ScopeWorkflow' && $arRight[
"XML_ID"] == $workflowId)
3103 if ($mode ==
'Clear')
3104 unset($documentRights[
$i]);
3106 if ($mode ==
'Rewrite')
3107 $overrideCodes[$arRight[
"GROUP_CODE"]] =
$i;
3114 $l = mb_strlen(
"user_");
3115 foreach ($arPermissions as $taskId => $arUsers)
3117 foreach ($arUsers as $user)
3122 if ($user ==
'author')
3128 elseif (mb_strpos($user,
'group_') === 0)
3130 $gc = mb_strtoupper(mb_substr($user, mb_strlen(
'group_')));
3134 $gc = ((mb_substr($user, 0,
$l) ==
"user_") ?
"U".mb_substr($user,
$l) :
"G".$user);
3138 $documentRights[
"n".$i] =
array(
"GROUP_CODE" => $gc,
"TASK_ID" => $taskId,
"XML_ID" => $workflowId);
3141 if (isset($overrideCodes[$gc]))
3142 unset($documentRights[$overrideCodes[$gc]]);
3147 $ob->SetRights($documentRights);
3158 $documentId = intval($documentId);
3159 if ($documentId <= 0)
3164 $dbDocumentList = CIBlockElement::GetList(
3166 array(
"ID" => $documentId,
"SHOW_NEW"=>
"Y",
"SHOW_HISTORY" =>
"Y")
3168 if ($objDocument = $dbDocumentList->GetNextElement())
3170 $arDocumentFields = $objDocument->GetFields();
3171 $arDocumentProperties = $objDocument->GetProperties();
3173 $arResult[
"NAME"] = $arDocumentFields[
"~NAME"];
3176 foreach ($arDocumentFields as $fieldKey => $fieldValue)
3178 if ($fieldKey ==
"~PREVIEW_PICTURE" || $fieldKey ==
"~DETAIL_PICTURE")
3180 $arResult[
"FIELDS"][mb_substr($fieldKey, 1)] = CBPDocument::PrepareFileForHistory(
3181 array(
"iblock",
"CIBlockDocument", $documentId),
3186 elseif (mb_substr($fieldKey, 0, 1) ==
"~")
3188 $arResult[
"FIELDS"][mb_substr($fieldKey, 1)] = $fieldValue;
3193 foreach ($arDocumentProperties as $propertyKey =>
$propertyValue)
3212 "VALUE" => CBPDocument::PrepareFileForHistory(
3213 array(
"iblock",
"CIBlockDocument", $documentId),
3241 $documentId = intval($documentId);
3242 if ($documentId <= 0)
3253 $dbProperties = CIBlockProperty::GetList(
3254 array(
"sort" =>
"asc",
"name" =>
"asc"),
3257 while ($arProperty = $dbProperties->Fetch())
3259 if (trim($arProperty[
"CODE"]) <>
'')
3260 $key = $arProperty[
"CODE"];
3262 $key = $arProperty[
"ID"];
3264 if (!array_key_exists(
$key, $arDocument[
"PROPERTIES"]))
3267 $documentValue = $arDocument[
"PROPERTIES"][
$key][
"VALUE"];
3269 if($arProperty[
"USER_TYPE"] ==
'' && $arProperty[
"PROPERTY_TYPE"] ==
"F")
3273 $rsFiles = CIBlockElement::GetProperty(
$arFields[
"IBLOCK_ID"], $documentId,
array(
"ID"=>$arProperty[
"ID"],
"EMPTY"=>
"N"));
3274 while($arFile = $rsFiles->Fetch())
3276 if($arFile[
"PROPERTY_VALUE_ID"] > 0)
3278 "VALUE" =>
array(
"del"=>
"Y"),
3279 "DESCRIPTION" =>
"",
3284 if(is_array($documentValue))
3287 foreach ($documentValue as
$i => $v)
3291 "VALUE" => CFile::MakeFileArray(
$io->GetPhysicalName($v)),
3292 "DESCRIPTION" => $arDocument[
"PROPERTIES"][
$key][
"DESCRIPTION"][
$i]
3298 if($documentValue <>
'')
3301 "VALUE" => CFile::MakeFileArray(
$io->GetPhysicalName($documentValue)),
3302 "DESCRIPTION" => $arDocument[
"PROPERTIES"][
$key][
"DESCRIPTION"]
3309 if(is_array($documentValue))
3312 foreach ($documentValue as
$i => $v)
3316 "DESCRIPTION" => $arDocument[
"PROPERTIES"][
$key][
"DESCRIPTION"][
$i]
3321 if($documentValue <>
'')
3323 "VALUE" => $documentValue,
3324 "DESCRIPTION" => $arDocument[
"PROPERTIES"][
$key][
"DESCRIPTION"]
3330 $iblockElement =
new CIBlockElement();
3332 if (intval(
$arFields[
"WF_STATUS_ID"]) > 1 && intval(
$arFields[
"WF_PARENT_ELEMENT_ID"]) <= 0)
3335 throw new Exception($iblockElement->LAST_ERROR);
3342 $iblockId = (int)mb_substr($documentType, mb_strlen(
"iblock_"));
3346 return CIBlock::GetArrayByID(
$iblockId,
"RIGHTS_MODE");
3353 $code = CUtil::translit(
$name, LANGUAGE_ID,
array(
"change_case" =>
"U"));
3357 while($property = $object->fetch())
3359 if($property[
"CODE"] ==
$code && $property[
"ID"] != $propertyId)
while($arIBType=$dbIBlockType->Fetch()) $dbIBlock
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static updateElementIndex($iblockId, $elementId)
static CalendarDate($sFieldName, $sValue="", $size="10", $bTime=false)
static GetListEx($arOrder=["ID"=> "DESC"], $arFilter=[], $arGroupBy=false, $arNavStartParams=false, $arSelectFields=[])
static GetOperations($ID, $return_names=false)
static RecoverDocumentFromHistory($documentId, $arDocument)
static generatePropertyCode($name, $code, $iblockId, $propertyId=0)
static generateMnemonicCode($integerCode=0)
static GetDocumentFieldTypes($documentType)
static CreateDocument($parentDocumentId, $arFields)
static GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
static GetDocumentType($documentId)
static UpdateDocument($documentId, $arFields)
static PublishDocument($documentId)
static getDocumentTypeName($documentType)
static SetPermissions($documentId, $workflowId, $arPermissions, $bRewrite=true)
static CanUserOperateDocument($operation, $userId, $documentId, $arParameters=array())
static AddDocumentField($documentType, $arFields)
static getDocumentTypeCaption($documentType)
static GetAllowableOperations($documentType)
static IsDocumentLocked($documentId, $workflowId)
static GetFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors)
static GetDocumentFields($documentType)
static GetFieldInputControl($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection=false, $publicMode=false)
static LockDocument($documentId, $workflowId)
static UnpublishDocument($documentId)
static GetFieldValuePrintable($documentId, $fieldName, $fieldType, $fieldValue, $arFieldType)
static getDocumentName($documentId)
static GetJSFunctionsForFields($documentType, $objectName, $arDocumentFields=array(), $arDocumentFieldTypes=array())
static GetDocumentAdminPage($documentId)
static CloneElement($ID, $arFields=array())
static GetDocumentForHistory($documentId, $historyIndex)
static CanUserOperateDocumentType($operation, $userId, $documentType, $arParameters=array())
static GetDocument($documentId)
static UnlockDocument($documentId, $workflowId)
static GetUsersFromUserGroup($group, $documentId)
static GetAllowableUserGroups($documentType, $withExtended=false)
static isDocumentExists($documentId)
static DeleteDocument($documentId)
static GetFieldInputControlOptions($documentType, &$arFieldType, $jsFunctionName, &$value)
static isExtendedPermsSupported($documentType)
static GetIBlockTypes($arTop=false)
</td ></tr ></table ></td ></tr ><?endif?><? $propertyIndex=0;foreach( $arGlobalProperties as $propertyCode=> $propertyValue
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
ExecuteModuleEventEx($arEvent, $arParams=[])
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
$GLOBALS['_____370096793']