3namespace Bitrix\Bizproc\Workflow\Type;
6use Bitrix\Main\Localization\Loc;
23 return static::getAllAvailable($parameterDocumentType);
28 $cacheId = static::getCacheId();
30 if (!isset(static::$allSortByVisibilityCache[$cacheId]))
32 $all = static::getAllRows();
33 $allSortByVisibility = [];
34 foreach ($all as $id => $property)
36 $visibility = $property[
'Visibility'];
37 $allSortByVisibility[$visibility][$id] = $property;
40 static::$allSortByVisibilityCache[$cacheId] = $allSortByVisibility;
43 $global = static::$allSortByVisibilityCache[$cacheId][
'GLOBAL'] ?? [];
45 if (!$parameterDocumentType)
52 [
$moduleId,
$entity, $documentType] = \CBPHelper::ParseDocumentId($parameterDocumentType);
59 $module = static::$allSortByVisibilityCache[$cacheId][mb_strtoupper(
$moduleId)] ?? [];
61 static::$allSortByVisibilityCache[$cacheId][mb_strtoupper(
$moduleId) .
'_' . mb_strtoupper($documentType)]
65 return array_merge($global, $module, $document);
70 $cacheId = static::getCacheId();
72 if (!isset(static::$allCache[$cacheId]))
75 $table = static::getTableEntity();
76 if (method_exists(
$table,
'getList') && method_exists(
$table,
'convertToProperty'))
78 $rows = $table::getList();
80 foreach (
$rows as $row)
82 $all[$row[
'ID']] = $table::convertToProperty($row);
86 static::$allCache[$cacheId] = $all;
89 return static::$allCache[$cacheId];
94 return static::upsertByProperty($id, $property,
$userId)->isSuccess();
99 $table = static::getTableEntity();
100 if (method_exists(
$table,
'upsertByProperty'))
104 $cacheId = static::getCacheId();
105 static::clearStaticCache($cacheId);
110 return (
new Result())->addError(
111 new Error(Loc::getMessage(
'BIZPROC_LIB_WF_TYPE_GLOBALS_MANAGER_CAN_NOT_UPSERT'))
115 public static function delete($id): bool
117 $table = static::getTableEntity();
118 if (method_exists(
$table,
'delete'))
122 $cacheId = static::getCacheId();
123 static::clearStaticCache($cacheId);
133 static::$allCache[$cacheId] =
null;
134 static::$allSortByVisibilityCache[$cacheId] =
null;
139 $all = static::getAllRows();
141 return $all[$id] ??
null;
146 $all = static::getAllAvailable($documentType);
148 return $all[$id] ??
null;
153 $property = is_array($id) ? $id : static::getById($id);
155 return $property ? $property[
'Default'] :
null;
161 if (
$user->isAdmin())
166 $canCreateAutomation = \CBPDocument::CanUserOperateDocumentType(
171 if ($canCreateAutomation)
176 return \CBPDocument::CanUserOperateDocumentType(
185 return static::canUserRead($documentType,
$userId);
190 return static::canUserRead($documentType,
$userId);
195 [
$moduleId,
$entity, $documentType] = \CBPHelper::ParseDocumentId($parameterDocumentType);
196 if (in_array(mb_strtoupper(
$moduleId), [
'CRM',
'RPA']))
198 return [
'GLOBAL', mb_strtoupper(
$moduleId), mb_strtoupper(
$moduleId) .
'_' . mb_strtoupper($documentType)];
206 $runtime = \CBPRuntime::GetRuntime();
207 $runtime->StartRuntime();
208 $documentService = $runtime->GetService(
"DocumentService");
211 [
$moduleId,
$entity, $documentType] = \CBPHelper::ParseDocumentId($parameterDocumentType);
212 $documentCaption = $documentService->getDocumentTypeCaption($parameterDocumentType);
215 $names[
'GLOBAL'] = Loc::getMessage(
216 'BIZPROC_LIB_WF_TYPE_GLOBAL_FIELD_VISIBILITY_SHORT_GLOBAL'
223 $moduleVisibility = mb_strtoupper(
$moduleId);
224 $documentVisibility = $documentCaption;
227 $moduleVisibility =
'';
228 $documentVisibility =
'';
232 if (!$moduleVisibility)
237 $names[mb_strtoupper(
$moduleId)] = $moduleVisibility;
238 $names[mb_strtoupper(
$moduleId) .
'_' . mb_strtoupper($documentType)] = $documentVisibility;
247 Loc::loadLanguageFile(__FILE__);
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getVisibleById($id, $documentType)
static getAll(array $parameterDocumentType=[])
static upsertByProperty($id, $property, int $userId=null)
static getAllAvailable(array $parameterDocumentType=[])
static canUserRead(array $documentType, int $userId)
static loadLanguageFile()
static canUserDelete(array $documentType, int $userId)
static getAvailableVisibility(array $parameterDocumentType)
static getObjectNameForExpressions()
static $allSortByVisibilityCache
static getVisibilityFullNames(array $parameterDocumentType)
static canUserUpsert(array $documentType, int $userId)
static getVisibilityShortNames(array $parameterDocumentType)
static upsert($id, $property, int $userId=null)
static clearStaticCache($cacheId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)