$arContactList = $CIMContactList->GetList(); echo CUtil::PhpToJsObject(Array( 'USER_ID' => $USER->GetId(), 'USERS' => $arContactList['users'], 'GROUPS' => $arContactList['groups'], 'USER_IN_GROUP' => $arContactList['userInGroup'], 'WO_GROUPS' => $arContactList['woGroups'], 'WO_USER_IN_GROUP' => $arContactList['woUserInGroup'], 'ERROR' => '' )); } else if ($_POST['IM_RECENT_LIST'] == 'Y') { $ar = CIMContactList::GetRecentList(Array( 'USE_TIME_ZONE' => 'N', 'USE_SMILES' => 'N' )); $arRecent = Array(); $arUsers = Array(); $arChat = Array(); foreach ($ar as $userId => $value) { if ($value['TYPE'] == IM_MESSAGE_GROUP) { $arChat[$value['CHAT']['id']] = $value['CHAT']; $value['MESSAGE']['userId'] = $userId; $value['MESSAGE']['recipientId'] = $userId; } else { $value['MESSAGE']['userId'] = $userId;
} $arMessage['usersMessage']['chat' . $chatId] = $arMessage['usersMessage'][$chatId]; unset($arMessage['usersMessage'][$chatId]); } } else { $arMessage = $CIMHistory->SearchMessage($_POST['SEARCH'], intval($_POST['USER_ID']), false, false); } echo CUtil::PhpToJsObject(array('MESSAGE' => $arMessage['message'], 'USERS_MESSAGE' => $arMessage['usersMessage'], 'USER_ID' => htmlspecialcharsbx($_POST['USER_ID']), 'ERROR' => '')); } else { if ($_POST['IM_CONTACT_LIST'] == 'Y') { $CIMContactList = new CIMContactList(); $arContactList = $CIMContactList->GetList(); echo CUtil::PhpToJsObject(array('USER_ID' => $USER->GetId(), 'USERS' => $arContactList['users'], 'GROUPS' => $arContactList['groups'], 'USER_IN_GROUP' => $arContactList['userInGroup'], 'WO_GROUPS' => $arContactList['woGroups'], 'WO_USER_IN_GROUP' => $arContactList['woUserInGroup'], 'ERROR' => '')); } else { if ($_POST['IM_RECENT_LIST'] == 'Y') { $ar = CIMContactList::GetRecentList(array('USE_TIME_ZONE' => 'N')); $arRecent = array(); $arUsers = array(); $arChat = array(); foreach ($ar as $userId => $value) { $value['MESSAGE']['text_mobile'] = $value['MESSAGE']['text']; if ($value['TYPE'] == IM_MESSAGE_GROUP) { $arChat[$value['CHAT']['id']] = $value['CHAT']; $value['MESSAGE']['userId'] = $userId; $value['MESSAGE']['recipientId'] = $userId; } else { $value['MESSAGE']['userId'] = $userId; $value['MESSAGE']['recipientId'] = $userId; $arUsers[$value['USER']['id']] = $value['USER']; } $arRecent[] = $value['MESSAGE'];
} $GLOBALS["APPLICATION"]->SetPageProperty("BodyClass", "im-page"); if (isset($arParams['TEMPLATE_POPUP']) && $arParams['TEMPLATE_POPUP'] == 'Y') { $GLOBALS["APPLICATION"]->SetPageProperty("Viewport", "user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=290"); } else { if (isset($arParams['POSITION']) && $arParams['POSITION'] == 'RIGHT') { $GLOBALS["APPLICATION"]->SetPageProperty("BodyClass", "im-page im-page-right"); } } $arResult = array(); CIMContactList::SetOnline(); $arSettings = CIMSettings::Get(); $arResult['SETTINGS'] = $arSettings['settings']; $CIMContactList = new CIMContactList(); $arResult['CONTACT_LIST'] = $CIMContactList->GetList(); $arRecent = CIMContactList::GetRecentList(array('LOAD_LAST_MESSAGE' => 'Y', 'USE_TIME_ZONE' => 'N', 'USE_SMILES' => 'N')); $arResult['RECENT'] = array(); $CIMMessage = new CIMMessage(); $arResult['MESSAGE'] = $CIMMessage->GetUnreadMessage(array('USE_TIME_ZONE' => 'N', 'ORDER' => 'ASC')); $arResult["MESSAGE_COUNTER"] = $arResult['MESSAGE']['countMessage']; // legacy $CIMChat = new CIMChat(); $arChatMessage = $CIMChat->GetUnreadMessage(array('USE_TIME_ZONE' => 'N', 'ORDER' => 'ASC')); if ($arChatMessage['result']) { foreach ($arChatMessage['message'] as $id => $ar) { $ar['recipientId'] = 'chat' . $ar['recipientId']; $arResult['MESSAGE']['message'][$id] = $ar; } foreach ($arChatMessage['usersMessage'] as $chatId => $ar) { $arResult['MESSAGE']['usersMessage']['chat' . $chatId] = $ar; }