Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
usertogroupdataprovider.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Filter
;
4
5
use
Bitrix\Main\Loader
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Main\ModuleManager
;
8
use
Bitrix\Socialnetwork\UserToGroupTable
;
9
10
class
UserToGroupDataProvider
extends
\Bitrix\Main\Filter\EntityDataProvider
11
{
13
protected
$settings
;
14
15
public
function
__construct
(
UserToGroupSettings
$settings
)
16
{
17
$this->settings =
$settings
;
18
}
19
24
public
function
getSettings
(): ?
UserToGroupSettings
25
{
26
return
$this->settings
;
27
}
28
34
protected
function
getFieldName
($fieldID): string
35
{
36
$name =
Loc::getMessage
(
"SOCIALNETWORK_USERTOGROUP_FILTER_{$fieldID}"
);
37
38
if
($name ===
null
)
39
{
40
$name = $fieldID;
41
}
42
43
return
$name;
44
}
45
46
public
function
prepareFieldData
($fieldID): ?array
47
{
48
$result =
null
;
49
50
if
($fieldID ===
'ROLE'
)
51
{
52
$roles = [
53
UserToGroupTable::ROLE_OWNER
=>
Loc::getMessage
(
'SOCIALNETWORK_USERTOGROUP_FILTER_ROLE_OWNER'
),
54
UserToGroupTable::ROLE_MODERATOR
=>
Loc::getMessage
(
'SOCIALNETWORK_USERTOGROUP_FILTER_ROLE_MODERATOR'
),
55
UserToGroupTable::ROLE_USER
=>
Loc::getMessage
(
'SOCIALNETWORK_USERTOGROUP_FILTER_ROLE_USER'
),
56
UserToGroupTable::ROLE_REQUEST
=>
Loc::getMessage
(
'SOCIALNETWORK_USERTOGROUP_FILTER_ROLE_REQUEST'
),
57
];
58
$result = [
59
'params'
=> [
'multiple'
=>
'Y'
],
60
'items'
=> $roles
61
];
62
}
63
elseif ($fieldID ===
'INITIATED_BY_TYPE'
)
64
{
65
$result = [
66
'params'
=> [
'multiple'
=>
'N'
],
67
'items'
=> [
68
UserToGroupTable::INITIATED_BY_USER
=>
Loc::getMessage
(
'SOCIALNETWORK_USERTOGROUP_FILTER_INITIATED_BY_USER'
),
69
UserToGroupTable::INITIATED_BY_GROUP
=>
Loc::getMessage
(
'SOCIALNETWORK_USERTOGROUP_FILTER_INITIATED_BY_GROUP'
),
70
]
71
];
72
}
73
elseif (
74
$fieldID ===
'DEPARTMENT'
75
|| $fieldID ===
'DEPARTMENT_FLAT'
76
)
77
{
78
return
[
79
'params'
=> [
80
'apiVersion'
=> 3,
81
'context'
=>
'USERTOGROUP_LIST_FILTER_DEPARTMENT'
,
82
'multiple'
=>
'N'
,
83
'contextCode'
=>
'DR'
,
84
'enableDepartments'
=>
'Y'
,
85
'departmentFlatEnable'
=> ($fieldID ===
'DEPARTMENT_FLAT'
?
'Y'
:
'N'
),
86
'enableAll'
=>
'N'
,
87
'enableUsers'
=>
'N'
,
88
'enableSonetgroups'
=>
'N'
,
89
'allowEmailInvitation'
=>
'N'
,
90
'allowSearchEmailUsers'
=>
'N'
,
91
'departmentSelectDisable'
=>
'N'
,
92
'isNumeric'
=>
'N'
,
93
],
94
];
95
}
96
97
return
$result;
98
}
99
104
public
function
prepareFields
(): array
105
{
106
$result = [];
107
108
$fieldsList = [
109
'ID'
=> [],
110
'NAME'
=> [],
111
'LAST_NAME'
=> [
112
'options'
=> [
'default'
=> true ],
113
],
114
'FIRED'
=> [
115
'conditionMethod'
=>
'\Bitrix\Main\Filter\UserDataProvider::getFiredAvailability'
,
116
'options'
=> [
'type'
=>
'checkbox'
]
117
],
118
'EXTRANET'
=> [
119
'conditionMethod'
=>
'\Bitrix\Main\Filter\UserDataProvider::getExtranetAvailability'
,
120
'options'
=> [
'type'
=>
'checkbox'
],
121
],
122
'ROLE'
=> [
123
'options'
=> [
'default'
=>
true
,
'type'
=>
'list'
,
'partial'
=> true ],
124
],
125
'INITIATED_BY_TYPE'
=> [
126
'options'
=> [
'type'
=>
'list'
,
'partial'
=> true ],
127
],
128
'EMAIL'
=> [],
129
'DEPARTMENT'
=> [
130
'options'
=> [
'default'
=>
true
,
'type'
=>
'dest_selector'
,
'partial'
=> true ],
131
],
132
'DEPARTMENT_FLAT'
=> [
133
'options'
=> [
'type'
=>
'dest_selector'
,
'partial'
=> true ],
134
],
135
'AUTO_MEMBER'
=> [
136
'conditionMethod'
=>
'\Bitrix\Socialnetwork\Filter\UserToGroupDataProvider::getAutoMemberAvailability'
,
137
'options'
=> [
'type'
=>
'checkbox'
]
138
],
139
140
];
141
142
foreach
($fieldsList as $column => $field)
143
{
144
$whiteListPassed =
true
;
145
if
(
146
!empty($field[
'conditionMethod'
])
147
&& is_callable($field[
'conditionMethod'
])
148
)
149
{
150
$whiteListPassed = call_user_func_array($field[
'conditionMethod'
], []);
151
}
152
153
if
($whiteListPassed)
154
{
155
$result[$column] = $this->
createField
(
156
$column,
157
(!empty($field[
'options'
]) ? $field[
'options'
] : [])
158
);
159
}
160
}
161
162
return
$result;
163
}
164
165
public
static
function
getAutoMemberAvailability
(): bool
166
{
167
static
$result =
null
;
168
169
if
($result ===
null
)
170
{
171
$result = (
172
ModuleManager::isModuleInstalled(
'intranet'
)
173
&& (
174
!Loader::includeModule(
'extranet'
)
175
|| !\CExtranet::isExtranetSite()
176
)
177
);
178
}
179
180
return
$result;
181
}
182
183
}
Bitrix\Main\Filter\EntityDataProvider
Definition
entitydataprovider.php:7
Bitrix\Main\Filter\EntityDataProvider\createField
createField($fieldID, array $params=null)
Definition
entitydataprovider.php:25
Bitrix\Main\Loader
Definition
loader.php:12
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\Main\ModuleManager
Definition
modulemanager.php:5
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider
Definition
usertogroupdataprovider.php:11
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\prepareFieldData
prepareFieldData($fieldID)
Definition
usertogroupdataprovider.php:46
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\getAutoMemberAvailability
static getAutoMemberAvailability()
Definition
usertogroupdataprovider.php:165
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\getFieldName
getFieldName($fieldID)
Definition
usertogroupdataprovider.php:34
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\$settings
$settings
Definition
usertogroupdataprovider.php:13
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\__construct
__construct(UserToGroupSettings $settings)
Definition
usertogroupdataprovider.php:15
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\getSettings
getSettings()
Definition
usertogroupdataprovider.php:24
Bitrix\Socialnetwork\Filter\UserToGroupDataProvider\prepareFields
prepareFields()
Definition
usertogroupdataprovider.php:104
Bitrix\Socialnetwork\Filter\UserToGroupSettings
Definition
usertogroupsettings.php:6
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\INITIATED_BY_USER
const INITIATED_BY_USER
Definition
usertogroup.php:40
Bitrix\Socialnetwork\UserToGroupTable\ROLE_MODERATOR
const ROLE_MODERATOR
Definition
usertogroup.php:35
Bitrix\Socialnetwork\UserToGroupTable\ROLE_OWNER
const ROLE_OWNER
Definition
usertogroup.php:34
Bitrix\Socialnetwork\Filter
Definition
factorysocialnetwork.php:3
modules
socialnetwork
lib
filter
usertogroupdataprovider.php
Создано системой
1.10.0