Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
projectrolesprovider.php
1
<?php
2
namespace
Bitrix\SocialNetwork\Integration\UI\EntitySelector
;
3
4
use
Bitrix\Socialnetwork\Item\Workgroup
;
5
use
Bitrix\Main\Localization\Loc
;
6
use
Bitrix\UI\EntitySelector\BaseProvider
;
7
use
Bitrix\UI\EntitySelector\Dialog
;
8
use
Bitrix\UI\EntitySelector\Item
;
9
use
Bitrix\UI\EntitySelector\RecentItem
;
10
use
Bitrix\UI\EntitySelector\Tab
;
11
17
class
ProjectRolesProvider
extends
BaseProvider
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
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\SocialNetwork\Integration\UI\EntitySelector\ProjectRolesProvider
Definition
projectrolesprovider.php:18
Bitrix\SocialNetwork\Integration\UI\EntitySelector\ProjectRolesProvider\__construct
__construct(array $options=[])
Definition
projectrolesprovider.php:21
Bitrix\SocialNetwork\Integration\UI\EntitySelector\ProjectRolesProvider\fillDialog
fillDialog(Dialog $dialog)
Definition
projectrolesprovider.php:43
Bitrix\SocialNetwork\Integration\UI\EntitySelector\ProjectRolesProvider\getSelectedItems
getSelectedItems(array $ids)
Definition
projectrolesprovider.php:38
Bitrix\SocialNetwork\Integration\UI\EntitySelector\ProjectRolesProvider\getItems
getItems(array $ids)
Definition
projectrolesprovider.php:33
Bitrix\SocialNetwork\Integration\UI\EntitySelector\ProjectRolesProvider\isAvailable
isAvailable()
Definition
projectrolesprovider.php:28
Bitrix\Socialnetwork\Item\Workgroup\getById
static getById($groupId=0, $useCache=true)
Definition
workgroup.php:42
Bitrix\UI\EntitySelector\BaseProvider
Definition
baseprovider.php:5
Bitrix\UI\EntitySelector\BaseProvider\$options
$options
Definition
baseprovider.php:6
Bitrix\UI\EntitySelector\BaseProvider\getOption
getOption(string $option, $defaultValue=null)
Definition
baseprovider.php:48
Bitrix\UI\EntitySelector\Dialog
Definition
dialog.php:10
Bitrix\UI\EntitySelector\Dialog\addItems
addItems(array $items)
Definition
dialog.php:121
Bitrix\UI\EntitySelector\Dialog\addTab
addTab(Tab $tab)
Definition
dialog.php:235
Bitrix\UI\EntitySelector\Item
Definition
item.php:8
Bitrix\UI\EntitySelector\RecentItem
Definition
recentitem.php:6
Bitrix\UI\EntitySelector\Tab
Definition
tab.php:5
Bitrix\SocialNetwork\Integration\UI\EntitySelector
Definition
projectrolesprovider.php:2
Bitrix\Socialnetwork\Item\Workgroup
Definition
accessmanager.php:9
modules
socialnetwork
lib
integration
ui
entityselector
projectrolesprovider.php
Создано системой
1.10.0