Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
role.php
1
<?php
2
10
namespace
Bitrix\Socialnetwork\Helper\UI\Grid\Workgroup
;
11
12
use
Bitrix\Socialnetwork\Component\WorkgroupList
;
13
use
Bitrix\Socialnetwork\UserToGroupTable
;
14
use
Bitrix\Main\Localization\Loc
;
15
16
Loc::loadMessages
(__FILE__);
17
18
class
Role
19
{
20
public
static
function
getRoleValue
(array $params = []): string
21
{
22
$result =
''
;
23
24
$relationFields = ($params[
'RELATION'
] ?? []);
25
if
(empty($relationFields))
26
{
27
return
$result;
28
}
29
30
$groupFields = ($params[
'GROUP'
] ?? []);
31
if
($groupFields[
'SCRUM_MASTER_ID'
] > 0)
32
{
33
$suffix =
'_SCRUM'
;
34
}
35
elseif ($groupFields[
'PROJECT'
])
36
{
37
$suffix =
'_PROJECT'
;
38
}
39
else
40
{
41
$suffix =
''
;
42
}
43
44
$role = $relationFields[
'ROLE'
];
45
46
$classList = [
'ui-label'
];
47
48
if
(in_array($role,
UserToGroupTable::getRolesMember
(),
true
))
49
{
50
$classList[] =
'sonet-ui-grid-role'
;
51
52
$isScrumMaster = (int)$relationFields[
'USER_ID'
] === (
int
)$groupFields[
'SCRUM_MASTER_ID'
];
53
54
$parts = [];
55
56
if
(!(
57
$isScrumMaster
58
&& $role ===
UserToGroupTable::ROLE_MODERATOR
59
&& $relationFields[
'AUTO_MEMBER'
] ===
false
60
))
61
{
62
$parts = [
63
Loc::getMessage
(
64
'SOCIALNETWORK_HELPER_UI_GRID_ROLE_'
. $role
65
. $suffix
66
. ($relationFields[
'AUTO_MEMBER'
] ?
'_AUTO'
:
''
)
67
),
68
];
69
}
70
71
if
($isScrumMaster)
72
{
73
$parts[] =
Loc::getMessage
(
'SOCIALNETWORK_HELPER_UI_GRID_ROLE_SCRUM_MASTER'
);
74
}
75
76
$result = implode(
', '
, $parts);
77
78
switch
($role)
79
{
80
case
UserToGroupTable::ROLE_OWNER
:
81
$classList[] =
'--role-green'
;
82
break
;
83
case
UserToGroupTable::ROLE_MODERATOR
:
84
$classList[] =
'--role-yellow'
;
85
break
;
86
case
UserToGroupTable::ROLE_USER
:
87
$classList[] =
'--role-blue'
;
88
break
;
89
default
:
90
}
91
}
92
elseif ($role ===
UserToGroupTable::ROLE_REQUEST
)
93
{
94
$groupId = (int) $groupFields[
'ID'
];
95
$gridId = ($params[
'GRID_ID'
] ??
'SONET_GROUP_LIST'
);
96
$type = $relationFields[
'INITIATED_TYPE'
];
97
$onclick =
'event.stopPropagation();'
;
98
99
if
($type ===
UserToGroupTable::INITIATED_BY_GROUP
)
100
{
101
$acceptOnclick = $onclick .
'BX.Socialnetwork.WorkgroupList.Manager.getById(\''
102
. $gridId .
'\'
).getActionManager().act({action: \
''
103
.
WorkgroupList::AJAX_ACTION_JOIN
104
.
'\'
,groupId: \
''
. $groupId .
'\'
,});
';
105
106
$cancelOnclick = $onclick . '
BX
.Socialnetwork.WorkgroupList.Manager.getById(\
''
107
. $gridId .
'\'
).getActionManager().act({action: \
''
108
.
WorkgroupList::AJAX_ACTION_REJECT_OUTGOING_REQUEST
109
.
'\'
,groupId: \
''
. $groupId .
'\'
,});
';
110
111
return '
112
<span
class
=
"sonet-ui-grid-badge-invite-box"
>
113
<span
class
=
"ui-label sonet-ui-grid-badge-invite-accept"
>
114
<span
class
=
"ui-label-inner"
>
115
' . Loc::getMessage('
SOCIALNETWORK_HELPER_UI_GRID_ROLE_REQUEST_
' . $type) . '
116
</span>
117
</span>
118
<span
119
class
=
"ui-label sonet-ui-grid-badge-accept"
120
onclick=
"'. $acceptOnclick .'"
121
title=
"' . Loc::getMessage('SOCIALNETWORK_HELPER_UI_GRID_ROLE_JOIN') . '"
122
>
123
<span
class
=
"ui-label-inner"
></span>
124
</span>
125
<span
126
class
=
"ui-label sonet-ui-grid-badge-cancel"
127
onclick=
"'. $cancelOnclick .'"
128
title=
"' . Loc::getMessage('SOCIALNETWORK_HELPER_UI_GRID_ROLE_DELETE_OUTGOING_REQUEST') . '"
129
>
130
<span
class
=
"ui-label-inner"
></span>
131
</span>
132
</span>
133
';
134
}
135
elseif ($type === UserToGroupTable::INITIATED_BY_USER)
136
{
137
$onclick .= '
BX
.Socialnetwork.WorkgroupList.Manager.getById(\
''
138
. $gridId .
'\'
).getActionManager().act({action: \
''
139
.
WorkgroupList::AJAX_ACTION_DELETE_INCOMING_REQUEST
140
.
'\'
,groupId: \
''
. $groupId .
'\'
,});
';
141
142
return '
143
<span
class
=
"sonet-ui-grid-badge-invite-box"
>
144
<span
class
=
"ui-label sonet-ui-grid-badge-invite"
>
145
<span
class
=
"ui-label-inner"
>
146
' . Loc::getMessage('
SOCIALNETWORK_HELPER_UI_GRID_ROLE_REQUEST_
' . $type) . '
147
</span>
148
</span>
149
<span
150
class
=
"ui-label sonet-ui-grid-badge-cancel"
151
onclick=
"'. $onclick .'"
152
title=
"' . Loc::getMessage('SOCIALNETWORK_HELPER_UI_GRID_ROLE_DELETE_INCOMING_REQUEST') . '"
153
>
154
<span
class
=
"ui-label-inner"
></span>
155
</span>
156
</span>
157
';
158
}
159
}
160
elseif ($role === UserToGroupTable::ROLE_BAN)
161
{
162
$result = Loc::getMessage('
SOCIALNETWORK_HELPER_UI_GRID_ROLE_BAN
');
163
}
164
165
$result = '
166
<span
class
=
"' . implode(' ', $classList) . '"
>
167
<span
class
=
"ui-label-inner"
>
' . $result . '
</span>
168
</span>
169
';
170
171
return '
<span
class
=
"sonet-ui-grid-request-cont"
>
' . $result . '
</span>
';
172
}
173
174
public static function getJoinValue(array $params = []): string
175
{
176
$classList = [
177
'
ui-label
',
178
'
sonet-ui-grid-join
',
179
];
180
181
$result = Loc::getMessage('
SOCIALNETWORK_HELPER_UI_GRID_ROLE_JOIN
');
182
183
if (
184
isset($params['
OPENED
'])
185
&& $params['
OPENED
'] === true
186
)
187
{
188
$result = '
<span onclick=
"' . htmlspecialcharsbx($params['ONCLICK']) . '"
class
=
"' . implode(' ', $classList) . '"
><span
class
=
"ui-label-inner"
>
' . $result . '
</span></span>
';
189
}
190
else
191
{
192
$result = '
<a href=
"'. $params['PATH_TO_JOIN_GROUP'] . '"
class
=
"' . implode(' ', $classList) . '"
><span
class
=
"ui-label-inner"
>
' . $result . '
</span></a>
';
193
}
194
195
196
return '
<span
class
=
"sonet-ui-grid-request-cont"
>
' . $result . '
</span>
';
197
}
198
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Socialnetwork\Component\WorkgroupList\AJAX_ACTION_DELETE_INCOMING_REQUEST
const AJAX_ACTION_DELETE_INCOMING_REQUEST
Definition
workgrouplist.php:31
Bitrix\Socialnetwork\Component\WorkgroupList\AJAX_ACTION_REJECT_OUTGOING_REQUEST
const AJAX_ACTION_REJECT_OUTGOING_REQUEST
Definition
workgrouplist.php:32
Bitrix\Socialnetwork\Component\WorkgroupList\AJAX_ACTION_JOIN
const AJAX_ACTION_JOIN
Definition
workgrouplist.php:29
Bitrix\Socialnetwork\Helper\UI\Grid\Workgroup\Role
Definition
role.php:19
Bitrix\Socialnetwork\Helper\UI\Grid\Workgroup\Role\getRoleValue
static getRoleValue(array $params=[])
Definition
role.php:20
Bitrix\Socialnetwork\UserToGroupTable
Definition
usertogroup.php:33
Bitrix\Socialnetwork\UserToGroupTable\ROLE_USER
const ROLE_USER
Definition
usertogroup.php:36
Bitrix\Socialnetwork\UserToGroupTable\ROLE_REQUEST
const ROLE_REQUEST
Definition
usertogroup.php:38
Bitrix\Socialnetwork\UserToGroupTable\INITIATED_BY_GROUP
const INITIATED_BY_GROUP
Definition
usertogroup.php:41
Bitrix\Socialnetwork\UserToGroupTable\ROLE_MODERATOR
const ROLE_MODERATOR
Definition
usertogroup.php:35
Bitrix\Socialnetwork\UserToGroupTable\getRolesMember
static getRolesMember()
Definition
usertogroup.php:73
Bitrix\Socialnetwork\UserToGroupTable\ROLE_OWNER
const ROLE_OWNER
Definition
usertogroup.php:34
BX
Bitrix\Socialnetwork\Component\WorkgroupList
Definition
counter.php:3
Bitrix\Socialnetwork\Helper\UI\Grid\Workgroup
Definition
actions.php:10
modules
socialnetwork
lib
helper
ui
grid
workgroup
role.php
Создано системой
1.10.0