1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
im_contact_list.php
См. документацию.
1<?
3
4use Bitrix\Im as IM;
8
10{
11 private $user_id = 0;
12
13 const NETWORK_AUTH_ID = 'replica';
14
15 function __construct($user_id = false)
16 {
17 global $USER;
18 $user_id = intval($user_id);
19 if ($user_id == 0)
20 $user_id = intval($USER->GetID());
21
22 $this->user_id = $user_id;
23 }
24
25 private function getDepartments(): array
26 {
27 if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser())
28 {
29 return [];
30 }
31
32 $departments = [];
33 $departmentService = IM\V2\Integration\HumanResources\Department\Department::getInstance();
34 foreach ($departmentService->getList() as $department)
35 {
36 $departmentName = $department->name;
37 if (
38 $department->depthLevel > 0
39 && isset($departments[$department->parent]['name'])
40 )
41 {
42 $departmentName .= ' / ' . $departments[$department->parent]['name'];
43 }
44
45 $departments[$department->id] = [
46 'id' => $department->id,
47 'name' => $departmentName,
48 ];
49 }
50
51 return $departments;
52 }
53
54 function GetList($arParams = Array())
55 {
56 global $USER, $CACHE_MANAGER;
57
58 $bLoadUsers = isset($arParams['LOAD_USERS']) && $arParams['LOAD_USERS'] == 'N'? false: true;
59 $bLoadChats = isset($arParams['LOAD_CHATS']) && $arParams['LOAD_CHATS'] == 'N'? false: true;
60
61 $arGroups = [];
62 if(defined("BX_COMP_MANAGED_CACHE"))
63 $ttl = 2592000;
64 else
65 $ttl = 600;
66
67 $bBusShowAll = !IsModuleInstalled('intranet') && COption::GetOptionInt('im', 'contact_list_show_all_bus');
68
69 $bIntranetEnable = false;
70 if(CModule::IncludeModule('intranet'))
71 {
72 $bIntranetEnable = true;
73 $arGroups = $this->getDepartments();
74 }
75
76 $arUserSG = array();
77 $arUsers = array();
78 $arUserInGroup = array();
79 $arExtranetUsers = array();
80
82 if (is_array($groups))
83 {
84 foreach ($groups as $groupId => $group)
85 {
86 $arUserInGroup[$groupId] = Array('id' => $groupId, 'users' => $group['USERS']);
87 foreach ($group['USERS'] as $groupUserId)
88 {
89 $arExtranetUsers[$groupUserId] = $groupUserId;
90 }
91 $arUserSG[$groupId] = array(
92 'id' => $groupId,
93 'status' => 'open',
94 'name' => $group['NAME']
95 );
96 $arGroups[$groupId] = $arUserSG[$groupId];
97 }
98 }
99
100 $bFriendEnable = false;
101 if ((!CModule::IncludeModule('extranet') || !CExtranet::IsExtranetSite()) && CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed())
102 {
103 $bFriendEnable = true;
104 $dbFriends = CSocNetUserRelations::GetList(array(),array("USER_ID" => $USER->GetID(), "RELATION" => SONET_RELATIONS_FRIEND), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID", "DATE_CREATE", "DATE_UPDATE", "INITIATED_BY"));
105 if ($dbFriends)
106 {
107 while ($arFriends = $dbFriends->GetNext(true, false))
108 {
109 $friendId = $pref = (intval($USER->GetID()) == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
110 $arFriendUsers[$friendId] = $friendId;
111
112 /*
113 if (isset($arUserInGroup["friends"]))
114 $arUserInGroup["friends"]['users'][] = $friendId;
115 else
116 $arUserInGroup["friends"] = Array('id' => "friends", 'users' => Array($friendId));
117 */
118 }
119 }
120 /*
121 $arGroups['friends'] = array(
122 'id' => 'friends',
123 'status' => (isset($arGroupStatus['friends']) && $arGroupStatus['friends'] == 'close'? 'close': 'open'),
124 'name' => GetMessage('IM_CL_GROUP_FRIENDS')
125 );
126 */
127 }
128
129 $filter = array(
130 '=ACTIVE' => 'Y',
131 '=CONFIRM_CODE' => false,
132 '!=EXTERNAL_AUTH_ID' => \Bitrix\Im\Model\UserTable::filterExternalUserTypes([\Bitrix\Im\Bot::EXTERNAL_AUTH_ID])
133 );
134 if (CModule::IncludeModule('extranet'))
135 {
136 if(!CExtranet::IsIntranetUser())
137 {
138 $filter['=ID'] = array_merge(Array($USER->GetId()), $arExtranetUsers);
139 }
140 }
141
142 if ($bLoadUsers)
143 {
144 if ($bFriendEnable)
145 {
146 if (!$bIntranetEnable && !$bBusShowAll)
147 {
148 $filter['=ID'][] = $USER->GetId();
149 if (!empty($arFriendUsers))
150 {
151 $filter['=ID'] = array_merge($filter['=ID'], $arFriendUsers);
152 }
153 if (!empty($arExtranetUsers))
154 {
155 $filter['=ID'] = array_merge($filter['=ID'], $arExtranetUsers);
156 }
157 }
158 }
159
160 $bCLCacheEnable = false;
161 if ($bIntranetEnable && (!$bFriendEnable || $bBusShowAll))
162 $bCLCacheEnable = true;
163
164 if ($bCLCacheEnable && CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser())
165 $bCLCacheEnable = false;
166
167 $bVoximplantEnable = CModule::IncludeModule('voximplant');
168 $bColorEnabled = IM\Color::isEnabled();
169 $bOpenChatEnabled = CIMMessenger::CheckEnableOpenChat();
170
171 $nameTemplate = self::GetUserNameTemplate(SITE_ID);
172 $nameTemplateSite = CSite::GetNameFormat(false);
173 $cache_id = 'im_contact_list_v29_'.$nameTemplate.'_'.$nameTemplateSite.(!empty($arExtranetUsers)? '_'.$USER->GetID(): '').$bVoximplantEnable.$bColorEnabled.$bOpenChatEnabled;
174 $obCLCache = new CPHPCache;
175 $cache_dir = '/bx/imc/contact';
176
177 $arUsersToGroup = array();
178 $arUserInGroupStructure = array();
179 $arPhones = Array();
180
181 if($bCLCacheEnable && $obCLCache->InitCache($ttl, $cache_id, $cache_dir))
182 {
183 $tmpVal = $obCLCache->GetVars();
184 $arUsers = $tmpVal['USERS'];
185 $arPhones = $tmpVal['PHONES'];
186 $arUsersToGroup = $tmpVal['USER_TO_GROUP'];
187 $arUserInGroupStructure = $tmpVal['USER_IN_GROUP'];
188 unset($tmpVal);
189
190 $arOnline = CIMStatus::GetList();
191 foreach ($arUsers as $userId => $value)
192 {
193 /*$arUsers[$userId]['status'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['status']: 'offline';
194 $arUsers[$userId]['idle'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['idle']: false;
195 $arUsers[$userId]['mobile_last_date'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['mobile_last_date']: false;
196 $arUsers[$userId]['desktop_last_date'] = $arOnline['users'][$userId]['desktop_last_date'] ?? false;*/
197 $arUsers[$userId]['status'] = 'online';
198 $arUsers[$userId]['idle'] = false;
199 $arUsers[$userId]['mobile_last_date'] = false;
200 $arUsers[$userId]['desktop_last_date'] = false;
201
202 $arUsers[$userId]['last_activity_date'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['last_activity_date']: false;
203 $arUsers[$userId]['absent'] = self::formatAbsentResult($userId);
204 if (isset($arOnline['users'][$userId]['color']) && $arOnline['users'][$userId]['color'])
205 {
206 $arUsers[$userId]['color'] = $arOnline['users'][$userId]['color'];
207 }
208 }
209 }
210 else
211 {
212 $select = array(
213 "ID", "LAST_NAME", "NAME", "LOGIN", "PERSONAL_PHOTO", "SECOND_NAME", "PERSONAL_BIRTHDAY", "WORK_POSITION", "PERSONAL_GENDER", "EXTERNAL_AUTH_ID", "WORK_PHONE", "PERSONAL_PHONE", "PERSONAL_MOBILE", "ACTIVE", "LAST_ACTIVITY_DATE",
214 "COLOR" => "ST.COLOR", "STATUS" => "ST.STATUS", "IDLE" => "ST.IDLE", "MOBILE_LAST_DATE" => "ST.MOBILE_LAST_DATE", "DESKTOP_LAST_DATE" => "ST.DESKTOP_LAST_DATE",
215 );
216 if($bIntranetEnable)
217 {
218 $select[] = 'UF_ZOOM';
219 $select[] = 'UF_SKYPE';
220 $select[] = 'UF_SKYPE_LINK';
221 $select[] = 'UF_PHONE_INNER';
222 $select[] = 'UF_DEPARTMENT';
223 }
224 if ($bVoximplantEnable)
225 {
226 $select[] = 'UF_VI_PHONE';
227 }
228
230 'select' => $select,
231 'filter' => $filter,
232 'runtime' => Array(
233 new \Bitrix\Main\Entity\ReferenceField(
234 'ST',
235 '\Bitrix\Im\Model\StatusTable',
236 array(
237 "=ref.USER_ID" => "this.ID",
238 ),
239 array("join_type"=>"LEFT")
240 )
241 ),
242 'order' => Array('LAST_NAME' => 'ASC')
243 ));
244
245 $bots = \Bitrix\Im\Bot::getListCache();
246
247 while ($arUser = $orm->fetch())
248 {
249 $arUser = CIMStatus::prepareLastDate($arUser);
250
251 $skipUser = false;
252 if(is_array($arUser["UF_DEPARTMENT"]) && !empty($arUser["UF_DEPARTMENT"]))
253 {
254 foreach($arUser["UF_DEPARTMENT"] as $dep_id)
255 {
256 if (isset($arUserInGroupStructure[$dep_id]))
257 $arUserInGroupStructure[$dep_id]['users'][] = $arUser["ID"];
258 else
259 $arUserInGroupStructure[$dep_id] = Array('id' => $dep_id, 'users' => Array($arUser["ID"]));
260 }
261 }
262 /*
263 else if ($bBusShowAll)
264 {
265 $skipUser = false;
266
267 if (isset($arUserInGroup['all']))
268 $arUserInGroup['all']['users'][] = $arUser["ID"];
269 else
270 $arUserInGroup['all'] = Array('id' => 'all', 'users' => Array($arUser["ID"]));
271 }*/
272 else
273 {
274 $skipUser = true;
275 if ($arUser['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID)
276 $skipUser = false;
277 else if (isset($arExtranetUsers[$arUser["ID"]]))
278 $skipUser = false;
279 elseif (isset($arFriendUsers[$arUser["ID"]]))
280 $skipUser = false;
281 elseif ($arUser["ID"] == $USER->GetID())
282 $skipUser = false;
283 }
284
285 if (!$skipUser)
286 {
287 foreach ($arUser as $key => $value)
288 {
289 $arUser[$key] = !is_array($value) && !is_object($value)? htmlspecialcharsEx($value): $value;
290 }
291
292 $color = self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M'? 'M': 'F');
293 if (isset($arUser['COLOR']) && $arUser['COLOR'] <> '')
294 {
295 $color = IM\Color::getColor($arUser['COLOR']);
296 }
297 if (!$color)
298 {
299 $color = self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M'? 'M': 'F');
300 }
301
302 $arUsersToGroup[$arUser['ID']] = $arUser["UF_DEPARTMENT"];
303 $arUser['PERSONAL_BIRTHDAY'] = $arUser['PERSONAL_BIRTHDAY'] instanceof \Bitrix\Main\Type\Date? $arUser['PERSONAL_BIRTHDAY']->format('d-m'): false;
304 $arUser['LAST_ACTIVITY_DATE'] = $arUser['LAST_ACTIVITY_DATE'] instanceof \Bitrix\Main\Type\DateTime? $arUser['LAST_ACTIVITY_DATE']: false;
305
306 $userExternalAuthId = $arUser['EXTERNAL_AUTH_ID'] ?? 'default';
307 $userItemId = $arUser["ITEM_ID"] ?? null;
308 $userById = $arUser["ID"] ?? null;
309
310 $botByUserItemId = $bots[$userItemId] ?? null;
311 $botByUserId = $bots[$userById] ?? null;
312
313 $botClassName = $botByUserItemId['CLASS'] ?? null;
314 $botType = $botByUserId['TYPE'] ?? null;
315 if (
316 $userExternalAuthId == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID
317 && $botType == \Bitrix\Im\Bot::TYPE_NETWORK
318 && (
319 $botClassName === \Bitrix\ImBot\Bot\Support24::class
320 || $botClassName === \Bitrix\ImBot\Bot\Partner24::class
321 || $botClassName === \Bitrix\ImBot\Bot\SaleSupport24::class
322 )
323 )
324 {
325 $userExternalAuthId = 'support24';
326 }
327
328 $arUsers[$arUser["ID"]] = Array(
329 'id' => $arUser["ID"],
330 'name' => \Bitrix\Im\User::formatFullNameFromDatabase($arUser),
331 'active' => $arUser['ACTIVE'] == 'Y',
332 'first_name' => \Bitrix\Im\User::formatNameFromDatabase($arUser),
333 'last_name' => $arUser['LAST_NAME'],
334 'work_position' => $arUser['WORK_POSITION'],
335 'color' => $color,
336 'avatar' => CIMChat::GetAvatarImage($arUser["PERSONAL_PHOTO"]),
337 'birthday' => $arUser['PERSONAL_BIRTHDAY'],
338 'gender' => $arUser['PERSONAL_GENDER'] == 'F'? 'F': 'M',
339 'phone_device' => $bVoximplantEnable && $arUser['UF_VI_PHONE'] == 'Y',
340 'extranet' => self::IsExtranet($arUser),
341 'network' => ($userExternalAuthId === self::NETWORK_AUTH_ID) || ($userExternalAuthId === \Bitrix\Im\Bot::EXTERNAL_AUTH_ID) && ($botType === \Bitrix\Im\Bot::TYPE_NETWORK),
342 'bot' => $userExternalAuthId === \Bitrix\Im\Bot::EXTERNAL_AUTH_ID,
343 'profile' => CIMContactList::GetUserPath($arUser["ID"]),
344 'external_auth_id' => $userExternalAuthId,
345 /*'status' => $arUser['STATUS'],
346 'idle' => $arUser['IDLE'],*/
347 'status' => 'online',
348 'idle' => false,
349 'last_activity_date' => $arUser['LAST_ACTIVITY_DATE'],
350 /*'mobile_last_date' => $arUser['MOBILE_LAST_DATE'],
351 'desktop_last_date' => $arUser['DESKTOP_LAST_DATE'],*/
352 'mobile_last_date' => false,
353 'desktop_last_date' => false,
354 'absent' => self::formatAbsentResult($arUser["ID"]),
355 );
356
357 $services = [];
358 if (!empty($arUser['UF_ZOOM']))
359 {
360 $services['zoom'] = $arUser['UF_ZOOM'];
361 }
362 if (!empty($arUser['UF_SKYPE_LINK']))
363 {
364 $services['skype'] = $arUser['UF_SKYPE_LINK'];
365 }
366 else if (!empty($arUser['UF_SKYPE']))
367 {
368 $services['skype'] = 'skype://'.$arUser['UF_SKYPE'];
369 }
370
371 $arUsers[$arUser["ID"]]['services'] = empty($services)? null: array_change_key_case($services, CASE_LOWER);
372
373 if ($bVoximplantEnable)
374 {
375 $result = CVoxImplantPhone::Normalize($arUser["WORK_PHONE"]);
376 if ($result)
377 {
378 $arPhones[$arUser["ID"]]['WORK_PHONE'] = $arUser['WORK_PHONE'];
379 }
380 $result = CVoxImplantPhone::Normalize($arUser["PERSONAL_MOBILE"]);
381 if ($result)
382 {
383 $arPhones[$arUser["ID"]]['PERSONAL_MOBILE'] = $arUser['PERSONAL_MOBILE'];
384 }
385 $result = CVoxImplantPhone::Normalize($arUser["PERSONAL_PHONE"]);
386 if ($result)
387 {
388 $arPhones[$arUser["ID"]]['PERSONAL_PHONE'] = $arUser['PERSONAL_PHONE'];
389 }
390 $result = preg_replace("/[^0-9\#\*]/i", "", $arUser["UF_PHONE_INNER"]);
391 if ($result)
392 {
393 $arPhones[$arUser["ID"]]['INNER_PHONE'] = $result;
394 }
395 }
396 else
397 {
398 $arPhones[$arUser["ID"]]['WORK_PHONE'] = $arUser['WORK_PHONE'];
399 $arPhones[$arUser["ID"]]['PERSONAL_MOBILE'] = $arUser['PERSONAL_MOBILE'];
400 $arPhones[$arUser["ID"]]['PERSONAL_PHONE'] = $arUser['PERSONAL_PHONE'];
401 $arPhones[$arUser["ID"]]['INNER_PHONE'] = $arUser['UF_PHONE_INNER'];
402 }
403 }
404 }
405 if ($bCLCacheEnable)
406 {
407 if(defined("BX_COMP_MANAGED_CACHE"))
408 {
409 $CACHE_MANAGER->StartTagCache($cache_dir);
410 $CACHE_MANAGER->RegisterTag("IM_CONTACT_LIST");
411 $CACHE_MANAGER->RegisterTag($bVoximplantEnable? "USER_CARD": "USER_NAME");
412 $CACHE_MANAGER->EndTagCache();
413 }
414 if($obCLCache->StartDataCache())
415 {
416 $obCLCache->EndDataCache(array(
417 'USERS' => $arUsers,
418 'USER_TO_GROUP' => $arUsersToGroup,
419 'USER_IN_GROUP' => $arUserInGroupStructure,
420 'PHONES' => $arPhones
421 )
422 );
423 }
424 }
425 }
426
427 if (is_array($arUsersToGroup[$USER->GetID()]))
428 {
429 foreach($arUsersToGroup[$USER->GetID()] as $dep_id)
430 {
431 if (isset($arGroups[$dep_id]))
432 {
433 $arGroups[$dep_id]['status'] = 'open';
434 }
435 }
436 }
437 foreach ($arUserInGroupStructure as $key => $val)
438 {
439 $arUserInGroup[$key] = $val;
440 }
441 unset($arUsersToGroup, $arUserInGroupStructure);
442 }
443
444 $arChats = Array();
445 if ($bLoadChats)
446 {
447 $bColorEnabled = IM\Color::isEnabled();
448 $bOpenChatEnabled = CIMMessenger::CheckEnableOpenChat();
449 $cache_id = 'im_chats_v10_'.$USER->GetID().'_'.$bColorEnabled.'_'.$bOpenChatEnabled;
450 $obCLCache = new CPHPCache;
451 $cache_dir = '/bx/imc/chats';
452
453 if($obCLCache->InitCache($ttl, $cache_id, $cache_dir))
454 {
455 $tmpVal = $obCLCache->GetVars();
456 $arChats = $tmpVal['CHATS'];
457 unset($tmpVal);
458 }
459 else
460 {
461 $arChats = CIMChat::GetChatData(Array(
462 'SKIP_PRIVATE' => 'Y',
463 'GET_LIST' => 'Y',
464 'USER_ID' => $USER->GetID()
465 ));
466
467 if (CIMMessenger::CheckEnableOpenChat() && !IM\User::getInstance($USER->GetID())->isExtranet())
468 {
469 $chatsOpen = CIMChat::GetOpenChatData(Array(
470 'USER_ID' => $USER->GetID()
471 ));
472
473 foreach ($chatsOpen['chat'] as $key => $value)
474 {
475 $arChats['chat'][$key] = $value;
476 }
477 foreach ($chatsOpen['userInChat'] as $key => $value)
478 {
479 $arChats['userInChat'][$key] = $value;
480 }
481 foreach ($chatsOpen['userCallStatus'] as $key => $value)
482 {
483 $arChats['userCallStatus'][$key] = $value;
484 }
485 foreach ($chatsOpen['userChatBlockStatus'] as $key => $value)
486 {
487 $arChats['userChatBlockStatus'][$key] = $value;
488 }
489 }
490
491 if($obCLCache->StartDataCache())
492 {
493 $obCLCache->EndDataCache(array(
494 'CHATS' => $arChats,
495 ));
496 }
497 }
498 }
499
500 $arContactList = Array('users' => $arUsers, 'groups' => $arGroups, 'chats' => $arChats['chat'], 'lines' => $arChats['lines'], 'phones' => $arPhones, 'userInGroup' => $arUserInGroup);
501
502 foreach(GetModuleEvents("im", "OnAfterContactListGetList", true) as $arEvent)
503 ExecuteModuleEventEx($arEvent, array(&$arContactList));
504
505 return $arContactList;
506 }
507
508 public static function CleanChatCache($userId)
509 {
510 $bColorEnabled = IM\Color::isEnabled();
511 $bOpenChatEnabled = CIMMessenger::CheckEnableOpenChat();
512 $cache_id = 'im_chats_v10_'.$userId.'_'.$bColorEnabled.'_'.$bOpenChatEnabled;
513 $cache_dir = '/bx/imc/chats';
514
515 $obCLCache = new CPHPCache;
516 $obCLCache->Clean($cache_id, $cache_dir);
517
519 }
520
521 public static function CleanAllChatCache()
522 {
523 $cache_dir = '/bx/imc/chats';
524
525 $obCache = new CPHPCache();
526 $obCache->CleanDir($cache_dir);
527 }
528
529 function SearchUsers($searchText)
530 {
531 $searchText = trim($searchText);
532 if (mb_strlen($searchText) < 3)
533 {
534 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_CL_SEARCH_EMPTY"), "ERROR_SEARCH_EMPTY");
535 return false;
536 }
537
538 $nameTemplate = self::GetUserNameTemplate(SITE_ID);
539 $nameTemplateSite = CSite::GetNameFormat(false);
540
541 $filter = \Bitrix\Main\UserUtils::getUserSearchFilter(Array('FIND'=> $searchText));
542 $filter["=ACTIVE"] = "Y";
543 $filter["=CONFIRM_CODE"] = false;
544 $filter["=IS_REAL_USER"] = "Y";
545
546 $bIntranetEnable = IsModuleInstalled('intranet');
547 $bVoximplantEnable = IsModuleInstalled('voximplant');
548
549 if (!$bIntranetEnable)
550 {
554 else
555 $filter['=UF_IM_SEARCH'] = CIMSettings::PRIVACY_RESULT_ALL;
556 }
557
558 $select = Array(
559 "ID", "LAST_NAME", "NAME", "SECOND_NAME", "LOGIN", "PERSONAL_PHOTO", "PERSONAL_BIRTHDAY", "WORK_POSITION", "PERSONAL_GENDER", "EXTERNAL_AUTH_ID", "ACTIVE", "UF_IM_SEARCH", "LAST_ACTIVITY_DATE",
560 "COLOR" => "ST.COLOR", "STATUS" => "ST.STATUS", "IDLE" => "ST.IDLE", "MOBILE_LAST_DATE" => "ST.MOBILE_LAST_DATE", "DESKTOP_LAST_DATE" => "ST.DESKTOP_LAST_DATE",
561 );
562 if($bIntranetEnable)
563 $select[] = 'UF_DEPARTMENT';
564 if ($bVoximplantEnable)
565 $select[] = 'UF_VI_PHONE';
566
567 $bots = \Bitrix\Im\Bot::getListCache();
568
570 'select' => $select,
571 'filter' => $filter,
572 'runtime' => Array(
573 new \Bitrix\Main\Entity\ReferenceField(
574 'ST',
575 '\Bitrix\Im\Model\StatusTable',
576 array(
577 "=ref.USER_ID" => "this.ID",
578 ),
579 array("join_type"=>"LEFT")
580 )
581 ),
582 'order' => Array('LAST_NAME' => 'ASC')
583 ));
584 $arUsers = Array();
585 while ($arUser = $orm->fetch())
586 {
587 $arUser['PERSONAL_BIRTHDAY'] = $arUser['PERSONAL_BIRTHDAY'] instanceof \Bitrix\Main\Type\Date? $arUser['PERSONAL_BIRTHDAY']->format('d-m'): false;
588 $arUser['LAST_ACTIVITY_DATE'] = $arUser['LAST_ACTIVITY_DATE'] instanceof \Bitrix\Main\Type\DateTime? $arUser['LAST_ACTIVITY_DATE']: false;
589
590 $arUser = CIMStatus::prepareLastDate($arUser);
591
592 $userExternalAuthId = $arUser['EXTERNAL_AUTH_ID']? $arUser['EXTERNAL_AUTH_ID']: 'default';
593 if (
594 $userExternalAuthId == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID
595 && $bots[$arUser["ID"]]['TYPE'] == \Bitrix\Im\Bot::TYPE_NETWORK
596 && (
597 $bots[$arUser["ITEM_ID"]]['CLASS'] == \Bitrix\ImBot\Bot\Support24::class
598 || $bots[$arUser["ITEM_ID"]]['CLASS'] == \Bitrix\ImBot\Bot\Partner24::class
599 || $bots[$arUser["ITEM_ID"]]['CLASS'] == \Bitrix\ImBot\Bot\SaleSupport24::class
600 )
601 )
602 {
603 $userExternalAuthId = 'support24';
604 }
605
606 $arUsers[$arUser["ID"]] = Array(
607 'id' => $arUser["ID"],
608 'name' => \Bitrix\Im\User::formatFullNameFromDatabase($arUser),
609 'active' => $arUser['ACTIVE'] == 'Y',
610 'first_name' => \Bitrix\Im\User::formatNameFromDatabase($arUser),
611 'last_name' => $arUser['LAST_NAME'],
612 'work_position' => $arUser['WORK_POSITION'],
613 'color' => self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M'? 'M': 'F'),
614 'avatar' => CIMChat::GetAvatarImage($arUser["PERSONAL_PHOTO"]),
615 'birthday' => $arUser['PERSONAL_BIRTHDAY'],
616 'gender' => $arUser['PERSONAL_GENDER'] == 'F'? 'F': 'M',
617 'phone_device' => $bVoximplantEnable && $arUser['UF_VI_PHONE'] == 'Y',
618 'extranet' => self::IsExtranet($arUser),
619 'network' => $arUser['EXTERNAL_AUTH_ID'] == self::NETWORK_AUTH_ID || $arUser['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID && $bots[$arUser["ID"]]['TYPE'] == \Bitrix\Im\Bot::TYPE_NETWORK,
620 'bot' => $arUser['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID,
621 'profile' => CIMContactList::GetUserPath($arUser["ID"]),
622 'search_mark' => $searchText,
623 'external_auth_id' => $userExternalAuthId,
624 /*'status' => $arUser['STATUS'],
625 'idle' => $arUser['IDLE'],*/
626 'status' => 'online',
627 'idle' => false,
628 'last_activity_date' => $arUser['LAST_ACTIVITY_DATE'],
629 /*'mobile_last_date' => $arUser['MOBILE_LAST_DATE'],
630 'desktop_last_date' => $arUser['DESKTOP_LAST_DATE'],*/
631 'mobile_last_date' => false,
632 'desktop_last_date' => false,
633 'absent' => self::formatAbsentResult($arUser["ID"]),
634 );
635 }
636
637 if (CModule::IncludeModule('imbot'))
638 {
639 $result = \Bitrix\ImBot\Bot\Network::search($searchText);
640 if ($result)
641 {
642 foreach ($result as $arLine)
643 {
644 $id = 'networkLines'.$arLine["CODE"];
645 $arUsers[$id] = Array(
646 'id' => $id,
647 'name' => htmlspecialcharsbx($arLine["LINE_NAME"]),
648 'work_position' => $arLine["LINE_DESC"]? htmlspecialcharsbx($arLine["LINE_DESC"]): GetMessage('IM_SEARCH_OL'),
649 'color' => IM\Color::getColor('GRAY'),
650 'avatar' => empty($arLine['LINE_AVATAR'])? '/bitrix/js/im/images/blank.gif': $arLine['LINE_AVATAR'],
651 'birthday' => false,
652 'gender' => 'M',
653 'phone_device' => false,
654 'extranet' => true,
655 'network' => true,
656 'bot' => true,
657 'profile' => '',
658 'select' => 'Y',
659 'network_id' => $arLine["CODE"],
660 'search_mark' => $searchText,
661 'external_auth_id' => 'network',
662 'status' => 'online',
663 'idle' => false,
664 'last_activity_date' => false,
665 'mobile_last_date' => false,
666 'desktop_last_date' => false,
667 'absent' => false,
668 );
669 }
670 }
671 }
672
673 return Array('users' => $arUsers);
674 }
675
676 static function AllowToSend($arParams)
677 {
678 $bResult = false;
679 if (isset($arParams['TO_USER_ID']))
680 {
681 global $USER;
682 $toUserId = intval($arParams['TO_USER_ID']);
683
684 $bResult = true;
685 if(IsModuleInstalled('intranet') && CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser())
686 {
687 $bResult = false;
688 if (CModule::IncludeModule("socialnetwork"))
689 {
690 global $USER, $CACHE_MANAGER;
691
692 if(defined("BX_COMP_MANAGED_CACHE"))
693 $ttl = 2592000;
694 else
695 $ttl = 600;
696
697 $cache_id = 'im_user_sg_'.$USER->GetID();
698 $obSGCache = new CPHPCache;
699 $cache_dir = '/bx/imc/sonet';
700
701 if($obSGCache->InitCache($ttl, $cache_id, $cache_dir))
702 {
703 $tmpVal = $obSGCache->GetVars();
704 $bResult = in_array($toUserId, $tmpVal['EXTRANET_USERS']);
705 }
706 else
707 {
708 if(defined("BX_COMP_MANAGED_CACHE"))
709 $CACHE_MANAGER->StartTagCache($cache_dir);
710
711 $dbUsersInGroup = CSocNetUserToGroup::GetList(
712 array(),
713 array(
714 "USER_ID" => $USER->GetID(),
715 "<=ROLE" => SONET_ROLES_USER,
716 "GROUP_SITE_ID" => CExtranet::GetExtranetSiteID(),
717 "GROUP_ACTIVE" => "Y",
718 "GROUP_CLOSED" => "N"
719 ),
720 false,
721 false,
722 array("ID", "GROUP_ID", "GROUP_NAME")
723 );
724
725 $arUserSocNetGroups = Array();
726 $arUserSG = Array();
727 while ($ar = $dbUsersInGroup->GetNext(true, false))
728 {
729 $arUserSocNetGroups[] = $ar["GROUP_ID"];
730 $arUserSG['SG'.$ar['GROUP_ID']] = array(
731 'id' => 'SG'.$ar['GROUP_ID'],
732 'status' => 'close',
733 'name' => GetMessage('IM_CL_GROUP_SG').$ar['GROUP_NAME']
734 );
735 if(defined("BX_COMP_MANAGED_CACHE"))
736 {
737 $CACHE_MANAGER->RegisterTag('sonet_group_'.$ar['GROUP_ID']);
738 $CACHE_MANAGER->RegisterTag('sonet_user2group_G'.$ar['GROUP_ID']);
739 }
740 }
741
742 $arExtranetUsers = Array();
743 $arUserInGroup = Array();
744 if (count($arUserSocNetGroups) > 0)
745 {
746 $dbUsersInGroup = CSocNetUserToGroup::GetList(
747 array(),
748 array(
749 "GROUP_ID" => $arUserSocNetGroups,
750 "<=ROLE" => SONET_ROLES_USER,
751 "USER_ACTIVE" => "Y",
752 "USER_CONFIRM_CODE" => false
753 ),
754 false,
755 false,
756 array("ID", "USER_ID", "GROUP_ID")
757 );
758
759 while ($ar = $dbUsersInGroup->GetNext(true, false))
760 {
761 if($USER->GetID() != $ar["USER_ID"])
762 {
763 $arExtranetUsers[$ar["USER_ID"]] = $ar["USER_ID"];
764
765 if (isset($arUserInGroup["SG".$ar["GROUP_ID"]]))
766 $arUserInGroup["SG".$ar["GROUP_ID"]]['users'][] = $ar["USER_ID"];
767 else
768 $arUserInGroup["SG".$ar["GROUP_ID"]] = Array('id' => "SG".$ar["GROUP_ID"], 'users' => Array($ar["USER_ID"]));
769 }
770 }
771 }
772 if(defined("BX_COMP_MANAGED_CACHE"))
773 $CACHE_MANAGER->EndTagCache();
774 if($obSGCache->StartDataCache())
775 {
776 $obSGCache->EndDataCache(array(
777 'USER_SG' => $arUserSG,
778 'EXTRANET_USERS' => $arExtranetUsers,
779 'USER_IN_GROUP' => $arUserInGroup
780 ));
781 }
782 $bResult = in_array($toUserId, $arExtranetUsers);
783 }
784 unset($obSGCache);
785 }
786 }
787 else if (!IsModuleInstalled('intranet'))
788 {
789 if (CIMSettings::GetPrivacy(CIMSettings::PRIVACY_MESSAGE) == CIMSettings::PRIVACY_RESULT_CONTACT && CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed() && !CSocNetUserRelations::IsFriends($USER->GetID(), $arParams['TO_USER_ID']))
790 {
791 $bResult = false;
792 }
793 else if (CIMSettings::GetPrivacy(CIMSettings::PRIVACY_MESSAGE, $arParams['TO_USER_ID']) == CIMSettings::PRIVACY_RESULT_CONTACT && CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed() && !CSocNetUserRelations::IsFriends($USER->GetID(), $arParams['TO_USER_ID']))
794 {
795 $bResult = false;
796 }
797 }
798 }
799 else if (isset($arParams['TO_CHAT_ID']))
800 {
801 global $DB, $USER;
802 $toChatId = intval($arParams['TO_CHAT_ID']);
803 $fromUserId = intval($USER->GetID());
804
805 $groupTypes = CIMChat::implodeTypesForQuery(CIMChat::getGroupTypes());
806
807 $strSql = "
808 SELECT R.CHAT_ID
809 FROM b_im_relation R
810 WHERE R.USER_ID = ".$fromUserId."
811 AND R.MESSAGE_TYPE IN ({$groupTypes})
812 AND R.CHAT_ID = ".$toChatId."";
813 $dbRes = $DB->Query($strSql);
814 if ($arRes = $dbRes->Fetch())
815 $bResult = true;
816 else
817 $bResult = false;
818 }
819 return $bResult;
820 }
821
822 static function GetUserData($arParams = Array())
823 {
824 $paramsDepartment = $arParams['DEPARTMENT'] ?? null;
825 $paramsHrPhoto = $arParams['HR_PHOTO'] ?? null;
826 $paramsPhones = $arParams['PHONES'] ?? null;
827 $paramsUseCache = $arParams['USE_CACHE'] ?? null;
828 $paramsShowOnline = $arParams['SHOW_ONLINE'] ?? null;
829 $paramsExtraFields = $arParams['EXTRA_FIELDS'] ?? null;
830 $paramsCacheTtl = $arParams['CACHE_TTL'] ?? null;
831
832 $getDepartment = !($paramsDepartment === 'N');
833 $getHrPhoto = $paramsHrPhoto === 'Y';
834 $getPhones = $paramsPhones === 'Y' && IsModuleInstalled('intranet');
835 $useCache = !($paramsUseCache === 'N');
836 $showOnline = !($paramsShowOnline === 'N');
837 $extraFields = $paramsExtraFields === 'Y';
838
839 $arFilter = Array();
840 if (isset($arParams['ID']) && is_array($arParams['ID']) && !empty($arParams['ID']))
841 {
842 foreach ($arParams['ID'] as $key => $value)
843 {
844 if (intval($value) > 0)
845 {
846 $arParams['ID'][$key] = intval($value);
847 }
848 }
849 $arFilter['=ID'] = $arParams['ID'];
850 }
851 else if (isset($arParams['ID']) && intval($arParams['ID']) > 0)
852 {
853 $arFilter['=ID'] = Array(intval($arParams['ID']));
854 }
855
856 if (empty($arFilter))
857 return false;
858
859 $nameTemplate = self::GetUserNameTemplate(SITE_ID);
860 $nameTemplateSite = CSite::GetNameFormat(false);
861
862 $bIntranetEnable = false;
863 if(IsModuleInstalled('intranet') && CModule::IncludeModule('intranet'))
864 $bIntranetEnable = true;
865
866 $bVoximplantEnable = IsModuleInstalled('voximplant');
867 $bColorEnabled = IM\Color::isEnabled();
868
869 if ($useCache)
870 {
871 $obCache = new \CPHPCache;
872 $cache_ttl = (int)$paramsCacheTtl;
873 if ($cache_ttl <= 0)
874 {
875 $cache_ttl = defined("BX_COMP_MANAGED_CACHE") ? 18144000 : 1800;
876 }
877
878 $uid = md5(implode('|', $arFilter['=ID']));
879 $cache_id = 'user_data_v40_'.$uid.'_'.$nameTemplate.'_'.$nameTemplateSite.'_'.$extraFields.'_'.$getPhones.'_'.$getDepartment.'_'.$bIntranetEnable.'_'.$bVoximplantEnable.'_'.LANGUAGE_ID.'_'.$bColorEnabled;
880 $cache_dir = '/bx/imc/userdata/' . mb_substr($uid, 0, 2) . '/' . mb_substr($uid, 2, 2) . '/' . $uid;
881 if ($obCache->initCache($cache_ttl, $cache_id, $cache_dir))
882 {
883 $arCacheResult = $obCache->getVars();
884 if ($showOnline)
885 {
886 $onlineUserId = array_keys(array_filter($arCacheResult['users'], function($user) {
887 return !$user['bot'];
888 }));
889 if (!empty($onlineUserId))
890 {
891 $arOnline = CIMStatus::GetList(Array('ID' => $onlineUserId));
892 }
893 }
894
895 foreach ($arCacheResult['users'] as $userId => $value)
896 {
897 if ($showOnline)
898 {
899 /* $arCacheResult['users'][$userId]['status'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['status']: 'offline';
900 $arCacheResult['users'][$userId]['idle'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['idle']: false;
901 $arCacheResult['users'][$userId]['mobile_last_date'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['mobile_last_date']: false;
902 $arCacheResult['users'][$userId]['desktop_last_date'] = $arOnline['users'][$userId]['desktop_last_date'] ?? false;*/
903 $arCacheResult['users'][$userId]['status'] = 'online';
904 $arCacheResult['users'][$userId]['idle'] = false;
905 $arCacheResult['users'][$userId]['mobile_last_date'] = false;
906 $arCacheResult['users'][$userId]['desktop_last_date'] = false;
907 $arCacheResult['users'][$userId]['last_activity_date'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['last_activity_date']: false;
908 $arCacheResult['users'][$userId]['absent'] = isset($arOnline['users'][$userId])? $arOnline['users'][$userId]['absent']: false;
909 }
910
911 if ($getHrPhoto && !isset($arCacheResult['hrphoto']))
912 {
913 $arCacheResult['hrphoto'][$userId] = $arCacheResult['users'][$userId]['avatar'];
914 }
915
916 if ($value['bot'])
917 {
918 $converter = new Converter(Converter::TO_SNAKE | Converter::TO_LOWER | Converter::KEYS);
919
920 $botData = \Bitrix\Im\V2\Entity\User\Data\BotData::getInstance((int)$userId)->toRestFormat();
921 $arCacheResult['users'][$userId]['bot_data'] = !empty($botData)
922 ? $converter->process($botData)
923 : null
924 ;
925 }
926 else
927 {
928 $arCacheResult['users'][$userId]['bot_data'] = null;
929 }
930 }
931 return $arCacheResult;
932 }
933 }
934
935 $arSelect = array("ID", "LAST_NAME", "NAME", "EMAIL", "LOGIN", "PERSONAL_PHOTO", "SECOND_NAME", "PERSONAL_BIRTHDAY", "WORK_POSITION", "PERSONAL_GENDER", "EXTERNAL_AUTH_ID", "PERSONAL_WWW", "ACTIVE", "LAST_ACTIVITY_DATE");
936 if ($getPhones)
937 {
938 $arSelect[] = 'WORK_PHONE';
939 $arSelect[] = 'PERSONAL_PHONE';
940 $arSelect[] = 'PERSONAL_MOBILE';
941 }
942 if($bIntranetEnable)
943 {
944 $arSelect[] = 'UF_ZOOM';
945 $arSelect[] = 'UF_SKYPE';
946 $arSelect[] = 'UF_SKYPE_LINK';
947 $arSelect[] = 'UF_PHONE_INNER';
948 $arSelect[] = 'UF_DEPARTMENT';
949 }
950 if ($bVoximplantEnable)
951 {
952 $arSelect[] = 'UF_VI_PHONE';
953 }
954
955 $arUsers = array();
956 $arUserInGroup = array();
957 $arPhones = array();
958 $arHrPhoto = array();
959 $arSource = array();
960
961 $query = new \Bitrix\Main\Entity\Query(\Bitrix\Main\UserTable::getEntity());
962
963 $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('ref', 'Bitrix\Im\Model\StatusTable', array('=this.ID' => 'ref.USER_ID')));
964 $query->addSelect('ref.COLOR', 'COLOR')
965 ->addSelect('ref.STATUS', 'STATUS')
966 ->addSelect('ref.IDLE', 'IDLE')
967 ->addSelect('ref.MOBILE_LAST_DATE', 'MOBILE_LAST_DATE')
968 ->addSelect('ref.DESKTOP_LAST_DATE', 'DESKTOP_LAST_DATE');
969
970 foreach ($arSelect as $value)
971 {
972 $query->addSelect($value);
973 }
974 foreach ($arFilter as $key => $value)
975 {
976 $query->addFilter($key, $value);
977 }
978 $resultQuery = $query->exec();
979
980 $bots = \Bitrix\Im\Bot::getListCache();
981
982 while ($arUser = $resultQuery->fetch())
983 {
984 $arUser = CIMStatus::prepareLastDate($arUser);
985
986 foreach ($arUser as $key => $value)
987 {
988 $arUser[$key] = !is_array($value) && !is_object($value)? htmlspecialcharsEx($value): $value;
989 }
990
991 $arSource[$arUser["ID"]]["PERSONAL_PHOTO"] = $arUser["PERSONAL_PHOTO"];
992
993 $color = self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M'? 'M': 'F');
994 if (isset($arUser['COLOR']) && $arUser['COLOR'] <> '')
995 {
996 $color = IM\Color::getColor($arUser['COLOR']);
997 }
998 if (!$color)
999 {
1000 $color = self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M'? 'M': 'F');
1001 }
1002
1003 $arUser['PERSONAL_BIRTHDAY'] = $arUser['PERSONAL_BIRTHDAY'] instanceof \Bitrix\Main\Type\Date? $arUser['PERSONAL_BIRTHDAY']->format('d-m'): false;
1004 $arUser['LAST_ACTIVITY_DATE'] = $arUser['LAST_ACTIVITY_DATE'] instanceof \Bitrix\Main\Type\DateTime? $arUser['LAST_ACTIVITY_DATE']: false;
1005
1006 $userExternalAuthId = $arUser['EXTERNAL_AUTH_ID']? $arUser['EXTERNAL_AUTH_ID']: 'default';
1007 if (
1008 $userExternalAuthId == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID
1009 && $bots[$arUser["ID"]]['TYPE'] == \Bitrix\Im\Bot::TYPE_NETWORK
1010 && (
1011 $bots[$arUser["ID"]]['CLASS'] == \Bitrix\ImBot\Bot\Support24::class
1012 || $bots[$arUser["ID"]]['CLASS'] == \Bitrix\ImBot\Bot\Partner24::class
1013 || $bots[$arUser["ID"]]['CLASS'] == \Bitrix\ImBot\Bot\SaleSupport24::class
1014 )
1015 )
1016 {
1017 $userExternalAuthId = 'support24';
1018 }
1019
1020 $userV2 = IM\V2\Entity\User\User::getInstance((int)$arUser["ID"]);
1021
1022 $arUsers[$arUser["ID"]] = Array(
1023 'id' => $arUser["ID"],
1024 'name' => \Bitrix\Im\User::formatFullNameFromDatabase($arUser),
1025 'active' => $arUser['ACTIVE'] == 'Y',
1026 'first_name' => \Bitrix\Im\User::formatNameFromDatabase($arUser),
1027 'last_name' => $arUser['LAST_NAME'],
1028 'work_position' => $arUser['WORK_POSITION'],
1029 'color' => $color,
1030 'avatar' => CIMChat::GetAvatarImage($arUser["PERSONAL_PHOTO"]),
1031 'avatar_id' => $arUser["PERSONAL_PHOTO"],
1032 'birthday' => $arUser['PERSONAL_BIRTHDAY'],
1033 'gender' => $arUser['PERSONAL_GENDER'] == 'F'? 'F': 'M',
1034 'phone_device' => $bVoximplantEnable && $arUser['UF_VI_PHONE'] == 'Y',
1035 'phones' => $bVoximplantEnable && $arUser['UF_VI_PHONE'] == 'Y',
1036 'extranet' => self::IsExtranet($arUser),
1037 'network' => $arUser['EXTERNAL_AUTH_ID'] == self::NETWORK_AUTH_ID || $arUser['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID && $bots[$arUser["ID"]]['TYPE'] == \Bitrix\Im\Bot::TYPE_NETWORK,
1038 'bot' => $arUser['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID,
1039 'connector' => $arUser['EXTERNAL_AUTH_ID'] == "imconnector",
1040 'profile' => CIMContactList::GetUserPath($arUser["ID"]),
1041 'external_auth_id' => $userExternalAuthId,
1042 /*'status' => $arUser['STATUS'],
1043 'idle' => $arUser['IDLE']?: false,*/
1044 'status' => 'online',
1045 'idle' => false,
1046 'last_activity_date' => $arUser['LAST_ACTIVITY_DATE']?: false,
1047 /*'mobile_last_date' => $arUser['MOBILE_LAST_DATE']?: false,
1048 'desktop_last_date' => $arUser['DESKTOP_LAST_DATE']?: false,*/
1049 'mobile_last_date' => false,
1050 'desktop_last_date' => false,
1051 'departments' => $getDepartment && !empty($arUser["UF_DEPARTMENT"]) && is_array($arUser["UF_DEPARTMENT"])? array_values($arUser["UF_DEPARTMENT"]): Array(),
1052 'absent' => self::formatAbsentResult($arUser["ID"]),
1053 'type' => $userV2->getType()->value,
1054 );
1055
1056 $services = [];
1057 if (!empty($arUser['UF_ZOOM']))
1058 {
1059 $services['zoom'] = $arUser['UF_ZOOM'];
1060 }
1061 if (!empty($arUser['UF_SKYPE_LINK']))
1062 {
1063 $services['skype'] = $arUser['UF_SKYPE_LINK'];
1064 }
1065 else if (!empty($arUser['UF_SKYPE']))
1066 {
1067 $services['skype'] = 'skype://'.$arUser['UF_SKYPE'];
1068 }
1069
1070 $arUsers[$arUser["ID"]]['services'] = empty($services)? null: array_change_key_case($services, CASE_LOWER);
1071
1072 if ($extraFields)
1073 {
1074 $arUsers[$arUser["ID"]]['website'] = $arUser['PERSONAL_WWW'];
1075 $arUsers[$arUser["ID"]]['email'] = $arUser['EMAIL'];
1076 }
1077
1078 foreach($arUsers[$arUser["ID"]]["departments"] as $dep_id)
1079 {
1080 if (isset($arUserInGroup[$dep_id]))
1081 $arUserInGroup[$dep_id]['users'][] = $arUser["ID"];
1082 else
1083 $arUserInGroup[$dep_id] = Array('id' => $dep_id, 'users' => Array($arUser["ID"]));
1084 }
1085
1086 if ($getHrPhoto)
1087 {
1088 $arHrPhoto[$arUser["ID"]] = $arUsers[$arUser["ID"]]['avatar'];
1089 }
1090
1091 if ($getPhones)
1092 {
1093 if (CModule::IncludeModule('voximplant'))
1094 {
1095 $result = CVoxImplantPhone::Normalize($arUser["WORK_PHONE"]);
1096 if ($result)
1097 {
1098 $arPhones[$arUser["ID"]]['WORK_PHONE'] = $arUser['WORK_PHONE'];
1099 }
1100 $result = CVoxImplantPhone::Normalize($arUser["PERSONAL_MOBILE"]);
1101 if ($result)
1102 {
1103 $arPhones[$arUser["ID"]]['PERSONAL_MOBILE'] = $arUser['PERSONAL_MOBILE'];
1104 }
1105 $result = CVoxImplantPhone::Normalize($arUser["PERSONAL_PHONE"]);
1106 if ($result)
1107 {
1108 $arPhones[$arUser["ID"]]['PERSONAL_PHONE'] = $arUser['PERSONAL_PHONE'];
1109 }
1110 $result = preg_replace("/[^0-9\#\*]/i", "", $arUser["UF_PHONE_INNER"]);
1111 if ($result)
1112 {
1113 $arPhones[$arUser["ID"]]['INNER_PHONE'] = $result;
1114 }
1115 }
1116 else
1117 {
1118 $arPhones[$arUser["ID"]]['WORK_PHONE'] = $arUser['WORK_PHONE'];
1119 $arPhones[$arUser["ID"]]['PERSONAL_MOBILE'] = $arUser['PERSONAL_MOBILE'];
1120 $arPhones[$arUser["ID"]]['PERSONAL_PHONE'] = $arUser['PERSONAL_PHONE'];
1121 $arPhones[$arUser["ID"]]['INNER_PHONE'] = $arUser['UF_PHONE_INNER'];
1122 }
1123
1124 if (isset($arPhones[$arUser["ID"]]))
1125 {
1126 $arUsers[$arUser["ID"]]['phones'] = array_change_key_case($arPhones[$arUser["ID"]], CASE_LOWER);
1127 }
1128 }
1129 }
1130
1131 $result = array('users' => $arUsers, 'hrphoto' => $arHrPhoto, 'userInGroup' => $arUserInGroup, 'phones' => $arPhones, 'source' => $arSource);
1132
1133 if($useCache)
1134 {
1135 $cacheTag = array();
1136 if($obCache->StartDataCache())
1137 {
1138 if(defined("BX_COMP_MANAGED_CACHE"))
1139 {
1140 global $CACHE_MANAGER;
1141 $CACHE_MANAGER->StartTagCache($cache_dir);
1142 if(is_array($arParams['ID']))
1143 {
1144 foreach ($arParams['ID'] as $id)
1145 {
1146 $tag = 'USER_NAME_'.intval($id);
1147 if(!in_array($tag, $cacheTag))
1148 {
1149 $cacheTag[] = $tag;
1150 $CACHE_MANAGER->RegisterTag($tag);
1151 }
1152 }
1153 }
1154 elseif (isset($arParams['ID']) && intval($arParams['ID']) > 0)
1155 {
1156 $tag = 'USER_NAME_'.intval($arParams['ID']);
1157 $CACHE_MANAGER->RegisterTag($tag);
1158 }
1159 $CACHE_MANAGER->EndTagCache();
1160 }
1161 $obCache->EndDataCache($result);
1162 unset($cacheTag);
1163 }
1164 }
1165
1166 unset($result['source']);
1167
1168 foreach ($result['users'] as $userId => $user)
1169 {
1170 if ($user['bot'])
1171 {
1172 $converter = new Converter(Converter::TO_SNAKE | Converter::TO_LOWER | Converter::KEYS);
1173
1174 $botData = \Bitrix\Im\V2\Entity\User\Data\BotData::getInstance((int)$userId)->toRestFormat();
1175 $result['users'][$userId]['bot_data'] = (!empty($botData)) ? $converter->process($botData) : null;
1176 }
1177 else
1178 {
1179 $result['users'][$userId]['bot_data'] = null;
1180 }
1181 }
1182
1183 return $result;
1184 }
1185
1186 public static function SetOnline($userId = null, $cache = true)
1187 {
1188 return CUser::SetLastActivityDate($userId, $cache);
1189 }
1190
1191 public static function SetOffline($userId = null)
1192 {
1193 global $USER, $DB;
1194
1196 if (!$userId)
1197 {
1198 return false;
1199 }
1200
1202 $helper = $connection->getSqlHelper();
1203
1204 $sqlDateFunction = 'NULL';
1205 if ($DB->type == "MSSQL")
1206 {
1207 $sqlDateFunction = "dateadd(SECOND, -120, getdate())";
1208 }
1209 elseif ($DB->type == "ORACLE")
1210 {
1211 $sqlDateFunction = "SYSDATE-(1/24/60/60*120)";
1212 }
1213 else
1214 {
1215 $sqlDateFunction = $helper->addSecondsToDateTime(-120);
1216 }
1217
1218 $connection->queryExecute("UPDATE b_user SET LAST_ACTIVITY_DATE = ".$sqlDateFunction." WHERE ID = ".$userId);
1219
1220 if ($userId == $USER->GetId())
1221 {
1222 unset($_SESSION['IM_LAST_ONLINE'], $_SESSION['USER_LAST_ONLINE_'.$userId]);
1223 }
1224
1225 $USER->Logout();
1226
1227 return true;
1228 }
1229
1230 public static function SetCurrentTab($userId)
1231 {
1232 return true;
1233 }
1234
1235 public static function InRecent($userId, $type, $itemId)
1236 {
1237 $userId = intval($userId);
1238 if ($userId <= 0)
1239 return false;
1240
1241 $messageId = false;
1242 $result = \Bitrix\Im\Model\RecentTable::getList(Array(
1243 'filter' => Array(
1244 '=USER_ID' => $userId,
1245 '=ITEM_TYPE' => $type,
1246 '=ITEM_ID' => $itemId,
1247 )
1248 ))->fetch();
1249 if ($result)
1250 {
1251 $messageId = $result['ITEM_MID'];
1252 }
1253
1254 return $messageId;
1255 }
1256
1257 public static function SetRecentForNewUser($userId)
1258 {
1259 $userId = intval($userId);
1260 if ($userId <= 0)
1261 {
1262 return false;
1263 }
1264
1266 foreach ($colleagues as $uid)
1267 {
1268 self::SetRecent(Array(
1269 'ENTITY_ID' => $uid,
1270 'USER_ID' => $userId
1271 ));
1272 }
1273
1274 return true;
1275 }
1276
1277 public static function SetRecent($arParams)
1278 {
1279 $messageDateParam = $arParams['MESSAGE_DATE'] ?? null;
1280
1281 $userId = (int)($arParams['USER_ID'] ?? 0);
1282 $itemId = (int)($arParams['ENTITY_ID'] ?? 0);
1283 $chatId = (int)($arParams['CHAT_ID'] ?? 0);
1284 $relationId = (int)($arParams['RELATION_ID'] ?? 0);
1285 $sessionId = (int)($arParams['SESSION_ID'] ?? 0);
1286 $pinned = isset($arParams['PINNED']) && $arParams['PINNED'] === 'Y' ? 'Y': 'N';
1287 $messageId = (int)($arParams['MESSAGE_ID'] ?? 0);
1288 $dateMessage = $messageDateParam instanceof \Bitrix\Main\Type\DateTime ? $messageDateParam : new \Bitrix\Main\Type\DateTime();
1289 $dateUpdate = new \Bitrix\Main\Type\DateTime();
1290
1291 $arParams['ENTITY_TYPE'] = $arParams['CHAT_TYPE'] ?? $arParams['ENTITY_TYPE'] ?? IM_MESSAGE_PRIVATE;
1292 if (in_array($arParams['ENTITY_TYPE'], CIMChat::getGroupTypes(), true))
1293 {
1294 $itemType = $arParams['ENTITY_TYPE'];
1295 }
1296 else
1297 {
1298 $itemType = IM_MESSAGE_PRIVATE;
1299 }
1300
1301 if ($itemId <= 0)
1302 {
1303 return false;
1304 }
1305
1306 if (
1307 $sessionId
1308 && $itemType === IM\V2\Chat::IM_TYPE_OPEN_LINE
1309 && class_exists('\Bitrix\ImOpenLines\Recent')
1310 && \Bitrix\ImOpenLines\Recent::recentAvailable($sessionId)
1311 )
1312 {
1313 $session = \Bitrix\ImOpenLines\Model\SessionTable::getByPrimary($sessionId)->fetch();
1314 $config = \Bitrix\ImOpenLines\Model\ConfigTable::getByPrimary($session['CONFIG_ID'])->fetch();
1315
1316 if (
1317 $config['QUEUE_TYPE'] === \Bitrix\ImOpenLines\Config::QUEUE_TYPE_ALL
1318 || \Bitrix\ImOpenLines\Recent::isCurrentRecent($userId, $chatId)
1319 )
1320 {
1321 \Bitrix\ImOpenLines\Recent::setRecent($userId, $chatId, $messageId, $sessionId);
1322 }
1323 }
1324 else
1325 {
1327
1328 // $isUserAlreadyInRecent = $connection->queryScalar("SELECT 1 FROM b_im_recent WHERE USER_ID = ".$userId);
1329
1330 $merge = $connection->getSqlHelper()->prepareMerge(
1331 "b_im_recent",
1332 ['USER_ID', 'ITEM_TYPE', 'ITEM_ID'],
1333 [
1334 'USER_ID' => $userId,
1335 'ITEM_TYPE' => $itemType,
1336 'ITEM_ID' => $itemId,
1337 'ITEM_MID' => $messageId,
1338 'ITEM_CID' => $chatId,
1339 'ITEM_RID' => $relationId,
1340 'ITEM_OLID' => $sessionId,
1341 'PINNED' => $pinned,
1342 'DATE_MESSAGE' => $dateMessage,
1343 'DATE_UPDATE' => $dateUpdate,
1344 'DATE_LAST_ACTIVITY' => $dateMessage,
1345 ],
1346 [
1347 'ITEM_MID' => $messageId,
1348 'ITEM_CID' => $chatId,
1349 'ITEM_RID' => $relationId,
1350 'ITEM_OLID' => $sessionId,
1351 'DATE_MESSAGE' => $dateMessage,
1352 'DATE_UPDATE' => $dateUpdate,
1353 'DATE_LAST_ACTIVITY' => $dateMessage,
1354 ]
1355 );
1356 if ($merge && $merge[0] != "")
1357 {
1358 $connection->query($merge[0]);
1359 }
1360 }
1361
1362 // if (isset($isUserAlreadyInRecent) && !$isUserAlreadyInRecent)
1363 // {
1364 // $event = new \Bitrix\Main\Event("im", "OnAfterRecentAdd", array(
1365 // "user_id" => $userId,
1366 // ));
1367 // $event->send();
1368 // }
1369
1370 return true;
1371 }
1372
1373 public static function DeleteRecent($entityId, $isChat = false, $userId = false, $withoutRead = false)
1374 {
1375 global $DB;
1376
1377 if (is_array($entityId))
1378 {
1379 foreach ($entityId as $key => $value)
1380 {
1381 $entityId[$key] = (int)$value;
1382 }
1383
1384 $entityId = array_slice($entityId, 0, 1000);
1385
1386 $sqlEntityId = 'ITEM_ID IN ('.implode(',', $entityId).')';
1387 }
1388 else if ((int)$entityId > 0)
1389 {
1390 $sqlEntityId = 'ITEM_ID = '.(int)$entityId;
1391 }
1392 else
1393 {
1394 return false;
1395 }
1396
1397 if ((int)$userId <= 0)
1398 {
1399 if ($GLOBALS['USER'] instanceof \CUser && $GLOBALS['USER']->getId() > 0)
1400 {
1401 $userId = $GLOBALS['USER']->getId();
1402 }
1403 else
1404 {
1405 return false;
1406 }
1407 }
1408
1409 if ($isChat)
1410 {
1411 $itemType = "ITEM_TYPE IN ('".implode("','", \Bitrix\Im\Chat::getTypes())."')";
1412 }
1413 else
1414 {
1415 $itemType = "ITEM_TYPE = '".IM_MESSAGE_PRIVATE."'";
1416 }
1417
1418 /*$strSQL = "
1419 UPDATE b_im_relation R
1420 INNER JOIN b_im_recent RC
1421 ON R.ID = RC.ITEM_RID
1422 SET
1423 R.STATUS = '".IM_STATUS_READ."'
1424 , R.UNREAD_ID = 0
1425 , R.MESSAGE_STATUS = '".IM_MESSAGE_STATUS_RECEIVED."'
1426 , R.COUNTER = 0
1427 , R.LAST_READ = NOW()
1428 WHERE
1429 RC.USER_ID = {$userId}
1430 AND RC.{$itemType}
1431 AND RC.{$sqlEntityId}
1432 ";
1433 $DB->Query($strSQL);*/
1434
1435 if ($isChat)
1436 {
1437 $chat = IM\V2\Chat::getInstance((int)$entityId);
1438 }
1439 else
1440 {
1441 $chat = IM\V2\Entity\User\User::getInstance($userId)->getChatWith($entityId, false);
1442 }
1443
1444 $lineRemoveComplete = false;
1445 if (
1446 $isChat
1447 && $chat->getChatId()
1448 && $chat->getType() === IM\V2\Chat::IM_TYPE_OPEN_LINE
1449 && class_exists('\Bitrix\ImOpenLines\Recent')
1450 )
1451 {
1452 $lineRemoveResult = \Bitrix\ImOpenLines\Recent::removeRecent((int)$userId, $chat->getChatId());
1453 $lineRemoveComplete = $lineRemoveResult->isSuccess();
1454 }
1455
1456 $strSQL = "DELETE FROM b_im_recent WHERE USER_ID = {$userId} AND {$itemType} AND {$sqlEntityId}";
1457 $DB->Query($strSQL);
1458
1459 if (!$withoutRead && $chat !== null && !($chat instanceof IM\V2\Chat\NullChat) && $chat->getChatId())
1460 {
1461 $chat = $chat->withContextUser($userId);
1462 if ($chat instanceof IM\V2\Chat\OpenLineChat)
1463 {
1464 $chat->read(false, false, true);
1465 }
1466 else
1467 {
1468 $chat->read();
1469 }
1470
1472 new Sync\Event(Sync\Event::DELETE_EVENT, Sync\Event::CHAT_ENTITY, $chat->getChatId()),
1473 $userId,
1474 $chat
1475 );
1476 }
1477
1478 if ($isChat && \Bitrix\Main\Loader::includeModule('pull'))
1479 {
1480 if (is_array($entityId))
1481 {
1482 foreach ($entityId as $value)
1483 {
1484 \CPullWatch::delete($userId, 'IM_PUBLIC_'.(int)$value);
1485 }
1486 }
1487 else
1488 {
1489 \CPullWatch::delete($userId, 'IM_PUBLIC_'.(int)$entityId);
1490 if ($chat->getType() === Chat::IM_TYPE_CHANNEL)
1491 {
1492 \CPullWatch::delete($userId, 'IM_PUBLIC_COMMENT_'.(int)$entityId);
1493 }
1494 }
1495 }
1496
1497 //\Bitrix\Im\Counter::clearCache($userId);
1498
1499 $strSQL = $DB->TopSql("SELECT 1 FROM b_im_recent WHERE USER_ID = ".$userId, 1);
1500 $rs = $DB->Query($strSQL);
1501 if (!$rs->Fetch() || $lineRemoveComplete)
1502 {
1503 $event = new \Bitrix\Main\Event("im", "OnAfterRecentDelete", array(
1504 "user_id" => $userId,
1505 ));
1506 $event->send();
1507 }
1508
1509 return true;
1510 }
1511
1512 public static function DialogHide($dialogId, $userId = null)
1513 {
1515 if (!$userId)
1516 {
1517 return false;
1518 }
1519
1520 $pullInclude = \Bitrix\Main\Loader::includeModule("pull");
1521 $lines = false;
1522
1523 if (mb_substr($dialogId, 0, 4) == 'chat')
1524 {
1525 $chatId = (int)mb_substr($dialogId, 4);
1526 $lines = Chat::getInstance($chatId)->getType() === Chat::IM_TYPE_OPEN_LINE;
1527 self::deleteRecent($chatId, true, $userId);
1528 }
1529 else
1530 {
1531 $dialogId = (int)$dialogId;
1532 $chatId = null;
1533 $chat = IM\V2\Entity\User\User::getInstance($userId)->getChatWith($dialogId, false);
1534 if ($chat !== null)
1535 {
1536 $chatId = $chat->getId();
1537 }
1538 self::deleteRecent($dialogId, false, $userId);
1539 }
1540
1541 if ($pullInclude)
1542 {
1544 'module_id' => 'im',
1545 'command' => 'chatHide',
1546 'expiry' => 3600,
1547 'params' => Array(
1548 'dialogId' => $dialogId,
1549 'chatId' => $chatId,
1550 'lines' => $lines,
1551 ),
1552 'extra' => \Bitrix\Im\Common::getPullExtra()
1553 ));
1554 }
1555
1556 return true;
1557 }
1558
1559 public static function ClearRecentCache($userId = null)
1560 {
1561 }
1562
1563 public static function GetRecentList($arParams = Array())
1564 {
1565 global $DB, $USER;
1566
1567 $bLoadUnreadMessage = isset($arParams['LOAD_UNREAD_MESSAGE']) && $arParams['LOAD_UNREAD_MESSAGE'] == 'Y'? true: false;
1568 $bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N'? false: true;
1569 $bSmiles = isset($arParams['USE_SMILES']) && $arParams['USE_SMILES'] == 'N'? false: true;
1570 $userId = isset($arParams['USER_ID'])? $arParams['USER_ID']: $USER->GetId();
1571 if ($userId <= 0)
1572 {
1573 return false;
1574 }
1575
1576 $arRecent = Array();
1577 $arUsers = Array();
1578
1579 $generalChatId = CIMChat::GetGeneralChatId();
1580
1582
1583 if (!$bTimeZone)
1584 CTimeZone::Disable();
1585
1586 $strSql = "
1587 SELECT
1588 R.ITEM_TYPE,
1589 R.ITEM_ID,
1590 R.PINNED,
1591 R.ITEM_MID as M_ID,
1592 M.AUTHOR_ID as M_AUTHOR_ID,
1593 M.ID as M_ID,
1594 M.CHAT_ID as M_CHAT_ID,
1595 M.MESSAGE as M_MESSAGE,
1596 ".$DB->DatetimeToTimestampFunction('R.DATE_UPDATE')." as M_DATE_CREATE,
1597 C.TITLE as C_TITLE,
1598 C.AUTHOR_ID as C_OWNER_ID,
1599 C.ENTITY_TYPE as CHAT_ENTITY_TYPE,
1600 C.ENTITY_ID as CHAT_ENTITY_ID,
1601 C.ENTITY_DATA_1 as CHAT_ENTITY_DATA_1,
1602 C.ENTITY_DATA_2 as CHAT_ENTITY_DATA_2,
1603 C.ENTITY_DATA_3 as CHAT_ENTITY_DATA_3,
1604 C.AVATAR as C_AVATAR,
1605 C.CALL_NUMBER as C_CALL_NUMBER,
1606 C.EXTRANET as CHAT_EXTRANET,
1607 C.COLOR as CHAT_COLOR,
1608 C.TYPE as CHAT_TYPE,
1609 U.LOGIN,
1610 U.NAME,
1611 U.LAST_NAME,
1612 U.PERSONAL_PHOTO,
1613 U.SECOND_NAME,
1614 ".$DB->DatetimeToTimestampFunction('U.PERSONAL_BIRTHDAY')." as PERSONAL_BIRTHDAY,
1615 ".$DB->DatetimeToTimestampFunction('U.LAST_ACTIVITY_DATE')." as LAST_ACTIVITY_DATE,
1616 U.PERSONAL_GENDER,
1617 U.EXTERNAL_AUTH_ID,
1618 U.WORK_POSITION,
1619 U.ACTIVE,
1620 ST.COLOR,
1621 ST.STATUS,
1622 ".$DB->DatetimeToTimestampFunction('ST.IDLE')." as IDLE,
1623 ".$DB->DatetimeToTimestampFunction('ST.MOBILE_LAST_DATE')." as MOBILE_LAST_DATE,
1624 ".$DB->DatetimeToTimestampFunction('ST.DESKTOP_LAST_DATE')." as DESKTOP_LAST_DATE,
1625 C1.USER_ID as RID,
1626 C1.NOTIFY_BLOCK as RELATION_NOTIFY_BLOCK,
1627 C1.USER_ID as RELATION_USER_ID
1628 ".($isOperator? ", S.ID as LINES_ID, S.STATUS as LINES_STATUS": "")."
1629 FROM
1630 b_im_recent R
1631 LEFT JOIN b_user U ON R.ITEM_TYPE = '".IM_MESSAGE_PRIVATE."' AND R.ITEM_ID = U.ID
1632 LEFT JOIN b_im_status ST ON R.ITEM_TYPE = '".IM_MESSAGE_PRIVATE."' AND R.ITEM_ID = ST.USER_ID
1633 LEFT JOIN b_im_chat C ON R.ITEM_TYPE != '".IM_MESSAGE_PRIVATE."' AND R.ITEM_ID = C.ID
1634 LEFT JOIN b_im_message M ON R.ITEM_MID = M.ID
1635 LEFT JOIN b_im_relation C1 ON C1.CHAT_ID = C.ID AND C1.USER_ID = ".$userId."
1636 ".($isOperator? "LEFT JOIN b_imopenlines_session S ON R.ITEM_OLID > 0 AND S.ID = R.ITEM_OLID": "")."
1637 WHERE R.USER_ID = ".$userId;
1638 if (!$bTimeZone)
1639 CTimeZone::Enable();
1640
1641 $enableOpenChat = CIMMessenger::CheckEnableOpenChat();
1642 $bots = \Bitrix\Im\Bot::getListCache();
1643
1644 $arMessageId = Array();
1645
1646 $dbRes = $DB->Query($strSql);
1647 $counters = (new IM\V2\Message\CounterService($userId))->getForEachChat();
1648 while ($arRes = $dbRes->GetNext(true, false))
1649 {
1650 $arRes['ITEM_TYPE'] = trim($arRes['ITEM_TYPE']);
1651 $arRes['CHAT_TYPE'] = trim($arRes['CHAT_TYPE']);
1652 $arRes['CHAT_EXTRANET'] = trim($arRes['CHAT_EXTRANET']);
1653
1654 if ($arRes['ITEM_TYPE'] == IM_MESSAGE_OPEN)
1655 {
1656 if (!$enableOpenChat)
1657 {
1658 continue;
1659 }
1660 else if (intval($arRes['RID']) <= 0 && IM\User::getInstance($userId)->isExtranet())
1661 {
1662 continue;
1663 }
1664 }
1665 else if (in_array($arRes['ITEM_TYPE'], CIMChat::getGroupTypes()))
1666 {
1667 if (intval($arRes['RID']) <= 0)
1668 {
1669 continue;
1670 }
1671 }
1672
1673 $arMessageId[] = $arRes['M_ID'];
1674
1675 if ($arRes['M_ID'] > 0 && $arRes['M_DATE_CREATE']+2592000 < time())
1676 {
1677 continue;
1678 }
1679
1680 $itemId = $arRes['ITEM_ID'];
1681 $item = Array(
1682 'TYPE' => $arRes['ITEM_TYPE'],
1683 'MESSAGE' => Array(
1684 'id' => $arRes['M_ID'],
1685 'chatId' => $arRes['M_CHAT_ID'],
1686 'senderId' => $arRes['M_AUTHOR_ID'],
1687 'date' => \Bitrix\Main\Type\DateTime::createFromTimestamp($arRes['M_DATE_CREATE']),
1688 'text' => \Bitrix\Im\Text::parse($arRes['M_MESSAGE'], Array('CUT_STRIKE' => 'Y', 'SMILES' => 'N', 'SAFE' => 'N')),
1689 'pinned' => $arRes['PINNED'] == 'Y',
1690 ),
1691 'COUNTER' => $counters[(int)$arRes['M_CHAT_ID']],
1692 );
1693 $item['MESSAGE']['text'] = preg_replace('#\-{54}.+?\-{54}#s', " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" "," ", " ", " "), $item['MESSAGE']['text']), "<img>"));
1694
1695 if ($arRes['ITEM_TYPE'] == IM_MESSAGE_PRIVATE)
1696 {
1697 $arUsers[] = $arRes['ITEM_ID'];
1698
1699 $arRes['PERSONAL_BIRTHDAY'] = $arRes['PERSONAL_BIRTHDAY']? \Bitrix\Main\Type\DateTime::createFromTimestamp($arRes['PERSONAL_BIRTHDAY'])->format('d-m'): false;
1700 $arRes['LAST_ACTIVITY_DATE'] = $arRes['LAST_ACTIVITY_DATE']? \Bitrix\Main\Type\DateTime::createFromTimestamp($arRes['LAST_ACTIVITY_DATE']): false;
1701 $arRes = CIMStatus::prepareLastDate($arRes);
1702
1703 $userExternalAuthId = $arRes['EXTERNAL_AUTH_ID']? $arRes['EXTERNAL_AUTH_ID']: 'default';
1704 if (
1705 $userExternalAuthId == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID
1706 && $bots[$arRes["ITEM_ID"]]['TYPE'] == \Bitrix\Im\Bot::TYPE_NETWORK
1707 && (
1708 $bots[$arRes["ITEM_ID"]]['CLASS'] == \Bitrix\ImBot\Bot\Support24::class
1709 || $bots[$arRes["ITEM_ID"]]['CLASS'] == \Bitrix\ImBot\Bot\Partner24::class
1710 || $bots[$arRes["ITEM_ID"]]['CLASS'] == \Bitrix\ImBot\Bot\SaleSupport24::class
1711 )
1712 )
1713 {
1714 $userExternalAuthId = 'support24';
1715 }
1716
1717 $item['USER'] = Array(
1718 'id' => $arRes['ITEM_ID'],
1720 'active' => $arRes['ACTIVE'] == 'Y',
1721 'first_name' => \Bitrix\Im\User::formatNameFromDatabase($arRes),
1722 'last_name' => $arRes['LAST_NAME'],
1723 'work_position' => $arRes['WORK_POSITION'],
1724 'color' => self::GetUserColor($arRes["ID"], $arRes['PERSONAL_GENDER'] == 'M'? 'M': 'F'),
1725 'avatar' => CIMChat::GetAvatarImage($arRes["PERSONAL_PHOTO"]),
1726 'birthday' => $arRes['PERSONAL_BIRTHDAY'],
1727 'gender' => $arRes['PERSONAL_GENDER'] == 'F'? 'F': 'M',
1728 'extranet' => false,
1729 'network' => $arRes['EXTERNAL_AUTH_ID'] == self::NETWORK_AUTH_ID || $arRes['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID && $bots[$arRes["ITEM_ID"]]['TYPE'] == \Bitrix\Im\Bot::TYPE_NETWORK,
1730 'bot' => $arRes['EXTERNAL_AUTH_ID'] == \Bitrix\Im\Bot::EXTERNAL_AUTH_ID,
1731 'phone_device' => false,
1732 'profile' => CIMContactList::GetUserPath($arRes["ITEM_ID"]),
1733 'external_auth_id' => $userExternalAuthId,
1734 'status' => $arRes['STATUS'],
1735 'idle' => $arRes['IDLE'],
1736 'last_activity_date' => $arRes['LAST_ACTIVITY_DATE'],
1737 'mobile_last_date' => $arRes['MOBILE_LAST_DATE'],
1738 'desktop_last_date' => $arRes['DESKTOP_LAST_DATE'],
1739 'absent' => self::formatAbsentResult($arRes["ITEM_ID"]),
1740 );
1741 if (!$item['MESSAGE']['text'])
1742 {
1743 $item['MESSAGE']['text'] = $arRes['WORK_POSITION'];
1744 }
1745
1746 }
1747 else
1748 {
1749 $chatType = \Bitrix\Im\Chat::getType($arRes);
1750
1751 if ($arRes["CHAT_ENTITY_TYPE"] == 'LINES')
1752 {
1753 if ($isOperator)
1754 {
1755 $item['LINES'] = Array(
1756 'ID' => $arRes['LINES_ID'],
1757 'STATUS' => $arRes['LINES_STATUS']
1758 );
1759 }
1760 }
1761 else if ($generalChatId == $arRes['M_CHAT_ID'])
1762 {
1763 $arRes["CHAT_ENTITY_TYPE"] = 'GENERAL';
1764 }
1765
1766 $muteList = Array();
1767 if ($arRes['RELATION_NOTIFY_BLOCK'] == 'Y')
1768 {
1769 $muteList = Array($arRes['RELATION_USER_ID'] => true);
1770 }
1771
1772 $itemId = 'chat'.$itemId;
1773 $item['CHAT'] = Array(
1774 'id' => $arRes['ITEM_ID'],
1775 'name' => \Bitrix\Im\Text::decodeEmoji($arRes["C_TITLE"]),
1776 'color' => $arRes["CHAT_COLOR"] == ""? IM\Color::getColorByNumber($arRes['ITEM_ID']): IM\Color::getColor($arRes['CHAT_COLOR']),
1777 'avatar' => CIMChat::GetAvatarImage($arRes["C_AVATAR"]),
1778 'extranet' => $arRes["CHAT_EXTRANET"] == ""? "": ($arRes["CHAT_EXTRANET"] == "Y"? true: false),
1779 'owner' => $arRes["C_OWNER_ID"],
1780 'type' => $chatType,
1781 'entity_type' => $arRes["CHAT_ENTITY_TYPE"],
1782 'entity_id' => $arRes["CHAT_ENTITY_ID"],
1783 'entity_data_1' => trim($arRes["CHAT_ENTITY_DATA_1"]),
1784 'entity_data_2' => trim($arRes["CHAT_ENTITY_DATA_2"]),
1785 'entity_data_3' => trim($arRes["CHAT_ENTITY_DATA_3"]),
1786 'mute_list' => $muteList,
1787 'message_type' => $arRes['CHAT_TYPE'],
1788 'call_number' => $arRes["C_CALL_NUMBER"]
1789 );
1790 }
1791 $arRecent[$itemId] = $item;
1792 }
1793 $params = CIMMessageParam::Get($arMessageId);
1794 foreach ($arRecent as $key => $value)
1795 {
1796 if (isset($params[$value['MESSAGE']['id']]) && is_array($params[$value['MESSAGE']['id']]['FILE_ID']))
1797 {
1798 if (count($params[$value['MESSAGE']['id']]['FILE_ID']) > 0 && trim($arRecent[$key]['MESSAGE']['text']) == '')
1799 {
1800 $arRecent[$key]['MESSAGE']['text'] = "[".GetMessage('IM_FILE')."]";
1801 }
1802 }
1803 $arRecent[$key]['MESSAGE']['params'] = $params[$value['MESSAGE']['id']];
1804 }
1805
1806 $bIntranetEnable = IsModuleInstalled('intranet');
1807 $bVoximplantEnable = IsModuleInstalled('voximplant');
1808 if ($bIntranetEnable || $bVoximplantEnable)
1809 {
1810 $arUserPhone = Array();
1811 $arUserDepartment = Array();
1812
1813 $arSelectParams = Array();
1814 if ($bIntranetEnable)
1815 $arSelectParams[] = 'UF_DEPARTMENT';
1816 if ($bVoximplantEnable)
1817 $arSelectParams[] = 'UF_VI_PHONE';
1818
1819 $dbUsers = CUser::GetList(['last_name'=>'asc'], '', Array('ID' => $userId."|".implode('|', $arUsers)), Array('FIELDS' => Array("ID"), 'SELECT' => $arSelectParams));
1820 while ($arUser = $dbUsers->GetNext(true, false))
1821 {
1822 $arUserPhone[$arUser['ID']] = $arUser['UF_VI_PHONE'] == 'Y';
1823 $arUserDepartment[$arUser['ID']] = self::IsExtranet($arUser);
1824 }
1825
1826 foreach ($arRecent as $key => $value)
1827 {
1828 if (isset($value['USER']))
1829 {
1830 $arRecent[$key]['USER']['extranet'] = $arUserDepartment[$value['USER']['id']];
1831 $arRecent[$key]['USER']['phone_device'] = $arUserPhone[$value['USER']['id']];
1832 }
1833 }
1834 }
1835
1836 if ($bLoadUnreadMessage)
1837 {
1838 $CIMMessage = new CIMMessage(false, Array(
1839 'HIDE_LINK' => 'Y'
1840 ));
1841
1842 $ar = $CIMMessage->GetUnreadMessage(Array(
1843 'LOAD_DEPARTMENT' => 'N',
1844 'ORDER' => 'ASC',
1845 'GROUP_BY_CHAT' => 'Y',
1846 'USE_TIME_ZONE' => $bTimeZone? 'Y': 'N',
1847 'USE_SMILES' => $bSmiles? 'Y': 'N'
1848 ));
1849 foreach ($ar['message'] as $data)
1850 {
1851 if (!isset($arRecent[$data['senderId']]))
1852 {
1853 $arRecent[$data['senderId']] = Array(
1854 'TYPE' => IM_MESSAGE_PRIVATE,
1855 'USER' => $ar['users'][$data['senderId']]
1856 );
1857 }
1858 $arRecent[$data['senderId']]['MESSAGE'] = Array(
1859 'id' => $data['id'],
1860 'senderId' => $data['senderId'],
1861 'date' => $data['date'],
1862 'text' => preg_replace('#\-{54}.+?\-{54}#s', " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" ", " ", " ", " "), $data['text']), "<img>"))
1863 );
1864
1865 $arRecent[$data['senderId']]['COUNTER'] = $data['counter'];
1866 }
1867
1868 $CIMChat = new CIMChat(false, Array(
1869 'HIDE_LINK' => 'Y'
1870 ));
1871
1872 $ar = $CIMChat->GetUnreadMessage(Array(
1873 'ORDER' => 'ASC',
1874 'GROUP_BY_CHAT' => 'Y',
1875 'USER_LOAD' => 'N',
1876 'FILE_LOAD' => 'N',
1877 'USE_SMILES' => $bSmiles? 'Y': 'N',
1878 'USE_TIME_ZONE' => $bTimeZone? 'Y': 'N'
1879 ));
1880 foreach ($ar['message'] as $data)
1881 {
1882 if (!isset($arRecent['chat'.$data['recipientId']]))
1883 {
1884 $arRecent['chat'.$data['recipientId']] = Array(
1885 'TYPE' => $ar['messageType']? $ar['messageType']: IM_MESSAGE_CHAT,
1886 'CHAT' => $ar['chat']
1887 );
1888 }
1889 $arRecent['chat'.$data['recipientId']]['MESSAGE'] = Array(
1890 'id' => $data['id'],
1891 'senderId' => $data['senderId'],
1892 'date' => $data['date'],
1893 'text' => $data['text']
1894 );
1895 $arRecent['chat'.$data['recipientId']]['COUNTER'] = $data['counter'];
1896 }
1897 }
1898
1899 if (!empty($arRecent))
1900 {
1902 $arRecent,
1903 array(
1904 'COUNTER' => array(SORT_NUMERIC, SORT_DESC),
1905 'MESSAGE' => array(SORT_NUMERIC, SORT_DESC)
1906 ),
1907 array(
1908 'COUNTER' => array(__CLASS__, 'GetRecentListSortCounter'),
1909 'MESSAGE' => array(__CLASS__, 'GetRecentListSortMessage'),
1910 ),
1911 null, true
1912 );
1913 }
1914 return $arRecent;
1915 }
1916
1917 public static function GetRecentListSortCounter($counter)
1918 {
1919 return !is_null($counter);
1920 }
1921
1922 public static function GetRecentListSortMessage($recent)
1923 {
1924 return $recent['date'];
1925 }
1926
1927 public static function IsExtranet($arUser)
1928 {
1929 $result = false;
1930
1931 if (!IsModuleInstalled('intranet'))
1932 {
1933 return false;
1934 }
1935
1936 if (($arUser['EXTERNAL_AUTH_ID'] ?? null) === \Bitrix\Im\Bot::EXTERNAL_AUTH_ID)
1937 {
1938 return false;
1939 }
1940
1941 if (!\Bitrix\Main\Loader::includeModule('humanresources'))
1942 {
1943 return false;
1944 }
1945
1946 try
1947 {
1948 return !\Bitrix\HumanResources\Service\Container::getUserService()->isEmployee((int)$arUser['ID']);
1949 }
1950 catch (\Exception $exception)
1951 {
1952 return false;
1953 }
1954 }
1955
1956 public static function GetUserPath($userId = false)
1957 {
1958 static $extranetSiteID = false;
1959
1960 $userId = intval($userId);
1961
1962 if (
1963 $extranetSiteID === false
1964 && CModule::IncludeModule("extranet")
1965 )
1966 {
1967 $extranetSiteID = CExtranet::GetExtranetSiteID();
1968 }
1969
1970 if (IsModuleInstalled('intranet'))
1971 {
1972 $strPathTemplate = COption::GetOptionString(
1973 "socialnetwork",
1974 "user_page",
1975 SITE_DIR.'company/personal/',
1976 (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser() ? $extranetSiteID : SITE_ID)
1977 )."user/#user_id#/";
1978 }
1979 else
1980 {
1981 $strPathTemplate = COption::GetOptionString(
1982 "im",
1983 "path_to_user_profile",
1984 "/club/user/#user_id#/",
1985 SITE_ID
1986 );
1987 }
1988
1989 if ($userId <= 0)
1990 {
1991 return $strPathTemplate;
1992 }
1993 else
1994 {
1995 return CComponentEngine::MakePathFromTemplate(
1996 $strPathTemplate,
1997 array("user_id" => $userId)
1998 );
1999 }
2000 }
2001
2002 public static function GetUserNameTemplate($siteId = false, $langId = false, $getDefault = false)
2003 {
2004 if (!$langId && defined('LANGUAGE_ID'))
2005 {
2006 $langId = LANGUAGE_ID;
2007 }
2008
2009 if (in_array($langId, Array('ru', 'kz', 'by', 'ua')))
2010 {
2011 $template = "#LAST_NAME# #NAME#";
2012 }
2013 else
2014 {
2015 $template = "#LAST_NAME#, #NAME#";
2016 }
2017
2018 return $getDefault? $template: COption::GetOptionString("im", "user_name_template", $template, $siteId);
2019 }
2020
2021 public static function GetUserColor($id, $gender)
2022 {
2024 if ($gender == 'M')
2025 {
2026 $replaceColor = IM\Color::getReplaceColors();
2027 if (isset($replaceColor[$code]))
2028 {
2029 $code = $replaceColor[$code];
2030 }
2031 }
2032
2033 return IM\Color::getColor($code);
2034 }
2035
2036 public static function PrepareUserId($id, $searchMark = '')
2037 {
2038 $result = self::PrepareUserIds(Array($id), $searchMark);
2039
2040 return $result[$id];
2041 }
2042
2043 public static function formatAbsentResult($userId)
2044 {
2045 if (!CModule::IncludeModule('intranet'))
2046 {
2047 return false;
2048 }
2049
2050 $result = \Bitrix\Intranet\UserAbsence::isAbsentOnVacation($userId, true);
2051 if ($result)
2052 {
2054 }
2055 else
2056 {
2057 $result = false;
2058 }
2059
2060 return $result;
2061 }
2062
2063 public static function PrepareUserIds($userIds, $searchMark = '')
2064 {
2065 $portalId = Array();
2066 $networkId = Array();
2067 $structureId = Array();
2068 foreach ($userIds as $userId)
2069 {
2070 if (mb_substr($userId, 0, 7) == 'network')
2071 {
2072 $networkId[$userId] = mb_substr($userId, 7);
2073 }
2074 elseif (mb_substr($userId, 0, 10) == 'department')
2075 {
2076 $sid = intval(mb_substr($userId, 10));
2077 if ($sid > 0)
2078 {
2079 $structureId[$userId] = $sid;
2080 }
2081 }
2082 elseif (mb_substr($userId, 0, 9) == 'structure')
2083 {
2084 $sid = intval(mb_substr($userId, 9));
2085 if ($sid > 0)
2086 {
2087 $structureId[$userId] = $sid;
2088 }
2089 }
2090 else
2091 {
2092 $userId = intval($userId);
2093 if ($userId > 0)
2094 {
2095 $portalId[$userId] = $userId;
2096 }
2097 }
2098 }
2099 if (!empty($networkId) && CModule::IncludeModule('socialservices'))
2100 {
2101 $network = new \Bitrix\Socialservices\Network();
2102 $networkEnabled = $network->isEnabled();
2103 if ($networkEnabled)
2104 {
2105 $users = $network->addUsersById($networkId, $searchMark);
2106 if ($users)
2107 {
2108 foreach ($users as $networkId => $userId)
2109 {
2110 $portalId['network'.$networkId] = $userId;
2111 }
2112 }
2113 }
2114 }
2115 if (!empty($structureId) && CModule::IncludeModule('intranet'))
2116 {
2118 'select' => Array('ID', 'UF_DEPARTMENT'),
2119 'filter' => Array('=ACTIVE' => 'Y', '=UF_DEPARTMENT' => array_values($structureId))
2120 ));
2121 while ($row = $orm->fetch())
2122 {
2123 $portalId[$row['ID']] = $row['ID'];
2124 }
2125 }
2126
2127 return $portalId;
2128 }
2129}
2130?>
$arParams
Определения access_dialog.php:21
$connection
Определения actionsdefinitions.php:38
$type
Определения options.php:106
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getType($chatData, bool $camelCase=true)
Определения chat.php:45
static getColorByNumber($number)
Определения color.php:144
static isEnabled()
Определения color.php:50
static getColor($code)
Определения color.php:121
static getReplaceColors()
Определения color.php:112
static getCodeByNumber($number)
Определения color.php:166
static getPullExtra()
Определения common.php:127
static getUserId($userId=null)
Определения common.php:73
static getColleagues($userId=null, $options=array())
Определения department.php:8
static isOperator($userId=null)
Определения user.php:6
static getGroup($params, $userId=null, bool $filterActiveUser=true)
Определения extranet.php:15
static clearCache($userId=null)
Определения lastsearch.php:351
static parse($text, $params=Array())
Определения text.php:28
static decodeEmoji($text)
Определения text.php:378
static formatFullNameFromDatabase($fields)
Определения user.php:1243
static formatNameFromDatabase($fields)
Определения user.php:1222
static getInstance(?int $id)
Определения BotData.php:34
static getInstance(?int $id)
Определения User.php:72
const DELETE_EVENT
Определения Event.php:10
const CHAT_ENTITY
Определения Event.php:14
static getInstance()
Определения Logger.php:37
static getInstance()
Определения application.php:98
static includeModule($moduleName)
Определения loader.php:67
static getEntity()
Определения datamanager.php:65
static getList(array $parameters=array())
Определения datamanager.php:431
static getTypes()
Определения join.php:40
static createFromTimestamp($timestamp)
Определения datetime.php:246
static getUserSearchFilter(array $fields)
Определения userutils.php:18
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
Определения event.php:22
static GetRecentListSortCounter($counter)
Определения im_contact_list.php:1917
GetList($arParams=Array())
Определения im_contact_list.php:54
static formatAbsentResult($userId)
Определения im_contact_list.php:2043
static InRecent($userId, $type, $itemId)
Определения im_contact_list.php:1235
static DeleteRecent($entityId, $isChat=false, $userId=false, $withoutRead=false)
Определения im_contact_list.php:1373
static GetRecentListSortMessage($recent)
Определения im_contact_list.php:1922
static PrepareUserId($id, $searchMark='')
Определения im_contact_list.php:2036
static GetRecentList($arParams=Array())
Определения im_contact_list.php:1563
static SetOnline($userId=null, $cache=true)
Определения im_contact_list.php:1186
static AllowToSend($arParams)
Определения im_contact_list.php:676
static GetUserData($arParams=Array())
Определения im_contact_list.php:822
static ClearRecentCache($userId=null)
Определения im_contact_list.php:1559
static IsExtranet($arUser)
Определения im_contact_list.php:1927
static SetRecentForNewUser($userId)
Определения im_contact_list.php:1257
static DialogHide($dialogId, $userId=null)
Определения im_contact_list.php:1512
static SetOffline($userId=null)
Определения im_contact_list.php:1191
static GetUserColor($id, $gender)
Определения im_contact_list.php:2021
static SetRecent($arParams)
Определения im_contact_list.php:1277
__construct($user_id=false)
Определения im_contact_list.php:15
SearchUsers($searchText)
Определения im_contact_list.php:529
static GetUserNameTemplate($siteId=false, $langId=false, $getDefault=false)
Определения im_contact_list.php:2002
static CleanChatCache($userId)
Определения im_contact_list.php:508
const NETWORK_AUTH_ID
Определения im_contact_list.php:13
static GetUserPath($userId=false)
Определения im_contact_list.php:1956
static CleanAllChatCache()
Определения im_contact_list.php:521
static SetCurrentTab($userId)
Определения im_contact_list.php:1230
static PrepareUserIds($userIds, $searchMark='')
Определения im_contact_list.php:2063
static IsFriends($firstUserID, $secondUserID)
Определения user_relations.php:355
Определения im_chat.php:15
Определения im_message.php:14
const PRIVACY_RESULT_ALL
Определения im_settings.php:28
const PRIVACY_RESULT_CONTACT
Определения im_settings.php:29
const PRIVACY_MESSAGE
Определения im_settings.php:23
static GetPrivacy($type, $userId=false)
Определения im_settings.php:519
static GetDefaultSettings($type)
Определения im_settings.php:318
const PRIVACY_SEARCH
Определения im_settings.php:26
const SETTINGS
Определения im_settings.php:12
Определения cache.php:11
Clean($uniq_str, $initdir=false, $basedir="cache")
Определения cache.php:20
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения user_relations.php:156
Определения user.php:6037
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$data['IS_AVAILABLE']
Определения .description.php:13
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$arGroups
Определения options.php:1766
$result
Определения get_property_values.php:14
$query
Определения get_search.php:11
$uid
Определения hot_keys_act.php:8
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
const IM_MESSAGE_CHAT
Определения include.php:23
const IM_MESSAGE_OPEN
Определения include.php:24
const IM_MESSAGE_PRIVATE
Определения include.php:22
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
const SITE_DIR(!defined('LANG'))
Определения include.php:72
$groups
Определения options.php:30
$siteId
Определения ajax.php:8
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
IsModuleInstalled($module_id)
Определения tools.php:5301
htmlspecialcharsEx($str)
Определения tools.php:2685
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
Определения tools.php:5087
Определения contextmenu.php:9
Определения alias.php:2
Определения ChatsSync.php:3
Определения ActionUuid.php:3
Определения ufield.php:9
Определения collection.php:2
$user
Определения mysql_to_pgsql.php:33
$GLOBALS['____1690880296']
Определения license.php:1
$entityId
Определения payment.php:4
$counter
Определения options.php:5
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
$config
Определения quickway.php:69
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
$counters
Определения options.php:100
const SONET_ROLES_USER
Определения include.php:31
const SONET_RELATIONS_FRIEND
Определения include.php:24
$arRes
Определения options.php:104
const SITE_ID
Определения sonet_set_content_view.php:12
$rs
Определения action.php:82
$arFilter
Определения user_search.php:106
$dbRes
Определения yandex_detail.php:168