1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
userdataprovider.php
См. документацию.
1<?php
2namespace Bitrix\Main\Filter;
3
4use Bitrix\Main\Localization\Loc;
5use Bitrix\Main\Config\Option;
6use Bitrix\Main\Loader;
7use Bitrix\Main\ModuleManager;
8
10{
12 protected $settings = null;
13
15 {
16 $this->settings = $settings;
17 }
18
19 public static function extranetSite()
20 {
21 static $result = null;
22
23 if ($result === null)
24 {
25 $result = (
26 Loader::includeModule('extranet')
27 && \CExtranet::isExtranetSite()
28 );
29 }
30
31 return $result;
32 }
33
34 public static function getFiredAvailability(): bool
35 {
36 global $USER;
37
38 static $result = null;
39
40 if ($result === null)
41 {
42 $result = (
43 (
44 Option::get('bitrix24', 'show_fired_employees', 'Y') === 'Y'
45 || $USER->canDoOperation('edit_all_users')
46 )
48 );
49 }
50
51 return $result;
52 }
53
54 public static function getExtranetAvailability(): bool
55 {
56 static $result = null;
57
58 if ($result === null)
59 {
60 $result = (
62 && Option::get('extranet', 'extranet_site') !== ''
63 && method_exists(\Bitrix\Extranet\PortalSettings::class, 'isExtranetUsersAvailable')
64 && \Bitrix\Extranet\PortalSettings::getInstance()->isExtranetUsersAvailable()
65 );
66 }
67
68 return $result;
69 }
70
71 public static function getInvitedAvailability()
72 {
73 global $USER;
74
75 static $result = null;
76
77 if ($result === null)
78 {
79 $result = (
80 $USER->IsAuthorized()
81 && (
83 || Option::get("extranet", "extranet_site") == '' // master hasn't been run
84 || !self::extranetSite()
85 )
86 );
87 }
88
89 return $result;
90 }
91
92 public static function getIntegratorAvailability()
93 {
94 global $USER;
95
96 static $result = null;
97
98 if ($result === null)
99 {
100 $result = (
101 $USER->canDoOperation('edit_all_users')
103 && (
105 || (
106 Option::get("extranet", "extranet_site") <> ''
107 && !self::extranetSite()
108 )
109 )
110 );
111 }
112
113 return $result;
114 }
115
116 public static function getAdminAvailability()
117 {
118 global $USER;
119
120 static $result = null;
121
122 if ($result === null)
123 {
124 $result = (
125 $USER->canDoOperation('edit_all_users')
126 && (
128 || Option::get("extranet", "extranet_site", "") === ""
129 || !self::extranetSite()
130 )
131 );
132 }
133
134 return $result;
135 }
136
137 public static function getVisitorAvailability(): bool
138 {
139 global $USER;
140
141 static $result = null;
142
143 if ($result === null)
144 {
145 $result = (
146 $USER->canDoOperation('edit_all_users')
147 );
148 }
149
150 return $result;
151 }
152
156 public function getSettings()
157 {
158 return $this->settings;
159 }
160
166 protected function getFieldName($fieldID)
167 {
168 $name = Loc::getMessage("MAIN_USER_FILTER_{$fieldID}");
169
170 if($name === null)
171 {
172 $name = $fieldID;
173 }
174
175 return $name;
176 }
177
178 public function prepareFieldData($fieldID)
179 {
180 $result = null;
181
182 if ($fieldID === 'GENDER')
183 {
184 $result = [
185 'params' => ['multiple' => 'N'],
186 'items' => [
187 'F' => Loc::getMessage('MAIN_USER_FILTER_GENDER_F'),
188 'M' => Loc::getMessage('MAIN_USER_FILTER_GENDER_M')
189 ]
190 ];
191 }
192 elseif (in_array($fieldID, [ 'INTEGRATOR', 'ADMIN' ]))
193 {
194 $result = [
195 'params' => ['multiple' => 'N'],
196 'items' => [
197 'Y' => Loc::getMessage('MAIN_USER_FILTER_Y'),
198 ]
199 ];
200 }
201 elseif (
202 $fieldID === 'PERSONAL_COUNTRY'
203 || $fieldID === 'WORK_COUNTRY'
204 )
205 {
206 $countriesList = [];
207 $countries = getCountryArray();
208 foreach($countries['reference_id'] as $key => $countryId)
209 {
210 $countriesList[$countryId] = $countries['reference'][$key];
211 }
212
213 $result = [
214 'items' => $countriesList
215 ];
216 }
217 elseif (
218 $fieldID === 'DEPARTMENT'
219 || $fieldID === 'DEPARTMENT_FLAT'
220 )
221 {
222 return [
223 'params' => [
224 'apiVersion' => 3,
225 'context' => 'USER_LIST_FILTER_DEPARTMENT',
226 'multiple' => 'N',
227 'contextCode' => 'DR',
228 'enableDepartments' => 'Y',
229 'departmentFlatEnable' => ($fieldID === 'DEPARTMENT_FLAT' ? 'Y' : 'N'),
230 'enableAll' => 'N',
231 'enableUsers' => 'N',
232 'enableSonetgroups' => 'N',
233 'allowEmailInvitation' => 'N',
234 'allowSearchEmailUsers' => 'N',
235 'departmentSelectDisable' => 'N',
236 'isNumeric' => 'N',
237 ]
238 ];
239 }
240
241 return $result;
242 }
243
248 public function prepareFields()
249 {
250 $result = [];
251
252 $whiteList = $this->getSettings()->getWhiteList();
253
254 $fieldsList = [
255 'ID' => [],
256 'NAME' => [
257 'whiteList' => [ 'FULL_NAME', 'NAME' ]
258 ],
259 'LAST_NAME' => [
260 'whiteList' => [ 'FULL_NAME', 'LAST_NAME' ],
261 'options' => [ 'default' => true ]
262 ],
263 'SECOND_NAME' => [
264 'whiteList' => [ 'SECOND_NAME' ]
265 ],
266 'FIRED' => [
267// 'conditionMethod' => 'self::getFiredAvailability',
268 'options' => [ 'type' => 'checkbox' ]
269 ],
270 'EXTRANET' => [
271 'conditionMethod' => 'self::getExtranetAvailability',
272 'options' => [ 'type' => 'checkbox' ]
273 ],
274 'INVITED' => [
275 'conditionMethod' => 'self::getInvitedAvailability',
276 'options' => [ 'type' => 'checkbox' ]
277 ],
278 'VISITOR' => [
279 'conditionMethod' => 'self::getVisitorAvailability',
280 'options' => ['type' => 'checkbox']
281 ],
282 'INTEGRATOR' => [
283 'conditionMethod' => 'self::getIntegratorAvailability',
284 'options' => [ 'type' => 'list', 'partial' => true ]
285 ],
286 'ADMIN' => [
287 'conditionMethod' => 'self::getAdminAvailability',
288 'options' => [ 'type' => 'list', 'partial' => true ]
289 ],
290 'IS_ONLINE' => [
291 'options' => [ 'type' => 'checkbox' ]
292 ],
293 'DEPARTMENT' => [
294 'whiteList' => [ 'UF_DEPARTMENT' ],
295 'options' => [ 'default' => true, 'type' => 'dest_selector', 'partial' => true ]
296 ],
297 'DEPARTMENT_FLAT' => [
298 'whiteList' => [ 'UF_DEPARTMENT_FLAT' ],
299 'options' => [ 'type' => 'dest_selector', 'partial' => true ]
300 ],
301 'TAGS' => [
302 'whiteList' => [ 'TAGS' ],
303 'options' => [ 'default' => true ]
304 ],
305 'LOGIN' => [
306 'whiteList' => [ 'LOGIN' ]
307 ],
308 'EMAIL' => [
309 'whiteList' => [ 'EMAIL' ]
310 ],
311 'DATE_REGISTER' => [
312 'whiteList' => [ 'DATE_REGISTER' ],
313 'options' => [ 'type' => 'date' ]
314 ],
315 'LAST_ACTIVITY_DATE' => [
316 'whiteList' => [ 'LAST_ACTIVITY_DATE' ],
317 'options' => [ 'type' => 'date' ]
318 ],
319 'BIRTHDAY' => [
320 'whiteList' => [ 'PERSONAL_BIRTHDAY' ],
321 'options' => [ 'type' => 'date' ]
322 ],
323 'GENDER' => [
324 'whiteList' => [ 'PERSONAL_GENDER' ],
325 'options' => [ 'type' => 'list', 'partial' => true ]
326 ],
327 'PHONE_MOBILE' => [
328 'whiteList' => [ 'PERSONAL_MOBILE' ]
329 ],
330 'PERSONAL_CITY' => [
331 'whiteList' => [ 'PERSONAL_CITY' ]
332 ],
333 'PERSONAL_STREET' => [
334 'whiteList' => [ 'PERSONAL_STREET' ]
335 ],
336 'PERSONAL_STATE' => [
337 'whiteList' => [ 'PERSONAL_STATE' ]
338 ],
339 'PERSONAL_ZIP' => [
340 'whiteList' => [ 'PERSONAL_ZIP' ]
341 ],
342 'PERSONAL_MAILBOX' => [
343 'whiteList' => [ 'PERSONAL_MAILBOX' ]
344 ],
345 'PERSONAL_COUNTRY' => [
346 'whiteList' => [ 'PERSONAL_COUNTRY' ],
347 'options' => [ 'type' => 'list', 'partial' => true ]
348 ],
349 'WORK_CITY' => [
350 'whiteList' => [ 'WORK_CITY' ]
351 ],
352 'WORK_STREET' => [
353 'whiteList' => [ 'WORK_STREET' ]
354 ],
355 'WORK_STATE' => [
356 'whiteList' => [ 'WORK_STATE' ]
357 ],
358 'WORK_ZIP' => [
359 'whiteList' => [ 'WORK_ZIP' ]
360 ],
361 'WORK_MAILBOX' => [
362 'whiteList' => [ 'WORK_MAILBOX' ]
363 ],
364 'WORK_COUNTRY' => [
365 'whiteList' => [ 'WORK_COUNTRY' ],
366 'options' => [ 'type' => 'list', 'partial' => true ]
367 ],
368 'WORK_PHONE' => [
369 'whiteList' => [ 'WORK_PHONE' ]
370 ],
371 'POSITION' => [
372 'whiteList' => [ 'WORK_POSITION' ]
373 ],
374 'COMPANY' => [
375 'whiteList' => [ 'WORK_COMPANY' ]
376 ],
377 'WORK_DEPARTMENT' => [
378 'whiteList' => [ 'WORK_DEPARTMENT' ]
379 ],
380 ];
381
382 foreach($fieldsList as $column => $field)
383 {
384 $whiteListPassed = false;
385 if (
386 !empty($field['conditionMethod'])
387 && is_callable($field['conditionMethod'])
388 )
389 {
390 $whiteListPassed = call_user_func_array($field['conditionMethod'], []);
391 }
392 elseif (
393 empty($whiteList)
394 || empty($field['whiteList'])
395 )
396 {
397 $whiteListPassed = true;
398 }
399 else
400 {
401 foreach($field['whiteList'] as $whiteListField)
402 {
403 if (in_array($whiteListField, $whiteList))
404 {
405 $whiteListPassed = true;
406 break;
407 }
408 }
409 }
410
411 if ($whiteListPassed)
412 {
413 $result[$column] = $this->createField(
414 $column,
415 (!empty($field['options']) ? $field['options'] : [])
416 );
417 }
418 }
419
420 return $result;
421 }
422
423}
createField($fieldID, array $params=null)
Определения entitydataprovider.php:26
static getIntegratorAvailability()
Определения userdataprovider.php:92
static getInvitedAvailability()
Определения userdataprovider.php:71
__construct(UserSettings $settings)
Определения userdataprovider.php:14
static getExtranetAvailability()
Определения userdataprovider.php:54
static includeModule($moduleName)
Определения loader.php:67
static isModuleInstalled($moduleName)
Определения modulemanager.php:125
$result
Определения get_property_values.php:14
global $USER
Определения csv_new_run.php:40
$name
Определения menu_edit.php:35
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257