Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
projectrolesprovider.php
1<?php
3
11
18{
19 private $entityId = 'project-roles';
20
21 public function __construct(array $options = [])
22 {
23 parent::__construct();
24
25 $this->options['projectId'] = $options['projectId'];
26 }
27
28 public function isAvailable(): bool
29 {
30 return $GLOBALS['USER']->isAuthorized();
31 }
32
33 public function getItems(array $ids): array
34 {
35 return [];
36 }
37
38 public function getSelectedItems(array $ids): array
39 {
40 return [];
41 }
42
43 public function fillDialog(Dialog $dialog): void
44 {
45 $groupId = $this->getOption('projectId');
46
47 $group = Workgroup::getById($groupId);
48
49 if ($group && $group->isScrumProject())
50 {
51 $dialog->addItems($this->makeScrumRoles());
52 }
53 else
54 {
55 $dialog->addItems($this->makeRoles());
56 }
57
58 $dialog->addTab(new Tab([
59 'id' => $this->entityId,
60 'title' => Loc::getMessage('SES_PROJECT_ROLES_TAB_TITLE'),
61 'stub' => true
62 ]));
63 }
64
65 private function makeScrumRoles(): array
66 {
67 $roles = [];
68
69 $projectId = $this->getOption('projectId');
70
71 $roles[] = new Item(
72 [
73 'id' => $projectId . '_' . SONET_ROLES_OWNER,
74 'entityId' => $this->entityId,
75 'entityType' => 'role',
76 'title' => Loc::getMessage('SES_PROJECT_SCRUM_OWNER_ROLE'),
77 'tabs' => ['project-roles']
78 ]
79 );
80
81 $roles[] = new Item(
82 [
83 'id' => $projectId . '_M',
84 'entityId' => $this->entityId,
85 'entityType' => 'role',
86 'title' => Loc::getMessage('SES_PROJECT_SCRUM_MASTER_ROLE'),
87 'tabs' => ['project-roles']
88 ]
89 );
90
91 $roles[] = new Item(
92 [
93 'id' => $projectId . '_' . SONET_ROLES_MODERATOR,
94 'entityId' => $this->entityId,
95 'entityType' => 'role',
96 'title' => Loc::getMessage('SES_PROJECT_SCRUM_MODERATOR_ROLE'),
97 'tabs' => ['project-roles']
98 ]
99 );
100
101 $roles[] = new Item(
102 [
103 'id' => $projectId . '_' . SONET_ROLES_USER,
104 'entityId' => $this->entityId,
105 'entityType' => 'role',
106 'title' => Loc::getMessage('SES_PROJECT_SCRUM_EMPLOYER_ROLE'),
107 'tabs' => ['project-roles']
108 ]
109 );
110
111 return $roles;
112 }
113
114 private function makeRoles(): array
115 {
116 $roles = [];
117
118 $projectId = $this->getOption('projectId');
119
120 $roles[] = new Item(
121 [
122 'id' => $projectId . '_' . SONET_ROLES_OWNER,
123 'entityId' => $this->entityId,
124 'entityType' => 'role',
125 'title' => Loc::getMessage('SES_PROJECT_OWNER_ROLE'),
126 'tabs' => ['project-roles']
127 ]
128 );
129
130 $roles[] = new Item(
131 [
132 'id' => $projectId . '_' . SONET_ROLES_MODERATOR,
133 'entityId' => $this->entityId,
134 'entityType' => 'role',
135 'title' => Loc::getMessage('SES_PROJECT_MODERATOR_ROLE'),
136 'tabs' => ['project-roles']
137 ]
138 );
139
140 $roles[] = new Item(
141 [
142 'id' => $projectId . '_' . SONET_ROLES_USER,
143 'entityId' => $this->entityId,
144 'entityType' => 'role',
145 'title' => Loc::getMessage('SES_PROJECT_EMPLOYER_ROLE'),
146 'tabs' => ['project-roles']
147 ]
148 );
149
150 return $roles;
151 }
152}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getById($groupId=0, $useCache=true)
Definition workgroup.php:42
getOption(string $option, $defaultValue=null)