1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
bizprocdocument.php
См. документацию.
1<?php
2
6
7Loc::loadMessages(__FILE__);
8
9if (!Loader::includeModule('bizproc') || !Loader::includeModule('iblock'))
10{
11 return;
12}
13
15{
16 const DOCUMENT_TYPE_PREFIX = 'iblock_';
17 private static $cachedTasks;
18 private static $elements = [];
19 private static $cachedGroups = [];
20
21 public static function getEntityName()
22 {
23 return Loc::getMessage('LISTS_BIZPROC_ENTITY_NAME');
24 }
25
30 public static function generateDocumentType($iblockId)
31 {
32 $iblockId = (int)$iblockId;
33 return self::DOCUMENT_TYPE_PREFIX . $iblockId;
34 }
35
41 public static function generateDocumentComplexType($iblockType, $iblockId)
42 {
43 if($iblockType == COption::GetOptionString("lists", "livefeed_iblock_type_id"))
44 return array('lists', get_called_class(), self::generateDocumentType($iblockId));
45 else
46 return array('lists', 'Bitrix\Lists\BizprocDocumentLists', self::generateDocumentType($iblockId));
47 }
48
54 public static function getDocumentComplexId($iblockType, $documentId)
55 {
56 if($iblockType == COption::getOptionString("lists", "livefeed_iblock_type_id"))
57 return array('lists', get_called_class(), $documentId);
58 else
59 return array('lists', 'Bitrix\Lists\BizprocDocumentLists', $documentId);
60 }
61
65 public static function deleteDataIblock($iblockId)
66 {
67 $iblockId = intval($iblockId);
68 $documentType = array('lists', get_called_class(), self::generateDocumentType($iblockId));
69 $errors = array();
70 $templateObject = CBPWorkflowTemplateLoader::getList(
71 array('ID' => 'DESC'),
72 array('DOCUMENT_TYPE' => $documentType),
73 false,
74 false,
75 array('ID')
76 );
77 while($template = $templateObject->fetch())
78 {
79 CBPDocument::deleteWorkflowTemplate($template['ID'], $documentType, $errors);
80 }
81 }
82
89 public static function getDocumentIcon($documentId)
90 {
91 $documentId = intval($documentId);
92 if ($documentId <= 0)
93 throw new CBPArgumentNullException('documentId');
94
95 $db = CIBlockElement::getList(
96 array(),
97 array('ID' => $documentId, 'SHOW_NEW'=>'Y', 'SHOW_HISTORY' => 'Y'),
98 false,
99 false,
100 array('ID', 'IBLOCK_ID')
101 );
102 if ($element = $db->fetch())
103 {
104 $iblockPicture = CIBlock::getArrayByID($element['IBLOCK_ID'], 'PICTURE');
105 $imageFile = CFile::getFileArray($iblockPicture);
106 if(!empty($imageFile['SRC']))
107 return $imageFile['SRC'];
108 }
109
110 return null;
111 }
112
120 public static function getDocument($documentId)
121 {
122 $args = func_get_args();
123 $select = $args[2] ?? [];
124 $documentId = (int)$documentId;
125 if ($documentId <= 0)
126 {
127 throw new CBPArgumentNullException('documentId');
128 }
129
130 $result = [];
131 $element = [];
132 $elementProperty = [];
133
134 if (!empty($select))
135 {
136 $select = array_filter($select, fn($field) => !str_starts_with($field, 'PROPERTY_'));
137 $select = array_merge(['ID', 'IBLOCK_ID'], $select);
138
139 if (in_array('CREATED_BY', $select) && !in_array('CREATED_USER_NAME', $select))
140 {
141 $select[] = 'CREATED_USER_NAME';
142 }
143 if (in_array('MODIFIED_BY', $select) && !in_array('USER_NAME', $select))
144 {
145 $select[] = 'USER_NAME';
146 }
147 }
148
149 $userNameFields = [
150 'CREATED_BY_PRINTABLE' => 'CREATED_USER_NAME',
151 'MODIFIED_BY_PRINTABLE' => 'USER_NAME',
152 ];
153
154 $select = array_map(static fn($selectField) => $userNameFields[$selectField] ?? $selectField, $select);
155
156 $queryElement = CIBlockElement::getList(
157 [],
158 ['ID' => $documentId, 'SHOW_NEW' => 'Y', 'SHOW_HISTORY' => 'Y'],
159 arSelectFields: $select
160 );
161 while ($queryResult = $queryElement->fetch())
162 {
163 $element = $queryResult;
164 $queryProperty = CIBlockElement::getProperty(
165 $queryResult['IBLOCK_ID'],
166 $queryResult['ID'],
167 ['sort' => 'asc', 'id' => 'asc', 'enum_sort' => 'asc', 'value_id' => 'asc'],
168 ['ACTIVE' => 'Y', 'EMPTY' => 'N']
169 );
170 while ($property = $queryProperty->fetch())
171 {
172 $propertyKey = 'PROPERTY_' . $property['ID'];
173 if ($property['MULTIPLE'] == 'Y')
174 {
175 if (!array_key_exists($propertyKey, $elementProperty))
176 {
177 $elementProperty[$propertyKey] = $property;
178 $elementProperty[$propertyKey]['VALUE'] = [];
179 }
180 $elementProperty[$propertyKey]['VALUE'][] = $property['VALUE'];
181 }
182 else
183 {
184 $elementProperty[$propertyKey] = $property;
185 }
186 }
187 }
188
189 foreach ($element as $fieldId => $fieldValue)
190 {
191 $result[$fieldId] = $fieldValue;
192 if (in_array($fieldId, ['MODIFIED_BY', 'CREATED_BY']))
193 {
194 $result[$fieldId] = 'user_' . $fieldValue;
195 $result[$fieldId . '_PRINTABLE'] =
196 $element[($fieldId == 'MODIFIED_BY')
197 ? 'USER_NAME'
198 : 'CREATED_USER_NAME']
199 ;
200 }
201 elseif (in_array($fieldId, ['PREVIEW_TEXT', 'DETAIL_TEXT']))
202 {
203 if ($element[$fieldId . '_TYPE'] == 'html')
204 {
205 $result[$fieldId] = HTMLToTxt($fieldValue);
206 }
207 }
208 }
209 foreach ($elementProperty as $propertyId => $property)
210 {
211 if (trim($property['CODE']) <> '')
212 {
213 $propertyId = $property['CODE'];
214 }
215 else
216 {
217 $propertyId = $property['ID'];
218 }
219
220 if (!empty($property['USER_TYPE']))
221 {
222 if (
223 $property['USER_TYPE'] == 'UserID'
224 || $property['USER_TYPE'] == 'employee'
225 && (COption::getOptionString('bizproc', 'employee_compatible_mode', 'N') != 'Y')
226 )
227 {
228 if (empty($property['VALUE']))
229 {
230 continue;
231 }
232 if (!is_array($property['VALUE']))
233 {
234 $property['VALUE'] = [$property['VALUE']];
235 }
236
237 $listUsers = implode(' | ', $property['VALUE']);
238 $userQuery = CUser::getList(
239 'ID',
240 'ASC',
241 ['ID' => $listUsers],
242 [
243 'FIELDS' => ['ID', 'LOGIN', 'NAME', 'LAST_NAME'],
244 ]
245 );
246 while ($user = $userQuery->fetch())
247 {
248 if ($property['MULTIPLE'] == 'Y')
249 {
250 $result = self::setArray($result, 'PROPERTY_' . $propertyId);
251 $result = self::setArray($result, 'PROPERTY_' . $propertyId . '_PRINTABLE');
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'];
256 }
257 else
258 {
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'];
263 }
264 }
265 }
266 elseif ($property['USER_TYPE'] == 'DiskFile')
267 {
268 $diskValues = is_array($property['VALUE']) ? current($property['VALUE']) : null;
269 $userType = \CIBlockProperty::getUserType($property['USER_TYPE']);
270 if (is_array($diskValues))
271 {
272 $result = self::setArray($result, 'PROPERTY_' . $propertyId);
273 $result = self::setArray($result, 'PROPERTY_' . $propertyId . '_PRINTABLE');
274 foreach ($diskValues as $attachedId)
275 {
276 $fileId = null;
277 if (array_key_exists('GetObjectId', $userType))
278 {
279 $fileId = call_user_func_array($userType['GetObjectId'], [$attachedId]);
280 }
281 if (!$fileId)
282 {
283 continue;
284 }
285 $printableUrl = '';
286 if (array_key_exists('GetUrlAttachedFileElement', $userType))
287 {
288 $printableUrl = call_user_func_array(
289 $userType['GetUrlAttachedFileElement'],
290 [$documentId, $fileId]
291 );
292 }
293
294 $result['PROPERTY_' . $propertyId][$attachedId] = $fileId;
295 $result['PROPERTY_' . $propertyId . '_PRINTABLE'][$attachedId] = $printableUrl;
296 }
297 }
298 else
299 {
300 continue;
301 }
302 }
303 elseif ($property['USER_TYPE'] == 'HTML')
304 {
305 if (\CBPHelper::isAssociativeArray($property['VALUE']))
306 {
307 if ($property['VALUE']['TYPE'] == 'HTML')
308 {
309 $result['PROPERTY_' . $propertyId] = HTMLToTxt($property['VALUE']['TEXT']);
310 }
311 else
312 {
313 $result['PROPERTY_' . $propertyId] = $property['VALUE']['TEXT'];
314 }
315 }
316 else
317 {
318 $result = self::setArray($result, 'PROPERTY_' . $propertyId);
319 foreach ($property['VALUE'] as $htmlValue)
320 {
321 if ($htmlValue['TYPE'] == 'HTML')
322 {
323 $result['PROPERTY_' . $propertyId][] = HTMLToTxt($htmlValue['TEXT']);
324 }
325 else
326 {
327 $result['PROPERTY_' . $propertyId][] = $htmlValue['TEXT'];
328 }
329 }
330 }
331 }
332 elseif ($property['USER_TYPE'] == 'Money')
333 {
334 $userType = \CIBlockProperty::getUserType($property['USER_TYPE']);
335 if (is_array($property['VALUE']))
336 {
337 $result = self::setArray($result, 'PROPERTY_' . $propertyId);
338 $result = self::setArray($result, 'PROPERTY_' . $propertyId . '_PRINTABLE');
339 foreach ($property['VALUE'] as $moneyValue)
340 {
341 $result['PROPERTY_' . $propertyId][] = $moneyValue;
342 if (array_key_exists('GetPublicViewHTML', $userType))
343 {
344 $result['PROPERTY_' . $propertyId . '_PRINTABLE'][] = call_user_func_array(
345 $userType['GetPublicViewHTML'],
346 [$property, ['VALUE' => $moneyValue], []]
347 );
348 }
349 }
350 }
351 else
352 {
353 $result['PROPERTY_' . $propertyId] = $property['VALUE'];
354 if (array_key_exists('GetPublicViewHTML', $userType))
355 {
356 $result['PROPERTY_' . $propertyId . '_PRINTABLE'] = call_user_func_array(
357 $userType['GetPublicViewHTML'],
358 [$property, ['VALUE' => $property['VALUE']], []]
359 );
360 }
361 }
362 }
363 else
364 {
365 $result['PROPERTY_' . $propertyId] = $property['VALUE'];
366 }
367 }
368 elseif ($property['PROPERTY_TYPE'] == 'L')
369 {
370 $result = self::setArray($result, 'PROPERTY_' . $propertyId);
371 //$result = self::setArray($result, 'PROPERTY_'.$propertyId.'_PRINTABLE');
372 $propertyArray = [];
373 $propertyKeyArray = [];
374 if (!is_array($property['VALUE']))
375 {
376 $property['VALUE'] = [$property['VALUE']];
377 }
378 foreach ($property['VALUE'] as $enumId)
379 {
380 $enumsObject = CIBlockProperty::getPropertyEnum(
381 $property['ID'],
382 ['SORT' => 'asc'],
383 ['ID' => $enumId]
384 );
385 while ($enums = $enumsObject->fetch())
386 {
387 $propertyArray[] = $enums['VALUE'];
388 $propertyKeyArray[] = $enums['XML_ID'];
389 }
390 }
391 for ($i = 0, $cnt = count($propertyArray); $i < $cnt; $i++)
392 {
393 $result['PROPERTY_' . $propertyId][$propertyKeyArray[$i]] = $propertyArray[$i];
394 }
395 }
396 elseif ($property['PROPERTY_TYPE'] == 'F')
397 {
398 $result = self::setArray($result, 'PROPERTY_' . $propertyId);
399 $result = self::setArray($result, 'PROPERTY_' . $propertyId . '_PRINTABLE');
400 $propertyArray = $property['VALUE'];
401 if (!is_array($propertyArray))
402 {
403 $propertyArray = [$propertyArray];
404 }
405
406 foreach ($propertyArray as $v)
407 {
408 $fileArray = \CFile::getFileArray($v);
409 if ($fileArray)
410 {
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"]) . "]" .
415 htmlspecialcharsbx($fileArray["ORIGINAL_NAME"]) . "[/url]";
416 }
417 }
418 }
419 else
420 {
421 $result['PROPERTY_' . $propertyId] = $property['VALUE'];
422 }
423 }
424
425 if (!empty($result))
426 {
427 $documentFields = static::getDocumentFields(static::getDocumentType($documentId));
428 foreach ($documentFields as $fieldKey => $field)
429 {
430 if (!array_key_exists($fieldKey, $result))
431 {
432 $result[$fieldKey] = null;
433 }
434 }
435 }
436
437 return $result;
438 }
439
440 protected static function setArray(array $result, $value)
441 {
442 if (!isset($result[$value]) || !is_array($result[$value]))
443 {
444 $result[$value] = array();
445 }
446 return $result;
447 }
448
449 protected static function getSystemIblockFields()
450 {
451 $result = array(
452 "ID" => array(
453 "Name" => GetMessage("IBD_FIELD_ID"),
454 "Type" => "int",
455 "Filterable" => true,
456 "Editable" => false,
457 "Required" => false,
458 ),
459 "TIMESTAMP_X" => array(
460 "Name" => GetMessage("IBD_FIELD_TIMESTAMP_X"),
461 "Type" => "datetime",
462 "Filterable" => true,
463 "Editable" => true,
464 "Required" => false,
465 ),
466 "MODIFIED_BY" => array(
467 "Name" => GetMessage("IBD_FIELD_MODYFIED"),
468 "Type" => "user",
469 "Filterable" => true,
470 "Editable" => true,
471 "Required" => false,
472 ),
473 "MODIFIED_BY_PRINTABLE" => array(
474 "Name" => GetMessage("IBD_FIELD_MODIFIED_BY_USER_PRINTABLE"),
475 "Type" => "string",
476 "Filterable" => false,
477 "Editable" => false,
478 "Required" => false,
479 ),
480 "DATE_CREATE" => array(
481 "Name" => GetMessage("IBD_FIELD_DATE_CREATE"),
482 "Type" => "datetime",
483 "Filterable" => true,
484 "Editable" => true,
485 "Required" => false,
486 ),
487 "CREATED_BY" => array(
488 "Name" => GetMessage("IBD_FIELD_CREATED"),
489 "Type" => "user",
490 "Filterable" => true,
491 "Editable" => false,
492 "Required" => false,
493 ),
494 "CREATED_BY_PRINTABLE" => array(
495 "Name" => GetMessage("IBD_FIELD_CREATED_BY_USER_PRINTABLE"),
496 "Type" => "string",
497 "Filterable" => false,
498 "Editable" => false,
499 "Required" => false,
500 ),
501 "IBLOCK_ID" => array(
502 "Name" => GetMessage("IBD_FIELD_IBLOCK_ID"),
503 "Type" => "int",
504 "Filterable" => true,
505 "Editable" => true,
506 "Required" => true,
507 ),
508 "ACTIVE" => array(
509 "Name" => GetMessage("IBD_FIELD_ACTIVE"),
510 "Type" => "bool",
511 "Filterable" => true,
512 "Editable" => true,
513 "Required" => false,
514 ),
515 "BP_PUBLISHED" => array(
516 "Name" => GetMessage("IBD_FIELD_BP_PUBLISHED"),
517 "Type" => "bool",
518 "Filterable" => false,
519 "Editable" => true,
520 "Required" => false,
521 ),
522 "ACTIVE_FROM" => array(
523 "Name" => GetMessage("IBD_FIELD_DATE_ACTIVE_FROM"),
524 "Type" => "datetime",
525 "Filterable" => true,
526 "Editable" => true,
527 "Required" => false,
528 ),
529 "ACTIVE_TO" => array(
530 "Name" => GetMessage("IBD_FIELD_DATE_ACTIVE_TO"),
531 "Type" => "datetime",
532 "Filterable" => true,
533 "Editable" => true,
534 "Required" => false,
535 ),
536 "SORT" => array(
537 "Name" => GetMessage("IBD_FIELD_SORT"),
538 "Type" => "int",
539 "Filterable" => true,
540 "Editable" => true,
541 "Required" => false,
542 ),
543 "NAME" => array(
544 "Name" => GetMessage("IBD_FIELD_NAME"),
545 "Type" => "string",
546 "Filterable" => true,
547 "Editable" => true,
548 "Required" => true,
549 ),
550 "PREVIEW_PICTURE" => array(
551 "Name" => GetMessage("IBD_FIELD_PREVIEW_PICTURE"),
552 "Type" => "file",
553 "Filterable" => false,
554 "Editable" => true,
555 "Required" => false,
556 ),
557 "PREVIEW_TEXT" => array(
558 "Name" => GetMessage("IBD_FIELD_PREVIEW_TEXT"),
559 "Type" => "text",
560 "Filterable" => false,
561 "Editable" => true,
562 "Required" => false,
563 ),
564 "PREVIEW_TEXT_TYPE" => array(
565 "Name" => GetMessage("IBD_FIELD_PREVIEW_TEXT_TYPE"),
566 "Type" => "select",
567 "Options" => array(
568 "text" => GetMessage("IBD_DESC_TYPE_TEXT"),
569 "html" => "Html",
570 ),
571 "Filterable" => false,
572 "Editable" => true,
573 "Required" => false,
574 ),
575 "DETAIL_PICTURE" => array(
576 "Name" => GetMessage("IBD_FIELD_DETAIL_PICTURE"),
577 "Type" => "file",
578 "Filterable" => false,
579 "Editable" => true,
580 "Required" => false,
581 ),
582 "DETAIL_TEXT" => array(
583 "Name" => GetMessage("IBD_FIELD_DETAIL_TEXT"),
584 "Type" => "text",
585 "Filterable" => false,
586 "Editable" => true,
587 "Required" => false,
588 ),
589 "DETAIL_TEXT_TYPE" => array(
590 "Name" => GetMessage("IBD_FIELD_DETAIL_TEXT_TYPE"),
591 "Type" => "select",
592 "Options" => array(
593 "text" => GetMessage("IBD_DESC_TYPE_TEXT"),
594 "html" => "Html",
595 ),
596 "Filterable" => false,
597 "Editable" => true,
598 "Required" => false,
599 ),
600 "CODE" => array(
601 "Name" => GetMessage("IBD_FIELD_CODE"),
602 "Type" => "string",
603 "Filterable" => true,
604 "Editable" => true,
605 "Required" => false,
606 ),
607 "XML_ID" => array(
608 "Name" => GetMessage("IBD_FIELD_XML_ID"),
609 "Type" => "string",
610 "Filterable" => true,
611 "Editable" => true,
612 "Required" => false,
613 ),
614 );
615
616 $keys = array_keys($result);
617 foreach ($keys as $key)
618 {
619 $result[$key]["Multiple"] = false;
620 $result[$key]["active"] = false;
621 }
622
623 return $result;
624 }
625
631 public static function getDocumentFields($documentType)
632 {
633 $iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
634 if ($iblockId <= 0)
635 throw new CBPArgumentOutOfRangeException("documentType", $documentType);
636
637 $documentFieldTypes = self::getDocumentFieldTypes($documentType);
638
640
642 'select' => [
643 'ID', 'CODE', 'USER_TYPE', 'NAME', 'FILTRABLE', 'IS_REQUIRED',
644 'MULTIPLE', 'PROPERTY_TYPE', 'USER_TYPE_SETTINGS_LIST', 'DEFAULT_VALUE', 'LINK_IBLOCK_ID',
645 ],
646 'filter' => ['=IBLOCK_ID' => $iblockId, '=ACTIVE' => 'Y'],
647 'order' => ['SORT' => 'ASC'],
648 'cache' => ['ttl' => 3600],
649 ]);
650
651 $ignoreProperty = array();
652 while ($property = $dbProperties->fetch())
653 {
654 if (trim($property["CODE"]) <> '')
655 {
656 $key = "PROPERTY_".$property["CODE"];
657 $ignoreProperty["PROPERTY_".$property["ID"]] = "PROPERTY_".$property["CODE"];
658 }
659 else
660 {
661 $key = "PROPERTY_".$property["ID"];
662 $ignoreProperty["PROPERTY_".$property["ID"]] = 0;
663 }
664
665 $settings = $property["USER_TYPE_SETTINGS_LIST"];
666 $result[$key] = array(
667 "Name" => $property["NAME"],
668 "Filterable" => ($property["FILTRABLE"] == "Y"),
669 "Editable" => true,
670 "Required" => ($property["IS_REQUIRED"] == "Y"),
671 "Multiple" => ($property["MULTIPLE"] == "Y"),
672 "TypeReal" => $property["PROPERTY_TYPE"],
673 "UserTypeSettings" => $settings
674 );
675
676 if(trim($property["CODE"]) <> '')
677 $result[$key]["Alias"] = "PROPERTY_".$property["ID"];
678
679 if ($property["USER_TYPE"] <> '')
680 {
681 $arUserType = CIBlockProperty::GetUserType($property["USER_TYPE"]);
682 if (isset($arUserType["ConvertFromDB"]) && array_key_exists("DEFAULT_VALUE", $property))
683 {
684 $value = [
685 "VALUE" => $property["DEFAULT_VALUE"],
686 "DESCRIPTION" => "",
687 ];
688 $value = call_user_func_array($arUserType["ConvertFromDB"], [$property, $value]);
689 $res["DEFAULT_VALUE"] = $value["VALUE"] ?? null;
690 }
691
692 $result[$key]["TypeReal"] = $property["PROPERTY_TYPE"].":".$property["USER_TYPE"];
693
694 if ($property["USER_TYPE"] == "UserID"
695 || $property["USER_TYPE"] == "employee" && (COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y"))
696 {
697 $result[$key]["Type"] = "user";
698 $result[$key."_PRINTABLE"] = array(
699 "Name" => $property["NAME"].GetMessage("IBD_FIELD_USERNAME_PROPERTY"),
700 "Filterable" => false,
701 "Editable" => false,
702 "Required" => false,
703 "Multiple" => ($property["MULTIPLE"] == "Y"),
704 "Type" => "string",
705 );
706 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
707 }
708 elseif ($property["USER_TYPE"] == "DateTime")
709 {
710 $result[$key]["Type"] = "datetime";
711 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
712 }
713 elseif ($property["USER_TYPE"] == "Date")
714 {
715 $result[$key]["Type"] = "date";
716 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
717 }
718 elseif ($property["USER_TYPE"] == "EList")
719 {
720 $result[$key]["Type"] = "E:EList";
721 $result[$key]["Options"] = $property["LINK_IBLOCK_ID"];
722 }
723 elseif ($property["USER_TYPE"] == "ECrm")
724 {
725 $result[$key]["Type"] = "E:ECrm";
726 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
727 $result[$key]["Options"] = $settings;
728 }
729 elseif ($property["USER_TYPE"] == "Money")
730 {
731 $result[$key]["Type"] = "S:Money";
732 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
733 $result[$key."_PRINTABLE"] = array(
734 "Name" => $property["NAME"].GetMessage("IBD_FIELD_USERNAME_PROPERTY"),
735 "Filterable" => false,
736 "Editable" => false,
737 "Required" => false,
738 "Multiple" => ($property["MULTIPLE"] == "Y"),
739 "Type" => "string",
740 );
741 }
742 elseif ($property["USER_TYPE"] == "Sequence")
743 {
744 $result[$key]["Type"] = "N:Sequence";
745 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
746 $result[$key]["Options"] = $settings;
747 }
748 elseif ($property["USER_TYPE"] == "DiskFile")
749 {
750 $result[$key]["Type"] = "S:DiskFile";
751 $result[$key."_PRINTABLE"] = array(
752 "Name" => $property["NAME"].GetMessage("IBD_FIELD_USERNAME_PROPERTY"),
753 "Filterable" => false,
754 "Editable" => false,
755 "Required" => false,
756 "Multiple" => ($property["MULTIPLE"] == "Y"),
757 "Type" => "int",
758 );
759 }
760 elseif ($property["USER_TYPE"] == "HTML")
761 {
762 $result[$key]["Type"] = "S:HTML";
763 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
764 }
765 else
766 {
767 $result[$key]["Type"] = "string";
768 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
769 }
770 }
771 elseif ($property["PROPERTY_TYPE"] == "L")
772 {
773 $result[$key]["Type"] = "select";
774
775 $result[$key]["Options"] = array();
776 $dbPropertyEnums = CIBlockProperty::getPropertyEnum($property["ID"]);
777 while ($propertyEnum = $dbPropertyEnums->getNext())
778 {
779 $result[$key]["Options"][$propertyEnum["XML_ID"]] = $propertyEnum["~VALUE"];
780 if($propertyEnum["DEF"] == "Y")
781 $result[$key]["DefaultValue"] = $propertyEnum["~VALUE"];
782 }
783 }
784 elseif ($property["PROPERTY_TYPE"] == "N")
785 {
786 $result[$key]["Type"] = "double";
787 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
788 }
789 elseif ($property["PROPERTY_TYPE"] == "F")
790 {
791 $result[$key]["Type"] = "file";
792 $result[$key."_PRINTABLE"] = array(
793 "Name" => $property["NAME"].GetMessage("IBD_FIELD_USERNAME_PROPERTY"),
794 "Filterable" => false,
795 "Editable" => false,
796 "Required" => false,
797 "Multiple" => ($property["MULTIPLE"] == "Y"),
798 "Type" => "string",
799 );
800 }
801 elseif ($property["PROPERTY_TYPE"] == "S")
802 {
803 $result[$key]["Type"] = "string";
804 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
805 }
806 elseif ($property["PROPERTY_TYPE"] == "E")
807 {
808 $result[$key]["Type"] = "E:EList";
809 $result[$key]["Options"] = $property["LINK_IBLOCK_ID"];
810 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
811 }
812 else
813 {
814 $result[$key]["Type"] = "string";
815 $result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
816 }
817 }
818
819 $list = new CList($iblockId);
820 $fields = $list->getFields();
821 foreach($fields as $fieldId => $field)
822 {
823 if(empty($field["SETTINGS"]))
824 $field["SETTINGS"] = array("SHOW_ADD_FORM" => 'Y', "SHOW_EDIT_FORM"=>'Y');
825
826 if(array_key_exists($fieldId, $ignoreProperty))
827 {
828 $ignoreProperty[$fieldId] ? $key = $ignoreProperty[$fieldId] : $key = $fieldId;
829 $result[$key]["sort"] = $field["SORT"];
830 $result[$key]["settings"] = $field["SETTINGS"];
831 $result[$key]["active"] = true;
832 $result[$key]["DefaultValue"] = $field["DEFAULT_VALUE"];
833 if($field["ROW_COUNT"] && $field["COL_COUNT"])
834 {
835 $result[$key]["row_count"] = $field["ROW_COUNT"];
836 $result[$key]["col_count"] = $field["COL_COUNT"];
837 }
838 }
839 else
840 {
841 $result[$fieldId] = array(
842 "Name" => $field['NAME'],
843 "Filterable" => !empty($result[$fieldId]['Filterable']) ? $result[$fieldId]['Filterable'] : false,
844 "Editable" => !empty($result[$fieldId]['Editable']) ? $result[$fieldId]['Editable'] : true,
845 "Required" => ($field['IS_REQUIRED'] == 'Y'),
846 "Multiple" => ($field['MULTIPLE'] == 'Y'),
847 "Type" => !empty($result[$fieldId]['Type']) ? $result[$fieldId]['Type'] : $field['TYPE'],
848 "sort" => $field["SORT"],
849 "settings" => $field["SETTINGS"],
850 "active" => true,
851 "active_type" => $field['TYPE'],
852 "DefaultValue" => $field["DEFAULT_VALUE"],
853 );
854 if(isset($field['ROW_COUNT'], $field['COL_COUNT']) && $field["ROW_COUNT"] && $field["COL_COUNT"])
855 {
856 $result[$fieldId]["row_count"] = $field["ROW_COUNT"];
857 $result[$fieldId]["col_count"] = $field["COL_COUNT"];
858 }
859 }
860 }
861
862 $keys = array_keys($result);
863 foreach ($keys as $k)
864 {
865 $result[$k]["BaseType"] = $documentFieldTypes[$result[$k]["Type"]]["BaseType"];
866 $result[$k]["Complex"] = $documentFieldTypes[$result[$k]["Type"]]["Complex"] ?? null;
867 }
868
869 return $result;
870 }
871
876 public static function generateMnemonicCode($integerCode = 0)
877 {
878 $code = '';
879 for ($i = 1; $integerCode >= 0 && $i < 10; $i++)
880 {
881 $code = chr(0x41 + ($integerCode % pow(26, $i) / pow(26, $i - 1))) . $code;
882 $integerCode -= pow(26, $i);
883 }
884 return $code;
885 }
886
893 public static function addDocumentField($documentType, $fields)
894 {
895 $iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
896 if ($iblockId <= 0)
897 throw new CBPArgumentOutOfRangeException("documentType", $documentType);
898
899 if (mb_substr($fields["code"], 0, mb_strlen("PROPERTY_")) == "PROPERTY_")
900 $fields["code"] = mb_substr($fields["code"], mb_strlen("PROPERTY_"));
901
902 if(!empty($fields["active_type"]))
903 $fields["type"] = $fields["active_type"];
904
905 $fieldsTemporary = array(
906 "NAME" => $fields["name"],
907 "ACTIVE" => "Y",
908 "SORT" => $fields["sort"] ?? 900,
909 "CODE" => $fields["code"],
910 'MULTIPLE' => $fields['multiple'] == 'Y' || (string)$fields['multiple'] === '1' ? 'Y' : 'N',
911 'IS_REQUIRED' => $fields['required'] == 'Y' || (string)$fields['required'] === '1' ? 'Y' : 'N',
912 "IBLOCK_ID" => $iblockId,
913 "FILTRABLE" => "Y",
914 "SETTINGS" => $fields["settings"] ?? ["SHOW_ADD_FORM" => 'Y', "SHOW_EDIT_FORM"=>'Y'],
915 "DEFAULT_VALUE" => $fields['DefaultValue'] ?? null,
916 );
917
918 if (mb_strpos("0123456789", mb_substr($fieldsTemporary["CODE"], 0, 1)) !== false)
919 $fieldsTemporary["CODE"] = self::generatePropertyCode($fields["name"], $fields["code"], $iblockId);
920
921 if (array_key_exists("additional_type_info", $fields))
922 $fieldsTemporary["LINK_IBLOCK_ID"] = intval($fields["additional_type_info"]);
923
924 if(!empty($fields["UserTypeSettings"]))
925 $fieldsTemporary["USER_TYPE_SETTINGS"] = $fields["UserTypeSettings"];
926
927 if(mb_strstr($fields["type"], ":") !== false)
928 {
929 [$fieldsTemporary["TYPE"], $fieldsTemporary["USER_TYPE"]] = explode(":", $fields["type"], 2);
930 if($fields["type"] == "E:EList")
931 {
932 $fieldsTemporary["LINK_IBLOCK_ID"] = $fields["options"] ?? null;
933 }
934 elseif($fields["type"] == "E:ECrm")
935 {
936 $fieldsTemporary["TYPE"] = "S:ECrm";
937 }
938 }
939 elseif ($fields["type"] == "user")
940 {
941 $fieldsTemporary["TYPE"] = "S:employee";
942 $fieldsTemporary["USER_TYPE"]= "UserID";
943 }
944 elseif ($fields["type"] == "date")
945 {
946 $fieldsTemporary["TYPE"] = "S:Date";
947 $fieldsTemporary["USER_TYPE"]= "Date";
948 }
949 elseif ($fields["type"] == "datetime")
950 {
951 $fieldsTemporary["TYPE"] = "S:DateTime";
952 $fieldsTemporary["USER_TYPE"]= "DateTime";
953 }
954 elseif ($fields["type"] == "file")
955 {
956 $fieldsTemporary["TYPE"] = "F";
957 $fieldsTemporary["USER_TYPE"]= "";
958 }
959 elseif ($fields["type"] == "select")
960 {
961 $fieldsTemporary["TYPE"] = "L";
962 $fieldsTemporary["USER_TYPE"]= false;
963
964 if (is_array($fields["options"]))
965 {
966 $i = 10;
967 foreach ($fields["options"] as $k => $v)
968 {
969 $def = "N";
970 if($fields['DefaultValue'] == $v)
971 $def = "Y";
972 $fieldsTemporary["VALUES"][] = array("XML_ID" => $k, "VALUE" => $v, "DEF" => $def, "SORT" => $i);
973 $i = $i + 10;
974 }
975 }
976 elseif (is_string($fields["options"]) && ($fields["options"] <> ''))
977 {
978 $a = explode("\n", $fields["options"]);
979 $i = 10;
980 foreach ($a as $v)
981 {
982 $v = trim(trim($v), "\r\n");
983 if (!$v)
984 continue;
985 $v1 = $v2 = $v;
986 if (mb_substr($v, 0, 1) == "[" && mb_strpos($v, "]") !== false)
987 {
988 $v1 = mb_substr($v, 1, mb_strpos($v, "]") - 1);
989 $v2 = trim(mb_substr($v, mb_strpos($v, "]") + 1));
990 }
991 $def = "N";
992 if(($fields['DefaultValue'] ?? null) == $v2)
993 {
994 $def = "Y";
995 }
996 $fieldsTemporary["VALUES"][] = array("XML_ID" => $v1, "VALUE" => $v2, "DEF" => $def, "SORT" => $i);
997 $i = $i + 10;
998 }
999 }
1000 }
1001 elseif($fields["type"] == "string")
1002 {
1003 $fieldsTemporary["TYPE"] = "S";
1004
1005 if (!empty($fields["row_count"]))
1006 {
1007 $fieldsTemporary["ROW_COUNT"] = $fields["row_count"];
1008 $fieldsTemporary["COL_COUNT"] = $fields["col_count"];
1009 }
1010 else
1011 {
1012 $fieldsTemporary["ROW_COUNT"] = 1;
1013 $fieldsTemporary["COL_COUNT"] = 30;
1014 }
1015 }
1016 elseif($fields["type"] == "text")
1017 {
1018 $fieldsTemporary["TYPE"] = "S";
1019 if (!empty($fields["row_count"]))
1020 {
1021 $fieldsTemporary["ROW_COUNT"] = $fields["row_count"];
1022 $fieldsTemporary["COL_COUNT"] = $fields["col_count"];
1023 }
1024 else
1025 {
1026 $fieldsTemporary["ROW_COUNT"] = 4;
1027 $fieldsTemporary["COL_COUNT"] = 30;
1028 }
1029 }
1030 elseif($fields["type"] == "int" || $fields["type"] == "double")
1031 {
1032 $fieldsTemporary["TYPE"] = "N";
1033 }
1034 elseif($fields["type"] == "bool")
1035 {
1036 $fieldsTemporary["TYPE"] = "L";
1037 $fieldsTemporary["VALUES"][] = array(
1038 "XML_ID" => 'Y',
1039 "VALUE" => GetMessage("BPVDX_YES"),
1040 "DEF" => "N",
1041 "SORT" => 10
1042 );
1043 $fieldsTemporary["VALUES"][] = array(
1044 "XML_ID" => 'N',
1045 "VALUE" => GetMessage("BPVDX_NO"),
1046 "DEF" => "N",
1047 "SORT" => 20
1048 );
1049 }
1050 else
1051 {
1052 $fieldsTemporary["TYPE"] = $fields["type"];
1053 $fieldsTemporary["USER_TYPE"] = false;
1054 }
1055
1056 $idField = false;
1057 $properties = CIBlockProperty::getList(
1058 array(),
1059 array("IBLOCK_ID" => $fieldsTemporary["IBLOCK_ID"], "CODE" => $fieldsTemporary["CODE"])
1060 );
1061 if(!$properties->fetch())
1062 {
1063 $listObject = new CList($iblockId);
1064 $idField = $listObject->addField($fieldsTemporary);
1065 }
1066
1067 if($idField)
1068 {
1069 global $CACHE_MANAGER;
1070 $CACHE_MANAGER->clearByTag("lists_list_".$iblockId);
1071 if(!empty($fieldsTemporary["CODE"]))
1072 {
1073 $idField = mb_substr($idField, 0, mb_strlen("PROPERTY_")).$fieldsTemporary["CODE"];
1074 }
1075 return $idField;
1076 }
1077 return false;
1078 }
1079
1086 public static function updateDocumentField($documentType, $fields)
1087 {
1088 if(!isset($fields['settings'])) // check field on the activity
1089 return false;
1090
1091 if(!empty($fields["active_type"]))
1092 $fields["type"] = $fields["active_type"];
1093
1094 $iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
1095 if ($iblockId <= 0)
1096 throw new CBPArgumentOutOfRangeException("documentType", $documentType);
1097
1098 $fieldId = false;
1099 if (mb_substr($fields["code"], 0, mb_strlen("PROPERTY_")) == "PROPERTY_")
1100 {
1101 $fields["code"] = mb_substr($fields["code"], mb_strlen("PROPERTY_"));
1102 $propertyObject = CIBlockProperty::getList(
1103 array(),
1104 array("IBLOCK_ID" => $iblockId, "CODE" => $fields["code"])
1105 );
1106 if($property = $propertyObject->fetch())
1107 {
1108 $fieldId = "PROPERTY_".$property["ID"];
1109 }
1110 }
1111 else
1112 {
1113 if(empty($fields["code"]))
1114 {
1115 return false;
1116 }
1117
1118 $fieldId = $fields["code"];
1119 }
1120
1121 if($fieldId)
1122 {
1123 $fieldData = array(
1124 "NAME" => $fields["name"],
1125 "ACTIVE" => "Y",
1126 "SORT" => $fields["sort"] ? $fields["sort"] : 900,
1127 "CODE" => $fields["code"],
1128 'MULTIPLE' => $fields['multiple'] == 'Y' || (string)$fields['multiple'] === '1' ? 'Y' : 'N',
1129 'IS_REQUIRED' => $fields['required'] == 'Y' || (string)$fields['required'] === '1' ? 'Y' : 'N',
1130 "IBLOCK_ID" => $iblockId,
1131 "FILTRABLE" => "Y",
1132 "SETTINGS" => $fields["settings"] ? $fields["settings"] :
1133 array("SHOW_ADD_FORM" => 'Y', "SHOW_EDIT_FORM"=>'Y'),
1134 "DEFAULT_VALUE" => $fields['DefaultValue'] ?? null,
1135 );
1136
1137 if (array_key_exists("additional_type_info", $fields))
1138 $fieldData["LINK_IBLOCK_ID"] = intval($fields["additional_type_info"]);
1139
1140 if(!empty($fields["UserTypeSettings"]))
1141 $fieldData["USER_TYPE_SETTINGS"] = $fields["UserTypeSettings"];
1142
1143 if(mb_strstr($fields["type"], ":") !== false)
1144 {
1145 [$fieldData["TYPE"], $fieldData["USER_TYPE"]] = explode(":", $fields["type"], 2);
1146 if($fields["type"] == "E:EList")
1147 {
1148 $fieldData["LINK_IBLOCK_ID"] = $fields["options"] ?? null;
1149 }
1150 elseif($fields["type"] == "E:ECrm")
1151 {
1152 $fieldData["TYPE"] = "S:ECrm";
1153 }
1154 }
1155 elseif ($fields["type"] == "user")
1156 {
1157 $fieldData["TYPE"] = "S:employee";
1158 $fieldData["USER_TYPE"]= "UserID";
1159 }
1160 elseif ($fields["type"] == "date")
1161 {
1162 $fieldData["TYPE"] = "S:Date";
1163 $fieldData["USER_TYPE"]= "Date";
1164 }
1165 elseif ($fields["type"] == "datetime")
1166 {
1167 $fieldData["TYPE"] = "S:DateTime";
1168 $fieldData["USER_TYPE"]= "DateTime";
1169 }
1170 elseif ($fields["type"] == "file")
1171 {
1172 $fieldData["TYPE"] = "F";
1173 $fieldData["USER_TYPE"]= "";
1174 }
1175 elseif ($fields["type"] == "select")
1176 {
1177 $fieldData["TYPE"] = "L";
1178 $fieldData["USER_TYPE"]= false;
1179
1180 if (is_array($fields["options"]))
1181 {
1182 $i = 10;
1183 foreach ($fields["options"] as $k => $v)
1184 {
1185 $def = "N";
1186 if($fields['DefaultValue'] == $v)
1187 $def = "Y";
1188 $fieldData["VALUES"][] = array("XML_ID" => $k, "VALUE" => $v, "DEF" => $def, "SORT" => $i);
1189 $i = $i + 10;
1190 }
1191 }
1192 elseif (is_string($fields["options"]) && ($fields["options"] <> ''))
1193 {
1194 $a = explode("\n", $fields["options"]);
1195 $i = 10;
1196 foreach ($a as $v)
1197 {
1198 $v = trim(trim($v), "\r\n");
1199 if (!$v)
1200 continue;
1201 $v1 = $v2 = $v;
1202 if (mb_substr($v, 0, 1) == "[" && mb_strpos($v, "]") !== false)
1203 {
1204 $v1 = mb_substr($v, 1, mb_strpos($v, "]") - 1);
1205 $v2 = trim(mb_substr($v, mb_strpos($v, "]") + 1));
1206 }
1207 $def = "N";
1208 if($fields['DefaultValue'] == $v2)
1209 $def = "Y";
1210 $fieldData["VALUES"][] = array("XML_ID" => $v1, "VALUE" => $v2, "DEF" => $def, "SORT" => $i);
1211 $i = $i + 10;
1212 }
1213 }
1214 }
1215 elseif($fields["type"] == "string")
1216 {
1217 $fieldData["TYPE"] = "S";
1218
1219 if($fields["row_count"] && $fields["col_count"])
1220 {
1221 $fieldData["ROW_COUNT"] = $fields["row_count"];
1222 $fieldData["COL_COUNT"] = $fields["col_count"];
1223 }
1224 else
1225 {
1226 $fieldData["ROW_COUNT"] = 1;
1227 $fieldData["COL_COUNT"] = 30;
1228 }
1229 }
1230 elseif($fields["type"] == "text")
1231 {
1232 $fieldData["TYPE"] = "S";
1233 if($fields["row_count"] && $fields["col_count"])
1234 {
1235 $fieldData["ROW_COUNT"] = $fields["row_count"];
1236 $fieldData["COL_COUNT"] = $fields["col_count"];
1237 }
1238 else
1239 {
1240 $fieldData["ROW_COUNT"] = 4;
1241 $fieldData["COL_COUNT"] = 30;
1242 }
1243 }
1244 elseif($fields["type"] == "int" || $fields["type"] == "double")
1245 {
1246 $fieldData["TYPE"] = "N";
1247 }
1248 elseif($fields["type"] == "bool")
1249 {
1250 $fieldData["TYPE"] = "L";
1251 $fieldData["VALUES"][] = array(
1252 "XML_ID" => 'Y',
1253 "VALUE" => GetMessage("BPVDX_YES"),
1254 "DEF" => "N",
1255 "SORT" => 10
1256 );
1257 $fieldData["VALUES"][] = array(
1258 "XML_ID" => 'N',
1259 "VALUE" => GetMessage("BPVDX_NO"),
1260 "DEF" => "N",
1261 "SORT" => 20
1262 );
1263 }
1264 else
1265 {
1266 $fieldData["TYPE"] = $fields["type"];
1267 $fieldData["USER_TYPE"] = false;
1268 }
1269
1270 $list = new CList($iblockId);
1271 $oldFields = $list->getFields();
1272 if(array_key_exists($fieldId, $oldFields))
1273 {
1274 if($oldFields[$fieldId]["TYPE"] != $fieldData["TYPE"])
1275 $fieldData["TYPE"] = $oldFields[$fieldId]["TYPE"];
1276 $fieldId = $list->updateField($fieldId, $fieldData);
1277 }
1278 else
1279 {
1280 $fieldId = $list->addField($fieldData);
1281 }
1282
1283 if($fieldId)
1284 {
1285 global $CACHE_MANAGER;
1286 $CACHE_MANAGER->clearByTag("lists_list_".$iblockId);
1287 return $fieldId;
1288 }
1289 }
1290
1291 return false;
1292 }
1293
1294 public static function updateDocument($documentId, $arFields)
1295 {
1296 $documentId = intval($documentId);
1297 if ($documentId <= 0)
1298 {
1299 throw new CBPArgumentNullException('documentId');
1300 }
1301
1302 CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
1303
1304 $arFieldsPropertyValues = [];
1305
1306 $dbResult = CIBlockElement::GetList(
1307 [],
1308 ['ID' => $documentId, 'SHOW_NEW' => 'Y', 'SHOW_HISTORY' => 'Y'],
1309 );
1310 $arResult = $dbResult->Fetch();
1311 if (!$arResult)
1312 {
1313 throw new CBPArgumentOutOfRangeException('Element is not found');
1314 }
1315
1316 $complexDocumentId = ['lists', get_called_class(), $documentId];
1317 $arDocumentFields = self::GetDocumentFields('iblock_' . $arResult['IBLOCK_ID']);
1318
1319 $arKeys = array_keys($arFields);
1320 foreach ($arKeys as $key)
1321 {
1322 if (!array_key_exists($key, $arDocumentFields))
1323 {
1324 continue;
1325 }
1326
1327 $arFields[$key] =
1328 (is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]))
1329 ? $arFields[$key]
1330 : [$arFields[$key]];
1331 $realKey = (
1332 (mb_substr($key, 0, mb_strlen('PROPERTY_')) == 'PROPERTY_')
1333 ? mb_substr($key, mb_strlen('PROPERTY_'))
1334 : $key
1335 );
1336
1337 if ($arDocumentFields[$key]['Type'] == 'user')
1338 {
1339 $arFields[$key] = \CBPHelper::extractUsers($arFields[$key], $complexDocumentId);
1340 }
1341 elseif ($arDocumentFields[$key]['Type'] == 'select')
1342 {
1343 $arV = [];
1344 $db = CIBlockProperty::GetPropertyEnum(
1345 $realKey,
1346 false,
1347 ['IBLOCK_ID' => $arResult['IBLOCK_ID']]
1348 );
1349 while ($ar = $db->GetNext())
1350 {
1351 $arV[$ar['XML_ID']] = $ar['ID'];
1352 }
1353
1354 $listValue = [];
1355 foreach ($arFields[$key] as &$value)
1356 {
1357 if (is_array($value) && CBPHelper::isAssociativeArray($value))
1358 {
1359 $listXmlId = array_keys($value);
1360 foreach ($listXmlId as $xmlId)
1361 {
1362 $listValue[] = $arV[$xmlId];
1363 }
1364 }
1365 else
1366 {
1367 if (array_key_exists($value, $arV))
1368 {
1369 $value = $arV[$value];
1370 }
1371 }
1372 }
1373 if (!empty($listValue))
1374 {
1375 $arFields[$key] = $listValue;
1376 }
1377 }
1378 elseif ($arDocumentFields[$key]['Type'] == 'file')
1379 {
1380 $files = [];
1381 foreach ($arFields[$key] as $value)
1382 {
1383 if (is_array($value))
1384 {
1385 foreach ($value as $file)
1386 {
1387 $makeFileArray = CFile::MakeFileArray($file);
1388 if ($makeFileArray)
1389 {
1390 $files[] = $makeFileArray;
1391 }
1392 }
1393 }
1394 else
1395 {
1396 $makeFileArray = CFile::MakeFileArray($value);
1397 if ($makeFileArray)
1398 {
1399 $files[] = $makeFileArray;
1400 }
1401 }
1402 }
1403 if ($files)
1404 {
1405 $arFields[$key] = $files;
1406 }
1407 else
1408 {
1409 $arFields[$key] = [['del' => 'Y']];
1410 }
1411 }
1412 elseif ($arDocumentFields[$key]['Type'] == 'S:DiskFile')
1413 {
1414 foreach ($arFields[$key] as &$value)
1415 {
1416 if (!empty($value))
1417 {
1418 $value = 'n' . $value;
1419 }
1420 }
1421 $arFields[$key] = ['VALUE' => $arFields[$key], 'DESCRIPTION' => 'workflow'];
1422 }
1423 elseif ($arDocumentFields[$key]['Type'] == 'S:HTML')
1424 {
1425 foreach ($arFields[$key] as &$value)
1426 {
1427 $value = ['VALUE' => $value];
1428 }
1429 }
1430
1431 unset($value);
1432
1433 if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key]))
1434 {
1435 if (count($arFields[$key]) > 0)
1436 {
1437 $a = array_values($arFields[$key]);
1438 $arFields[$key] = $a[0];
1439 }
1440 else
1441 {
1442 $arFields[$key] = null;
1443 }
1444 }
1445
1446 if (mb_substr($key, 0, mb_strlen("PROPERTY_")) == "PROPERTY_")
1447 {
1448 $realKey = mb_substr($key, mb_strlen("PROPERTY_"));
1449 $arFieldsPropertyValues[$realKey] = (is_array($arFields[$key])
1450 && !CBPHelper::IsAssociativeArray($arFields[$key])) ? $arFields[$key] : [$arFields[$key]];
1451 if (empty($arFieldsPropertyValues[$realKey]))
1452 $arFieldsPropertyValues[$realKey] = [null];
1453 unset($arFields[$key]);
1454 }
1455
1456 if (isset($arResult[$key]) && $arResult[$key] === $arFields[$key])
1457 {
1458 unset($arFields[$key]);
1459 }
1460 }
1461
1462 if (count($arFieldsPropertyValues) > 0)
1463 {
1464 $arFields['PROPERTY_VALUES'] = $arFieldsPropertyValues;
1465 }
1466
1467 $valuesUpdated = false;
1468 $propertyValuesUpdated = false;
1469
1470 $iblockElement = new CIBlockElement();
1471 if (isset($arFields['PROPERTY_VALUES']) && count($arFields['PROPERTY_VALUES']) > 0)
1472 {
1473 $iblockElement->SetPropertyValuesEx($documentId, $arResult['IBLOCK_ID'], $arFields['PROPERTY_VALUES']);
1474 $propertyValuesUpdated = true;
1475 }
1476
1477 unset($arFields['PROPERTY_VALUES']);
1478
1479 if (!empty($arFields))
1480 {
1481 $res = $iblockElement->Update($documentId, $arFields, false, true, true);
1482 if (!$res)
1483 {
1484 throw new CBPArgumentException($iblockElement->LAST_ERROR);
1485 }
1486
1487 $valuesUpdated = true;
1488
1489 if (isset($arFields['BP_PUBLISHED']) && $arFields['BP_PUBLISHED'] === 'Y')
1490 {
1491 self::publishDocument($documentId);
1492 }
1493 elseif (isset($arFields['BP_PUBLISHED']) &&$arFields['BP_PUBLISHED'] === 'N')
1494 {
1495 self::unpublishDocument($documentId);
1496 }
1497 }
1498
1499 if (CModule::includeModule('lists') && ($valuesUpdated || $propertyValuesUpdated))
1500 {
1501 CLists::rebuildSeachableContentForElement($arResult['IBLOCK_ID'], $documentId);
1502 }
1503 }
1504
1505 public static function onTaskChange($documentId, $taskId, $taskData, $status)
1506 {
1507 CListsLiveFeed::setMessageLiveFeed($taskData['USERS'] ?? null, $documentId, $taskData['WORKFLOW_ID'], false);
1509 {
1510 $runtime = CBPRuntime::getRuntime();
1514 $stateService = $runtime->getService('StateService');
1515 $stateService->setStatePermissions(
1516 $taskData['WORKFLOW_ID'],
1517 array('R' => array('user_'.$taskData['USERS'][0])),
1519 );
1520 }
1521 }
1522
1529 public static function onWorkflowStatusChange($documentId, $workflowId, $status, $rootActivity)
1530 {
1532 {
1533 CListsLiveFeed::setMessageLiveFeed(array(), $documentId, $workflowId, true);
1534 }
1535
1537 {
1538 CLists::deleteSocnetLog(array($workflowId));
1539 }
1540
1541 if (
1542 $rootActivity
1544 && !$rootActivity->workflow->isNew()
1545 )
1546 {
1547 $iblockTypeId = 'lists';
1548
1549 $elementQuery = CIBlockElement::getList(
1550 [],
1551 ['ID' => $documentId],
1552 false,
1553 false,
1554 ['IBLOCK_TYPE_ID']
1555 );
1556 if ($element = $elementQuery->fetch())
1557 {
1558 $iblockTypeId = $element['IBLOCK_TYPE_ID'];
1559 }
1560
1561 if (!\CLists::isBpFeatureEnabled($iblockTypeId))
1562 {
1563 throw new \CBPNotSupportedException(Loc::getMessage('LISTS_BIZPROC_RESUME_RESTRICTED'));
1564 }
1565 }
1566 }
1567
1573 public static function getDocumentAdminPage($documentId)
1574 {
1575 $documentId = intval($documentId);
1576 if ($documentId <= 0)
1577 throw new CBPArgumentNullException("documentId");
1578
1579 $elementQuery = CIBlockElement::getList(
1580 array(),
1581 array("ID" => $documentId, "SHOW_NEW"=>"Y", "SHOW_HISTORY" => "Y"),
1582 false,
1583 false,
1584 array("ID", "IBLOCK_ID", "IBLOCK_TYPE_ID", "DETAIL_PAGE_URL")
1585 );
1586 if ($element = $elementQuery->fetch())
1587 {
1588 return COption::getOptionString('lists', 'livefeed_url').'?livefeed=y&list_id='.$element["IBLOCK_ID"].'&element_id='.$documentId;
1589 }
1590
1591 return null;
1592 }
1593
1594 protected static function getRightsTasks()
1595 {
1596 if (self::$cachedTasks === null)
1597 {
1598 $iterator = CTask::getList(
1599 array("LETTER"=>"asc"),
1600 array(
1601 "MODULE_ID" => "iblock",
1602 "BINDING" => "iblock"
1603 )
1604 );
1605
1606 while($ar = $iterator->fetch())
1607 {
1608 if ($ar['LETTER'] === '')
1609 {
1610 $ar['LETTER'] = $ar['ID'];
1611 }
1612 self::$cachedTasks[$ar["LETTER"]] = $ar;
1613 }
1614 }
1615 return self::$cachedTasks;
1616 }
1617
1623 public static function getAllowableOperations($documentType)
1624 {
1625 $iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
1626 if ($iblockId <= 0)
1627 throw new CBPArgumentOutOfRangeException("documentType", $documentType);
1628
1629 if (CIBlock::getArrayByID($iblockId, "RIGHTS_MODE") === "E")
1630 {
1631 $operations = array();
1632 $tasks = self::getRightsTasks();
1633
1634 foreach($tasks as $ar)
1635 {
1636 $key = empty($ar['LETTER']) ? $ar['ID'] : $ar['LETTER'];
1637 $operations[$key] = $ar['TITLE'];
1638 }
1639
1640 return $operations;
1641 }
1642 return parent::getAllowableOperations($documentType);
1643 }
1644
1650 public static function toInternalOperations($documentType, $permissions)
1651 {
1652 $permissions = (array) $permissions;
1653 $tasks = self::getRightsTasks();
1654
1655 $normalized = array();
1656 foreach ($permissions as $key => $value)
1657 {
1658 if (isset($tasks[$key]))
1659 $key = $tasks[$key]['ID'];
1660 $normalized[$key] = $value;
1661 }
1662
1663 return $normalized;
1664 }
1665
1671 public static function toExternalOperations($documentType, $permissions)
1672 {
1673 $permissions = (array) $permissions;
1674 $tasks = self::getRightsTasks();
1675 $letters = array();
1676 foreach ($tasks as $k => $t)
1677 {
1678 $letters[$t['ID']] = $k;
1679 }
1680 unset($tasks);
1681
1682 $normalized = array();
1683 foreach ($permissions as $key => $value)
1684 {
1685 if (isset($letters[$key]))
1686 $key = $letters[$key];
1687 $normalized[$key] = $value;
1688 }
1689
1690 return $normalized;
1691 }
1692
1693 public static function CanUserOperateDocument($operation, $userId, $documentId, $parameters = array())
1694 {
1695 $documentId = trim($documentId);
1696 if ($documentId == '')
1697 return false;
1698
1699 if (self::isAdmin())
1700 {
1701 return true;
1702 }
1703
1704 if (!array_key_exists("IBlockId", $parameters)
1705 && (
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")
1710 )
1711 || !array_key_exists("CreatedBy", $parameters) && !array_key_exists("AllUserGroups", $parameters))
1712 {
1713 if (empty(self::$elements[$documentId]))
1714 {
1715 $elementListQuery = CIBlockElement::getList(
1716 array(),
1717 array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"),
1718 false,
1719 false,
1720 array("ID", "IBLOCK_ID", "CREATED_BY")
1721 );
1722 self::$elements[$documentId] = $elementListQuery->fetch();
1723 }
1724
1725 if (empty(self::$elements[$documentId]))
1726 return false;
1727
1728 $element = self::$elements[$documentId];
1729
1730 $parameters["IBlockId"] = $element["IBLOCK_ID"];
1731 $parameters["CreatedBy"] = $element["CREATED_BY"];
1732 }
1733
1734 if (!array_key_exists("IBlockRightsMode", $parameters))
1735 $parameters["IBlockRightsMode"] = CIBlock::getArrayByID($parameters["IBlockId"], "RIGHTS_MODE");
1736
1737 if ($parameters["IBlockRightsMode"] === "E")
1738 {
1739 if (
1742 )
1743 return CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_read");
1745 return CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_edit");
1747 {
1748 if (CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_edit"))
1749 return true;
1750
1751 if (!array_key_exists("WorkflowId", $parameters))
1752 return false;
1753
1754 if (!CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_read"))
1755 return false;
1756
1757 $userId = intval($userId);
1758 if (!array_key_exists("AllUserGroups", $parameters))
1759 {
1760 if (!array_key_exists("UserGroups", $parameters))
1761 $parameters["UserGroups"] = CUser::getUserGroup($userId);
1762
1763 $parameters["AllUserGroups"] = $parameters["UserGroups"];
1764 if ($userId == $parameters["CreatedBy"])
1765 $parameters["AllUserGroups"][] = "Author";
1766 }
1767
1768 if (!array_key_exists("DocumentStates", $parameters))
1769 {
1771 $parameters["DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(array('lists', get_called_class(), self::generateDocumentType($parameters["IBlockId"])));
1772 else
1773 $parameters["DocumentStates"] = CBPDocument::getDocumentStates(
1774 array('lists', get_called_class(), self::generateDocumentType($parameters["IBlockId"])),
1775 array('lists', get_called_class(), $documentId)
1776 );
1777 }
1778
1779 if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"]))
1780 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
1781 else
1782 return false;
1783
1784 $allowableOperations = CBPDocument::getAllowableOperations(
1785 $userId,
1786 $parameters["AllUserGroups"],
1787 $parameters["DocumentStates"],
1788 true
1789 );
1790
1791 if (!is_array($allowableOperations))
1792 return false;
1793
1794 if (($operation === CBPCanUserOperateOperation::ViewWorkflow) && in_array("read", $allowableOperations)
1795 || ($operation === CBPCanUserOperateOperation::StartWorkflow) && in_array("write", $allowableOperations))
1796 return true;
1797
1798 $chop = ($operation === CBPCanUserOperateOperation::ViewWorkflow) ? "element_read" : "element_edit";
1799
1800 $tasks = self::getRightsTasks();
1801 foreach ($allowableOperations as $op)
1802 {
1803 if (isset($tasks[$op]))
1804 $op = $tasks[$op]['ID'];
1805 $ar = CTask::getOperations($op, true);
1806 if (in_array($chop, $ar))
1807 return true;
1808 }
1809 }
1811 {
1812 return CBPDocument::canUserOperateDocumentType(
1814 $userId,
1815 array('lists', get_called_class(), $parameters['IBlockId']),
1816 $parameters
1817 );
1818 }
1819
1820 return false;
1821 }
1822
1823 if (!array_key_exists("IBlockPermission", $parameters))
1824 {
1825 if (CModule::includeModule('lists'))
1826 $parameters["IBlockPermission"] = CLists::getIBlockPermission($parameters["IBlockId"], $userId);
1827 else
1828 $parameters["IBlockPermission"] = CIBlock::getPermission($parameters["IBlockId"], $userId);
1829 }
1830
1831 if ($parameters["IBlockPermission"] <= "R")
1832 return false;
1833 elseif ($parameters["IBlockPermission"] >= "W")
1834 return true;
1835
1836 $userId = intval($userId);
1837 if (!array_key_exists("AllUserGroups", $parameters))
1838 {
1839 if (!array_key_exists("UserGroups", $parameters))
1840 $parameters["UserGroups"] = CUser::getUserGroup($userId);
1841
1842 $parameters["AllUserGroups"] = $parameters["UserGroups"];
1843 if ($userId == $parameters["CreatedBy"])
1844 $parameters["AllUserGroups"][] = "Author";
1845 }
1846
1847 if (!array_key_exists("DocumentStates", $parameters))
1848 {
1849 $parameters["DocumentStates"] = CBPDocument::getDocumentStates(
1850 array("lists", get_called_class(), "iblock_".$parameters["IBlockId"]),
1851 array('lists', get_called_class(), $documentId)
1852 );
1853 }
1854
1855 if (array_key_exists("WorkflowId", $parameters))
1856 {
1857 if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"]))
1858 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
1859 else
1860 return false;
1861 }
1862
1863 $allowableOperations = CBPDocument::getAllowableOperations(
1864 $userId,
1865 $parameters["AllUserGroups"],
1866 $parameters["DocumentStates"]
1867 );
1868
1869 if (!is_array($allowableOperations))
1870 return false;
1871
1872 $r = false;
1873 switch ($operation)
1874 {
1876 $r = in_array("read", $allowableOperations);
1877 break;
1879 $r = in_array("write", $allowableOperations);
1880 break;
1882 $r = false;
1883 break;
1885 $r = in_array("write", $allowableOperations);
1886 break;
1888 $r = in_array("read", $allowableOperations) || in_array("write", $allowableOperations);
1889 break;
1890 default:
1891 $r = false;
1892 }
1893
1894 return $r;
1895 }
1896
1897 public static function CanUserOperateDocumentType($operation, $userId, $documentType, $parameters = array())
1898 {
1899 $documentType = trim($documentType);
1900 if ($documentType == '')
1901 return false;
1902
1903 if (self::isAdmin())
1904 {
1905 return true;
1906 }
1907
1908 if(is_numeric($documentType))
1909 $parameters["IBlockId"] = intval($documentType);
1910 else
1911 $parameters["IBlockId"] = intval(mb_substr($documentType, mb_strlen("iblock_")));
1912 $parameters['sectionId'] = !empty($parameters['sectionId']) ? (int)$parameters['sectionId'] : 0;
1913
1914 if (!array_key_exists("IBlockRightsMode", $parameters))
1915 $parameters["IBlockRightsMode"] = CIBlock::getArrayByID($parameters["IBlockId"], "RIGHTS_MODE");
1916
1917 if ($parameters["IBlockRightsMode"] === "E")
1918 {
1920 return CIBlockRights::userHasRightTo($parameters["IBlockId"], $parameters["IBlockId"], "iblock_rights_edit");
1922 return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters["sectionId"], "section_element_bind");
1925 {
1927 {
1928 return (
1929 CIBlockRights::userHasRightTo($parameters["IBlockId"], 0, "element_read")
1930 || CIBlockRights::userHasRightTo($parameters["IBlockId"], $parameters["IBlockId"], "iblock_rights_edit")
1931 );
1932 }
1933
1935 return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters['sectionId'], "section_element_bind");
1936
1937
1938 $userId = intval($userId);
1939 if (!array_key_exists("AllUserGroups", $parameters))
1940 {
1941 if (!array_key_exists("UserGroups", $parameters))
1942 $parameters["UserGroups"] = CUser::getUserGroup($userId);
1943
1944 $parameters["AllUserGroups"] = $parameters["UserGroups"];
1945 $parameters["AllUserGroups"][] = "Author";
1946 }
1947
1948 if (!array_key_exists("DocumentStates", $parameters))
1949 {
1951 $parameters["DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(array("lists", get_called_class(), "iblock_".$parameters["IBlockId"]));
1952 else
1953 $parameters["DocumentStates"] = CBPDocument::getDocumentStates(
1954 array("lists", get_called_class(), "iblock_".$parameters["IBlockId"]),
1955 null
1956 );
1957 }
1958
1959 if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"]))
1960 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
1961 else
1962 return false;
1963
1964 $allowableOperations = CBPDocument::getAllowableOperations(
1965 $userId,
1966 $parameters["AllUserGroups"],
1967 $parameters["DocumentStates"],
1968 true
1969 );
1970
1971 if (!is_array($allowableOperations))
1972 return false;
1973
1974 if (($operation === CBPCanUserOperateOperation::ViewWorkflow) && in_array("read", $allowableOperations)
1975 || ($operation === CBPCanUserOperateOperation::StartWorkflow) && in_array("write", $allowableOperations))
1976 return true;
1977
1978 $chop = ($operation === CBPCanUserOperateOperation::ViewWorkflow) ? "element_read" : "section_element_bind";
1979
1980 $tasks = self::getRightsTasks();
1981 foreach ($allowableOperations as $op)
1982 {
1983 if (isset($tasks[$op]))
1984 $op = $tasks[$op]['ID'];
1985 $ar = CTask::getOperations($op, true);
1986 if (in_array($chop, $ar))
1987 return true;
1988 }
1989 }
1990
1991 return false;
1992 }
1993
1994 if (!array_key_exists("IBlockPermission", $parameters))
1995 {
1996 if(CModule::includeModule('lists'))
1997 $parameters["IBlockPermission"] = CLists::getIBlockPermission($parameters["IBlockId"], $userId);
1998 else
1999 $parameters["IBlockPermission"] = CIBlock::getPermission($parameters["IBlockId"], $userId);
2000 }
2001
2002 if ($parameters["IBlockPermission"] <= "R")
2003 return false;
2004 elseif ($parameters["IBlockPermission"] >= "W")
2005 return true;
2006
2007 $userId = intval($userId);
2008 if (!array_key_exists("AllUserGroups", $parameters))
2009 {
2010 if (!array_key_exists("UserGroups", $parameters))
2011 $parameters["UserGroups"] = CUser::getUserGroup($userId);
2012
2013 $parameters["AllUserGroups"] = $parameters["UserGroups"];
2014 $parameters["AllUserGroups"][] = "Author";
2015 }
2016
2017 if (!array_key_exists("DocumentStates", $parameters))
2018 {
2019 $parameters["DocumentStates"] = CBPDocument::getDocumentStates(
2020 array("lists", get_called_class(), "iblock_".$parameters["IBlockId"]),
2021 null
2022 );
2023 }
2024
2025 if (array_key_exists("WorkflowId", $parameters))
2026 {
2027 if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"]))
2028 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
2029 else
2030 return false;
2031 }
2032
2033 $allowableOperations = CBPDocument::getAllowableOperations(
2034 $userId,
2035 $parameters["AllUserGroups"],
2036 $parameters["DocumentStates"]
2037 );
2038
2039 if (!is_array($allowableOperations))
2040 return false;
2041
2042 $r = false;
2043 switch ($operation)
2044 {
2046 $r = in_array("read", $allowableOperations);
2047 break;
2049 $r = in_array("write", $allowableOperations);
2050 break;
2052 $r = in_array("write", $allowableOperations);
2053 break;
2055 $r = in_array("write", $allowableOperations);
2056 break;
2058 $r = false;
2059 break;
2060 default:
2061 $r = false;
2062 }
2063
2064 return $r;
2065 }
2066
2067 protected static function isAdmin()
2068 {
2069 global $USER;
2070 if (is_object($USER) && $USER->IsAuthorized())
2071 {
2072 if ($USER->IsAdmin() || CModule::IncludeModule("bitrix24") && CBitrix24::IsPortalAdmin($USER->GetID()))
2073 {
2074 return true;
2075 }
2076 }
2077
2078 return false;
2079 }
2080
2086 public static function GetAllowableUserGroups($documentType, $withExtended = false): array|bool
2087 {
2088 $documentType = trim($documentType);
2089 if ($documentType === '')
2090 {
2091 return false;
2092 }
2093
2094 $groupsKey = $documentType . ($withExtended ? '@withExtended' : '');
2095
2096 if (isset(self::$cachedGroups[$groupsKey]))
2097 {
2098 return self::$cachedGroups[$groupsKey];
2099 }
2100
2101 $iblockId = (int)mb_substr($documentType, mb_strlen("iblock_"));
2102
2103 $groups = ["Author" => GetMessage("IBD_DOCUMENT_AUTHOR")];
2104
2105 $groupsId = [1];
2106 $extendedGroupsCode = [];
2107 if (CIBlock::getArrayByID($iblockId, "RIGHTS_MODE") === "E")
2108 {
2110 foreach ($rights->getGroups(/*"element_bizproc_start"*/) as $iblockGroupCode)
2111 {
2112 if (preg_match("/^G(\\d+)\$/", $iblockGroupCode, $match))
2113 {
2114 $groupsId[] = $match[1];
2115 }
2116 else
2117 {
2118 $extendedGroupsCode[] = $iblockGroupCode;
2119 }
2120 }
2121 }
2122 else
2123 {
2124 foreach (CIBlock::getGroupPermissions($iblockId) as $groupId => $perm)
2125 {
2126 if ($perm > "R")
2127 {
2128 $groupsId[] = $groupId;
2129 }
2130 }
2131 }
2132
2133 $groupsIterator = CGroup::getListEx(array("NAME" => "ASC"), array("ID" => $groupsId));
2134 while ($group = $groupsIterator->fetch())
2135 {
2136 $groups[$group["ID"]] = $group["NAME"];
2137 }
2138
2139 if ($withExtended && $extendedGroupsCode)
2140 {
2141 foreach ($extendedGroupsCode as $groupCode)
2142 {
2143 $groups['group_'.$groupCode] = CBPHelper::getExtendedGroupName($groupCode);
2144 }
2145 }
2146
2147 self::$cachedGroups[$groupsKey] = $groups;
2148
2149 return $groups;
2150 }
2151
2152 public static function SetPermissions($documentId, $workflowId, $permissions, $rewrite = true)
2153 {
2154 $permissions = self::toInternalOperations(null, $permissions);
2155 parent::setPermissions($documentId, $workflowId, $permissions, $rewrite);
2156 }
2157
2158 public static function GetFieldInputControl($documentType, $fieldType, $fieldName, $fieldValue, $allowSelection = false, $publicMode = false)
2159 {
2160 $iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
2161 if ($iblockId <= 0)
2162 throw new CBPArgumentOutOfRangeException("documentType", $documentType);
2163
2164 static $documentFieldTypes = array();
2165 if (!array_key_exists($documentType, $documentFieldTypes))
2166 $documentFieldTypes[$documentType] = self::getDocumentFieldTypes($documentType);
2167
2168 $fieldType["BaseType"] = "string";
2169 $fieldType["Complex"] = false;
2170 if (array_key_exists($fieldType["Type"], $documentFieldTypes[$documentType]))
2171 {
2172 $fieldType["BaseType"] = $documentFieldTypes[$documentType][$fieldType["Type"]]["BaseType"];
2173 $fieldType["Complex"] = $documentFieldTypes[$documentType][$fieldType["Type"]]["Complex"];
2174 }
2175
2176 if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::isAssociativeArray($fieldValue))
2177 $fieldValue = array($fieldValue);
2178
2179 $customMethodName = "";
2180 $customMethodNameMulty = "";
2181 if (mb_strpos($fieldType["Type"], ":") !== false)
2182 {
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"];
2188 }
2189
2190 ob_start();
2191
2192 if ($fieldType["Type"] == "select")
2193 {
2194 $fieldValueTmp = $fieldValue;
2195 ?>
2196 <select id="id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>" name="<?= htmlspecialcharsbx($fieldName["Field"]).($fieldType["Multiple"] ? "[]" : "") ?>"<?= ($fieldType["Multiple"] ? ' size="5" multiple' : '') ?>>
2197 <?
2198 if (!$fieldType["Required"])
2199 echo '<option value="">['.GetMessage("BPCGHLP_NOT_SET").']</option>';
2200 foreach ($fieldType["Options"] as $k => $v)
2201 {
2202 if (is_array($v) && count($v) == 2)
2203 {
2204 $v1 = array_values($v);
2205 $k = $v1[0];
2206 $v = $v1[1];
2207 }
2208
2209 $ind = array_search($k, $fieldValueTmp);
2210 echo '<option value="'.htmlspecialcharsbx($k).'"'.($ind !== false ? ' selected' : '').'>'.htmlspecialcharsbx($v).'</option>';
2211 if ($ind !== false)
2212 unset($fieldValueTmp[$ind]);
2213 }
2214 ?>
2215 </select>
2216 <?
2217 if ($allowSelection)
2218 {
2219 ?>
2220 <br /><input type="text" id="id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text" name="<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text" value="<?
2221 if (count($fieldValueTmp) > 0)
2222 {
2223 $a = array_values($fieldValueTmp);
2224 echo htmlspecialcharsbx($a[0]);
2225 }
2226 ?>">
2227 <input type="button" value="..." onclick="BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text', 'select');">
2228 <?
2229 }
2230 }
2231 elseif ($fieldType["Type"] == "user")
2232 {
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');"><?
2235 }
2236 elseif ((mb_strpos($fieldType["Type"], ":") !== false)
2237 && $fieldType["Multiple"]
2238 && (
2239 is_array($customMethodNameMulty) && count($customMethodNameMulty) > 0
2240 || !is_array($customMethodNameMulty) && $customMethodNameMulty <> ''
2241 )
2242 )
2243 {
2244 if (!is_array($fieldValue))
2245 $fieldValue = array();
2246
2247 if ($allowSelection)
2248 {
2249 $fieldValueTmp1 = array();
2250 $fieldValueTmp2 = array();
2251 foreach ($fieldValue as $v)
2252 {
2253 $vTrim = trim($v);
2254 if (\CBPDocument::IsExpression($vTrim))
2255 $fieldValueTmp1[] = $vTrim;
2256 else
2257 $fieldValueTmp2[] = $v;
2258 }
2259 }
2260 else
2261 {
2262 $fieldValueTmp1 = array();
2263 $fieldValueTmp2 = $fieldValue;
2264 }
2265
2266 if (($fieldType["Type"] == "S:employee") && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y")
2267 $fieldValueTmp2 = CBPHelper::stripUserPrefix($fieldValueTmp2);
2268
2269 foreach ($fieldValueTmp2 as &$fld)
2270 if (!isset($fld['VALUE']))
2271 $fld = array("VALUE" => $fld);
2272
2273 if ($fieldType["Type"] == "E:EList")
2274 {
2275 static $fl = true;
2276 if ($fl)
2277 {
2278 if (!empty($_SERVER['HTTP_BX_AJAX']))
2279 $GLOBALS["APPLICATION"]->showAjaxHead();
2280 $GLOBALS["APPLICATION"]->addHeadScript('/bitrix/js/iblock/iblock_edit.js');
2281 }
2282 $fl = false;
2283 }
2284 echo call_user_func_array(
2285 $customMethodNameMulty,
2286 array(
2287 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
2288 $fieldValueTmp2,
2289 array(
2290 "FORM_NAME" => $fieldName["Form"],
2291 "VALUE" => htmlspecialcharsbx($fieldName["Field"])
2292 ),
2293 true
2294 )
2295 );
2296
2297 if ($allowSelection)
2298 {
2299 ?>
2300 <br /><input type="text" id="id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text" name="<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text" value="<?
2301 if (count($fieldValueTmp1) > 0)
2302 {
2303 $a = array_values($fieldValueTmp1);
2304 echo htmlspecialcharsbx($a[0]);
2305 }
2306 ?>">
2307 <input type="button" value="..." onclick="BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text', 'user', '<?= $fieldType["Type"] == 'S:employee'? 'employee' : '' ?>');">
2308 <?
2309 }
2310 }
2311 else
2312 {
2313 if (!array_key_exists("CBPVirtualDocumentCloneRowPrinted", $GLOBALS) && $fieldType["Multiple"])
2314 {
2315 $GLOBALS["CBPVirtualDocumentCloneRowPrinted"] = 1;
2316 ?>
2317 <script>
2318 function CBPVirtualDocumentCloneRow(tableID)
2319 {
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;
2325 var p = 0;
2326 while (true)
2327 {
2328 var s = sHTML.indexOf('[n', p);
2329 if (s < 0)
2330 break;
2331 var e = sHTML.indexOf(']', s);
2332 if (e < 0)
2333 break;
2334 var n = parseInt(sHTML.substr(s + 2, e - s));
2335 sHTML = sHTML.substr(0, s) + '[n' + (++n) + ']' + sHTML.substr(e + 1);
2336 p = s + 1;
2337 }
2338 var p = 0;
2339 while (true)
2340 {
2341 var s = sHTML.indexOf('__n', p);
2342 if (s < 0)
2343 break;
2344 var e = sHTML.indexOf('_', s + 2);
2345 if (e < 0)
2346 break;
2347 var n = parseInt(sHTML.substr(s + 3, e - s));
2348 sHTML = sHTML.substr(0, s) + '__n' + (++n) + '_' + sHTML.substr(e + 1);
2349 p = e + 1;
2350 }
2351 oCell.innerHTML = sHTML;
2352 var patt = new RegExp('<' + 'script' + '>[^\000]*?<' + '\/' + 'script' + '>', 'ig');
2353 var code = sHTML.match(patt);
2354 if (code)
2355 {
2356 for (var i = 0; i < code.length; i++)
2357 {
2358 if (code[i] != '')
2359 {
2360 var s = code[i].substring(8, code[i].length - 9);
2361 jsUtils.EvalGlobal(s);
2362 }
2363 }
2364 }
2365 }
2366 function createAdditionalHtmlEditor(tableId)
2367 {
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(
2374 {
2375 'id':idEditor,
2376 'inputName':inputNameEditor,
2377 'content':'',
2378 'useFileDialogs':false,
2379 'width':'100%',
2380 'height':'200',
2381 'allowPhp':false,
2382 'limitPhpAccess':false,
2383 'templates':[],
2384 'templateId':'',
2385 'templateParams':[],
2386 'componentFilter':'',
2387 'snippets':[],
2388 'placeholder':'Text here...',
2389 'actionUrl':'/bitrix/tools/html_editor_action.php',
2390 'cssIframePath':'/bitrix/js/fileman/html_editor/iframe-style.css?1412693817',
2391 'bodyClass':'',
2392 'bodyId':'',
2393 'spellcheck_path':'/bitrix/js/fileman/html_editor/html-spell.js?v=1412693817',
2394 'usePspell':'N',
2395 'useCustomSpell':'Y',
2396 'bbCode':false,
2397 'askBeforeUnloadPage':true,
2398 'settingsKey':'user_settings_1',
2399 'showComponents':true,
2400 'showSnippets':true,
2401 'view':'wysiwyg',
2402 'splitVertical':false,
2403 'splitRatio':'1',
2404 'taskbarShown':false,
2405 'taskbarWidth':'250',
2406 'lastSpecialchars':false,
2407 'cleanEmptySpans':true,
2408 'lazyLoad':false,
2409 'showTaskbars':false,
2410 'showNodeNavi':false,
2411 'controlsMap':[
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'}],
2433 'autoResize':true,
2434 'autoResizeOffset':'40',
2435 'minBodyWidth':'350',
2436 'normalBodyWidth':'555'
2437 });
2438 var htmlEditor = BX.findChildrenByClassName(BX(tableId), 'bx-html-editor');
2439 for(var k in htmlEditor)
2440 {
2441 var editorId = htmlEditor[k].getAttribute('id');
2442 var frameArray = BX.findChildrenByClassName(BX(editorId), 'bx-editor-iframe');
2443 if(frameArray.length > 1)
2444 {
2445 for(var i = 0; i < frameArray.length - 1; i++)
2446 {
2447 frameArray[i].parentNode.removeChild(frameArray[i]);
2448 }
2449 }
2450
2451 }
2452 }
2453 </script>
2454 <?
2455 }
2456
2457 if ($fieldType["Multiple"])
2458 echo '<table width="100%" border="0" cellpadding="2" cellspacing="2" id="CBPVirtualDocument_'.htmlspecialcharsbx($fieldName["Field"]).'_Table">';
2459
2460 $fieldValueTmp = $fieldValue;
2461
2462 if (sizeof($fieldValue) == 0)
2463 $fieldValue[] = null;
2464
2465 $ind = -1;
2466 foreach ($fieldValue as $key => $value)
2467 {
2468 $ind++;
2469 $fieldNameId = 'id_'.htmlspecialcharsbx($fieldName["Field"]).'__n'.$ind.'_';
2470 $fieldNameName = htmlspecialcharsbx($fieldName["Field"]).($fieldType["Multiple"] ? "[n".$ind."]" : "");
2471
2472 if ($fieldType["Multiple"])
2473 echo '<tr><td>';
2474
2475 if (is_array($customMethodName) && count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <> '')
2476 {
2477 if($fieldType["Type"] == "S:HTML")
2478 {
2479 if (Loader::includeModule("fileman"))
2480 {
2481 $editor = new CHTMLEditor;
2482 $res = array_merge(
2483 array(
2484 'useFileDialogs' => false,
2485 'height' => 200,
2486 'useFileDialogs' => false,
2487 'minBodyWidth' => 350,
2488 'normalBodyWidth' => 555,
2489 'bAllowPhp' => false,
2490 'limitPhpAccess' => false,
2491 'showTaskbars' => false,
2492 'showNodeNavi' => false,
2493 'askBeforeUnloadPage' => true,
2494 'bbCode' => false,
2495 'siteId' => SITE_ID,
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)
2525 )
2526 ),
2527 array(
2528 'name' => $fieldNameName,
2529 'inputName' => $fieldNameName,
2530 'id' => $fieldNameId,
2531 'width' => '100%',
2532 'content' => htmlspecialcharsBack($value),
2533 )
2534 );
2535 $editor->show($res);
2536 }
2537 else
2538 {
2539 ?><textarea rows="5" cols="40" id="<?= $fieldNameId ?>" name="<?= $fieldNameName ?>"><?= htmlspecialcharsbx($value) ?></textarea><?
2540 }
2541 }
2542 else
2543 {
2544 $value1 = $value;
2545 if ($allowSelection && \CBPDocument::IsExpression(trim($value1)))
2546 $value1 = null;
2547 else
2548 unset($fieldValueTmp[$key]);
2549
2550 if (($fieldType["Type"] == "S:employee") && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y")
2551 $value1 = CBPHelper::stripUserPrefix($value1);
2552
2553 echo call_user_func_array(
2554 $customMethodName,
2555 array(
2556 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
2557 array("VALUE" => $value1),
2558 array(
2559 "FORM_NAME" => $fieldName["Form"],
2560 "VALUE" => $fieldNameName
2561 ),
2562 true
2563 )
2564 );
2565 }
2566 }
2567 else
2568 {
2569 switch ($fieldType["Type"])
2570 {
2571 case "int":
2572 case "double":
2573 unset($fieldValueTmp[$key]);
2574 ?><input type="text" size="10" id="<?= $fieldNameId ?>" name="<?= $fieldNameName ?>" value="<?= htmlspecialcharsbx($value) ?>"><?
2575 break;
2576 case "file":
2577 if ($publicMode)
2578 {
2579 //unset($fieldValueTmp[$key]);
2580 ?><input type="file" id="<?= $fieldNameId ?>" name="<?= $fieldNameName ?>"><?
2581 }
2582 break;
2583 case "bool":
2584 if (in_array($value, array("Y", "N")))
2585 unset($fieldValueTmp[$key]);
2586 ?>
2587 <select id="<?= $fieldNameId ?>" name="<?= $fieldNameName ?>">
2588 <?
2589 if (!$fieldType["Required"])
2590 echo '<option value="">['.GetMessage("BPCGHLP_NOT_SET").']</option>';
2591 ?>
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>
2594 </select>
2595 <?
2596 break;
2597 case "text":
2598 unset($fieldValueTmp[$key]);
2599 ?><textarea rows="5" cols="40" id="<?= $fieldNameId ?>" name="<?= $fieldNameName ?>"><?= htmlspecialcharsbx($value) ?></textarea><?
2600 break;
2601 case "date":
2602 case "datetime":
2603 if (defined("ADMIN_SECTION") && ADMIN_SECTION)
2604 {
2605 $v = "";
2606 if (!\CBPDocument::IsExpression(trim($value)))
2607 {
2608 $v = $value;
2609 unset($fieldValueTmp[$key]);
2610 }
2611 require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/interface/init_admin.php");
2612 echo CAdminCalendar::calendarDate($fieldNameName, $v, 19, ($fieldType["Type"] != "date"));
2613 }
2614 else
2615 {
2616 $value1 = $value;
2617 if ($allowSelection && \CBPDocument::IsExpression(trim($value1)))
2618 $value1 = null;
2619 else
2620 unset($fieldValueTmp[$key]);
2621
2622 if($fieldType["Type"] == "date")
2623 $type = "Date";
2624 else
2625 $type = "DateTime";
2626 $ar = CIBlockProperty::getUserType($type);
2627 echo call_user_func_array(
2628 $ar["GetPublicEditHTML"],
2629 array(
2630 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
2631 array("VALUE" => $value1),
2632 array(
2633 "FORM_NAME" => $fieldName["Form"],
2634 "VALUE" => $fieldNameName
2635 ),
2636 true
2637 )
2638 );
2639 }
2640
2641 break;
2642 default:
2643 unset($fieldValueTmp[$key]);
2644 ?><input type="text" size="40" id="<?= $fieldNameId ?>" name="<?= $fieldNameName ?>" value="<?= htmlspecialcharsbx($value) ?>"><?
2645 }
2646 }
2647
2648 if ($allowSelection)
2649 {
2650 if (!in_array($fieldType["Type"], array("file", "bool", "date", "datetime")) && (is_array($customMethodName) && count($customMethodName) <= 0 || !is_array($customMethodName) && $customMethodName == ''))
2651 {
2652 ?><input type="button" value="..." onclick="BPAShowSelector('<?= $fieldNameId ?>', '<?= htmlspecialcharsbx($fieldType["BaseType"]) ?>');"><?
2653 }
2654 }
2655
2656 if ($fieldType["Multiple"])
2657 echo '</td></tr>';
2658 }
2659
2660 if ($fieldType["Multiple"])
2661 echo "</table>";
2662
2663 if ($fieldType["Multiple"] && $fieldType["Type"] != "S:HTML" && (($fieldType["Type"] != "file") || $publicMode))
2664 {
2665 echo '<input type="button" value="'.GetMessage("BPCGHLP_ADD").'" onclick="CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$fieldName["Field"].'_Table\')"/><br />';
2666 }
2667 elseif($fieldType["Multiple"] && $fieldType["Type"] == "S:HTML")
2668 {
2669 $functionOnclick = 'CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$fieldName["Field"].'_Table\');createAdditionalHtmlEditor(\'CBPVirtualDocument_'.$fieldName["Field"].'_Table\');';
2670 echo '<input type="button" value="'.GetMessage("BPCGHLP_ADD").'" onclick="'.$functionOnclick.'"/><br />';
2671 }
2672
2673 if ($allowSelection)
2674 {
2675 if (in_array($fieldType["Type"], array("file", "bool", "date", "datetime")) || (is_array($customMethodName) && count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <> ''))
2676 {
2677 ?>
2678 <input type="text" id="id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text" name="<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text" value="<?
2679 if (count($fieldValueTmp) > 0)
2680 {
2681 $a = array_values($fieldValueTmp);
2682 echo htmlspecialcharsbx($a[0]);
2683 }
2684 ?>">
2685 <input type="button" value="..." onclick="BPAShowSelector('id_<?= htmlspecialcharsbx($fieldName["Field"]) ?>_text', '<?= htmlspecialcharsbx($fieldType["BaseType"]) ?>', '<?= $fieldType["Type"] == 'S:employee'? 'employee' : '' ?>');">
2686 <?
2687 }
2688 }
2689 }
2690
2691 $s = ob_get_contents();
2692 ob_end_clean();
2693
2694 return $s;
2695 }
2696
2697 public static function GetFieldInputValue($documentType, $fieldType, $fieldName, $request, &$errors)
2698 {
2699 $iblockId = intval(mb_substr($documentType, mb_strlen("iblock_")));
2700 if ($iblockId <= 0)
2701 throw new CBPArgumentOutOfRangeException("documentType", $documentType);
2702
2703 $result = array();
2704
2705 if ($fieldType["Type"] == "user")
2706 {
2707 $value = $request[$fieldName["Field"]];
2708 if ($value <> '')
2709 {
2710 $result = CBPHelper::usersStringToArray($value, array("lists", get_called_class(), $documentType), $errors);
2711 if (count($errors) > 0)
2712 {
2713 foreach ($errors as $e)
2714 $errors[] = $e;
2715 }
2716 }
2717 else
2718 $result = null;
2719 }
2720 elseif (array_key_exists($fieldName["Field"], $request) || array_key_exists($fieldName["Field"]."_text", $request))
2721 {
2722 $valueArray = array();
2723 if (array_key_exists($fieldName["Field"], $request))
2724 {
2725 $valueArray = $request[$fieldName["Field"]];
2726 if (!is_array($valueArray) || is_array($valueArray) && CBPHelper::isAssociativeArray($valueArray))
2727 $valueArray = array($valueArray);
2728 }
2729 if (array_key_exists($fieldName["Field"]."_text", $request))
2730 $valueArray[] = $request[$fieldName["Field"]."_text"];
2731
2732 foreach ($valueArray as $value)
2733 {
2734 if (is_array($value) || !is_array($value) && !\CBPDocument::IsExpression(trim($value)))
2735 {
2736 if ($fieldType["Type"] == "int")
2737 {
2738 if ($value <> '')
2739 {
2740 $value = str_replace(" ", "", str_replace(",", ".", $value));
2741 if (is_numeric($value))
2742 {
2743 $value = doubleval($value);
2744 }
2745 else
2746 {
2747 $value = null;
2748 $errors[] = array(
2749 "code" => "ErrorValue",
2750 "message" => GetMessage("LISTS_BIZPROC_INVALID_INT"),
2751 "parameter" => $fieldName["Field"],
2752 );
2753 }
2754 }
2755 else
2756 {
2757 $value = null;
2758 }
2759 }
2760 elseif ($fieldType["Type"] == "double")
2761 {
2762 if ($value <> '')
2763 {
2764 $value = str_replace(" ", "", str_replace(",", ".", $value));
2765 if (is_numeric($value))
2766 {
2767 $value = doubleval($value);
2768 }
2769 else
2770 {
2771 $value = null;
2772 $errors[] = array(
2773 "code" => "ErrorValue",
2774 "message" => GetMessage("LISTS_BIZPROC_INVALID_INT"),
2775 "parameter" => $fieldName["Field"],
2776 );
2777 }
2778 }
2779 else
2780 {
2781 $value = null;
2782 }
2783 }
2784 elseif ($fieldType["Type"] == "select")
2785 {
2786 if (!is_array($fieldType["Options"]) || count($fieldType["Options"]) <= 0 || $value == '')
2787 {
2788 $value = null;
2789 }
2790 else
2791 {
2792 $ar = array_values($fieldType["Options"]);
2793 if (is_array($ar[0]))
2794 {
2795 $b = false;
2796 foreach ($ar as $a)
2797 {
2798 if ($a[0] == $value)
2799 {
2800 $b = true;
2801 break;
2802 }
2803 }
2804 if (!$b)
2805 {
2806 $value = null;
2807 $errors[] = array(
2808 "code" => "ErrorValue",
2809 "message" => GetMessage("LISTS_BIZPROC_INVALID_SELECT"),
2810 "parameter" => $fieldName["Field"],
2811 );
2812 }
2813 }
2814 else
2815 {
2816 if (!array_key_exists($value, $fieldType["Options"]))
2817 {
2818 $value = null;
2819 $errors[] = array(
2820 "code" => "ErrorValue",
2821 "message" => GetMessage("LISTS_BIZPROC_INVALID_SELECT"),
2822 "parameter" => $fieldName["Field"],
2823 );
2824 }
2825 }
2826 }
2827 }
2828 elseif ($fieldType["Type"] == "bool")
2829 {
2830 if ($value !== "Y" && $value !== "N")
2831 {
2832 if ($value === true)
2833 {
2834 $value = "Y";
2835 }
2836 elseif ($value === false)
2837 {
2838 $value = "N";
2839 }
2840 elseif ($value <> '')
2841 {
2842 $value = mb_strtolower($value);
2843 if (in_array($value, array("y", "yes", "true", "1")))
2844 {
2845 $value = "Y";
2846 }
2847 elseif (in_array($value, array("n", "no", "false", "0")))
2848 {
2849 $value = "N";
2850 }
2851 else
2852 {
2853 $value = null;
2854 $errors[] = array(
2855 "code" => "ErrorValue",
2856 "message" => GetMessage("BPCGWTL_INVALID45"),
2857 "parameter" => $fieldName["Field"],
2858 );
2859 }
2860 }
2861 else
2862 {
2863 $value = null;
2864 }
2865 }
2866 }
2867 elseif ($fieldType["Type"] == "file")
2868 {
2869 if (is_array($value) && array_key_exists("name", $value) && $value["name"] <> '')
2870 {
2871 if (!array_key_exists("MODULE_ID", $value) || $value["MODULE_ID"] == '')
2872 $value["MODULE_ID"] = "bizproc";
2873
2874 $value = CFile::saveFile($value, "bizproc_wf", true, true);
2875 if (!$value)
2876 {
2877 $value = null;
2878 $errors[] = array(
2879 "code" => "ErrorValue",
2880 "message" => GetMessage("BPCGWTL_INVALID915"),
2881 "parameter" => $fieldName["Field"],
2882 );
2883 }
2884 }
2885 else
2886 {
2887 $value = null;
2888 }
2889 }
2890 elseif ($fieldType["Type"] == "date")
2891 {
2892 if ($value <> '')
2893 {
2894 if(!CheckDateTime($value, FORMAT_DATE))
2895 {
2896 $value = null;
2897 $errors[] = array(
2898 "code" => "ErrorValue",
2899 "message" => GetMessage("LISTS_BIZPROC_INVALID_DATE"),
2900 "parameter" => $fieldName["Field"],
2901 );
2902 }
2903 }
2904 else
2905 {
2906 $value = null;
2907 }
2908
2909 }
2910 elseif ($fieldType["Type"] == "datetime")
2911 {
2912 if ($value <> '')
2913 {
2914 $valueTemporary = array();
2915 $valueTemporary["VALUE"] = $value;
2916 $result = CIBlockPropertyDateTime::checkFields('', $valueTemporary);
2917 if (!empty($result))
2918 {
2919 $message = '';
2920 foreach ($result as $error)
2921 $message .= $error;
2922
2923 $value = null;
2924 $errors[] = array(
2925 "code" => "ErrorValue",
2926 "message" => $message,
2927 "parameter" => $fieldName["Field"],
2928 );
2929 }
2930 }
2931 else
2932 {
2933 $value = null;
2934 }
2935 }
2936 elseif (mb_strpos($fieldType["Type"], ":") !== false && $fieldType["Type"] != "S:HTML")
2937 {
2938 $customType = CIBlockProperty::getUserType(mb_substr($fieldType["Type"], 2));
2939 if (array_key_exists("GetLength", $customType))
2940 {
2941 if (call_user_func_array(
2942 $customType["GetLength"],
2943 array(
2944 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
2945 array("VALUE" => $value)
2946 )
2947 ) <= 0)
2948 {
2949 $value = null;
2950 }
2951 }
2952
2953 if (($value != null) && array_key_exists("CheckFields", $customType))
2954 {
2955 $errorsTemporary = call_user_func_array(
2956 $customType["CheckFields"],
2957 array(
2958 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
2959 array("VALUE" => $value)
2960 )
2961 );
2962 if (count($errorsTemporary) > 0)
2963 {
2964 $value = null;
2965 foreach ($errorsTemporary as $e)
2966 $errors[] = array(
2967 "code" => "ErrorValue",
2968 "message" => $e,
2969 "parameter" => $fieldName["Field"],
2970 );
2971 }
2972 }
2973 elseif (!array_key_exists("GetLength", $customType) && $value === '')
2974 $value = null;
2975
2976 if (
2977 $value !== null &&
2978 $fieldType["Type"] == "S:employee" &&
2979 COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y"
2980 )
2981 {
2982 $value = "user_".$value;
2983 }
2984 }
2985 else
2986 {
2987 if (!is_array($value) && $value == '')
2988 $value = null;
2989 }
2990 }
2991
2992 if ($value !== null)
2993 $result[] = $value;
2994 }
2995 }
2996
2997 if (!$fieldType["Multiple"])
2998 {
2999 if (is_array($result) && count($result) > 0)
3000 $result = $result[0];
3001 else
3002 $result = null;
3003 }
3004
3005 return $result;
3006 }
3007
3008 public static function GetFieldInputValuePrintable($documentType, $fieldType, $fieldValue)
3009 {
3010 $result = $fieldValue;
3011
3012 switch ($fieldType['Type'])
3013 {
3014 case "user":
3015 if (!is_array($fieldValue))
3016 $fieldValue = array($fieldValue);
3017
3018 $result = CBPHelper::usersArrayToString($fieldValue, null, array("lists", get_called_class(), $documentType));
3019 break;
3020
3021 case "bool":
3022 if (is_array($fieldValue))
3023 {
3024 $result = array();
3025 foreach ($fieldValue as $r)
3026 $result[] = ((mb_strtoupper($r) != "N" && !empty($r)) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"));
3027 }
3028 else
3029 {
3030 $result = ((mb_strtoupper($fieldValue) != "N" && !empty($fieldValue)) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"));
3031 }
3032 break;
3033
3034 case "file":
3035 if (is_array($fieldValue))
3036 {
3037 $result = array();
3038 foreach ($fieldValue as $r)
3039 {
3040 $r = intval($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]";
3044 }
3045 }
3046 else
3047 {
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]";
3052 }
3053 break;
3054
3055 case "select":
3056 if (is_array($fieldType["Options"]))
3057 {
3058 if (is_array($fieldValue))
3059 {
3060 $result = array();
3061 foreach ($fieldValue as $r)
3062 {
3063 if (array_key_exists($r, $fieldType["Options"]))
3064 $result[] = $fieldType["Options"][$r];
3065 }
3066 }
3067 else
3068 {
3069 if (array_key_exists($fieldValue, $fieldType["Options"]))
3070 $result = $fieldType["Options"][$fieldValue];
3071 }
3072 }
3073 break;
3074 }
3075
3076 if (mb_strpos($fieldType['Type'], ":") !== false)
3077 {
3078 if ($fieldType["Type"] == "S:employee")
3079 $fieldValue = CBPHelper::stripUserPrefix($fieldValue);
3080
3081 $customType = CIBlockProperty::getUserType(mb_substr($fieldType['Type'], 2));
3082 if (array_key_exists("GetPublicViewHTML", $customType))
3083 {
3084 if (is_array($fieldValue) && !CBPHelper::isAssociativeArray($fieldValue))
3085 {
3086 $result = array();
3087 foreach ($fieldValue as $value)
3088 {
3089 $r = call_user_func_array(
3090 $customType["GetPublicViewHTML"],
3091 array(
3092 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
3093 array("VALUE" => $value),
3094 ""
3095 )
3096 );
3097
3098 $result[] = HTMLToTxt($r);
3099 }
3100 }
3101 else
3102 {
3103 $result = call_user_func_array(
3104 $customType["GetPublicViewHTML"],
3105 array(
3106 array("LINK_IBLOCK_ID" => $fieldType["Options"]),
3107 array("VALUE" => $fieldValue),
3108 ""
3109 )
3110 );
3111
3113 }
3114 }
3115 }
3116
3117 return $result;
3118 }
3119
3120 public static function UnlockDocument($documentId, $workflowId)
3121 {
3122 global $DB;
3123
3124 $strSql = "
3125 SELECT * FROM b_iblock_element_lock
3126 WHERE IBLOCK_ELEMENT_ID = ".intval($documentId)."
3127 ";
3128 $query = $DB->query($strSql);
3129 if($query->fetch())
3130 {
3131 $strSql = "
3132 DELETE FROM b_iblock_element_lock
3133 WHERE IBLOCK_ELEMENT_ID = ".intval($documentId)."
3134 AND (LOCKED_BY = '".$DB->forSQL($workflowId, 32)."' OR '".$DB->forSQL($workflowId, 32)."' = '')
3135 ";
3136 $query = $DB->query($strSql);
3137 $result = $query->affectedRowsCount();
3138 }
3139 else
3140 {//Success unlock when there is no locks at all
3141 $result = 1;
3142 }
3143
3144 if ($result > 0)
3145 {
3146 foreach (GetModuleEvents("iblock", "CIBlockDocument_OnUnlockDocument", true) as $event)
3147 {
3148 ExecuteModuleEventEx($event, array(array("lists", get_called_class(), $documentId)));
3149 }
3150 }
3151
3152 return $result > 0;
3153 }
3154
3160 public static function PublishDocument($documentId)
3161 {
3162 global $DB;
3163 $ID = intval($documentId);
3164
3165 $elementQuery = CIBlockElement::getList(array(), array("ID"=>$ID, "SHOW_HISTORY"=>"Y"), false, false,
3166 array(
3167 "ID",
3168 "TIMESTAMP_X",
3169 "MODIFIED_BY",
3170 "DATE_CREATE",
3171 "CREATED_BY",
3172 "IBLOCK_ID",
3173 "ACTIVE",
3174 "ACTIVE_FROM",
3175 "ACTIVE_TO",
3176 "SORT",
3177 "NAME",
3178 "PREVIEW_PICTURE",
3179 "PREVIEW_TEXT",
3180 "PREVIEW_TEXT_TYPE",
3181 "DETAIL_PICTURE",
3182 "DETAIL_TEXT",
3183 "DETAIL_TEXT_TYPE",
3184 "WF_STATUS_ID",
3185 "WF_PARENT_ELEMENT_ID",
3186 "WF_NEW",
3187 "WF_COMMENTS",
3188 "IN_SECTIONS",
3189 "CODE",
3190 "TAGS",
3191 "XML_ID",
3192 "TMP_ID",
3193 )
3194 );
3195 if($element = $elementQuery->fetch())
3196 {
3197 $parentId = intval($element["WF_PARENT_ELEMENT_ID"]);
3198 if($parentId)
3199 {
3200 $elementObject = new CIBlockElement;
3201 $element["WF_PARENT_ELEMENT_ID"] = false;
3202
3203 if($element["PREVIEW_PICTURE"])
3204 $element["PREVIEW_PICTURE"] = CFile::makeFileArray($element["PREVIEW_PICTURE"]);
3205 else
3206 $element["PREVIEW_PICTURE"] = array("tmp_name" => "", "del" => "Y");
3207
3208 if($element["DETAIL_PICTURE"])
3209 $element["DETAIL_PICTURE"] = CFile::makeFileArray($element["DETAIL_PICTURE"]);
3210 else
3211 $element["DETAIL_PICTURE"] = array("tmp_name" => "", "del" => "Y");
3212
3213 $element["IBLOCK_SECTION"] = array();
3214 if($element["IN_SECTIONS"] == "Y")
3215 {
3216 $sectionsQuery = CIBlockElement::getElementGroups($element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID'));
3217 while($section = $sectionsQuery->fetch())
3218 $element["IBLOCK_SECTION"][] = $section["ID"];
3219 }
3220
3221 $element["PROPERTY_VALUES"] = array();
3222 $props = &$element["PROPERTY_VALUES"];
3223
3224 //Delete old files
3225 $propsQuery = CIBlockElement::getProperty($element["IBLOCK_ID"], $parentId, array("value_id" => "asc"), array("PROPERTY_TYPE" => "F", "EMPTY" => "N"));
3226 while($prop = $propsQuery->fetch())
3227 {
3228 if(!array_key_exists($prop["ID"], $props))
3229 $props[$prop["ID"]] = array();
3230 $props[$prop["ID"]][$prop["PROPERTY_VALUE_ID"]] = array(
3231 "VALUE" => array("tmp_name" => "", "del" => "Y"),
3232 "DESCRIPTION" => false,
3233 );
3234 }
3235
3236 //Add new proiperty values
3237 $propsQuery = CIBlockElement::getProperty($element["IBLOCK_ID"], $element["ID"], array("value_id" => "asc"));
3238 $i = 0;
3239 while($prop = $propsQuery->fetch())
3240 {
3241 $i++;
3242 if(!array_key_exists($prop["ID"], $props))
3243 $props[$prop["ID"]] = array();
3244
3245 if($prop["PROPERTY_VALUE_ID"])
3246 {
3247 if($prop["PROPERTY_TYPE"] == "F")
3248 $props[$prop["ID"]]["n".$i] = array(
3249 "VALUE" => CFile::makeFileArray($prop["VALUE"]),
3250 "DESCRIPTION" => $prop["DESCRIPTION"],
3251 );
3252 else
3253 $props[$prop["ID"]]["n".$i] = array(
3254 "VALUE" => $prop["VALUE"],
3255 "DESCRIPTION" => $prop["DESCRIPTION"],
3256 );
3257 }
3258 }
3259
3260 $elementObject->update($parentId, $element);
3261 CBPDocument::mergeDocuments(
3262 array("lists", get_called_class(), $parentId),
3263 array("lists", get_called_class(), $documentId)
3264 );
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);
3270 return $parentId;
3271 }
3272 else
3273 {
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);
3278 return $ID;
3279 }
3280 }
3281 return false;
3282 }
3283
3291 public static function GetDocumentForHistory($documentId, $historyIndex)
3292 {
3293 $documentId = intval($documentId);
3294 if ($documentId <= 0)
3295 throw new CBPArgumentNullException("documentId");
3296
3297 $result = null;
3298
3299 $dbDocumentList = CIBlockElement::getList(
3300 array(),
3301 array("ID" => $documentId, "SHOW_NEW"=>"Y", "SHOW_HISTORY" => "Y")
3302 );
3303 if ($objDocument = $dbDocumentList->getNextElement())
3304 {
3305 $fields = $objDocument->getFields();
3306 $properties = $objDocument->getProperties();
3307
3308 $result["NAME"] = $fields["~NAME"];
3309
3310 $result["FIELDS"] = array();
3311 foreach ($fields as $fieldKey => $fieldValue)
3312 {
3313 if ($fieldKey == "~PREVIEW_PICTURE" || $fieldKey == "~DETAIL_PICTURE")
3314 {
3315 $result["FIELDS"][mb_substr($fieldKey, 1)] = CBPDocument::prepareFileForHistory(
3316 array("lists", get_called_class(), $documentId),
3317 $fieldValue,
3318 $historyIndex
3319 );
3320 }
3321 elseif (mb_substr($fieldKey, 0, 1) == "~")
3322 {
3323 $result["FIELDS"][mb_substr($fieldKey, 1)] = $fieldValue;
3324 }
3325 }
3326
3327 $result["PROPERTIES"] = array();
3328 foreach ($properties as $propertyKey => $propertyValue)
3329 {
3330 if ($propertyValue["USER_TYPE"] <> '')
3331 {
3332 $result["PROPERTIES"][$propertyKey] = array(
3333 "VALUE" => $propertyValue["VALUE"],
3334 "DESCRIPTION" => $propertyValue["DESCRIPTION"]
3335 );
3336 }
3337 elseif ($propertyValue["PROPERTY_TYPE"] == "L")
3338 {
3339 $result["PROPERTIES"][$propertyKey] = array(
3340 "VALUE" => $propertyValue["VALUE_ENUM_ID"],
3341 "DESCRIPTION" => $propertyValue["DESCRIPTION"]
3342 );
3343 }
3344 elseif ($propertyValue["PROPERTY_TYPE"] == "F")
3345 {
3346 $result["PROPERTIES"][$propertyKey] = array(
3347 "VALUE" => CBPDocument::prepareFileForHistory(
3348 array("lists", get_called_class(), $documentId),
3349 $propertyValue["VALUE"],
3350 $historyIndex
3351 ),
3352 "DESCRIPTION" => $propertyValue["DESCRIPTION"]
3353 );
3354 }
3355 else
3356 {
3357 $result["PROPERTIES"][$propertyKey] = array(
3358 "VALUE" => $propertyValue["VALUE"],
3359 "DESCRIPTION" => $propertyValue["DESCRIPTION"]
3360 );
3361 }
3362 }
3363 }
3364
3365 return $result;
3366 }
3367
3368 public static function isFeatureEnabled($documentType, $feature)
3369 {
3370 return in_array($feature, array(\CBPDocumentService::FEATURE_MARK_MODIFIED_FIELDS));
3371 }
3372
3373 public static function getBizprocEditorUrl($documentType): ?string
3374 {
3375 $iblockId = (int)mb_substr($documentType[2], mb_strlen(self::DOCUMENT_TYPE_PREFIX));
3376 if ($iblockId > 0)
3377 {
3378 if ($documentType[1] === 'BizprocDocument')
3379 {
3380 return sprintf('/bizproc/processes/%d/bp_edit/#ID#/', $iblockId);
3381 }
3382
3383 if (ModuleManager::isModuleInstalled('bitrix24'))
3384 {
3385 return sprintf('/company/lists/%d/bp_edit/#ID#/', $iblockId);
3386 }
3387
3388 return sprintf('/services/lists/%d/bp_edit/#ID#/', $iblockId);
3389 }
3390
3391 return null;
3392 }
3393}
return select
Определения access_edit.php:440
$type
Определения options.php:106
const BX_ROOT
Определения bx_root.php:3
$arResult
Определения generate_coupon.php:16
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
Определения loader.php:13
static getList(array $parameters=array())
Определения datamanager.php:431
static getDocumentIcon($documentId)
Определения bizprocdocument.php:89
static getDocument($documentId)
Определения bizprocdocument.php:120
static generateMnemonicCode($integerCode=0)
Определения bizprocdocument.php:876
static generateDocumentType($iblockId)
Определения bizprocdocument.php:30
static getRightsTasks()
Определения bizprocdocument.php:1594
static getSystemIblockFields()
Определения bizprocdocument.php:449
static updateDocumentField($documentType, $fields)
Определения bizprocdocument.php:1086
static PublishDocument($documentId)
Определения bizprocdocument.php:3160
static CanUserOperateDocumentType($operation, $userId, $documentType, $parameters=array())
Определения bizprocdocument.php:1897
static getDocumentComplexId($iblockType, $documentId)
Определения bizprocdocument.php:54
static getBizprocEditorUrl($documentType)
Определения bizprocdocument.php:3373
static setArray(array $result, $value)
Определения bizprocdocument.php:440
static generateDocumentComplexType($iblockType, $iblockId)
Определения bizprocdocument.php:41
static CanUserOperateDocument($operation, $userId, $documentId, $parameters=array())
Определения bizprocdocument.php:1693
static GetFieldInputControl($documentType, $fieldType, $fieldName, $fieldValue, $allowSelection=false, $publicMode=false)
Определения bizprocdocument.php:2158
const DOCUMENT_TYPE_PREFIX
Определения bizprocdocument.php:16
static GetFieldInputValuePrintable($documentType, $fieldType, $fieldValue)
Определения bizprocdocument.php:3008
static getDocumentFields($documentType)
Определения bizprocdocument.php:631
static isAdmin()
Определения bizprocdocument.php:2067
static SetPermissions($documentId, $workflowId, $permissions, $rewrite=true)
Определения bizprocdocument.php:2152
static deleteDataIblock($iblockId)
Определения bizprocdocument.php:65
static addDocumentField($documentType, $fields)
Определения bizprocdocument.php:893
static isFeatureEnabled($documentType, $feature)
Определения bizprocdocument.php:3368
static getAllowableOperations($documentType)
Определения bizprocdocument.php:1623
static toExternalOperations($documentType, $permissions)
Определения bizprocdocument.php:1671
static onWorkflowStatusChange($documentId, $workflowId, $status, $rootActivity)
Определения bizprocdocument.php:1529
static GetDocumentForHistory($documentId, $historyIndex)
Определения bizprocdocument.php:3291
static UnlockDocument($documentId, $workflowId)
Определения bizprocdocument.php:3120
static updateDocument($documentId, $arFields)
Определения bizprocdocument.php:1294
static getDocumentAdminPage($documentId)
Определения bizprocdocument.php:1573
static toInternalOperations($documentType, $permissions)
Определения bizprocdocument.php:1650
static GetAllowableUserGroups($documentType, $withExtended=false)
Определения bizprocdocument.php:2086
static GetFieldInputValue($documentType, $fieldType, $fieldName, $request, &$errors)
Определения bizprocdocument.php:2697
static getEntityName()
Определения bizprocdocument.php:21
const ViewWorkflow
Определения constants.php:211
const CreateWorkflow
Определения constants.php:213
const StartWorkflow
Определения constants.php:212
const ReadDocument
Определения constants.php:216
const WriteDocument
Определения constants.php:215
const FEATURE_MARK_MODIFIED_FIELDS
Определения documentservice.php:9
const ScopeDocument
Определения constants.php:227
const Hold
Определения constants.php:222
const Delegate
Определения constants.php:317
const Running
Определения constants.php:82
const Completed
Определения constants.php:83
const Terminated
Определения constants.php:85
Определения html_editor.php:14
static generatePropertyCode($name, $code, $iblockId, $propertyId=0)
Определения iblockdocument.php:3349
static GetDocumentFields($documentType)
Определения iblockdocument.php:1291
Определения iblockelement.php:9
Определения iblock_rights.php:7
Определения list.php:6
static setMessageLiveFeed($users, $elementId, $workflowId, $flagCompleteProcess)
Определения livefeed.php:9
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$arFields
Определения dblapprove.php:5
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr ><?endif?><? $propertyIndex=0;foreach( $arGlobalProperties as $propertyCode=> $propertyValue
Определения file_new.php:729
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$perm
Определения options.php:169
$result
Определения get_property_values.php:14
$query
Определения get_search.php:11
if($ajaxMode) $ID
Определения get_user.php:27
$iblockTypeId
Определения group_lists.php:25
$iblockId
Определения iblock_catalog_edit.php:30
$errors
Определения iblock_catalog_edit.php:74
$select
Определения iblock_catalog_list.php:194
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
const FORMAT_DATE
Определения include.php:63
$groups
Определения options.php:30
$status
Определения session.php:10
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
Определения tools.php:2587
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
GetMessage($name, $aReplace=null)
Определения tools.php:3397
CheckDateTime($datetime, $format=false)
Определения tools.php:398
$message
Определения payment.php:8
$publicMode
Определения product_settings.php:144
$settings
Определения product_settings.php:43
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
if(empty($signedUserToken)) $key
Определения quickway.php:257
const ADMIN_SECTION
Определения rss.php:2
$i
Определения factura.php:643
font size
Определения invoice.php:442
</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."%"
Определения waybill.php:936
$props
Определения template.php:269
else $a
Определения template.php:137
const SITE_ID
Определения sonet_set_content_view.php:12
$error
Определения subscription_card_product.php:20
$k
Определения template_pdf.php:567
foreach($arTemplatesList as $templ) if(mb_strpos($templ["NAME"] $def
Определения template_copy.php:264
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3
$rights
Определения options.php:4
$iterator
Определения yandex_run.php:610
$fields
Определения yandex_run.php:501