Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
globalconst.php
1<?php
2
4
6{
7 const CONF_NAME = 'global_const';
8
9 protected static function getTableEntity(): string
10 {
11 return \Bitrix\Bizproc\Workflow\Type\Entity\GlobalConstTable::class;
12 }
13
14 protected static function getCacheId(): string
15 {
16 return 'constant';
17 }
18
19 public static function getObjectNameForExpressions(): string
20 {
21 return 'GlobalConst';
22 }
23
24 public static function getVisibilityFullNames(array $parameterDocumentType): array
25 {
26 $runtime = \CBPRuntime::GetRuntime();
27 $runtime->StartRuntime();
28 $documentService = $runtime->GetService("DocumentService");
29
30 [$moduleId, $entity, $documentType] = \CBPHelper::ParseDocumentId($parameterDocumentType);
31 $documentCaption = $documentService->getDocumentTypeCaption($parameterDocumentType);
32
33 $names = [];
34 $names['GLOBAL'] = \Bitrix\Main\Localization\Loc::getMessage(
35 'BIZPROC_LIB_WF_TYPE_GLOBAL_CONST_VISIBILITY_FULL_GLOBAL'
36 );
37
38 switch (mb_strtoupper($moduleId))
39 {
40 case 'CRM':
41 $moduleVisibility = \Bitrix\Main\Localization\Loc::getMessage(
42 'BIZPROC_LIB_WF_TYPE_GLOBAL_CONST_VISIBILITY_FULL_MODULE',
43 ['#MODULE#' => mb_strtoupper($moduleId)]
44 );
45 $documentVisibility = \Bitrix\Main\Localization\Loc::getMessage(
46 'BIZPROC_LIB_WF_TYPE_GLOBAL_CONST_VISIBILITY_FULL_DOCUMENT_SECTION',
47 ['#SECTION#' => $documentCaption]
48 );
49 break;
50 case 'RPA':
51 $moduleVisibility = \Bitrix\Main\Localization\Loc::getMessage(
52 'BIZPROC_LIB_WF_TYPE_GLOBAL_CONST_VISIBILITY_FULL_MODULE',
53 ['#MODULE#' => mb_strtoupper($moduleId)]
54 );
55 $documentVisibility = \Bitrix\Main\Localization\Loc::getMessage(
56 'BIZPROC_LIB_WF_TYPE_GLOBAL_CONST_VISIBILITY_FULL_DOCUMENT_PROCESS',
57 ['#PROCESS#' => $documentCaption]
58 );
59 break;
60 default:
61 $moduleVisibility = '';
62 $documentVisibility = '';
63 }
64
65 if (!$moduleVisibility)
66 {
67 return $names;
68 }
69
70 $names[mb_strtoupper($moduleId)] = $moduleVisibility;
71 $names[mb_strtoupper($moduleId) . '_' . mb_strtoupper($documentType)] = $documentVisibility;
72
73 return $names;
74 }
75
76 public static function saveAll(array $all, int $userId = null)
77 {
78 $diff = array_diff(array_keys(static::getAll()), array_keys($all));
79
80 foreach ($all as $id => $property)
81 {
82 Entity\GlobalConstTable::upsertByProperty($id, $property, $userId);
83 }
84
85 if ($diff)
86 {
87 foreach ($diff as $toDelete)
88 {
89 Entity\GlobalConstTable::delete($toDelete);
90 }
91 }
92
93 //clear cache
94 static::clearStaticCache(self::getCacheId());
95
96 return true;
97 }
98}
static saveAll(array $all, int $userId=null)
static getVisibilityFullNames(array $parameterDocumentType)