1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Department.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\Configuration;
4
5use Bitrix\Main\Loader;
6
8{
10 private $id;
11
12 public function __construct(int $id = 0)
13 {
14 if ($id > 0)
15 {
16 $this->id = $id;
17 }
18 }
19
23 public function setId(int $id): void
24 {
25 $this->id = $id;
26 }
27
33 {
34 $departmentTree = \CIntranetUtils::GetDeparmentsTree(0);
35 $topDepartmentId = self::getTopDepartmentId();
36
37 if (!$topDepartmentId || empty($departmentTree) || !$this->id)
38 {
39 return [];
40 }
41
42 $path[] = $this->id;
43 $departmentId = $this->id;
44
45 while ($departmentId && $departmentId != $topDepartmentId)
46 {
47 $departmentId = $this->getHeadDepartmentId($departmentId, $departmentTree) ?? $topDepartmentId;
48 $path[] = $departmentId;
49 }
50
51 return array_reverse($path);
52 }
53
60 protected function getHeadDepartmentId(int $curId, array $departmentTree): ?int
61 {
62 foreach ($departmentTree as $headDepartmentId => $subDepartments)
63 {
64 foreach ($subDepartments as $subDepartmentId)
65 {
66 if ((int)$subDepartmentId == $curId)
67 {
68 return (int)$headDepartmentId;
69 }
70 }
71 }
72
73 return null;
74 }
75
81 public function getAccessCodes(array $departmentIds): array
82 {
83 $accessCodes = [];
84 foreach ($departmentIds as $departmentId)
85 {
86 if ((int)$departmentId === $this->id)
87 {
88 $accessCodes[] = 'D' . $this->id;
89 $accessCodes[] = 'DR' . $this->id;
90 }
91 else
92 {
93 $accessCodes[] = 'DR' . $departmentId;
94 }
95 }
96 return $accessCodes;
97 }
98
102 public static function getTopDepartmentId(): false|int
103 {
105
106 return $topId ?? false;
107 }
108}
$path
Определения access_edit.php:21
getAccessCodes(array $departmentIds)
Определения Department.php:81
__construct(int $id=0)
Определения Department.php:12
getHeadDepartmentId(int $curId, array $departmentTree)
Определения Department.php:60
static getTopDepartmentId()
Определения Department.php:102
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
return false
Определения prolog_main_admin.php:185