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