コード例 #1
0
ファイル: im.ajax.php プロジェクト: k-kalashnikov/geekcon_new
         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]);
             if (isset($_POST['READ']) && $_POST['READ'] == 'Y') {
                 $CIMChat->SetReadMessage($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);
             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'];
コード例 #2
0
ファイル: factory.php プロジェクト: mrdeadmouse/u136006
 private function __SendMessage($senderId, $receiverId, $messageID, $type, $message, $domain = "")
 {
     if (!$this->isInitialized) {
         $this->Initialize();
     }
     $receiverId = intval($receiverId);
     if ($receiverId <= 0) {
         return false;
     }
     $messageID = intval($messageID);
     if ($messageID <= 0) {
         return false;
     }
     if (!in_array($type, array("P", "S"))) {
         return false;
     }
     if (strlen($message) <= 0) {
         return false;
     }
     if (!CXMPPUtility::CheckXmppStatusOnline()) {
         return false;
     }
     $senderJId = false;
     $receiverJId = false;
     $arUserID = array();
     $arUserID[] = $receiverId;
     $senderId = intval($senderId);
     if ($senderId <= 0) {
         if ($senderId != -5) {
             return false;
         }
         $senderJId = self::GetSystemJId($domain);
     } else {
         $arUserID[] = $senderId;
     }
     if (!($arJID = CXMPPUtility::GetJIdByUserId($arUserID, $domain))) {
         return false;
     }
     if ($senderId > 0) {
         $senderJId = $arJID[$senderId];
     }
     $receiverJId = $arJID[$receiverId];
     if (!$senderJId) {
         CXMPPUtility::Show("Error senderId=" . $senderId . ", receiverId=" . $receiverId . ", messageID=" . $messageID . " - Sender not found", 0);
         return false;
     }
     if (!$receiverJId) {
         CXMPPUtility::Show("Error senderId=" . $senderId . ", receiverId=" . $receiverId . ", messageID=" . $messageID . " - Reseiver not found", 0);
         return false;
     }
     $messageType = "chat";
     if ($type == "S") {
         $messageType = "normal";
     }
     $arMessage = CXMPPUtility::GetMessageArray($senderJId, $receiverJId, $messageType, $message, $domain);
     $result = false;
     if (CXMPPServer::IsServerStarted()) {
         $server = CXMPPServer::GetServer();
         $result = $server->Send($receiverJId, $arMessage, $domain);
     } else {
         $result = CXMPPUtility::SendToServer($arMessage, $domain);
     }
     if ($result === true) {
         if (IsModuleInstalled("im") && CModule::IncludeModule("im")) {
             if ($type == "S") {
                 $CIMNotify = new CIMNotify($receiverId);
                 $CIMNotify->MarkNotifyRead($messageID);
             } else {
                 $CIMMessage = new CIMMessage($receiverId);
                 $CIMMessage->SetReadMessage($senderId);
             }
         } else {
             CSocNetMessages::MarkMessageRead($receiverId, $messageID);
         }
     } else {
         CXMPPUtility::Show("Error senderId=" . $senderId . ", receiverId=" . $receiverId . ", messageID=" . $messageID . " - Message was not send", 0);
     }
     return $result;
 }
コード例 #3
0
				$arMessage['usersMessage']['chat'.$chatId] = $arMessage['usersMessage'][$chatId];
				unset($arMessage['usersMessage'][$chatId]);
				if (isset($_POST['READ']) && $_POST['READ'] == 'Y')
					$CIMChat->SetReadMessage($chatId);
			}
		}
		else
		{
			$chatId = 0;
			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);
				if (isset($_POST['READ']) && $_POST['READ'] == 'Y')
					$CIMMessage->SetReadMessage(intval($_POST['USER_ID']));

				if ($_POST['USER_LOAD'] == 'Y' && count($arMessage['users']) <= 1)
				{
					$arMessage = Array();
					$error = 'ACCESS_DENIED';
				}
				else
				{
					$chatId = $arMessage['chatId'];
					if ($chatId <= 0)
					{
						$chatId = CIMMessage::GetChatId($USER->GetId(), $_POST['USER_ID']);
					}
				}
			}