1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
helper.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Automation;
4
5use Bitrix\Bizproc\Automation\Engine\DelayInterval;
6use Bitrix\Disk;
7use Bitrix\Main\Loader;
8use Bitrix\Bizproc;
9use Bitrix\Bizproc\WorkflowTemplateTable;
10
11class Helper
12{
13 const CURRENT_DATE_BASIS = '{=System:Date}';
14 const CURRENT_DATETIME_BASIS = '{=System:Now}';
15 private const CACHE_TTL = 3600;
16
17 protected static $maps;
18 protected static $documentFields;
19
20 public static function prepareUserSelectorEntities(array $documentType, $users, $config = []): array
21 {
22 $result = [];
23 $users = (array)$users;
24 $documentUserFields = static::getDocumentFields($documentType, 'user');
25 $documentUserGroups = self::getDocumentUserServiceGroups($documentType);
26
27 foreach ($users as $user)
28 {
29 if (!is_scalar($user))
30 continue;
31
32 if (mb_substr($user, 0, 5) === "user_")
33 {
34 $user = intval(mb_substr($user, 5));
35 if (($user > 0) && !in_array($user, $result))
36 {
37 $userInfo = self::getUserInfo($user);
38 $result[] = [
39 'id' => 'U'.$user,
40 'entityId' => $user,
41 'name' => htmlspecialcharsBx($userInfo['fullName']),
42 'photoSrc' => $userInfo['photoSrc'],
43 'url' => $userInfo['url'],
44 'entityType' => 'users',
45 ];
46 }
47 }
48 elseif ($user === 'author' &&
49 (
50 isset($documentUserFields['ASSIGNED_BY_ID']) ||
51 isset($documentUserFields['RESPONSIBLE_ID'])
52 )
53 )
54 {
55 $responsibleKey = isset($documentUserFields['ASSIGNED_BY_ID']) ? 'ASSIGNED_BY_ID' : 'RESPONSIBLE_ID';
56
57 $result[] = array(
58 'id' => $documentUserFields[$responsibleKey]['Expression'],
59 'entityId' => $documentUserFields[$responsibleKey]['Expression'],
60 'name' => htmlspecialcharsBx($documentUserFields[$responsibleKey]['Name']),
61 'entityType' => 'bpuserroles'
62 );
63 }
64 elseif (isset($documentUserGroups[$user]))
65 {
66 $result[] = array(
67 'id' => $user,
68 'entityId' => $user,
69 'name' => htmlspecialcharsBx($documentUserGroups[$user]),
70 'entityType' => 'bpuserroles'
71 );
72 }
73 else
74 {
75 $found = false;
76 foreach ($documentUserFields as $field)
77 {
78 if ($user === $field['Expression'] || $user === $field['SystemExpression'])
79 {
80 $result[] = array(
81 'id' => $field['Expression'],
82 'entityId' => $field['Expression'],
83 'name' => htmlspecialcharsBx($field['Name']),
84 'entityType' => 'bpuserroles'
85 );
86 $found = true;
87 }
88 }
89
90 if (!$found && isset($config['additionalFields']))
91 {
92 foreach ($config['additionalFields'] as $field)
93 {
94 if ($user === $field['entityId'])
95 {
96 $result[] = array(
97 'id' => $field['id'],
98 'entityId' => $field['entityId'],
99 'name' => htmlspecialcharsBx($field['name']),
100 'entityType' => 'bpuserroles'
101 );
102 }
103 }
104 }
105 }
106 }
107 return $result;
108 }
109
110 public static function getResponsibleUserExpression(array $documentType)
111 {
112 $documentUserFields = static::getDocumentFields($documentType, 'user');
113 $result = null;
114
115 if (isset($documentUserFields['ASSIGNED_BY_ID']) || isset($documentUserFields['RESPONSIBLE_ID']))
116 {
117 $responsibleKey = isset($documentUserFields['ASSIGNED_BY_ID']) ? 'ASSIGNED_BY_ID' : 'RESPONSIBLE_ID';
118 $result = '{=Document:'.$responsibleKey.'}';
119 }
120 elseif (isset($documentUserFields['CREATED_BY']))
121 {
122 $result = '{=Document:CREATED_BY}';
123 }
124 return $result;
125 }
126
132 public static function prepareDiskAttachments($attachments)
133 {
134 $result = array();
135
136 if (!Loader::includeModule('disk'))
137 return $result;
138
139 foreach ((array)$attachments as $attachmentId)
140 {
141 $attachmentId = (int)$attachmentId;
142 if ($attachmentId <= 0)
143 {
144 continue;
145 }
146
147 $file = Disk\File::loadById($attachmentId);
148 if ($file)
149 {
150 $result[] = array(
151 'id' => $file->getId(),
152 'name' => $file->getName(),
153 'size' => \CFile::FormatSize($file->getSize()),
154 'type' => 'disk'
155 );
156 }
157 }
158
159 return $result;
160 }
161
168 public static function prepareFileAttachments(array $documentType, $files)
169 {
170 $result = [];
172 $documentUserFields = static::getDocumentFields($documentType, 'file');
173
174 foreach ($files as $file)
175 {
176 if (!is_scalar($file))
177 continue;
178
179 $found = false;
180 foreach ($documentUserFields as $id => $field)
181 {
182 if ($file !== $field['Expression'])
183 continue;
184
185 $found = true;
186 $result[] = array(
187 'id' => $id,
188 'expression' => $field['Expression'],
189 'name' => $field['Name'],
190 'type' => 'file'
191 );
192 }
193
194 if (!$found && mb_strpos($file, '{') === 0)
195 {
196 $result[] = [
197 'id' => $file,
198 'expression' => $file,
199 'name' => $file,
200 'type' => 'file'
201 ];
202 }
203 }
204 return $result;
205 }
206
207 public static function convertExpressions($source, array $documentType, $useTilda = true)
208 {
209 if (!$source)
210 {
211 return $source;
212 }
213
215 [$mapIds, $mapNames, $mapObjectNames] = static::getExpressionsMaps($documentType);
216
217 $converter = function ($matches) use ($mapIds, $mapNames, $mapObjectNames, $useTilda)
218 {
219 $mods = [];
220 if (isset($matches['mod1']))
221 {
222 $mods[] = $matches['mod1'];
223 }
224 if (isset($matches['mod2']))
225 {
226 $mods[] = $matches['mod2'];
227 }
228 $modifiers = ($mods ? ' > ' . implode(',', $mods) : '');
229
230 $objectName = $matches['object'];
231 $fieldId = $matches['field'];
232
233 if (in_array($objectName, $mapObjectNames))
234 {
235 $key = array_search($fieldId, $mapIds[$objectName]);
236 if ($key !== false)
237 {
238 $fieldName = $mapNames[$objectName][$key];
239
240 return '{{' . $fieldName . $modifiers . '}}';
241 }
242 }
243 elseif ($useTilda && $objectName === 'Template')
244 {
245 return '{{~*:' . $fieldId . $modifiers . '}}';
246 }
247 elseif ($useTilda && $objectName === 'Constant')
248 {
249 return '{{~&:' . $fieldId . $modifiers . '}}';
250 }
251 elseif ($useTilda && preg_match('/^A[_0-9]+$/', $objectName))
252 {
253 return '{{~' . $objectName . ':' . $fieldId . $modifiers . '}}';
254 }
255
256 return $matches[0];
257 };
258
259 return preg_replace_callback($pattern, $converter, $source);
260 }
261
262 protected static function getExpressionsMaps($documentType): array
263 {
264 $mapIds = [];
265 $mapNames = [];
266 $mapObjectNames = [];
267
269 [$ids, $names] = static::getFieldsMap($documentType);
270 $mapIds[$objectName] = $ids;
271 $mapNames[$objectName] = $names;
272 $mapObjectNames[] = $objectName;
273
275 [$ids, $names] = static::getGlobalsMap($objectName, $documentType);
276 $mapIds[$objectName] = $ids;
277 $mapNames[$objectName] = $names;
278 $mapObjectNames[] = $objectName;
279
281 [$ids, $names] = static::getGlobalsMap($objectName, $documentType);
282 $mapIds[$objectName] = $ids;
283 $mapNames[$objectName] = $names;
284 $mapObjectNames[] = $objectName;
285
286 return [$mapIds, $mapNames, $mapObjectNames];
287 }
288
289 public static function unConvertExpressions($source, array $documentType)
290 {
291 $pattern = '/\{\{(?<mixed>[^=].*?)\}\}/is';
292 [$mapIds, $mapNames, $mapObjectNames] = static::getExpressionsMaps($documentType);
293
294 $converter = function ($matches) use ($mapIds, $mapNames, $mapObjectNames)
295 {
296 $matches['mixed'] = htmlspecialcharsback($matches['mixed']);
297
298 if (mb_strpos($matches['mixed'], '~') === 0)
299 {
300 $len = mb_strpos($matches['mixed'], '#');
301 $expression = ($len === false)
302 ? mb_substr($matches['mixed'], 1)
303 : mb_substr($matches['mixed'], 1, $len - 1)
304 ;
305
306 if (mb_strpos($expression, '*:') === 0)
307 {
308 $expression = ltrim($expression,'*');
309 $expression = 'Template' . $expression;
310 }
311
312 if (mb_strpos($expression, '&:') === 0)
313 {
314 $expression = ltrim($expression,'&');
315 $expression = 'Constant' . $expression;
316 }
317
318 return '{=' . trim($expression) . '}';
319 }
320
321 $pairs = explode('>', $matches['mixed']);
322 $fieldName = '';
323 $fieldId = '';
324 $objectName = '';
325
326 while (($pair = array_shift($pairs)) !== null)
327 {
328 $fieldName .= $fieldName ? '>' . $pair : $pair;
329
330 foreach ($mapObjectNames as $object)
331 {
332 $key = array_search(trim($fieldName), $mapNames[$object]);
333 if ($key !== false)
334 {
335 $objectName = $object;
336 $fieldId = $mapIds[$object][$key];
337 break;
338 }
339 }
340
341 if ($fieldId !== '')
342 {
343 break;
344 }
345 }
346
347 if (!$fieldId && mb_substr($fieldName, -10) === '_printable')
348 {
349 $fieldName = mb_substr($fieldName, 0, -10);
350 $key = array_search(trim($fieldName), $mapNames['Document']);
351 if ($key !== false)
352 {
353 $objectName = 'Document';
354 $fieldId = $mapIds['Document'][$key];
355 $pairs[] = 'printable';
356 }
357 }
358
359 if ($fieldId)
360 {
361 $mods = isset($pairs[0]) ? trim($pairs[0]) : '';
362 $modifiers = $mods ? ' > ' . $mods : '';
363
364 return '{=' . $objectName . ':' . $fieldId . $modifiers . '}';
365 }
366
367 return $matches[0];
368 };
369
370 return preg_replace_callback($pattern, $converter, $source);
371 }
372
373 public static function convertProperties(array $properties, array $documentType, $useTilda = true)
374 {
375 foreach ($properties as $code => $property)
376 {
377 if (is_array($property))
378 {
379 $properties[$code] = self::convertProperties($property, $documentType, $useTilda);
380 }
381 else
382 {
383 $properties[$code] = static::convertExpressions($property, $documentType, $useTilda);
384 }
385 }
386 return $properties;
387 }
388
389 public static function unConvertProperties(array $properties, array $documentType)
390 {
391 foreach ($properties as $code => $property)
392 {
393 if (is_array($property))
394 {
395 $properties[$code] = self::unConvertProperties($property, $documentType);
396 }
397 else
398 {
399 $properties[$code] = static::unConvertExpressions($property, $documentType);
400 }
401 }
402 return $properties;
403 }
404
411 public static function getDocumentFields(array $documentType, $typeFilter = null)
412 {
413 $key = implode('@', $documentType);
414 if (!isset(static::$documentFields[$key]))
415 {
416 $documentService = \CBPRuntime::getRuntime()->getDocumentService();
417 try
418 {
419 static::$documentFields[$key] = $documentService->GetDocumentFields($documentType);
420 }
421 catch (\Exception $exception)
422 {
423 static::$documentFields[$key] = [];
424 }
425 }
426
427 $resultFields = [];
428
429 if (is_array(static::$documentFields[$key]))
430 {
431 foreach (static::$documentFields[$key] as $id => $field)
432 {
433 if ($field['Type'] === 'UF:boolean')
434 {
435 //Mark as bizproc boolean type
436 $field['Type'] = $field['BaseType'] = 'bool';
437 }
438
439 if ($field['Type'] === 'UF:date')
440 {
441 //Mark as bizproc date type
442 $field['Type'] = $field['BaseType'] = 'date';
443 }
444
445 if ($typeFilter !== null && $field['Type'] !== $typeFilter)
446 continue;
447
448 $field['Name'] = trim($field['Name']);
449
450 $resultFields[$id] = [
451 'Id' => $id,
452 'Name' => $field['Name'],
453 'Type' => $field['Type'],
454 'BaseType' => $field['BaseType'] ?? $field['Type'],
455 'Expression' => '{{' . $field['Name'] . '}}',
456 'SystemExpression' => '{=Document:' . $id . '}',
457 'Options' => $field['Options'] ?? null,
458 'Settings' => $field['Settings'] ?? null,
459 'Multiple' => $field['Multiple'] ?? false,
460 ];
461 }
462 }
463
464 return $resultFields;
465 }
466
468 public static function getGlobalVariables(array $documentType): array
469 {
470 $globalVariables = Bizproc\Workflow\Type\GlobalVar::getAll($documentType);
471
472 $result = [];
473 $visibilityNames = Bizproc\Workflow\Type\GlobalVar::getVisibilityFullNames($documentType);
474 foreach ($globalVariables as $id => $variable)
475 {
476 $name = trim($variable['Name']);
477 $visibilityName = $visibilityNames[$variable['Visibility']];
478
479 $result[$id] = [
480 'Id' => $id,
481 'Name' => $name,
482 'Type' => $variable['Type'],
483 'BaseType' => $variable['Type'],
484 'Expression' => '{{' . $visibilityName . ': ' . $name . '}}',
485 'SystemExpression' => '{=' . Bizproc\Workflow\Template\SourceType::GlobalVariable . ':' . $id . '}',
486 'Options' => $variable['Options'] ?? null,
487 'Multiple' => $variable['Multiple'] ?? false,
488 'Visibility' => $variable['Visibility'],
489 'VisibilityName' => $visibilityName,
490 ];
491 }
492
493 return $result;
494 }
495
497 public static function getGlobalConstants(array $documentType): array
498 {
499 $globalConstants = Bizproc\Workflow\Type\GlobalConst::getAll($documentType);
500
501 $result = [];
502 $visibilityNames = Bizproc\Workflow\Type\GlobalConst::getVisibilityFullNames($documentType);
503 foreach ($globalConstants as $id => $constant)
504 {
505 $name = trim($constant['Name']);
506 $visibilityName = $visibilityNames[$constant['Visibility']];
507
508 $result[$id] = [
509 'Id' => $id,
510 'Name' => $name,
511 'Type' => $constant['Type'],
512 'BaseType' => $constant['Type'],
513 'Expression' => '{{' . $visibilityName . ': ' . $name . '}}',
514 'SystemExpression' => '{=' . Bizproc\Workflow\Template\SourceType::GlobalConstant . ':' . $id . '}',
515 'Options' => $constant['Options'] ?? null,
516 'Multiple' => $constant['Multiple'] ?? false,
517 'Visibility' => $constant['Visibility'],
518 'VisibilityName' => $visibilityName,
519 ];
520 }
521
522 return $result;
523 }
524
525 private static function getDocumentUserServiceGroups(array $documentType)
526 {
527 $documentService = \CBPRuntime::getRuntime()->getDocumentService();
528
529 return $documentService->GetAllowableUserGroups($documentType);
530 }
531
532 public static function getDocumentUserGroups(array $documentType): array
533 {
534 $docGroups = self::getDocumentUserServiceGroups($documentType);
535 $groups = [];
536
537 if ($docGroups)
538 {
539 foreach ($docGroups as $id => $groupName)
540 {
541 if (!$groupName || mb_strpos($id, 'group_') === 0)
542 {
543 continue;
544 }
545
546 $groups[] = [
547 'id' => preg_match('/^[0-9]+$/', $id) ? 'G'.$id : $id,
548 'name' => $groupName
549 ];
550 }
551 }
552
553 return $groups;
554 }
555
556 public static function isDocumentUserGroup(string $value, array $documentType): bool
557 {
558 $documentGroups = static::getDocumentUserGroups($documentType);
559 if (empty($documentGroups))
560 {
561 return false;
562 }
563
564 foreach ($documentGroups as $group)
565 {
566 if ($group['id'] === $value)
567 {
568 return true;
569 }
570 }
571
572 return false;
573 }
574
575 protected static function getFieldsMap(array $documentType)
576 {
577 $key = implode('@', $documentType);
578 if (!isset(static::$maps[$key]))
579 {
580 $id = [];
581 $name = [];
582
583 $fields = static::getDocumentFields($documentType);
584 foreach ($fields as $field)
585 {
586 $id[] = $field['Id'];
587 $name[] = $field['Name'];
588 }
589
590 static::$maps[$key] = [$id, $name];
591 }
592
593 return static::$maps[$key];
594 }
595
596 protected static function getGlobalsMap(string $type, array $documentType)
597 {
598 switch ($type)
599 {
600 case \Bitrix\Bizproc\Workflow\Template\SourceType::GlobalConstant:
601 $key = 'globals@const@' . implode('@', $documentType);
602 if (isset(static::$maps[$key]))
603 {
604 return static::$maps[$key];
605 }
606 $globals = static::getGlobalConstants($documentType);
607 break;
608 case \Bitrix\Bizproc\Workflow\Template\SourceType::GlobalVariable:
609 $key = 'globals@var@' . implode('@', $documentType);
610 if (isset(static::$maps[$key]))
611 {
612 return static::$maps[$key];
613 }
614 $globals = static::getGlobalVariables($documentType);
615 break;
616 default:
617 return [];
618 }
619
620 $ids = [];
621 $names = [];
622
623 foreach ($globals as $id => $property)
624 {
625 $ids[] = $id;
626 $names[] = $property['VisibilityName'] . ': ' . trim($property['Name']);
627 }
628
629 static::$maps[$key] = [$ids, $names];
630
631 return static::$maps[$key];
632 }
633
634 public static function parseDateTimeInterval($interval)
635 {
636 $interval = ltrim((string)$interval, '=');
637 $result = [
638 'basis' => null,
639 'workTime' => false,
640 'inTime' => null,
641 ];
642
643 $values = [
644 'i' => 0,
645 'h' => 0,
646 'd' => 0,
647 ];
648
649 if (mb_strpos($interval, 'settime(') === 0)
650 {
651 $interval = mb_substr($interval, 8, -1); // cut settime(...)
652 $intervalParts = explode(')', $interval);
653 $arguments = explode(',', array_pop($intervalParts));
654
655 $userOffset = count($arguments) > 3 ? array_pop($arguments) : 0;
656 $minute = array_pop($arguments);
657 $hour = array_pop($arguments);
658
659 $interval = implode(')', $intervalParts) . implode(',', $arguments);
660 $result['inTime'] = [(int)$hour, (int)$minute];
661
662 if ($userOffset > 0)
663 {
664 $result['inTime'][] = (int)$userOffset;
665 }
666 }
667
668 if (mb_strpos($interval, 'dateadd(') === 0 || mb_strpos($interval, 'workdateadd(') === 0)
669 {
670 if (mb_strpos($interval, 'workdateadd(') === 0)
671 {
672 $interval = mb_substr($interval, 12, -1); // cut workdateadd(...)
673 $result['workTime'] = true;
674 }
675 else
676 {
677 $interval = mb_substr($interval, 8, -1); // cut dateadd(...)
678 }
679
680 $arguments = explode(',', $interval);
681 $result['basis'] = trim($arguments[0]);
682
683 $arguments[1] = trim(($arguments[1] ?? ''), '"\'');
684 $result['type'] = mb_strpos($arguments[1], '-') === 0 ? DelayInterval::TYPE_BEFORE : DelayInterval::TYPE_AFTER;
685
686 preg_match_all('/\s*([\d]+)\s*(i|h|d)\s*/i', $arguments[1], $matches);
687 foreach ($matches[0] as $i => $match)
688 {
689 $values[$matches[2][$i]] = (int)$matches[1][$i];
690 }
691 }
692 elseif (\CBPDocument::IsExpression($interval))
693 {
694 $result['basis'] = $interval;
695
696 if ($result['basis'] !== static::CURRENT_DATETIME_BASIS)
697 {
699 }
700 else
701 {
703 }
704 }
705
706 $minutes = $values['i'] + $values['h'] * 60 + $values['d'] * 60 * 24;
707
708 if ($minutes % 1440 === 0)
709 {
710 $result['value'] = $minutes / 1440;
711 $result['valueType'] = 'd';
712 }
713 elseif ($minutes % 60 === 0)
714 {
715 $result['value'] = $minutes / 60;
716 $result['valueType'] = 'h';
717 }
718 else
719 {
720 $result['value'] = $minutes;
721 $result['valueType'] = 'i';
722 }
723
724 if (
725 !$result['value']
726 && (
727 $result['basis'] !== static::CURRENT_DATETIME_BASIS
728 || $result['inTime']
729 )
730 && \CBPDocument::IsExpression($result['basis'])
731 )
732 {
734 }
735
736 return $result + $values;
737 }
738
739 public static function getDateTimeIntervalString($interval)
740 {
741 if (empty($interval['basis']) || !\CBPDocument::IsExpression($interval['basis']))
742 {
743 $interval['basis'] = static::CURRENT_DATE_BASIS;
744 }
745
746 $days = isset($interval['d']) ? (int)$interval['d'] : 0;
747 $hours = isset($interval['h']) ? (int)$interval['h'] : 0;
748 $minutes = isset($interval['i']) ? (int)$interval['i'] : 0;
749
750 if (isset($interval['value']) && isset($interval['valueType']))
751 {
752 switch ($interval['valueType'])
753 {
754 case 'i':
755 $minutes = (int)$interval['value'];
756 break;
757 case 'h':
758 $hours = (int)$interval['value'];
759 break;
760 case 'd':
761 $days = (int)$interval['value'];
762 break;
763 }
764 }
765
766 $add = '';
767
768 if ($days > 0)
769 $add .= $days.'d';
770 if ($hours > 0)
771 $add .= $hours.'h';
772 if ($minutes > 0)
773 $add .= $minutes.'i';
774
775 if ($add && isset($interval['type']) && $interval['type'] === DelayInterval::TYPE_BEFORE)
776 {
777 $add = '-' . $add;
778 }
779
780 $fn = !empty($interval['workTime']) ? 'workdateadd' : 'dateadd';
781
782 if ($fn === 'workdateadd' && $add === '')
783 {
784 $add = '0d';
785 }
786
787 $worker = '';
788 if ($fn === 'workdateadd' && isset($interval['worker']))
789 {
790 $worker = $interval['worker'];
791 }
792
793 $result = $interval['basis'];
794 $isFunctionInResult = false;
795 if ($add)
796 {
797 $result = $fn . '(' . $interval['basis'] . ',"' . $add . '"' . ($worker ? ',' . $worker : '') . ')';
798 $isFunctionInResult = true;
799 }
800
801 if (isset($interval['inTime']))
802 {
803 $result = sprintf(
804 'settime(%s, %d, %d%s)',
805 $result,
806 $interval['inTime'][0] ?? 0,
807 $interval['inTime'][1] ?? 0,
808 isset($interval['inTime'][2]) ? ", {$interval['inTime'][2]}" : '',
809 );
810 $isFunctionInResult = true;
811 }
812
813 return $isFunctionInResult ? '=' . $result : $result;
814 }
815
816 public static function parseTimeString($time)
817 {
818 $pairs = preg_split('#[\s:]+#', $time);
819 $pairs[0] = (int)$pairs[0];
820 $pairs[1] = (int)$pairs[1];
821
822 if (count($pairs) === 3)
823 {
824 if ($pairs[2] == 'pm' && $pairs[0] < 12)
825 $pairs[0] += 12;
826 if ($pairs[2] == 'am' && $pairs[0] == 12)
827 $pairs[0] = 0;
828 }
829
830 return array('h' => $pairs[0], 'i' => $pairs[1]);
831 }
832
833 public static function countAllRobots(array $documentType, array $statuses): int
834 {
835 $cnt = 0;
836 $result = WorkflowTemplateTable::getList([
837 'filter' => [
838 '=MODULE_ID' => $documentType[0],
839 '=ENTITY' => $documentType[1],
840 '=DOCUMENT_TYPE' => $documentType[2],
841 '@DOCUMENT_STATUS' => $statuses,
842 ],
843 'select' => ['TEMPLATE'],
844 'cache' => ['ttl' => self::CACHE_TTL],
845 ]);
846 while ($row = $result->fetchObject())
847 {
848 $row['MODULE_ID'] = $documentType[0];
849 $row['ENTITY'] = $documentType[1];
850 $row['DOCUMENT_TYPE'] = $documentType[2];
852 $cnt += count($template->getActivatedRobots());
853 }
854
855 return $cnt;
856 }
857
858 private static function getUserInfo($userID, $format = '', $htmlEncode = false)
859 {
860 $userID = intval($userID);
861 if($userID <= 0)
862 {
863 return '';
864 }
865
866 $format = strval($format);
867 if($format === '')
868 {
869 $format = \CSite::GetNameFormat(false);
870 }
871
872 $dbUser = \CUser::GetList(
873 'id',
874 'asc',
875 array('ID'=> $userID),
876 array(
877 'FIELDS' => array(
878 'ID',
879 'NAME', 'SECOND_NAME', 'LAST_NAME',
880 'LOGIN', 'TITLE', 'EMAIL',
881 'PERSONAL_PHOTO'
882 )
883 )
884 );
885
886 $user = $dbUser ? $dbUser->Fetch() : null;
887
888 return [
889 'fullName' => $user ? \CUser::FormatName($format, $user, true, $htmlEncode) : '',
890 'photoSrc' => $user ? \CBPViewHelper::getUserPhotoSrc($user) : null,
891 'url' => sprintf('/company/personal/user/%s/', $userID),
892 ];
893 }
894}
$type
Определения options.php:106
static createByTpl(Tpl $tpl)
Определения template.php:101
static getResponsibleUserExpression(array $documentType)
Определения helper.php:110
static parseDateTimeInterval($interval)
Определения helper.php:634
static $maps
Определения helper.php:17
static $documentFields
Определения helper.php:18
const CURRENT_DATE_BASIS
Определения helper.php:13
static convertExpressions($source, array $documentType, $useTilda=true)
Определения helper.php:207
static isDocumentUserGroup(string $value, array $documentType)
Определения helper.php:556
static countAllRobots(array $documentType, array $statuses)
Определения helper.php:833
static getGlobalVariables(array $documentType)
Определения helper.php:468
static getDocumentFields(array $documentType, $typeFilter=null)
Определения helper.php:411
static parseTimeString($time)
Определения helper.php:816
const CURRENT_DATETIME_BASIS
Определения helper.php:14
static getGlobalsMap(string $type, array $documentType)
Определения helper.php:596
static getFieldsMap(array $documentType)
Определения helper.php:575
static getExpressionsMaps($documentType)
Определения helper.php:262
static prepareFileAttachments(array $documentType, $files)
Определения helper.php:168
static unConvertProperties(array $properties, array $documentType)
Определения helper.php:389
static getDateTimeIntervalString($interval)
Определения helper.php:739
static getGlobalConstants(array $documentType)
Определения helper.php:497
static getDocumentUserGroups(array $documentType)
Определения helper.php:532
static prepareDiskAttachments($attachments)
Определения helper.php:132
static unConvertExpressions($source, array $documentType)
Определения helper.php:289
static convertProperties(array $properties, array $documentType, $useTilda=true)
Определения helper.php:373
static prepareUserSelectorEntities(array $documentType, $users, $config=[])
Определения helper.php:20
static getVisibilityFullNames(array $parameterDocumentType)
Определения globalconst.php:24
static getVisibilityFullNames(array $parameterDocumentType)
Определения globalvar.php:22
static getAll(array $parameterDocumentType=[])
Определения globalsmanager.php:20
const ValueInlinePattern
Определения activity.php:28
Определения viewhelper.php:9
$hours
Определения cron_html_pages.php:15
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$groups
Определения options.php:30
htmlspecialcharsback($str)
Определения tools.php:2693
$name
Определения menu_edit.php:35
$user
Определения mysql_to_pgsql.php:33
$files
Определения mysql_to_pgsql.php:30
$time
Определения payment.php:61
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$config
Определения quickway.php:69
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
</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
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20
$matches
Определения index.php:22
$fields
Определения yandex_run.php:501