Пример #1
0
             $CIMMessage = new CIMMessage();
             $arMessage = $CIMMessage->GetLastMessage(intval($_POST['USER_ID']), false, $_POST['USER_LOAD'] == 'Y' ? true : false, false);
             if (isset($_POST['READ']) && $_POST['READ'] == 'Y') {
                 $CIMMessage->SetReadMessage(intval($_POST['TAB']));
             }
         }
     }
     echo CUtil::PhpToJsObject(array('USER_ID' => $_POST['CHAT'] == 'Y' ? htmlspecialcharsbx($_POST['USER_ID']) : intval($_POST['USER_ID']), 'MESSAGE' => isset($arMessage['message']) ? $arMessage['message'] : array(), 'USERS_MESSAGE' => isset($arMessage['usersMessage']) ? $arMessage['usersMessage'] : array(), 'USERS' => isset($arMessage['users']) ? $arMessage['users'] : array(), 'USER_IN_GROUP' => isset($arMessage['userInGroup']) ? $arMessage['userInGroup'] : array(), 'WO_USER_IN_GROUP' => isset($arMessage['woUserInGroup']) ? $arMessage['woUserInGroup'] : array(), 'CHAT' => isset($arMessage['chat']) ? $arMessage['chat'] : array(), 'USER_IN_CHAT' => isset($arMessage['userInChat']) ? $arMessage['userInChat'] : array(), 'USER_LOAD' => $_POST['USER_LOAD'] == 'Y' ? 'Y' : 'N', 'ERROR' => ''));
 } else {
     if ($_POST['IM_HISTORY_LOAD'] == 'Y') {
         $arMessage = array();
         $chatId = 0;
         if (substr($_POST['USER_ID'], 0, 4) == 'chat') {
             $chatId = intval(substr($_POST['USER_ID'], 4));
             $CIMChat = new CIMChat();
             $arMessage = $CIMChat->GetLastMessage($chatId, false, $_POST['USER_LOAD'] == 'Y' ? true : false, false);
             if (isset($arMessage['message'])) {
                 foreach ($arMessage['message'] as $id => $ar) {
                     $arMessage['message'][$id]['recipientId'] = 'chat' . $ar['recipientId'];
                 }
                 $arMessage['usersMessage']['chat' . $chatId] = $arMessage['usersMessage'][$chatId];
                 unset($arMessage['usersMessage'][$chatId]);
             }
         } else {
             if (CIMContactList::AllowToSend(array('TO_USER_ID' => $_POST['USER_ID']))) {
                 $CIMMessage = new CIMMessage();
                 $arMessage = $CIMMessage->GetLastMessage(intval($_POST['USER_ID']), false, $_POST['USER_LOAD'] == 'Y' ? true : false, false);
             }
         }
         echo CUtil::PhpToJsObject(array('USER_ID' => $chatId > 0 ? htmlspecialcharsbx($_POST['USER_ID']) : intval($_POST['USER_ID']), 'MESSAGE' => isset($arMessage['message']) ? $arMessage['message'] : array(), 'USERS_MESSAGE' => isset($arMessage['message']) ? $arMessage['usersMessage'] : array(), 'USERS' => isset($arMessage['users']) ? $arMessage['users'] : array(), 'USER_IN_GROUP' => isset($arMessage['userInGroup']) ? $arMessage['userInGroup'] : array(), 'WO_USER_IN_GROUP' => isset($arMessage['woUserInGroup']) ? $arMessage['woUserInGroup'] : array(), 'CHAT' => isset($arMessage['chat']) ? $arMessage['chat'] : array(), 'USER_IN_CHAT' => isset($arMessage['userInChat']) ? $arMessage['userInChat'] : array(), 'ERROR' => ''));
     } else {