1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
toolsmanager.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Integration\Intranet;
4
5use Bitrix\Intranet\Settings\Tools;
6use Bitrix\Main\Loader;
7
8final class ToolsManager
9{
10 private static ?ToolsManager $instance = null;
11 private bool $canUseIntranetToolsManager;
12
13 private const AUTOMATION_TOOL_ID = 'automation';
14 private const BIZPROC_TOOL_ID = 'bizproc';
15 private const ROBOTS_TOOL_ID = 'robots';
16 private const SCRIPTS_TOOL_ID = 'bizproc_script';
17
18 public static function getInstance(): self
19 {
20 if (self::$instance === null)
21 {
22 self::$instance = new self();
23 }
24
25 return self::$instance;
26 }
27
28 public function __construct()
29 {
30 $this->canUseIntranetToolsManager = (
31 Loader::includeModule('intranet')
32 && class_exists(\Bitrix\Intranet\Settings\Tools\ToolsManager::class)
33 );
34 }
35
36 public function isAutomationAvailable(): bool
37 {
38 return $this->check(self::AUTOMATION_TOOL_ID);
39 }
40
41 public function isBizprocAvailable(): bool
42 {
43 return $this->check(self::BIZPROC_TOOL_ID) && $this->isAutomationAvailable();
44 }
45
46 public function isRobotsAvailable(): bool
47 {
48 return $this->check(self::ROBOTS_TOOL_ID) && $this->isAutomationAvailable();
49 }
50
51 public function isScriptsAvailable(): bool
52 {
53 return $this->check(self::SCRIPTS_TOOL_ID) && $this->isAutomationAvailable();
54 }
55
57 {
58 ob_start();
59 global $APPLICATION;
60 $APPLICATION->IncludeComponent(
61 'bitrix:intranet.tool.inaccessibility',
62 '',
63 [
64 'SLIDER_CODE' => 'limit_automation_off',
65 ],
66 );
67
68 return ob_get_clean();
69 }
70
72 {
73 return 'limit_automation_off';
74 }
75
77 {
78 return 'limit_crm_rules_off';
79 }
80
81 private function check(string $toolId): bool
82 {
83 if ($this->canUseIntranetToolsManager)
84 {
85 return Tools\ToolsManager::getInstance()->checkAvailabilityByToolId($toolId);
86 }
87
88 return true;
89 }
90}
global $APPLICATION
Определения include.php:80