Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
settings.php
1<?php
2
4
5use Bitrix\Intranet\Settings\Tools\ToolsManager;
7
8final class Settings
9{
10 public const LIMIT_CODES = [
11 'workgroups' => 'limit_groups_off',
12 'projects' => 'limit_projects_off',
13 'scrum' => 'limit_tasks_scrum_off',
14 ];
15
16 public const TASKS_TOOLS = [
17 'base_tasks' => 'base_tasks',
18 'projects' => 'projects',
19 'scrum' => 'scrum',
20 'departments' => 'departments',
21 'effective' => 'effective',
22 'employee_plan' => 'employee_plan',
23 'report' => 'report',
24 ];
25
26 public const SONET_TOOLS = [
27 'news' => 'news',
28 'workgroups' => 'workgroups',
29 ];
30
31 public const CALENDAR_TOOLS = [
32 'calendar' => 'calendar',
33 ];
34
35 private function isAvailable(): bool
36 {
37 return Loader::includeModule('intranet') && class_exists(ToolsManager::class);
38 }
39
40 public function isGroupAvailableByType(bool $isProject, bool $isScrum): bool
41 {
42 return $this->isToolAvailable($this->getToolIdByType($isProject, $isScrum));
43 }
44
45 private function getToolIdByType(bool $isProject, bool $isScrum): string
46 {
47 if ($isScrum)
48 {
49 $toolId = self::TASKS_TOOLS['scrum'];
50 }
51 elseif ($isProject)
52 {
53 $toolId = self::TASKS_TOOLS['projects'];
54 }
55 else
56 {
57 $toolId = self::SONET_TOOLS['workgroups'];
58 }
59
60 return $toolId;
61 }
62
63 public function getGroupLimitCodeByType(bool $isProject, bool $isScrum): ?string
64 {
65 return self::LIMIT_CODES[$this->getToolIdByType($isProject, $isScrum)] ?? null;
66 }
67
68 public function isToolAvailable(string $tool): bool
69 {
70 $tools = array_merge(self::TASKS_TOOLS, self::SONET_TOOLS, self::CALENDAR_TOOLS);
71 if (!$this->isAvailable() || !array_key_exists($tool, $tools))
72 {
73 return true;
74 }
75
76 return ToolsManager::getInstance()->checkAvailabilityByToolId($tool);
77 }
78}
getGroupLimitCodeByType(bool $isProject, bool $isScrum)
Definition settings.php:63
isGroupAvailableByType(bool $isProject, bool $isScrum)
Definition settings.php:40