1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
log_destination.php
См. документацию.
1<?php
2
7use Bitrix\Socialnetwork\Item\Workgroup\Type;
9
11{
12 const LIST_USER_LIMIT = 11;
13
14 private const USERS_STEP_COUNT = 500;
15
20 public static function GetLastUser()
21 {
22 static $resultCache = array();
23
24 $userId = intval(CurrentUser::get()->getId());
25
26 if(!isset($resultCache[$userId]))
27 {
28 $arLastSelected = CUserOptions::GetOption("socialnetwork", "log_destination", array());
29 $arLastSelected = (
30 is_array($arLastSelected)
31 && $arLastSelected['users'] <> ''
32 && $arLastSelected['users'] !== '"{}"'
33 ? array_reverse(CUtil::JsObjectToPhp($arLastSelected['users']))
34 : array()
35 );
36
37 if (is_array($arLastSelected))
38 {
39 if (!isset($arLastSelected[$userId]))
40 {
41 $arLastSelected['U'.$userId] = 'U'.$userId;
42 }
43 }
44 else
45 {
46 $arLastSelected['U'.$userId] = 'U'.$userId;
47 }
48
49 $count = 0;
50 $arUsers = Array();
51 foreach ($arLastSelected as $userId)
52 {
53 if ($count < 5)
54 {
55 $count++;
56 }
57 else
58 {
59 break;
60 }
61
62 $arUsers[$userId] = $userId;
63 }
64 $resultCache[$userId] = array_reverse($arUsers);
65 }
66
67 return $resultCache[$userId];
68 }
69
74 public static function GetLastSocnetGroup()
75 {
76 $arLastSelected = CUserOptions::GetOption("socialnetwork", "log_destination", array());
77 $arLastSelected = (
78 is_array($arLastSelected)
79 && $arLastSelected['sonetgroups'] <> ''
80 && $arLastSelected['sonetgroups'] !== '"{}"'
81 ? array_reverse(CUtil::JsObjectToPhp($arLastSelected['sonetgroups']))
82 : array()
83 );
84
85 $count = 0;
86 $arSocnetGroups = Array();
87 foreach ($arLastSelected as $sgId)
88 {
89 if ($count <= 4)
90 {
91 $count++;
92 }
93 else
94 {
95 break;
96 }
97
98 $arSocnetGroups[$sgId] = $sgId;
99 }
100 return array_reverse($arSocnetGroups);
101 }
102
107 public static function GetLastDepartment()
108 {
109 $arLastSelected = CUserOptions::GetOption("socialnetwork", "log_destination", array());
110 $arLastSelected = (
111 is_array($arLastSelected)
112 && $arLastSelected['department'] <> ''
113 && $arLastSelected['department'] !== '"{}"'
114 ? array_reverse(CUtil::JsObjectToPhp($arLastSelected['department']))
115 : array()
116 );
117
118 $count = 0;
119 $arDepartment = Array();
120 foreach ($arLastSelected as $depId)
121 {
122 if ($count < 4)
123 {
124 $count++;
125 }
126 else
127 {
128 break;
129 }
130
131 $arDepartment[$depId] = $depId;
132 }
133
134 return array_reverse($arDepartment);
135 }
136
137 public static function GetStucture($arParams = Array())
138 {
139 $bIntranetEnabled = false;
140 if(
141 IsModuleInstalled('intranet')
142 && IsModuleInstalled('iblock')
143 )
144 {
145 $bIntranetEnabled = true;
146 }
147
148 $result = array(
149 "department" => array(),
150 "department_relation" => array(),
151 "department_relation_head" => array(),
152 );
153
154 $department_id = (
155 isset($arParams["DEPARTMENT_ID"])
156 && intval($arParams["DEPARTMENT_ID"]) > 0
157 ? intval($arParams["DEPARTMENT_ID"])
158 : false
159 );
160
161 if($bIntranetEnabled)
162 {
163 if (!(CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()))
164 {
165 if(($iblock_id = COption::GetOptionInt('intranet', 'iblock_structure', 0)) > 0)
166 {
167 global $CACHE_MANAGER;
168
169 $ttl = (
170 defined("BX_COMP_MANAGED_CACHE")
171 ? 2592000
172 : 600
173 );
174
175 $cache_id = 'sonet_structure_new4_'.$iblock_id.(intval($department_id) > 0 ? "_".$department_id : "");
176 $obCache = new CPHPCache;
177 $cache_dir = '/sonet/structure';
178
179 if($obCache->InitCache($ttl, $cache_id, $cache_dir))
180 {
181 $result = $obCache->GetVars();
182 }
183 else
184 {
185 CModule::IncludeModule('iblock');
186
187 if(defined("BX_COMP_MANAGED_CACHE"))
188 {
189 $CACHE_MANAGER->StartTagCache($cache_dir);
190 }
191
193 "IBLOCK_ID" => $iblock_id,
194 "ACTIVE" => "Y"
195 );
196
197 if (intval($department_id) > 0)
198 {
199 $rsSectionDepartment = CIBlockSection::GetList(
200 array(),
201 array(
202 "ID" => intval($department_id)
203 ),
204 false,
205 array("ID", "LEFT_MARGIN", "RIGHT_MARGIN")
206 );
207
208 if ($arSectionDepartment = $rsSectionDepartment->Fetch())
209 {
210 $arFilter[">=LEFT_MARGIN"] = $arSectionDepartment["LEFT_MARGIN"];
211 $arFilter["<=RIGHT_MARGIN"] = $arSectionDepartment["RIGHT_MARGIN"];
212 }
213 }
214
215 $dbRes = CIBlockSection::GetList(
216 array("left_margin"=>"asc"),
217 $arFilter,
218 false,
219 array("ID", "IBLOCK_SECTION_ID", "NAME")
220 );
221 while ($ar = $dbRes->Fetch())
222 {
223 $result["department"]['DR'.$ar['ID']] = array(
224 'id' => 'DR'.$ar['ID'],
225 'entityId' => $ar["ID"],
226 'name' => htmlspecialcharsbx($ar['NAME']),
227 'parent' => 'DR'.intval($ar['IBLOCK_SECTION_ID']),
228 );
229 }
230 if(defined("BX_COMP_MANAGED_CACHE"))
231 {
232 $CACHE_MANAGER->RegisterTag('iblock_id_'.$iblock_id);
233 $CACHE_MANAGER->EndTagCache();
234 }
235
236 if($obCache->StartDataCache())
237 {
238 $obCache->EndDataCache($result);
239 }
240 }
241 }
242 }
243 }
244
245 if (
246 !empty( $result["department"])
247 && !isset($arParams["LAZY_LOAD"])
248 )
249 {
250 $result["department_relation"] = self::GetTreeList('DR'.(intval($department_id) > 0 ? $department_id : 0), $result["department"], true);
251 if ((int) ($arParams["HEAD_DEPT"] ?? 0) > 0)
252 {
253 $result["department_relation_head"] = self::GetTreeList('DR'.intval($arParams["HEAD_DEPT"]), $result["department"], true);
254 }
255 }
256
257 return $result;
258 }
259
260 public static function GetExtranetUser(array $arParams = array())
261 {
262 global $CACHE_MANAGER;
263
264 static $resultCache = array();
265
266 $userId = (int)CurrentUser::get()->getId();
267
268 if(!isset($resultCache[$userId]))
269 {
270 $arUsers = Array();
271
272 if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser())
273 {
274 $cacheTtl = 3153600;
275 $cacheId = 'socnet_destination_getusers_'.md5(serialize($arParams)).'_'.$userId;
276 $cacheDir = '/socnet/dest_extranet/' . (int)($userId / 100) . '/' . $userId . '/';
277
278 $obCache = new CPHPCache;
279 if($obCache->initCache($cacheTtl, $cacheId, $cacheDir))
280 {
281 $arUsers = $obCache->getVars();
282 }
283 else
284 {
285 $obCache->startDataCache();
286 if(defined("BX_COMP_MANAGED_CACHE"))
287 {
288 $CACHE_MANAGER->StartTagCache($cacheDir);
289 }
290
291 if(defined("BX_COMP_MANAGED_CACHE"))
292 {
293 $CACHE_MANAGER->registerTag("sonet_user2group_U".$userId);
294 }
295
296 $workgroupIdList = [];
297 $res = CSocNetUserToGroup::getList(
298 array(),
299 array(
300 "USER_ID" => $userId,
301 "<=ROLE" => SONET_ROLES_USER,
302 "GROUP_SITE_ID" => 's1',
303 "GROUP_ACTIVE" => "Y",
304 "!GROUP_CLOSED" => "Y"
305 ),
306 false,
307 false,
308 array("ID", "GROUP_ID")
309 );
310 while($relationFields = $res->fetch())
311 {
312 $workgroupIdList[] = (int)$relationFields["GROUP_ID"];
313 if(defined("BX_COMP_MANAGED_CACHE"))
314 {
315 $CACHE_MANAGER->registerTag("sonet_user2group_G".$relationFields["GROUP_ID"]);
316 }
317 }
318
319 $arUsers = [];
320
321 if (!empty($workgroupIdList))
322 {
323 $arUsers = self::getUsersAll([
324 'RETURN_FULL_LIST' => 'Y'
325 ]);
326
327 if (defined("BX_COMP_MANAGED_CACHE"))
328 {
329 foreach($arUsers as $userData)
330 {
331 $CACHE_MANAGER->registerTag("USER_NAME_".(int)$userData['entityId']);
332 }
333 }
334 }
335
336 $obCache->endDataCache($arUsers);
337 }
338 }
339
340 $resultCache[$userId] = $arUsers;
341 }
342
343 return $resultCache[$userId];
344 }
345
346 public static function GetUsers($arParams = Array(), $bSelf = true)
347 {
348 global $CACHE_MANAGER;
349
350 $userId = (int)CurrentUser::get()->getId();
351
352 if (
353 isset($arParams['all'])
354 && $arParams['all'] === 'Y'
355 )
356 {
357 if (IsModuleInstalled("intranet"))
358 {
359 return self::getUsersAll($arParams);
360 }
361
362 $arParamsNew = $arParams;
363 $arParamsNew["id"] = array($userId);
364 unset($arParamsNew["all"]);
365
366 return CSocNetLogDestination::GetUsers($arParamsNew, $bSelf);
367 }
368
369 $bExtranet = false;
370 $filter = [];
371 if (
372 !isset($arParams['IGNORE_ACTIVITY'])
373 || $arParams['IGNORE_ACTIVITY'] !== 'Y'
374 )
375 {
376 $filter['=ACTIVE'] = 'Y';
377 }
378
379 if (
380 isset($arParams['ONLY_WITH_EMAIL'])
381 && $arParams['ONLY_WITH_EMAIL'] === 'Y'
382 )
383 {
384 $filter['!=EMAIL'] = false;
385 }
386
387 $arExternalAuthId = self::getExternalAuthIdBlackList([
388 'ALLOW_BOTS' => (isset($arParams['ALLOW_BOTS']) && $arParams['ALLOW_BOTS'] === true)
389 ]);
390
391 if (!empty($arExternalAuthId))
392 {
393 $filter['!=EXTERNAL_AUTH_ID'] = $arExternalAuthId;
394 }
395
396 if (
397 (
398 !isset($arParams['IGNORE_ACTIVITY'])
399 || $arParams['IGNORE_ACTIVITY'] !== 'Y'
400 )
401 && (
402 IsModuleInstalled("intranet")
403 || COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y"
404 )
405 )
406 {
407 $filter["=CONFIRM_CODE"] = false;
408 }
409
410 $select = [ "ID", "LAST_NAME", "NAME", "SECOND_NAME", "LOGIN", "EMAIL", "PERSONAL_PHOTO", "WORK_POSITION", "PERSONAL_PROFESSION", "IS_ONLINE", "EXTERNAL_AUTH_ID" ];
411
412 if (
413 isset($arParams["CRM_ENTITY"])
414 && $arParams["CRM_ENTITY"] === "Y"
415 && ModuleManager::isModuleInstalled('crm')
416 )
417 {
418 $select[] = 'UF_USER_CRM_ENTITY';
419 }
420
421 if (ModuleManager::isModuleInstalled('intranet'))
422 {
423 $select[] = 'USER_TYPE';
424 $select[] = 'UF_DEPARTMENT';
425 }
426
427 if (array_key_exists('id', $arParams))
428 {
429 if (empty($arParams['id']))
430 {
431 $filter['ID'] = $userId;
432 }
433 else
434 {
435 $arSelect = array($userId);
436 foreach ($arParams['id'] as $value)
437 {
438 if (
439 intval($value) > 0
440 && !in_array($value, $arSelect)
441 )
442 {
443 $arSelect[] = intval($value);
444 }
445 }
446 sort($arSelect);
447 $filter['@ID'] = $arSelect;
448 }
449 }
450 elseif (isset($arParams['deportament_id']))
451 {
452 if (is_array($arParams['deportament_id']))
453 {
454 $filter['=UF_DEPARTMENT'] = $arParams['deportament_id'];
455 }
456 else
457 {
458 if ($arParams['deportament_id'] === 'EX')
459 {
460 $bExtranet = true;
461 }
462 else
463 {
464 $filter['UF_DEPARTMENT'] = intval($arParams['deportament_id']);
465 }
466 }
467 }
468
469 $avatarSize = array(
470 "width" => (intval($arParams["THUMBNAIL_SIZE_WIDTH"] ?? 0) > 0 ? $arParams["THUMBNAIL_SIZE_WIDTH"] : 100),
471 "height" => (intval($arParams["THUMBNAIL_SIZE_HEIGHT"] ?? 0) > 0 ? $arParams["THUMBNAIL_SIZE_HEIGHT"] : 100)
472 );
473
474 $cacheTtl = 3153600;
475 $cacheId = 'socnet_destination_getusers_'.md5(serialize($filter)).$bSelf.CSocNetUser::IsCurrentUserModuleAdmin().($bExtranet ? '_ex_'.$userId : '').md5(serialize($avatarSize));
476 $cacheDir = '/socnet/dest/'.(
477 isset($arParams['id'])
478 ? 'user'
479 : 'dept'
480 ) . '/' . mb_substr(md5($cacheId), 0, 2) . '/';
481
482 $obCache = new CPHPCache;
483 if($obCache->InitCache($cacheTtl, $cacheId, $cacheDir))
484 {
485 $arUsers = $obCache->GetVars();
486 }
487 else
488 {
489 $obCache->StartDataCache();
490 if(defined("BX_COMP_MANAGED_CACHE"))
491 {
492 $CACHE_MANAGER->StartTagCache($cacheDir);
493 }
494
495 if (
496 $bExtranet
497 && CModule::IncludeModule("extranet")
498 )
499 {
500 $extranetSiteId = CExtranet::GetExtranetSiteID();
501
502 // get all extranet groups and set tags
503 $rsSonetGroup = CSocNetUserToGroup::GetList(
504 array(),
505 array(
506 "USER_ID" => $userId,
507 "GROUP_SITE_ID" => $extranetSiteId
508 ),
509 false,
510 false,
511 array("GROUP_ID")
512 );
513 while($arSonetGroup = $rsSonetGroup->Fetch())
514 {
515 $CACHE_MANAGER->RegisterTag("sonet_user2group_G".$arSonetGroup["GROUP_ID"]);
516 }
517
518 $CACHE_MANAGER->RegisterTag("sonet_user2group_U" . $userId);
519
520 $arUsers = Array();
521 $arExtranetUsers = CExtranet::GetMyGroupsUsersFull($extranetSiteId, $bSelf);
522 foreach($arExtranetUsers as $arUserTmp)
523 {
524 if (!empty($arUserTmp['UF_DEPARTMENT']))
525 {
526 continue;
527 }
528
529 $sName = trim(CUser::FormatName(empty($arParams["NAME_TEMPLATE"]) ? CSite::GetNameFormat(false) : $arParams["NAME_TEMPLATE"], $arUserTmp, true, false));
530 if (empty($sName))
531 {
532 $sName = $arUserTmp["~LOGIN"];
533 }
534
535 $arFileTmp = CFile::ResizeImageGet(
536 $arUserTmp["PERSONAL_PHOTO"],
537 $avatarSize,
539 false
540 );
541
542 $arUsers['U'.$arUserTmp["ID"]] = Array(
543 'id' => 'U'.$arUserTmp["ID"],
544 'entityId' => $arUserTmp["ID"],
545 'email' => $arUserTmp["EMAIL"] ? $arUserTmp["EMAIL"] : '',
546 'name' => $sName,
547 'avatar' => empty($arFileTmp['src'])? '': $arFileTmp['src'],
548 'desc' => self::getUserDescription($arUserTmp, [
549 'showEmail' => !empty($arParams["ONLY_WITH_EMAIL"])
550 ]),
551 );
552 if (defined("BX_COMP_MANAGED_CACHE"))
553 {
554 $CACHE_MANAGER->RegisterTag("USER_NAME_".intval($arUserTmp["ID"]));
555 }
556 }
557 }
558 else
559 {
560 $bExtranetInstalled = CModule::IncludeModule("extranet");
562
563 if (
564 !isset($filter['UF_DEPARTMENT'])
565 && $bExtranetInstalled
566 )
567 {
568 $arUserIdVisible = CExtranet::getMyGroupsUsersSimple(CExtranet::getExtranetSiteId());
569 }
570
571 $order = [ 'LAST_NAME' => 'ASC' ];
572
573 $arUsers = Array();
574
575 $className = (\Bitrix\Main\Loader::includeModule('intranet') ? '\Bitrix\Intranet\UserTable' : '\Bitrix\Main\UserTable');
576 $res = $className::getList([
577 'order' => $order,
578 'filter' => $filter,
579 'select' => $select
580 ]);
581
582 global $USER;
583
584 while ($arUser = $res->fetch())
585 {
586 foreach($arUser as $key => $value)
587 {
588 if (is_string($value))
589 {
591 }
592 }
593
594 if (
595 !$bSelf
596 && is_object($USER)
597 && $userId == $arUser["ID"]
598 )
599 {
600 continue;
601 }
602
603 if (
604 !isset($filter['UF_DEPARTMENT']) // all users
605 && $bExtranetInstalled
606 )
607 {
608 if (
609 isset($arUser["UF_DEPARTMENT"])
610 && $arUser['EXTERNAL_AUTH_ID'] !== 'email'
611 && (
612 $arUser['EXTERNAL_AUTH_ID'] !== 'bot'
613 || !isset($arParams['ALLOW_BOTS'])
614 || $arParams['ALLOW_BOTS'] !== true
615 )
616 && (
617 !is_array($arUser["UF_DEPARTMENT"])
618 || empty($arUser["UF_DEPARTMENT"])
619 || (int)$arUser["UF_DEPARTMENT"][0] <= 0
620 ) // extranet user
621 && (
622 empty($arUserIdVisible)
623 || !is_array($arUserIdVisible)
624 || !in_array($arUser["ID"], $arUserIdVisible)
625 )
626 )
627 {
628 continue;
629 }
630 }
631
632 $sName = trim(CUser::FormatName(empty($arParams["NAME_TEMPLATE"]) ? CSite::GetNameFormat(false) : $arParams["NAME_TEMPLATE"], $arUser, true, false));
633
634 if (empty($sName))
635 {
636 $sName = htmlspecialcharsBack($arUser["LOGIN"]);
637 }
638
639 $arFileTmp = CFile::ResizeImageGet(
640 $arUser["PERSONAL_PHOTO"],
641 $avatarSize,
643 false
644 );
645
646 $arUsers['U'.$arUser["ID"]] = Array(
647 'id' => 'U'.$arUser["ID"],
648 'entityId' => $arUser["ID"],
649 'email' => $arUser["EMAIL"],
650 'name' => $sName,
651 'avatar' => empty($arFileTmp['src'])? '': $arFileTmp['src'],
652 'desc' => self::getUserDescription($arUser, [
653 'showEmail' => !empty($arParams["ONLY_WITH_EMAIL"])
654 ]),
655 'isExtranet' => (isset($arUser['USER_TYPE']) && $arUser['USER_TYPE'] === 'extranet' ? "Y" : "N"),
656 'isEmail' => ($arUser['EXTERNAL_AUTH_ID'] === 'email' ? 'Y' : 'N'),
657 'isCrmEmail' => (
658 $arUser['EXTERNAL_AUTH_ID'] === 'email'
659 && !empty($arUser['UF_USER_CRM_ENTITY'])
660 ? 'Y'
661 : 'N'
662 )
663 );
664
665 if ($arUser['EXTERNAL_AUTH_ID'] === 'email')
666 {
667 $arUsers['U'.$arUser["ID"]]['email'] = $arUser['EMAIL'];
668 }
669
670 $arUsers['U'.$arUser["ID"]]['checksum'] = md5(serialize($arUsers['U'.$arUser["ID"]]));
671
672 if (defined("BX_COMP_MANAGED_CACHE"))
673 {
674 $CACHE_MANAGER->RegisterTag("USER_NAME_".intval($arUser["ID"]));
675 }
676 }
677 }
678
679 if (defined("BX_COMP_MANAGED_CACHE"))
680 {
681 $CACHE_MANAGER->RegisterTag("USER_NAME");
682 if (!empty($filter['UF_DEPARTMENT']))
683 {
684 $CACHE_MANAGER->RegisterTag('intranet_department_'.$filter['UF_DEPARTMENT']);
685 }
686 $CACHE_MANAGER->EndTagCache();
687 }
688
689 $obCache->EndDataCache($arUsers);
690 }
691
692 return $arUsers;
693 }
694
695 public static function GetGratMedalUsers($arParams = Array())
696 {
697 static $resultCache = array();
698
699 $userId = intval(CurrentUser::get()->getId());
700
701 if(!isset($resultCache[$userId]))
702 {
703 $arSubordinateDepts = array();
704
705 if (CModule::IncludeModule("intranet"))
706 {
707 $arSubordinateDepts = CIntranetUtils::GetSubordinateDepartments($userId, true);
708 }
709
710 $arFilter = Array(
711 "ACTIVE" => "Y",
712 "!UF_DEPARTMENT" => false
713 );
714
715 $arExtParams = Array(
716 "FIELDS" => Array("ID", "LAST_NAME", "NAME", "SECOND_NAME", "LOGIN", "EMAIL", "PERSONAL_PHOTO", "WORK_POSITION", "PERSONAL_PROFESSION", "IS_ONLINE"),
717 "SELECT" => Array("UF_DEPARTMENT")
718 );
719
720 if (isset($arParams["id"]))
721 {
722 if (empty($arParams["id"]))
723 {
724 $arFilter["ID"] = $userId;
725 }
726 else
727 {
728 $arSelect = array();
729 foreach ($arParams["id"] as $value)
730 {
731 $arSelect[] = intval($value);
732 }
733 $arFilter["ID"] = implode("|", $arSelect);
734 }
735 }
736
737 $arGratUsers = Array();
738 $arMedalUsers = Array();
739
740 $dbUsers = CUser::GetList(Array("last_name" => "asc", "IS_ONLINE" => "desc"), '', $arFilter, $arExtParams);
741 while ($arUser = $dbUsers->GetNext())
742 {
743 $sName = trim(CUser::FormatName(empty($arParams["NAME_TEMPLATE"]) ? CSite::GetNameFormat(false) : $arParams["NAME_TEMPLATE"], $arUser));
744
745 if (empty($sName))
746 {
747 $sName = $arUser["~LOGIN"];
748 }
749
750 $arFileTmp = CFile::ResizeImageGet(
751 $arUser["PERSONAL_PHOTO"],
752 array("width" => 100, "height" => 100),
754 false
755 );
756
757 $arGratUsers['U'.$arUser["ID"]] = Array(
758 "id" => "U".$arUser["ID"],
759 "entityId" => $arUser["ID"],
760 "email" => $arUser["EMAIL"],
761 "name" => $sName,
762 "avatar" => empty($arFileTmp["src"]) ? '' : $arFileTmp["src"],
763 "desc" => $arUser["WORK_POSITION"] ? $arUser["WORK_POSITION"] : ($arUser["PERSONAL_PROFESSION"] ? $arUser["PERSONAL_PROFESSION"] : "&nbsp;"),
764 );
765
766 if (
767 count($arSubordinateDepts) > 0
768 && count(array_intersect($arSubordinateDepts, $arUser["UF_DEPARTMENT"])) > 0
769 )
770 {
771 $arMedalUsers['U'.$arUser["ID"]] = $arGratUsers['U'.$arUser["ID"]];
772 }
773 }
774 $resultCache[$userId] = array("GRAT" => $arGratUsers, "MEDAL" => $arMedalUsers);
775 }
776
777 return $resultCache[$userId];
778 }
779
780 public static function __percent_walk(&$val)
781 {
782 $val = str_replace('%', '', $val)."%";
783 }
784
785 public static function searchUsers($search, &$nt = "", $bSelf = true, $bEmployeesOnly = false, $bExtranetOnly = false, $departmentId = false)
786 {
787 global $DB;
788
789 $nameTemplate = $nt;
790 $bEmailUsers = false;
791 $bCrmEmailUsers = false;
792 $bActiveOnly = true;
793 $bNetworkSearch = false;
794 $bSearchOnlyWithEmail = false;
795 $allowBots = false;
796 $showAllExtranetContacts = false;
797
798 if (is_array($search))
799 {
800 $arParams = $search;
801 $search = $arParams["SEARCH"];
802 $nameTemplate = ($arParams["NAME_TEMPLATE"] ?? '');
803 $bSelf = ($arParams["SELF"] ?? true);
804 $bEmployeesOnly = ($arParams["EMPLOYEES_ONLY"] ?? false);
805 $bExtranetOnly = ($arParams["EXTRANET_ONLY"] ?? false);
806 $departmentId = ($arParams["DEPARTAMENT_ID"] ?? false);
807 $bEmailUsers = ($arParams["EMAIL_USERS"] ?? false);
808 $bCrmEmailUsers = (isset($arParams["CRMEMAIL_USERS"]) && ModuleManager::isModuleInstalled('crm') ? $arParams["CRMEMAIL_USERS"] : false);
809 $bActiveOnly = (isset($arParams["CHECK_ACTIVITY"]) && $arParams["CHECK_ACTIVITY"] === false ? false : true);
810 $bNetworkSearch = ($arParams["NETWORK_SEARCH"] ?? false);
811 $bSearchOnlyWithEmail = ($arParams["ONLY_WITH_EMAIL"] ?? false);
812 $allowBots = ($arParams['ALLOW_BOTS'] ?? false);
813 $showAllExtranetContacts = ($arParams['SHOW_ALL_EXTRANET_CONTACTS'] ?? false);
814 }
815
816 $arUsers = array();
817 $search = trim($search);
818 if (
819 $search == ''
820 || !GetFilterQuery("TEST", $search)
821 )
822 {
823 return $arUsers;
824 }
825
826 $bSearchByEmail = false;
827
828 if (preg_match('/^([^<]+)\s<([^>]+)>$/i', $search, $matches)) // email
829 {
830 $search = $matches[2];
831 $nt = $search;
832 $bSearchByEmail = true;
833 }
834
835 $bIntranetEnabled = IsModuleInstalled('intranet');
836 $bExtranetEnabled = CModule::IncludeModule('extranet');
837 $bMailEnabled = IsModuleInstalled('mail');
838 $bBitrix24Enabled = IsModuleInstalled('bitrix24');
839
840 $bEmailUsersAll = ($bMailEnabled && \Bitrix\Main\Config\Option::get('socialnetwork', 'email_users_all', 'N') === 'Y');
841 $bExtranetUser = ($bExtranetEnabled && !CExtranet::IsIntranetUser());
842
843 $current_user_id = (int)CurrentUser::get()->getId();
844
845 if ($bExtranetEnabled)
846 {
848 }
849
850 $arSearchValue = preg_split('/\s+/', trim(mb_strtoupper($search)));
851 array_walk($arSearchValue, array('CSocNetLogDestination', '__percent_walk'));
852
853 $arMyUserId = array();
854
855 $filter = [];
856
857 $useFulltextIndex = class_exists('\Bitrix\Main\UserIndexTable');
858
859 if ($useFulltextIndex)
860 {
861 $filter['*INDEX.SEARCH_USER_CONTENT'] = \Bitrix\Main\Search\Content::prepareStringToken(implode(' ', $arSearchValue));
862 }
863 else
864 {
865 if (count($arSearchValue) == 2)
866 {
867 $arLogicFilter = array(
868 'LOGIC' => 'OR',
869 array('LOGIC' => 'AND', 'NAME' => $arSearchValue[0], 'LAST_NAME' => $arSearchValue[1]),
870 array('LOGIC' => 'AND', 'NAME' => $arSearchValue[1], 'LAST_NAME' => $arSearchValue[0]),
871 );
872 }
873 else
874 {
875 $arLogicFilter = array(
876 'LOGIC' => 'OR',
877 'NAME' => $arSearchValue,
878 'LAST_NAME' => $arSearchValue,
879 );
880
881 if (
882 $bIntranetEnabled
883 && count($arSearchValue) == 1
884 && mb_strlen($arSearchValue[0]) > 2
885 )
886 {
887 $arLogicFilter['LOGIN'] = $arSearchValue[0];
888 }
889 }
890
891 $filter[] = $arLogicFilter;
892 }
893
894 if ($bActiveOnly)
895 {
896 $filter['=ACTIVE'] = 'Y';
897 }
898
899 if ($bIntranetEnabled)
900 {
901 $arExternalAuthId = self::getExternalAuthIdBlackList(array(
902 'NETWORK_SEARCH' => $bNetworkSearch,
903 'ALLOW_BOTS' => $allowBots
904 ));
905
906 if (!empty($arExternalAuthId))
907 {
908 $filter['!=EXTERNAL_AUTH_ID'] = $arExternalAuthId;
909 }
910
911 if (
912 ($bEmailUsers || $bCrmEmailUsers)
913 && $bMailEnabled
914 && !$bEmailUsersAll
915 )
916 {
917 $finderDestFilter = array(
918 "USER_ID" => $current_user_id,
919 "=CODE_TYPE" => "U",
920 "=CODE_USER.EXTERNAL_AUTH_ID" => 'email'
921 );
922 $finderDestSelect = array(
923 'CODE_USER_ID'
924 );
925
926 if ($bCrmEmailUsers)
927 {
928 $finderDestFilter['!=CODE_USER.UF_USER_CRM_ENTITY'] = false;
929 $finderDestSelect[] = 'CODE_USER.UF_USER_CRM_ENTITY';
930 }
931
933 'order' => array(),
934 'filter' => $finderDestFilter,
935 'group' => array("CODE_USER_ID"),
936 'select' => $finderDestSelect
937 ));
938
939 while ($arUser = $rsUser->fetch())
940 {
941 $arMyUserId[] = $arUser['CODE_USER_ID'];
942 }
943 }
944 }
945
946 if (
947 !$bNetworkSearch
948 && (
949 $bIntranetEnabled
950 || COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y"
951 )
952 )
953 {
954 $filter["CONFIRM_CODE"] = false;
955 }
956
957 $bFilteredByMyUserId = false;
958
959 if(
960 $bIntranetEnabled
961 && $bExtranetEnabled
962 && !$bCrmEmailUsers
963 ) // consider extranet collaboration
964 {
965 CExtranet::fillUserListFilterORM(
966 array(
967 "CURRENT_USER_ID" => $current_user_id,
968 "EXTRANET_USER" => $bExtranetUser,
969 "INTRANET_ONLY" => ($bEmployeesOnly || ($bBitrix24Enabled && !$bExtranetEnabled)),
970 "EXTRANET_ONLY" => $bExtranetOnly,
971 "EMAIL_USERS_ALL" => $bEmailUsersAll,
972 "MY_USERS" => $arMyUserId,
973 'ALLOW_BOTS' => $allowBots,
974 'SHOW_ALL_EXTRANET_CONTACTS' => $showAllExtranetContacts
975 ),
976 $filter,
977 $bFilteredByMyUserId
978 );
979
980 if (!$filter)
981 {
982 return $arUsers;
983 }
984
985 if ($bNetworkSearch)
986 {
987 end($filter);
988 $filter[key($filter)]["=EXTERNAL_AUTH_ID"] = "replica";
989 }
990 }
991
992 if (
993 !empty($arMyUserId)
994 && !$bFilteredByMyUserId
995 )
996 {
997 $filter[] = array(
998 'LOGIC' => 'OR',
999 '!=EXTERNAL_AUTH_ID' => 'email',
1000 'ID' => $arMyUserId,
1001 );
1002 }
1003
1004 if ($bSearchOnlyWithEmail)
1005 {
1006 $filter["!EMAIL"] = false;
1007 }
1008
1009 $select = array(
1010 "ID",
1011 "ACTIVE",
1012 "NAME",
1013 "LAST_NAME",
1014 "SECOND_NAME",
1015 "EMAIL",
1016 "LOGIN",
1017 "WORK_POSITION",
1018 "PERSONAL_PROFESSION",
1019 "PERSONAL_PHOTO",
1020 "PERSONAL_GENDER",
1021 "EXTERNAL_AUTH_ID",
1022 new \Bitrix\Main\Entity\ExpressionField('MAX_LAST_USE_DATE', 'MAX(%s)', array('\Bitrix\Main\FinderDest:CODE_USER_CURRENT.LAST_USE_DATE'))
1023 );
1024
1025 if ($bCrmEmailUsers)
1026 {
1027 $select[] = "UF_USER_CRM_ENTITY";
1028 }
1029
1030 if (!$bActiveOnly)
1031 {
1032 $select[] = "ACTIVE";
1033 }
1034
1035 if ($useFulltextIndex)
1036 {
1037 $select['SEARCH_USER_CONTENT'] = 'INDEX.SEARCH_USER_CONTENT';
1038 }
1039
1040 $db_events = GetModuleEvents("socialnetwork", "OnSocNetLogDestinationSearchUsers");
1041 while ($arEvent = $db_events->Fetch())
1042 {
1043 ExecuteModuleEventEx($arEvent, array($arSearchValue, &$filter, &$select));
1044 }
1045
1046 $rsUser = null;
1047 if ($useFulltextIndex)
1048 {
1049 $rsUserFulltext = \Bitrix\Main\UserTable::getList(array(
1050 'order' => array(
1051 "MAX_LAST_USE_DATE" => 'DESC',
1052 'LAST_NAME' => 'ASC'
1053 ),
1054 'filter' => $filter,
1055 'select' => [
1056 'ID',
1057 new \Bitrix\Main\Entity\ExpressionField('MAX_LAST_USE_DATE', 'MAX(%s)', array('\Bitrix\Main\FinderDest:CODE_USER_CURRENT.LAST_USE_DATE'))
1058 ],
1059 'limit' => 100,
1060 'data_doubling' => false
1061 ));
1062
1063 $userIdList = [];
1064
1065 while ($arUser = $rsUserFulltext->fetch())
1066 {
1067 $userIdList[] = $arUser['ID'];
1068 }
1069
1070 if (!empty($userIdList))
1071 {
1073 'order' => array(
1074 "MAX_LAST_USE_DATE" => 'DESC',
1075 'LAST_NAME' => 'ASC'
1076 ),
1077 'filter' => [
1078 '@ID' => $userIdList
1079 ],
1080 'select' => $select
1081 ));
1082 }
1083 }
1084 else
1085 {
1087 'order' => array(
1088 "MAX_LAST_USE_DATE" => 'DESC',
1089 'LAST_NAME' => 'ASC'
1090 ),
1091 'filter' => $filter,
1092 'select' => $select,
1093 'limit' => 100,
1094 'data_doubling' => false
1095 ));
1096 }
1097
1098 $queryResultCnt = 0;
1099 if ($rsUser !== null)
1100 {
1101 $bUseLogin = (mb_strlen($search) > 3 && mb_strpos($search, '@') > 0);
1102 $params = array(
1103 "NAME_TEMPLATE" => $nameTemplate,
1104 "USE_EMAIL" => $bSearchByEmail,
1105 "USE_LOGIN" => $bUseLogin,
1106 "ONLY_WITH_EMAIL" => $bSearchOnlyWithEmail
1107 );
1108 while ($arUser = $rsUser->fetch())
1109 {
1110 $queryResultCnt++;
1111 if (
1112 !$bSelf
1113 && $current_user_id === (int)$arUser['ID']
1114 )
1115 {
1116 continue;
1117 }
1118
1119 if ((int)$departmentId > 0)
1120 {
1121 $arUserGroupCode = CAccess::GetUserCodesArray($arUser["ID"]);
1122
1123 if (!in_array("DR" . (int)$departmentId, $arUserGroupCode, true))
1124 {
1125 continue;
1126 }
1127 }
1128
1129 $arUser = (
1130 $arUser["EXTERNAL_AUTH_ID"] === "replica"
1131 ? self::formatNetworkUser($arUser, $params)
1132 : self::formatUser($arUser, $params)
1133 );
1134
1135 $arUsers[$arUser["id"]] = $arUser;
1136 }
1137 }
1138
1139 if (
1140 ($bEmailUsers || $bCrmEmailUsers || $bSearchOnlyWithEmail)
1141 && !$queryResultCnt
1142 && check_email($search, true)
1143 )
1144 {
1145 $arEmailFilter = array(
1146 'ACTIVE' => 'Y',
1147 '=EMAIL_OK' => 1
1148 );
1149
1150 if (!empty($arExternalAuthId))
1151 {
1152 $arEmailFilter['!=EXTERNAL_AUTH_ID'] = $arExternalAuthId;
1153 }
1154
1156 'order' => array(),
1157 'filter' => $arEmailFilter,
1158 'select' => array(
1159 "ID",
1160 "NAME",
1161 "LAST_NAME",
1162 "SECOND_NAME",
1163 "EMAIL",
1164 "LOGIN",
1165 "WORK_POSITION",
1166 "PERSONAL_PROFESSION",
1167 "PERSONAL_PHOTO",
1168 "PERSONAL_GENDER",
1169 "EXTERNAL_AUTH_ID",
1170 'ACTIVE',
1171 new \Bitrix\Main\Entity\ExpressionField('EMAIL_OK', 'CASE WHEN UPPER(%s) = \''.$DB->ForSql(mb_strtoupper(str_replace('%', '%%', $search))).'\' THEN 1 ELSE 0 END', ['EMAIL'])
1172 ),
1173 'limit' => 10
1174 ));
1175
1176 while ($arUser = $rsUser->fetch())
1177 {
1178 $arUsers['U'.$arUser["ID"]] = self::formatUser($arUser, array(
1179 "NAME_TEMPLATE" => $nameTemplate,
1180 "USE_EMAIL" => true,
1181 "ONLY_WITH_EMAIL" => $bSearchOnlyWithEmail
1182 ));
1183 }
1184 }
1185
1186 return $arUsers;
1187 }
1188
1189 public static function searchSonetGroups($params = array())
1190 {
1191 $result = array();
1192
1193 $search = is_array($params) && isset($params['SEARCH']) ? trim($params['SEARCH']) : '';
1194 if (empty($search))
1195 {
1196 return $result;
1197 }
1198
1199 if (
1200 $search == ''
1201 || !getFilterQuery("TEST", $search)
1202 )
1203 {
1204 return $result;
1205 }
1206
1207 $siteId = (
1208 isset($params['SITE_ID'])
1209 && $params['SITE_ID'] <> ''
1210 ? $params['SITE_ID']
1211 : SITE_ID
1212 );
1213
1214 $currentUserAdmin = CSocNetUser::isCurrentUserModuleAdmin($siteId);
1215
1216 $tmpList = array();
1217
1218 $filter = array(
1219 '%NAME' => $search,
1220 "SITE_ID" => $siteId,
1221 "ACTIVE" => "Y",
1222 );
1223
1224 if (
1225 !empty($params['LANDING'])
1226 && $params['LANDING'] === 'Y'
1227 )
1228 {
1229 $filter['LANDING'] = 'Y';
1230 }
1231
1232 if (!$currentUserAdmin)
1233 {
1234 $filter["CHECK_PERMISSIONS"] = (int)CurrentUser::get()->getId();
1235 }
1236
1237 if (!CollabFeature::isFeatureEnabledInPortalSettings())
1238 {
1239 $filter['!TYPE'] = Type::Collab->value;
1240 }
1241
1242 $res = CSocnetGroup::getList(
1243 array("NAME" => "ASC"),
1244 $filter,
1245 false,
1246 array("nTopCount" => 50),
1247 array("ID", "NAME", "DESCRIPTION", "IMAGE_ID")
1248 );
1249
1250 $extranetGroupsIdList = \Bitrix\Socialnetwork\ComponentHelper::getExtranetSonetGroupIdList();
1251
1252 while ($group = $res->fetch())
1253 {
1254 $tmp = array(
1255 "id" => $group["ID"],
1256 "entityId" => $group["ID"],
1257 "name" => htmlspecialcharsbx(Emoji::decode($group["NAME"])),
1258 "desc" => htmlspecialcharsbx(Emoji::decode($group["DESCRIPTION"])),
1259 "isExtranet" => (in_array($group["ID"], $extranetGroupsIdList) ? 'Y' : 'N')
1260 );
1261
1262 if($group["IMAGE_ID"])
1263 {
1264 $imageFile = CFile::getFileArray($group["IMAGE_ID"]);
1265 if ($imageFile !== false)
1266 {
1267 $arFileTmp = CFile::resizeImageGet(
1268 $imageFile,
1269 [
1270 "width" => ((int)($params["THUMBNAIL_SIZE_WIDTH"] ?? null) > 0 ? $params["THUMBNAIL_SIZE_WIDTH"] : 100),
1271 "height" => ((int)($params["THUMBNAIL_SIZE_HEIGHT"] ?? null) > 0 ? $params["THUMBNAIL_SIZE_HEIGHT"] : 100),
1272 ],
1273 BX_RESIZE_IMAGE_PROPORTIONAL,
1274 false
1275 );
1276 $tmp["avatar"] = $arFileTmp["src"];
1277 }
1278 }
1279 unset($group["IMAGE_ID"]);
1280 $tmpList[$tmp['id']] = $tmp;
1281 }
1282
1283 if (
1284 !$currentUserAdmin
1285 && isset($params['FEATURES'])
1286 && is_array($params['FEATURES'])
1287 && !empty($params['FEATURES'])
1288 )
1289 {
1290 self::getSocnetGroupFilteredByFeaturePerms($tmpList, $params['FEATURES']);
1291 }
1292
1293 if (
1294 !$currentUserAdmin
1295 && isset($params['INITIATE'])
1296 && $params['INITIATE'] === 'Y'
1297 )
1298 {
1299 self::getSocnetGroupFilteredByInitiatePerms($tmpList);
1300 }
1301
1302 foreach ($tmpList as $value)
1303 {
1304 $value['id'] = 'SG'.$value['id'];
1305 $result[$value['id']] = $value;
1306 }
1307
1308 return $result;
1309 }
1310
1311 public static function SearchCrmEntities($arParams)
1312 {
1313 $result = array();
1314
1315 $search = (!empty($arParams['SEARCH']) ? $arParams['SEARCH'] : false);
1316 if (
1317 $search
1318 && CModule::IncludeModule('crm')
1319 )
1320 {
1321 if (check_email($search, true))
1322 {
1323 $result = array();
1324
1325 if (
1326 empty($arParams['ENTITIES'])
1327 || in_array('CONTACT', $arParams['ENTITIES'])
1328 )
1329 {
1330 $dbRes = CCrmContact::GetListEx(
1331 array(),
1332 array(
1333 'CHECK_PERMISSIONS' => 'Y',
1334 '@CATEGORY_ID' => 0,
1335 'FM' => array(
1336 'EMAIL' => array(
1337 'VALUE' => $search
1338 )
1339 )
1340 ),
1341 false,
1342 false,
1343 array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO')
1344 );
1345 while($ar = $dbRes->Fetch())
1346 {
1347 $formatted = self::formatCrmEmailEntity($ar, array(
1348 'TYPE' => 'CONTACT',
1349 'NAME_TEMPLATE' => $arParams["NAME_TEMPLATE"],
1350 'EMAIL' => $search
1351 ));
1352 if (!empty($formatted))
1353 {
1354 $result[$formatted['id']] = $formatted;
1355 }
1356 }
1357 }
1358
1359 if (
1360 empty($arParams['ENTITIES'])
1361 || in_array('COMPANY', $arParams['ENTITIES'])
1362 )
1363 {
1364 $dbRes = CCrmCompany::GetListEx(
1365 array(),
1366 array(
1367 'CHECK_PERMISSIONS' => 'Y',
1368 '@CATEGORY_ID' => 0,
1369 'FM' => array(
1370 'EMAIL' => array(
1371 'VALUE' => $search
1372 )
1373 )
1374 ),
1375 false,
1376 false,
1377 array('ID', 'TITLE', 'LOGO')
1378 );
1379 while($ar = $dbRes->Fetch())
1380 {
1381 $formatted = self::formatCrmEmailEntity($ar, array(
1382 'TYPE' => 'COMPANY',
1383 'EMAIL' => $search
1384 ));
1385 if (!empty($formatted))
1386 {
1387 $result[$formatted['id']] = $formatted;
1388 }
1389 }
1390 }
1391
1392 if (
1393 empty($arParams['ENTITIES'])
1394 || in_array('LEAD', $arParams['ENTITIES'])
1395 )
1396 {
1397 $dbRes = CCrmLead::GetListEx(
1398 array(),
1399 array(
1400 'CHECK_PERMISSIONS' => 'Y',
1401 'FM' => array(
1402 'EMAIL' => array(
1403 'VALUE' => $search
1404 )
1405 )
1406 ),
1407 false,
1408 false,
1409 array('ID', 'TITLE', 'NAME', 'SECOND_NAME', 'LAST_NAME')
1410 );
1411 while($ar = $dbRes->Fetch())
1412 {
1413 $formatted = self::formatCrmEmailEntity($ar, array(
1414 'TYPE' => 'LEAD',
1415 'EMAIL' => $search
1416 ));
1417 if (!empty($formatted))
1418 {
1419 $result[$formatted['id']] = $formatted;
1420 }
1421 }
1422 }
1423 }
1424 elseif (
1425 !isset($arParams['SEARCH_BY_EMAIL_ONLY'])
1426 || $arParams['SEARCH_BY_EMAIL_ONLY'] !== 'Y'
1427 )
1428 {
1429 $keysList = array();
1430 $contacts = CCrmActivity::FindContactCommunications($search, 'EMAIL', 50);
1431 foreach($contacts as $contact)
1432 {
1433 $keysList[] = $contact['ENTITY_ID'].'_'.$contact['ENTITY_TYPE_ID'];
1434 }
1435
1436 $contactsByName = CCrmActivity::FindContactCommunications($search, '', 50);
1437 foreach($contactsByName as $contact)
1438 {
1439 if (
1440 in_array($contact['ENTITY_ID'].'_'.$contact['ENTITY_TYPE_ID'], $keysList)
1441 || empty($contact["VALUE"])
1442 )
1443 {
1444 continue;
1445 }
1446 $contacts[] = $contact;
1447 }
1448
1449 if (!empty($contacts))
1450 {
1451 $arId = $arEmail = array();
1452 foreach($contacts as $contact)
1453 {
1454 $arEmail[intval($contact["ENTITY_ID"])] = $contact["VALUE"];
1455 $arId[] = intval($contact["ENTITY_ID"]);
1456 }
1457
1458 $dbRes = CCrmContact::GetListEx(
1459 array(),
1460 array(
1461 'CHECK_PERMISSIONS' => 'Y',
1462 'ID' => $arId
1463 ),
1464 false,
1465 array('nTopCount' => 10),
1466 array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO')
1467 );
1468 while($ar = $dbRes->fetch())
1469 {
1470 $formatted = self::formatCrmEmailEntity($ar, array(
1471 'TYPE' => 'CONTACT',
1472 'NAME_TEMPLATE' => $arParams["NAME_TEMPLATE"],
1473 'EMAIL' => $arEmail[$ar['ID']]
1474 ));
1475 if (!empty($formatted))
1476 {
1477 $result[$formatted['id']] = $formatted;
1478 }
1479 }
1480 }
1481
1482 $companies = CCrmActivity::FindCompanyCommunications($search, 'EMAIL', 50);
1483 foreach($companies as $company)
1484 {
1485 $keysList[] = $company['ENTITY_ID'].'_'.$company['ENTITY_TYPE_ID'];
1486 }
1487
1488 $companiesByName = CCrmActivity::FindCompanyCommunications($search, '', 50);
1489 foreach($companiesByName as $company)
1490 {
1491 if (
1492 in_array($company['ENTITY_ID'].'_'.$company['ENTITY_TYPE_ID'], $keysList)
1493 || empty($company["VALUE"])
1494 )
1495 {
1496 continue;
1497 }
1498 $companies[] = $company;
1499 }
1500
1501 if (!empty($companies))
1502 {
1503 $arId = $arEmail = array();
1504 foreach($companies as $company)
1505 {
1506 $arEmail[intval($company["ENTITY_ID"])] = $company["VALUE"];
1507 $arId[] = intval($company["ENTITY_ID"]);
1508 }
1509 $dbRes = CCrmCompany::GetListEx(
1510 array(),
1511 array(
1512 'CHECK_PERMISSIONS' => 'Y',
1513 'ID' => $arId
1514 ),
1515 false,
1516 array('nTopCount' => 10),
1517 array('ID', 'TITLE', 'LOGO')
1518 );
1519 while($ar = $dbRes->Fetch())
1520 {
1521 $formatted = self::formatCrmEmailEntity($ar, array(
1522 'TYPE' => 'COMPANY',
1523 'EMAIL' => $arEmail[$ar['ID']]
1524 ));
1525 if (!empty($formatted))
1526 {
1527 $result[$formatted['id']] = $formatted;
1528 }
1529 }
1530 }
1531
1532 $leads = CCrmActivity::FindLeadCommunications($search, 'EMAIL', 50);
1533 foreach($leads as $lead)
1534 {
1535 $keysList[] = $lead['ENTITY_ID'].'_'.$lead['ENTITY_TYPE_ID'];
1536 }
1537
1538 $leadsByName = CCrmActivity::FindLeadCommunications($search, '', 50);
1539 foreach($leadsByName as $lead)
1540 {
1541 if (
1542 in_array($lead['ENTITY_ID'].'_'.$lead['ENTITY_TYPE_ID'], $keysList)
1543 || empty($lead["VALUE"])
1544 )
1545 {
1546 continue;
1547 }
1548 $leads[] = $lead;
1549 }
1550
1551 if (!empty($leads))
1552 {
1553 $arId = $arEmail = array();
1554 foreach($leads as $lead)
1555 {
1556 $arEmail[intval($lead["ENTITY_ID"])] = $lead["VALUE"];
1557 $arId[] = intval($lead["ENTITY_ID"]);
1558 }
1559
1560 $dbRes = CCrmLead::GetListEx(
1561 array(),
1562 array(
1563 'CHECK_PERMISSIONS' => 'Y',
1564 'ID' => $arId
1565 ),
1566 false,
1567 array('nTopCount' => 10),
1568 array('ID', 'TITLE', 'NAME', 'SECOND_NAME', 'LAST_NAME')
1569 );
1570 while($ar = $dbRes->Fetch())
1571 {
1572 $formatted = self::formatCrmEmailEntity($ar, array(
1573 'TYPE' => 'LEAD',
1574 'EMAIL' => $arEmail[$ar['ID']]
1575 ));
1576 if (!empty($formatted))
1577 {
1578 $result[$formatted['id']] = $formatted;
1579 }
1580 }
1581 }
1582 }
1583 }
1584
1585 return $result;
1586 }
1587
1588 public static function getSocnetGroup($arParams = array(), &$limitReached = false)
1589 {
1590 static $staticCache = array();
1591
1592 $userId = (int)CurrentUser::get()->getId();
1593
1594 $arSocnetGroups = [];
1595 $arSelect = [];
1596 if (isset($arParams['id']))
1597 {
1598 if (empty($arParams['id']))
1599 {
1600 return $arSocnetGroups;
1601 }
1602
1603 foreach ($arParams['id'] as $value)
1604 {
1605 $arSelect[] = intval($value);
1606 }
1607 }
1608
1609 $siteId = (
1610 isset($arParams['site_id'])
1611 && $arParams['site_id'] <> ''
1612 ? $arParams['site_id']
1613 : SITE_ID
1614 );
1615
1616 $limit = (isset($arParams["limit"]) && intval($arParams["limit"]) > 0 ? intval($arParams["limit"]) : 500);
1617
1618 $hash = md5(serialize($arParams).$userId.$siteId);
1619 if (isset($staticCache[$hash]))
1620 {
1621 $arSocnetGroups = $staticCache[$hash];
1622 }
1623 else
1624 {
1625 $arSocnetGroupsTmp = array();
1626 $tmpList = array();
1627
1628 $extranetGroupsIdList = \Bitrix\Socialnetwork\ComponentHelper::getExtranetSonetGroupIdList();
1629
1630 if (
1631 !isset($arParams["ALL"])
1632 || $arParams["ALL"] !== "Y"
1633 )
1634 {
1635 $filter = array(
1636 "USER_ID" => $userId,
1637 "GROUP_ID" => $arSelect,
1638 "<=ROLE" => UserToGroupTable::ROLE_USER,
1639 "GROUP_SITE_ID" => $siteId,
1640 "GROUP_ACTIVE" => "Y"
1641 );
1642
1643 if (!CollabFeature::isFeatureEnabledInPortalSettings())
1644 {
1645 $filter['!GROUP_TYPE'] = Type::Collab->value;
1646 }
1647
1648 if (
1649 !empty($arParams['landing'])
1650 && $arParams['landing'] === 'Y'
1651 )
1652 {
1653 $filter["GROUP_LANDING"] = $arParams['landing'];
1654 }
1655
1656 if(isset($arParams['GROUP_CLOSED']))
1657 {
1658 $filter['GROUP_CLOSED'] = $arParams['GROUP_CLOSED'];
1659 }
1660
1661 $res = CSocNetUserToGroup::getList(
1662 array("GROUP_NAME" => "ASC"),
1663 $filter,
1664 false,
1665 array("nTopCount" => $limit),
1666 array("ID", "GROUP_ID", "GROUP_NAME", "GROUP_DESCRIPTION", "GROUP_IMAGE_ID", "GROUP_PROJECT")
1667 );
1668 while($relation = $res->fetch())
1669 {
1670 $tmpList[] = array(
1671 "id" => $relation["GROUP_ID"],
1672 "entityId" => $relation["GROUP_ID"],
1673 "name" => htmlspecialcharsbx(Emoji::decode($relation["GROUP_NAME"])),
1674 "desc" => htmlspecialcharsbx(Emoji::decode($relation["GROUP_DESCRIPTION"])),
1675 "imageId" => $relation["GROUP_IMAGE_ID"],
1676 "project" => ($relation["GROUP_PROJECT"] === 'Y' ? 'Y' : 'N'),
1677 "isExtranet" => (in_array($relation["GROUP_ID"], $extranetGroupsIdList) ? 'Y' : 'N')
1678 );
1679 }
1680 }
1681 else
1682 {
1683 $filter = array(
1684 "CHECK_PERMISSIONS" => (int)CurrentUser::get()->getId(),
1685 "SITE_ID" => $siteId,
1686 "ACTIVE" => "Y",
1687 "ID" => $arSelect,
1688 );
1689
1690 if (!CollabFeature::isFeatureEnabledInPortalSettings())
1691 {
1692 $filter['!GROUP_TYPE'] = Type::Collab->value;
1693 }
1694
1695 if(isset($arParams['GROUP_CLOSED']))
1696 {
1697 $filter['CLOSED'] = $arParams['GROUP_CLOSED'];
1698 }
1699 if(
1700 !empty($arParams['landing'])
1701 && $arParams['landing'] === 'Y'
1702 )
1703 {
1704 $filter['LANDING'] = $arParams['landing'];
1705 }
1706
1707 $res = CSocnetGroup::getList(
1708 array("NAME" => "ASC"),
1709 $filter,
1710 false,
1711 array("nTopCount" => $limit),
1712 array("ID", "NAME", "DESCRIPTION", "IMAGE_ID", "PROJECT")
1713 );
1714
1715 while ($group = $res->Fetch())
1716 {
1717 $tmpList[] = array(
1718 "id" => $group["ID"],
1719 "entityId" => $group["ID"],
1720 "name" => htmlspecialcharsbx(Emoji::decode($group["NAME"])),
1721 "desc" => htmlspecialcharsbx(Emoji::decode($group["DESCRIPTION"])),
1722 "imageId" => $group["IMAGE_ID"],
1723 "project" => ($group["PROJECT"] === 'Y' ? 'Y' : 'N'),
1724 "isExtranet" => (in_array($group["ID"], $extranetGroupsIdList) ? 'Y' : 'N')
1725 );
1726 }
1727 }
1728
1729 $limitReached = (count($tmpList) == $limit);
1730
1731 foreach ($tmpList as $group)
1732 {
1733 if($group["imageId"])
1734 {
1735 $imageFile = CFile::GetFileArray($group["imageId"]);
1736 if ($imageFile !== false)
1737 {
1738 $arFileTmp = CFile::ResizeImageGet(
1739 $imageFile,
1740 [
1741 "width" => ((int) ($arParams["THUMBNAIL_SIZE_WIDTH"] ?? 0) > 0
1742 ? $arParams["THUMBNAIL_SIZE_WIDTH"]
1743 : 100
1744 ),
1745 "height" => ((int) ($arParams["THUMBNAIL_SIZE_HEIGHT"] ?? 0) > 0
1746 ? $arParams["THUMBNAIL_SIZE_HEIGHT"]
1747 : 100
1748 )
1749 ],
1750 );
1751 $group["avatar"] = $arFileTmp["src"];
1752 }
1753 }
1754 unset($group["imageId"]);
1755 $arSocnetGroupsTmp[$group['id']] = $group;
1756 }
1757
1758 if (isset($arParams['features']) && !empty($arParams['features']))
1759 {
1760 self::getSocnetGroupFilteredByFeaturePerms($arSocnetGroupsTmp, $arParams['features']);
1761 }
1762
1763 if (isset($arParams['initiate']) && $arParams['initiate'] === 'Y')
1764 {
1765 self::getSocnetGroupFilteredByInitiatePerms($arSocnetGroupsTmp);
1766 }
1767
1768 foreach ($arSocnetGroupsTmp as $value)
1769 {
1770 $value['id'] = 'SG'.$value['id'];
1771 $arSocnetGroups[$value['id']] = $value;
1772 }
1773
1774 $staticCache[$hash] = $arSocnetGroups;
1775 }
1776
1777 if (isset($arParams['useProjects']) && $arParams['useProjects'] === 'Y')
1778 {
1779 $groupsList = $projectsList = array();
1780 foreach($arSocnetGroups as $key => $value)
1781 {
1782 if (
1783 isset($value['project'])
1784 && $value['project'] === 'Y'
1785 )
1786 {
1787 $projectsList[$key] = $value;
1788 }
1789 else
1790 {
1791 $groupsList[$key] = $value;
1792 }
1793 }
1794
1795 return array(
1796 'SONETGROUPS' => $groupsList,
1797 'PROJECTS' => $projectsList
1798 );
1799 }
1800
1801 return $arSocnetGroups;
1802 }
1803
1804 public static function GetTreeList($id, $relation, $compat = false)
1805 {
1806 if ($compat)
1807 {
1808 $tmp = array();
1809 foreach($relation as $iid => $rel)
1810 {
1811 $p = $rel["parent"];
1812 if (!isset($tmp[$p]))
1813 {
1814 $tmp[$p] = array();
1815 }
1816 $tmp[$p][] = $iid;
1817 }
1818 $relation = $tmp;
1819 }
1820
1821 $arRelations = Array();
1822 if (is_array($relation[$id] ?? null))
1823 {
1824 foreach ($relation[$id] as $relId)
1825 {
1826 $arItems = Array();
1827 if (
1828 isset($relation[$relId])
1829 && !empty($relation[$relId])
1830 )
1831 {
1832 $arItems = self::GetTreeList($relId, $relation);
1833 }
1834
1835 $arRelations[$relId] = Array('id'=>$relId, 'type' => 'category', 'items' => $arItems);
1836 }
1837 }
1838
1839 return $arRelations;
1840 }
1841
1842 private static function GetSocnetGroupFilteredByFeaturePerms(&$arGroups, $arFeaturePerms)
1843 {
1844 $arGroupsIDs = array();
1845 foreach($arGroups as $value)
1846 {
1847 $arGroupsIDs[] = $value["id"];
1848 }
1849
1850 if (count($arGroupsIDs) <= 0)
1851 {
1852 return;
1853 }
1854
1855 $feature = $arFeaturePerms[0];
1856 $operations = $arFeaturePerms[1];
1857 if (!is_array($operations))
1858 {
1859 $operations = explode(",", $operations);
1860 }
1861 $arGroupsPerms = array();
1862 foreach($operations as $operation)
1863 {
1864 $tmpOps = CSocNetFeaturesPerms::CurrentUserCanPerformOperation(SONET_ENTITY_GROUP, $arGroupsIDs, $feature, $operation);
1865 if (is_array($tmpOps))
1866 {
1867 foreach ($tmpOps as $key=>$val)
1868 {
1869 if (!($arGroupsPerms[$key] ?? null))
1870 {
1871 $arGroupsPerms[$key] = $val;
1872 }
1873 }
1874 }
1875 }
1876 $arGroupsActive = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arGroupsIDs, $arFeaturePerms[0]);
1877 foreach ($arGroups as $key=>$group)
1878 {
1879 if (
1880 !$arGroupsActive[$group["id"]]
1881 || !$arGroupsPerms[$group["id"]]
1882 )
1883 {
1884 unset($arGroups[$key]);
1885 }
1886 }
1887 }
1888
1889 private static function GetSocnetGroupFilteredByInitiatePerms(&$arGroups)
1890 {
1891 $arGroupsIDs = array();
1892 foreach($arGroups as $value)
1893 {
1894 $arGroupsIDs[] = $value["id"];
1895 }
1896
1897 if (count($arGroupsIDs) <= 0)
1898 {
1899 return;
1900 }
1901
1902 if (
1903 CurrentUser::get()->isAdmin()
1904 || CSocNetUser::IsCurrentUserModuleAdmin(CSite::GetDefSite())
1905 )
1906 {
1907 return;
1908 }
1909
1910 $groupsList = array();
1911 $userRolesList = array();
1912
1913 $res = \Bitrix\Socialnetwork\WorkgroupTable::getList(array(
1914 'filter' => array(
1915 '@ID' => $arGroupsIDs
1916 ),
1917 'select' => array('ID', 'OWNER_ID', 'INITIATE_PERMS')
1918 ));
1919
1920 while ($group = $res->fetch())
1921 {
1922 $groupsList[$group['ID']] = array(
1923 'OWNER_ID' => $group['OWNER_ID'],
1924 'INITIATE_PERMS' => $group['INITIATE_PERMS']
1925 );
1926 }
1927
1928 $res = UserToGroupTable::getList(array(
1929 'filter' => array(
1930 'USER_ID' => (int)CurrentUser::get()->getId(),
1931 '@GROUP_ID' => $arGroupsIDs
1932 ),
1933 'select' => array('GROUP_ID', 'ROLE')
1934 ));
1935
1936 while ($relation = $res->fetch())
1937 {
1938 $userRolesList[$relation['GROUP_ID']] = $relation['ROLE'];
1939 }
1940
1941 $userId = (int)CurrentUser::get()->getId();
1942
1943 foreach ($arGroups as $key => $group)
1944 {
1945 $groupId = $group["id"];
1946
1947 $canInitiate = (
1948 (
1949 isset($groupsList[$groupId])
1950 && $groupsList[$groupId]["INITIATE_PERMS"] == UserToGroupTable::ROLE_OWNER
1951 && $userId == $groupsList[$groupId]["OWNER_ID"]
1952 )
1953 || (
1954 isset($groupsList[$groupId])
1955 && $groupsList[$groupId]["INITIATE_PERMS"] == UserToGroupTable::ROLE_MODERATOR
1956 && isset($userRolesList[$groupId])
1957 && in_array($userRolesList[$groupId], array(
1958 UserToGroupTable::ROLE_OWNER,
1959 UserToGroupTable::ROLE_MODERATOR
1960 ))
1961 )
1962 || (
1963 isset($groupsList[$groupId])
1964 && $groupsList[$groupId]["INITIATE_PERMS"] == UserToGroupTable::ROLE_USER
1965 && isset($userRolesList[$groupId])
1966 && in_array($userRolesList[$groupId], array(
1967 UserToGroupTable::ROLE_OWNER,
1968 UserToGroupTable::ROLE_MODERATOR,
1969 UserToGroupTable::ROLE_USER
1970 ))
1971 )
1972 );
1973
1974 if (!$canInitiate)
1975 {
1976 unset($arGroups[$key]);
1977 }
1978 }
1979 }
1980
1981 public static function GetDestinationUsers($accessCodes, $fetchUsers = false)
1982 {
1983 $userIds = [];
1984 $users = [];
1985 $fields = $fetchUsers
1986 ? ['ID', 'LOGIN', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'EMAIL', 'PERSONAL_PHOTO', 'WORK_POSITION', 'EXTERNAL_AUTH_ID']
1987 : ['ID'];
1988
1989 $usersToFetch = [];
1990
1991 if (is_array($accessCodes))
1992 {
1993 foreach($accessCodes as $code)
1994 {
1995 // All users
1996 if ($code === 'UA')
1997 {
1998 $dbRes = CUser::GetList(
1999 'ID',
2000 'ASC',
2001 ['INTRANET_USERS' => true],
2002 ['FIELDS' => $fields]
2003 );
2004
2005 while ($user = $dbRes->Fetch())
2006 {
2007 if (array_key_exists($user['ID'], $userIds))
2008 {
2009 continue;
2010 }
2011
2012 $userIds[$user['ID']] = $user['ID'];
2013 if ($fetchUsers)
2014 {
2015 $user['USER_ID'] = $user['ID'];
2016 $users[] = $user;
2017 }
2018 }
2019 break;
2020 }
2021 elseif (mb_substr($code, 0, 1) === 'U')
2022 {
2023 $userId = (int)mb_substr($code, 1);
2024 if (!array_key_exists($userId, $userIds))
2025 {
2026 $usersToFetch[] = $userId;
2027 if (!$fetchUsers)
2028 {
2029 $userIds[$userId] = $userId;
2030 }
2031 }
2032 }
2033 elseif (mb_substr($code, 0, 2) === 'SG')
2034 {
2035 $groupId = intval(mb_substr($code, 2));
2036
2037 $isProjectRoles = preg_match('/^SG([0-9]+)_?([AEKMO])?$/', $code, $match) && isset($match[2]);
2038
2039 if ($isProjectRoles)
2040 {
2041 // todo remove after new system the project roles.
2042 [$users, $userIds] = self::getUsersByRole($groupId, $match[2], $users, $userIds);
2043
2044 continue;
2045 }
2046
2047 $dbMembers = CSocNetUserToGroup::GetList(
2048 ["RAND" => "ASC"],
2049 ["GROUP_ID" => $groupId, "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"],
2050 false,
2051 false,
2052 ["ID", "USER_ID", "ROLE", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_EMAIL", "USER_PERSONAL_PHOTO", "USER_WORK_POSITION"]
2053 );
2054
2055 if ($dbMembers)
2056 {
2057 while ($user = $dbMembers->GetNext())
2058 {
2059 if (array_key_exists($user['USER_ID'], $userIds))
2060 {
2061 continue;
2062 }
2063 $userIds[$user['USER_ID']] = $user["USER_ID"];
2064 $users[] = [
2065 'ID' => $user["USER_ID"],
2066 'USER_ID' => $user["USER_ID"],
2067 'LOGIN' => $user["USER_LOGIN"],
2068 'NAME' => $user["USER_NAME"],
2069 'LAST_NAME' => $user["USER_LAST_NAME"],
2070 'SECOND_NAME' => $user["USER_SECOND_NAME"],
2071 'EMAIL' => $user["USER_EMAIL"],
2072 'PERSONAL_PHOTO' => $user["USER_PERSONAL_PHOTO"],
2073 'WORK_POSITION' => $user["USER_WORK_POSITION"]
2074 ];
2075 }
2076 }
2077 }
2078 elseif (mb_substr($code, 0, 2) === 'DR')
2079 {
2080 $depId = (int)mb_substr($code, 2);
2081
2082 $res = \Bitrix\Intranet\Util::getDepartmentEmployees([
2083 'DEPARTMENTS' => $depId,
2084 'RECURSIVE' => 'Y',
2085 'ACTIVE' => 'Y',
2086 'SELECT' => $fields
2087 ]);
2088
2089 while ($user = $res->Fetch())
2090 {
2091 if (!array_key_exists($user['ID'], $userIds))
2092 {
2093 $userIds[$user['ID']] = $user['ID'];
2094 if ($fetchUsers)
2095 {
2096 $user['USER_ID'] = $user['ID'];
2097 $users[] = $user;
2098 }
2099 }
2100 }
2101 }
2102 }
2103 }
2104
2105 if (
2106 !empty($usersToFetch)
2107 && $fetchUsers
2108 )
2109 {
2110 $usersToFetch = array_chunk(array_values($usersToFetch), self::USERS_STEP_COUNT);
2111
2112 foreach ($usersToFetch as $chunk)
2113 {
2114 $usersRes = \Bitrix\Main\UserTable::getList([
2115 'select' => $fields,
2116 'filter' => [
2117 '@ID' => array_values($chunk)
2118 ],
2119 'order' => [
2120 'ID' => 'ASC'
2121 ]
2122 ])->fetchAll();
2123
2124 foreach ($usersRes as $user)
2125 {
2126 if (array_key_exists($user['ID'], $userIds))
2127 {
2128 continue;
2129 }
2130
2131 $userIds[$user['ID']] = $user['ID'];
2132 $user['USER_ID'] = $user['ID'];
2133 $users[] = $user;
2134 }
2135 }
2136 }
2137
2138 return $fetchUsers ? $users : $userIds;
2139 }
2140
2141 private static function getUsersByRole(int $groupId, $role, array $users, array $userIds): array
2142 {
2143 $isScrumCustomRole = false;
2144 $scrumCustomRole = '';
2145
2146 $availableRoles = [
2147 SONET_ROLES_USER,
2148 SONET_ROLES_MODERATOR,
2149 SONET_ROLES_OWNER,
2150 ];
2151
2152 // todo maybe remove 'M' role after new system the project roles.
2153 $customScrumRoles = ['M'];
2154 $availableRoles = array_merge($availableRoles, $customScrumRoles);
2155
2156 $group = Bitrix\Socialnetwork\Item\Workgroup::getById($groupId);
2157
2158 $role = in_array($role, $availableRoles) ? $role : SONET_ROLES_USER;
2159
2160 if (in_array($role, $customScrumRoles))
2161 {
2162 $isScrumCustomRole = true;
2163 $scrumCustomRole = $role;
2164 $role = SONET_ROLES_MODERATOR;
2165 }
2166
2167 $dbMembers = CSocNetUserToGroup::GetList(
2168 ["RAND" => "ASC"],
2169 [
2170 "GROUP_ID" => $groupId,
2171 "=ROLE" => $isScrumCustomRole ? [SONET_ROLES_OWNER, SONET_ROLES_MODERATOR] : $role,
2172 "USER_ACTIVE" => "Y"
2173 ],
2174 false,
2175 false,
2176 [
2177 "ID",
2178 "USER_ID",
2179 "ROLE",
2180 "USER_NAME",
2181 "USER_LAST_NAME",
2182 "USER_SECOND_NAME",
2183 "USER_LOGIN",
2184 "USER_EMAIL",
2185 "USER_PERSONAL_PHOTO",
2186 "USER_WORK_POSITION",
2187 ]
2188 );
2189
2190 if ($dbMembers)
2191 {
2192 while ($user = $dbMembers->GetNext())
2193 {
2194 if ($group && $group->isScrumProject())
2195 {
2196 if ($role === SONET_ROLES_MODERATOR)
2197 {
2198 $scrumMasterId = $group->getScrumMaster();
2199
2200 if ($isScrumCustomRole)
2201 {
2202 if ($scrumCustomRole === 'M' && $user["USER_ID"] != $scrumMasterId)
2203 {
2204 continue;
2205 }
2206 }
2207 else
2208 {
2209 if ($user["USER_ID"] == $scrumMasterId)
2210 {
2211 continue;
2212 }
2213 }
2214 }
2215 }
2216
2217 if (!array_key_exists($user["USER_ID"], $userIds))
2218 {
2219 $userIds[$user["USER_ID"]] = $user["USER_ID"];
2220 $users[] = [
2221 'ID' => $user["USER_ID"],
2222 'USER_ID' => $user["USER_ID"],
2223 'LOGIN' => $user["USER_LOGIN"],
2224 'NAME' => $user["USER_NAME"],
2225 'LAST_NAME' => $user["USER_LAST_NAME"],
2226 'SECOND_NAME' => $user["USER_SECOND_NAME"],
2227 'EMAIL' => $user["USER_EMAIL"],
2228 'PERSONAL_PHOTO' => $user["USER_PERSONAL_PHOTO"],
2229 'WORK_POSITION' => $user["USER_WORK_POSITION"]
2230 ];
2231 }
2232 }
2233 }
2234
2235 return [$users, $userIds];
2236 }
2237
2238 public static function GetDestinationSort($arParams = array(), &$dataAdditional = false)
2239 {
2240 $res = \Bitrix\Main\UI\Selector\Entities::getLastSort($arParams);
2241 $dataAdditional = $res['DATA_ADDITIONAL'];
2242
2243 return $res['DATA'];
2244 }
2245
2246 public static function fillLastDestination($arDestinationSort, &$arLastDestination, $arParams = array())
2247 {
2248 $res = \Bitrix\Main\UI\Selector\Entities::fillLastDestination($arDestinationSort, $arParams);
2249 $arLastDestination = $res['LAST_DESTINATIONS'];
2250
2251 return $res['DATA'];
2252 }
2253
2254 public static function fillEmails(&$arDest)
2255 {
2256 $arDest["EMAILS"] = array();
2257 $arDest["LAST"]["EMAILS"] = array();
2258
2259 if (
2260 !empty($arDest)
2261 && !empty($arDest["LAST"])
2262 && !empty($arDest["LAST"]["USERS"])
2263 && !empty($arDest["USERS"])
2264 )
2265 {
2266 foreach($arDest["LAST"]["USERS"] as $key => $value)
2267 {
2268 if (
2269 isset($arDest["USERS"][$key])
2270 && is_array($arDest["USERS"][$key])
2271 && isset($arDest["USERS"][$key]["isEmail"])
2272 && $arDest["USERS"][$key]["isEmail"] === "Y"
2273 )
2274 {
2275 $arDest["EMAILS"][$key] = $arDest["USERS"][$key];
2276 $arDest["LAST"]["EMAILS"][$key] = $value;
2277 }
2278 }
2279 }
2280 }
2281
2282 public static function fillCrmEmails(&$arDest)
2283 {
2284 $arDest["CRMEMAILS"] = array();
2285 $arDest["LAST"]["CRMEMAILS"] = array();
2286
2287 if (
2288 !empty($arDest)
2289 && !empty($arDest["LAST"])
2290 && !empty($arDest["LAST"]["USERS"])
2291 && !empty($arDest["USERS"])
2292 )
2293 {
2294 foreach($arDest["LAST"]["USERS"] as $key => $value)
2295 {
2296 if (
2297 isset($arDest["USERS"][$key])
2298 && is_array($arDest["USERS"][$key])
2299 && isset($arDest["USERS"][$key]["isCrmEmail"])
2300 && $arDest["USERS"][$key]["isCrmEmail"] === "Y"
2301 )
2302 {
2303 $arDest["CRMEMAILS"][$key] = $arDest["USERS"][$key];
2304 $arDest["LAST"]["CRMEMAILS"][$key] = $value;
2305 }
2306 }
2307 }
2308 }
2309
2310 public static function getUsersAll($arParams = [])
2311 {
2312 global $DB;
2313 $connection = \Bitrix\Main\Application::getConnection();
2314 $helper = $connection->getSqlHelper();
2315
2316 static $arFieldsStatic = array(
2317 "ID" => Array("FIELD" => "U.ID", "TYPE" => "int"),
2318 "ACTIVE" => Array("FIELD" => "U.ACTIVE", "TYPE" => "string"),
2319 "NAME" => Array("FIELD" => "U.NAME", "TYPE" => "string"),
2320 "EMAIL" => Array("FIELD" => "U.EMAIL", "TYPE" => "string"),
2321 "LAST_NAME" => Array("FIELD" => "U.LAST_NAME", "TYPE" => "string"),
2322 "SECOND_NAME" => Array("FIELD" => "U.SECOND_NAME", "TYPE" => "string"),
2323 "LOGIN" => Array("FIELD" => "U.LOGIN", "TYPE" => "string"),
2324 "PERSONAL_PHOTO" => Array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "int"),
2325 "WORK_POSITION" => Array("FIELD" => "U.WORK_POSITION", "TYPE" => "string"),
2326 "CONFIRM_CODE" => Array("FIELD" => "U.CONFIRM_CODE", "TYPE" => "string"),
2327 "PERSONAL_PROFESSION" => Array("FIELD" => "U.PERSONAL_PROFESSION", "TYPE" => "string"),
2328 "EXTERNAL_AUTH_ID" => Array("FIELD" => "U.EXTERNAL_AUTH_ID", "TYPE" => "string")
2329 );
2330
2331 $arFields = $arFieldsStatic;
2332 $arFields["IS_ONLINE"] = Array(
2333 "FIELD" => "case when U.LAST_ACTIVITY_DATE > " . $helper->addSecondsToDateTime(-CUser::getSecondsForLimitOnline()) . " then 'Y' else 'N' end"
2334 );
2335
2336 $currentUserId = (int)CurrentUser::get()->getId();
2337
2338 if (!$currentUserId)
2339 {
2340 return array();
2341 }
2342
2343 $bExtranetEnabled = CModule::includeModule("extranet");
2344
2345 $bExtranetUser = (
2346 $bExtranetEnabled
2347 && !CExtranet::IsIntranetUser()
2348 );
2349
2350 $bExtranetWorkgroupsAllowed = (
2351 $bExtranetEnabled
2352 && CExtranet::WorkgroupsAllowed()
2353 );
2354
2355 $bShowAllContactsAllowed = (
2356 $bExtranetEnabled
2357 && CExtranet::ShowAllContactsAllowed()
2358 );
2359
2360 $rsData = CUserTypeEntity::GetList(
2361 array("ID" => "ASC"),
2362 array(
2363 "FIELD_NAME" => "UF_DEPARTMENT",
2364 "ENTITY_ID" => "USER"
2365 )
2366 );
2367 if($arRes = $rsData->Fetch())
2368 {
2369 $UFId = (int)$arRes["ID"];
2370 }
2371 else
2372 {
2373 return array();
2374 }
2375
2376 if (
2377 $bExtranetUser
2378 && !$bExtranetWorkgroupsAllowed
2379 ) // limited extranet
2380 {
2381 return false;
2382 }
2383
2384 $arOrder = array("ID" => "ASC");
2385 $arFilter = array('ACTIVE' => 'Y');
2386
2387 if (
2388 IsModuleInstalled("intranet")
2389 || COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y"
2390 )
2391 {
2392 $arFilter["CONFIRM_CODE"] = false;
2393 }
2394
2395 $arExternalAuthId = self::getExternalAuthIdBlackList([
2396 'ALLOW_BOTS' => (isset($arParams['ALLOW_BOTS']) && $arParams['ALLOW_BOTS'] === true)
2397 ]);
2398 $arExternalAuthId[] = 'email';
2399 $arFilter['!EXTERNAL_AUTH_ID'] = $arExternalAuthId;
2400
2401 $arGroupBy = false;
2402 $arSelectFields = array("ID", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "PERSONAL_PHOTO", "WORK_POSITION", "PERSONAL_PROFESSION", "EXTERNAL_AUTH_ID", "EMAIL", "IS_ONLINE");
2403
2404 $arSqls = CSocNetGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
2405 $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
2406 $strJoin = $strJoin2 = $arSqls2 = false;
2407
2408 if ($bExtranetEnabled)
2409 {
2410 if ($bExtranetWorkgroupsAllowed)
2411 {
2412 if (!$bExtranetUser)
2413 {
2414 $strJoin = "
2415 INNER JOIN b_utm_user UM ON UM.VALUE_ID = U.ID and FIELD_ID = ".intval($UFId)."
2416 ";
2417
2418 $tmp = $arSqls;
2419
2420 $arSqls["WHERE"] .= ($arSqls["WHERE"] <> '' ? " AND " : "")."
2421 (UM.VALUE_INT > 0)";
2422
2423 if (!$bShowAllContactsAllowed)
2424 {
2425 // select all the users (intranet and extranet from my groups)
2426 $strJoin2 = "
2427 INNER JOIN b_sonet_user2group UG ON UG.USER_ID = U.ID AND UG.ROLE <= '".SONET_ROLES_USER."'
2428 INNER JOIN b_sonet_user2group UG_MY
2429 ON UG_MY.GROUP_ID = UG.GROUP_ID AND UG_MY.USER_ID = ".(int)$currentUserId."
2430 AND UG_MY.ROLE <= '".UserToGroupTable::ROLE_USER."'
2431 LEFT JOIN b_utm_user UM ON UM.VALUE_ID = U.ID and FIELD_ID = ".(int)$UFId."
2432 ";
2433 $arSqls2 = $tmp;
2434 }
2435 }
2436 else
2437 {
2438 $strJoin = "
2439 INNER JOIN b_sonet_user2group UG ON UG.USER_ID = U.ID AND UG.ROLE <= '".SONET_ROLES_USER."'
2440 INNER JOIN b_sonet_user2group UG_MY
2441 ON UG_MY.GROUP_ID = UG.GROUP_ID AND UG_MY.USER_ID = ".(int)$currentUserId."
2442 AND UG_MY.ROLE <= '".UserToGroupTable::ROLE_USER."'
2443 LEFT JOIN b_utm_user UM ON UM.VALUE_ID = U.ID and FIELD_ID = ".(int)$UFId."
2444 ";
2445 }
2446 }
2447 elseif (!$bShowAllContactsAllowed) // limited extranet, only for intranet users, don't show extranet
2448 {
2449 $strJoin = "INNER JOIN b_utm_user UM ON UM.VALUE_ID = U.ID and FIELD_ID = ".intval($UFId);
2450 $arSqls["WHERE"] .= ($arSqls["WHERE"] <> '' ? " AND " : "")."UM.VALUE_INT > 0";
2451 }
2452 }
2453
2454 $strSql =
2455 "SELECT
2456 ".(
2457 $bExtranetEnabled
2458 ? $arSqls["SELECT"].", CASE WHEN UM.VALUE_INT > 0 THEN 'employee' WHEN EXTERNAL_AUTH_ID = 'email' THEN 'email' ELSE 'extranet' END USER_TYPE"
2459 : $arSqls["SELECT"].", CASE WHEN EXTERNAL_AUTH_ID = 'email' THEN 'email' ELSE 'employee' END USER_TYPE"
2460 )."
2461 FROM b_user U
2462 ".$arSqls["FROM"]." ";
2463
2464 if ($strJoin)
2465 {
2466 $strSql .= $strJoin." ";
2467 }
2468
2469 if ($arSqls["WHERE"] <> '')
2470 {
2471 $strSql .= "WHERE ".$arSqls["WHERE"]." ";
2472 }
2473
2474 $strSql .= "GROUP BY U.ID".($bExtranetEnabled ? ",UM.VALUE_INT" : "")." ";
2475
2476 if ($strJoin2)
2477 {
2478 $strSql .=
2479 "UNION SELECT
2480 ".$arSqls2["SELECT"].", CASE WHEN UM.VALUE_INT > 0 THEN 'employee' WHEN EXTERNAL_AUTH_ID = 'email' THEN 'email' ELSE 'extranet' END USER_TYPE
2481 FROM b_user U
2482 ".$arSqls2["FROM"]." ";
2483
2484 $strSql .= $strJoin2." ";
2485
2486 if ($arSqls2["WHERE"] <> '')
2487 {
2488 $strSql .= "WHERE ".$arSqls2["WHERE"]." ";
2489 }
2490
2491 $strSql .= "GROUP BY U.ID".($bExtranetEnabled ? ",UM.VALUE_INT" : "")." ";
2492
2493 $strSql .= "ORDER BY ID ASC"; // cannot use alias
2494 }
2495 else // only without union
2496 {
2497 if ($arSqls["ORDERBY"] <> '')
2498 {
2499 $strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";
2500 }
2501 }
2502
2503 //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
2504
2505 $dbRes = $DB->Query($strSql);
2506
2507 $maxCount = (IsModuleInstalled('bitrix24') ? 200 : 500);
2508 $resultCount = 0;
2509 $countExceeded = false;
2510 $arUsers = array();
2511
2512 if ($bExtranetEnabled)
2513 {
2515 }
2516
2517 while ($arUser = $dbRes->GetNext())
2518 {
2519 if (
2520 $resultCount > $maxCount
2521 && (!isset($arParams['RETURN_FULL_LIST']) || $arParams['RETURN_FULL_LIST'] !== 'Y')
2522 )
2523 {
2524 $countExceeded = true;
2525 break;
2526 }
2527
2528 $sName = trim(CUser::FormatName(empty($arParams["NAME_TEMPLATE"]) ? CSite::GetNameFormat(false) : $arParams["NAME_TEMPLATE"], $arUser, true, false));
2529
2530 if (empty($sName))
2531 {
2532 $sName = $arUser["~LOGIN"];
2533 }
2534
2535 $arFileTmp = CFile::ResizeImageGet(
2536 $arUser["PERSONAL_PHOTO"],
2537 array('width' => 100, 'height' => 100),
2539 false
2540 );
2541
2542 $arUsers['U'.$arUser["ID"]] = Array(
2543 'id' => 'U'.$arUser["ID"],
2544 'entityId' => $arUser["ID"],
2545 'email' => $arUser["EMAIL"],
2546 'name' => $sName,
2547 'avatar' => empty($arFileTmp['src'])? '': $arFileTmp['src'],
2548 'desc' => $arUser['WORK_POSITION'] ? $arUser['WORK_POSITION'] : ($arUser['PERSONAL_PROFESSION'] ? $arUser['PERSONAL_PROFESSION'] : '&nbsp;'),
2549 'isExtranet' => (isset($arUser['USER_TYPE']) && $arUser['USER_TYPE'] === 'extranet' ? "Y" : "N"),
2550 'isEmail' => ($arUser['EXTERNAL_AUTH_ID'] === 'email' ? 'Y' : 'N'),
2551 'active' => 'Y'
2552 );
2553
2554 if ($arUser['EXTERNAL_AUTH_ID'] === 'email')
2555 {
2556 $arUsers['U'.$arUser["ID"]]['email'] = $arUser['EMAIL'];
2557 }
2558
2559 $arUsers['U'.$arUser["ID"]]['checksum'] = md5(serialize($arUsers['U'.$arUser["ID"]]));
2560 $arUsers['U'.$arUser["ID"]]['login'] = '';
2561
2562 $resultCount++;
2563 }
2564
2565 if ($countExceeded)
2566 {
2568 array(
2569 "id" => array($currentUserId)
2570 ),
2571 true
2572 );
2573 }
2574
2575 return $arUsers;
2576 }
2577
2578 public static function formatUser($arUser, $arParams = array())
2579 {
2580 static $siteNameFormat = false;
2581 static $isIntranetInstalled = false;
2582 static $extranetUserIdList = false;
2583
2584 if ($siteNameFormat === false)
2585 {
2586 $siteNameFormat = CSite::GetNameFormat(false);
2587 }
2588
2589 if ($isIntranetInstalled === false)
2590 {
2591 $isIntranetInstalled = (IsModuleInstalled('intranet') ? 'Y' : 'N');
2592 }
2593
2594 if ($extranetUserIdList === false)
2595 {
2597 }
2598
2599 $arFileTmp = CFile::ResizeImageGet(
2600 $arUser["PERSONAL_PHOTO"],
2601 array('width' => 100, 'height' => 100),
2603 false
2604 );
2605
2606 $arRes = array(
2607 'id' => 'U'.$arUser["ID"],
2608 'entityId' => $arUser["ID"]
2609 );
2610
2611 if (ModuleManager::isModuleInstalled('intranet'))
2612 {
2613 $arRes["email"] = $arUser['EMAIL'];
2614 }
2615
2616 $arRes = array_merge($arRes, array(
2617 'name' => CUser::FormatName(
2618 (
2619 !empty($arParams["NAME_TEMPLATE"])
2620 ? $arParams["NAME_TEMPLATE"]
2621 : $siteNameFormat
2622 ),
2623 $arUser,
2624 true,
2625 true
2626 ),
2627 'avatar' => (
2628 empty($arFileTmp['src'])
2629 ? ''
2630 : $arFileTmp['src']
2631 ),
2632 'desc' => self::getUserDescription($arUser, [
2633 'showEmail' => !empty($arParams["ONLY_WITH_EMAIL"])
2634 ]),
2635 'isExtranet' => (
2636 in_array($arUser["ID"], $extranetUserIdList)
2637 ? "Y"
2638 : "N"
2639 ),
2640 'isEmail' => (
2641 isset($arUser['EXTERNAL_AUTH_ID'])
2642 && $arUser['EXTERNAL_AUTH_ID'] === 'email'
2643 ? 'Y'
2644 : 'N'
2645 )
2646 ));
2647
2648 if (!empty($arUser["UF_USER_CRM_ENTITY"]))
2649 {
2650 $arRes['crmEntity'] = $arUser["UF_USER_CRM_ENTITY"];
2651 }
2652
2653 if (!empty($arUser["ACTIVE"]))
2654 {
2655 $arRes['active'] = $arUser["ACTIVE"];
2656 }
2657
2658 if (
2659 (
2660 isset($arParams['USE_EMAIL'])
2661 && $arParams['USE_EMAIL']
2662 )
2663 || $arRes['isEmail'] === 'Y'
2664 )
2665 {
2666 if ($arUser["NAME"] <> '')
2667 {
2668 $arRes['showEmail'] = "Y";
2669 }
2670 }
2671
2672 $db_events = GetModuleEvents("socialnetwork", "OnSocNetLogDestinationFormatUser");
2673 while ($arEvent = $db_events->Fetch())
2674 {
2675 ExecuteModuleEventEx($arEvent, array($arUser, &$arRes));
2676 }
2677
2678 $checksum = md5(serialize($arRes));
2679 $arRes['checksum'] = $checksum;
2680
2681 $arRes['login'] = (
2682 $isIntranetInstalled === 'Y'
2683 && isset($arParams['USE_LOGIN'])
2684 && $arParams['USE_LOGIN']
2685 ? $arUser["LOGIN"]
2686 : ''
2687 );
2688
2689 $arRes['index'] = (
2690 isset($arUser["SEARCH_USER_CONTENT"])
2691 ? $arUser["SEARCH_USER_CONTENT"]
2692 : ''
2693 );
2694
2695 return $arRes;
2696 }
2697
2698 public static function formatCrmEmailEntity($fields, $params = array())
2699 {
2700 static $siteNameFormat = false;
2701
2702 $result = array();
2703 $userParams = array();
2704
2705 if (
2706 is_array($params)
2707 && isset($params["TYPE"])
2708 && in_array($params["TYPE"], array('CONTACT', 'COMPANY', 'LEAD'))
2709 )
2710 {
2711 if ($siteNameFormat === false)
2712 {
2713 $siteNameFormat = (
2714 !empty($params["NAME_TEMPLATE"])
2715 ? $params["NAME_TEMPLATE"]
2716 : CSite::GetNameFormat(false)
2717 );
2718 }
2719
2720 $prefix = '';
2721 if ($params["TYPE"] === 'CONTACT')
2722 {
2723 $prefix = 'C_';
2724 $imageField = 'PHOTO';
2725 $userParams = array(
2726 'name' => $fields['NAME'],
2727 'lastName' => $fields['LAST_NAME']
2728 );
2729 $name = CUser::FormatName(
2730 $siteNameFormat,
2731 $fields,
2732 true,
2733 true
2734 );
2735 }
2736 elseif ($params["TYPE"] === 'COMPANY')
2737 {
2738 $prefix = 'CO_';
2739 $imageField = 'LOGO';
2740 $name = $fields['TITLE'];
2741 $userParams = array(
2742 'name' => '',
2743 'lastName' => $fields['TITLE']
2744 );
2745 }
2746 elseif ($params["TYPE"] === 'LEAD')
2747 {
2748 $prefix = 'L_';
2749 $imageField = false;
2750 $name = $fields['TITLE'];
2751 $userParams = array(
2752 'name' => $fields['NAME'],
2753 'lastName' => $fields['LAST_NAME']
2754 );
2755 $username = CUser::FormatName(
2756 $siteNameFormat,
2757 $fields,
2758 true,
2759 true
2760 );
2761 if (!empty($username))
2762 {
2763 $name .= ', '.$username;
2764 }
2765 }
2766
2767 if (
2768 $imageField
2769 && isset($fields[$imageField])
2770 )
2771 {
2772 $arFileTmp = CFile::ResizeImageGet(
2773 $fields[$imageField],
2774 array('width' => 100, 'height' => 100),
2776 false
2777 );
2778 }
2779 else
2780 {
2781 $arFileTmp = array();
2782 }
2783
2784 $result = array(
2785 'id' => $prefix.$fields["ID"],
2786 'crmEntity' => $prefix.$fields["ID"],
2787 'entityId' => $fields['ID'],
2788 'name' => $name,
2789 'avatar' => (
2790 empty($arFileTmp['src'])
2791 ? ''
2792 : $arFileTmp['src']
2793 ),
2794 'desc' => (!empty($params['EMAIL']) ? $params['EMAIL'] : ''),
2795 'email' => (!empty($params['EMAIL']) ? $params['EMAIL'] : ''),
2796 'isExtranet' => 'N',
2797 'isEmail' => 'Y',
2798 'isCrmEmail' => 'Y',
2799 'params' => $userParams
2800 );
2801 }
2802
2803 return $result;
2804 }
2805
2806 public static function formatNetworkUser($fields, $params = array())
2807 {
2808 static $siteNameFormat = false;
2809
2810 if ($siteNameFormat === false)
2811 {
2812 $siteNameFormat = (
2813 !empty($params["NAME_TEMPLATE"])
2814 ? $params["NAME_TEMPLATE"]
2815 : CSite::GetNameFormat(false)
2816 );
2817 }
2818
2819 $name = CUser::FormatName(
2820 $siteNameFormat,
2821 $fields,
2822 true,
2823 true
2824 );
2825
2826 if (isset($fields["EXTERNAL_AUTH_ID"]) && $fields["EXTERNAL_AUTH_ID"] === "replica")
2827 [,$domain] = explode("@", $fields["LOGIN"], 2);
2828 else
2829 $domain = $fields["CLIENT_DOMAIN"];
2830
2831 if ($fields["PERSONAL_PHOTO"])
2832 {
2833 $arFileTmp = CFile::ResizeImageGet(
2834 $fields["PERSONAL_PHOTO"],
2835 array('width' => 32, 'height' => 32),
2837 false
2838 );
2839 }
2840
2841 $userParams = array(
2842 'name' => $fields['NAME'],
2843 'lastName' => $fields['LAST_NAME'],
2844 'domain' => $domain,
2845 );
2846
2847 $result = array(
2848 'id' => isset($fields['ID'])? $fields['ID']: $fields['XML_ID'],
2849 'entityId' => isset($fields['ID'])? $fields['ID']: $fields['XML_ID'],
2850 'name' => $name,
2851 'avatar' => $fields["PERSONAL_PHOTO"] && !empty($arFileTmp['src'])? $arFileTmp['src']: '',
2852 'desc' => $domain,
2853 'showDesc' => true,
2854 'email' => (!empty($fields['EMAIL']) ? $fields['EMAIL'] : ''),
2855 'networkId' => $fields['NETWORK_ID'],
2856 'isExtranet' => 'N',
2857 'isEmail' => 'N',
2858 'isNetwork' => 'Y',
2859 'params' => $userParams
2860 );
2861
2862 return $result;
2863 }
2864
2865 private static function getExternalAuthIdBlackList($params = array())
2866 {
2867 $result = [
2868 "imconnector"
2869 ];
2870
2871 if (
2872 !is_array($params)
2873 || !isset($params["NETWORK_SEARCH"])
2874 || !$params["NETWORK_SEARCH"]
2875 )
2876 {
2877 $result[] = 'replica';
2878 }
2879
2880 if (
2881 !is_array($params)
2882 || !isset($params['ALLOW_BOTS'])
2883 || !$params['ALLOW_BOTS']
2884 )
2885 {
2886 $result[] = 'bot';
2887 }
2888
2889 return $result;
2890 }
2891
2892 public static function getUserDescription(array $userFields = [], array $params = [])
2893 {
2894 $showEmail = (!empty($params['showEmail']) ? !!$params['showEmail'] : false);
2895
2896 return (
2897 $showEmail
2898 && ModuleManager::isModuleInstalled('intranet')
2899 ? (
2900 isset($userFields["EMAIL"])
2901 && $userFields["EMAIL"] <> ''
2902 ? $userFields["EMAIL"]
2903 : '&nbsp;'
2904 )
2905 : (
2906 isset($userFields['WORK_POSITION'])
2907 && $userFields['WORK_POSITION'] <> ''
2908 ? $userFields['WORK_POSITION']
2909 : (
2910 isset($userFields['PERSONAL_PROFESSION'])
2911 && $userFields['PERSONAL_PROFESSION'] <> ''
2912 ? $userFields['PERSONAL_PROFESSION']
2913 : '&nbsp;'
2914 )
2915 )
2916 );
2917 }
2918}
$arParams
Определения access_dialog.php:21
return select
Определения access_edit.php:440
$count
Определения admin_tab.php:4
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
static includeModule($moduleName)
Определения loader.php:67
static getList(array $parameters=array())
Определения datamanager.php:431
static prepareStringToken($token)
Определения content.php:18
Определения emoji.php:10
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения htmlfilter.php:12
static ResizeImageGet($file, $arSize, $resizeType=BX_RESIZE_IMAGE_PROPORTIONAL, $bInitSizes=false, $arFilters=false, $bImmediate=false, $jpgQuality=false)
Определения file.php:2242
Определения cache.php:11
static GetLastUser()
Определения log_destination.php:20
static GetLastDepartment()
Определения log_destination.php:107
static GetExtranetUser(array $arParams=array())
Определения log_destination.php:260
static getUserDescription(array $userFields=[], array $params=[])
Определения log_destination.php:2892
static GetGratMedalUsers($arParams=Array())
Определения log_destination.php:695
static formatUser($arUser, $arParams=array())
Определения log_destination.php:2578
static formatCrmEmailEntity($fields, $params=array())
Определения log_destination.php:2698
const LIST_USER_LIMIT
Определения log_destination.php:12
static searchUsers($search, &$nt="", $bSelf=true, $bEmployeesOnly=false, $bExtranetOnly=false, $departmentId=false)
Определения log_destination.php:785
static GetStucture($arParams=Array())
Определения log_destination.php:137
static formatNetworkUser($fields, $params=array())
Определения log_destination.php:2806
static GetLastSocnetGroup()
Определения log_destination.php:74
static GetUsers($arParams=Array(), $bSelf=true)
Определения log_destination.php:346
static __percent_walk(&$val)
Определения log_destination.php:780
static InitGlobalExtranetArrays($SITE_ID=SITE_ID)
Определения functions.php:1329
global $CACHE_MANAGER
Определения clear_component_cache.php:7
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$maxCount
Определения options.php:1622
$res
Определения filter_act.php:7
GetFilterQuery($field, $val, $procent="Y", $ex_sep=array(), $clob="N", $div_fields="Y", $clob_upper="N")
Определения filter_tools.php:383
$result
Определения get_property_values.php:14
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
const EMAIL
Определения idea_notify.php:6
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
const BX_RESIZE_IMAGE_EXACT
Определения constants.php:12
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
IsModuleInstalled($module_id)
Определения tools.php:5301
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
check_email($email, $strict=false, $domainCheck=false)
Определения tools.php:4571
$name
Определения menu_edit.php:35
$order
Определения payment.php:8
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$val
Определения options.php:1793
$matches
Определения index.php:22
const SONET_ROLES_USER
Определения include.php:31
$arRes
Определения options.php:104
const SITE_ID
Определения sonet_set_content_view.php:12
$arFilter
Определения user_search.php:106
$dbRes
Определения yandex_detail.php:168
$fields
Определения yandex_run.php:501