コード例 #1
0
ファイル: factory.php プロジェクト: mrdeadmouse/u136006
 public function SendUnreadMessages($receiverJId, $domain = "")
 {
     $receiverJId = trim($receiverJId);
     if (strlen($receiverJId) <= 0) {
         return false;
     }
     $receiver = CXMPPUtility::GetUserByJId($receiverJId, $domain);
     if (!$receiver) {
         return false;
     }
     $factory = CXMPPFactory::GetFactory();
     if (IsModuleInstalled("im") && CModule::IncludeModule("im")) {
         $CIMMessage = new CIMMessage($receiverJId, array('hide_link' => true));
         $arMessage = $CIMMessage->GetUnreadMessage(array('SPEED_CHECK' => 'N', 'ORDER' => 'ASC', 'USE_SMILES' => 'N', 'USER_LOAD' => 'N', 'LOAD_DEPARTMENT' => 'N'));
         if ($arMessage['result']) {
             foreach ($arMessage['message'] as $id => $arMessage) {
                 $factory->__SendMessage($arMessage["senderId"], $arMessage["recipientId"], $arMessage["id"], IM_MESSAGE_PRIVATE, htmlspecialcharsbx(CTextParser::convert4mail(str_replace(array("#BR#", "<br />", "<br>", "<br/>"), "\n", $arMessage["text"]))), $domain);
             }
         }
         // Notify
         $CIMNotify = new CIMNotify($receiverJId);
         $arNotify = $CIMNotify->GetUnreadNotify(array('SPEED_CHECK' => 'N', 'ORDER' => 'ASC'));
         if ($arNotify['result']) {
             foreach ($arNotify['original_notify'] as $id => $arNotify) {
                 if (isset($arNotify["NOTIFY_MODULE"]) && isset($arNotify["NOTIFY_EVENT"]) && !CIMSettings::GetNotifyAccess($arNotify["TO_USER_ID"], $arNotify["NOTIFY_MODULE"], $arNotify["NOTIFY_EVENT"], CIMSettings::CLIENT_XMPP)) {
                     continue;
                 }
                 if ($arNotify["MESSAGE_OUT"] == IM_MAIL_SKIP) {
                     $arNotify["MESSAGE_OUT"] = '';
                 }
                 $factory->__SendMessage($arNotify["FROM_USER_ID"], $arNotify["TO_USER_ID"], $arNotify["ID"], IM_MESSAGE_SYSTEM, htmlspecialcharsbx(CTextParser::convert4mail(str_replace(array("#BR#", "<br />", "<br>", "<br/>"), "\n", strlen($arNotify["MESSAGE_OUT"]) > 0 ? $arNotify["MESSAGE_OUT"] : $arNotify["MESSAGE"]))), $domain);
             }
         }
     } else {
         $parser = new CSocNetTextParser();
         $dbMessages = CSocNetMessages::GetList(array("DATE_CREATE" => "ASC"), array("TO_USER_ID" => $receiver["ID"], "DATE_VIEW" => "", "TO_DELETED" => "N", "IS_LOG_ALL" => "Y"), false, false, array("ID", "FROM_USER_ID", "TO_USER_ID", "MESSAGE", "DATE_VIEW", "MESSAGE_TYPE", "FROM_DELETED", "TO_DELETED", "IS_LOG"));
         while ($arMessage = $dbMessages->Fetch()) {
             $factory->__SendMessage($arMessage["IS_LOG"] == "Y" ? -5 : $arMessage["FROM_USER_ID"], $arMessage["TO_USER_ID"], $arMessage["ID"], $arMessage["MESSAGE_TYPE"], htmlspecialcharsbx($parser->convert4mail(str_replace(array("#BR#", "<br />", "<br>", "<br/>"), "\n", $arMessage["MESSAGE"]))), $domain);
         }
     }
     return true;
 }
コード例 #2
0
ファイル: im.ajax.php プロジェクト: k-kalashnikov/geekcon_new
         $arResult['COUNTER_UNREAD_MESSAGES'] = $arData;
     }
     if (CModule::IncludeModule('pull')) {
         $arChannel = CPullChannel::Get($USER->GetId());
         if (is_array($arChannel)) {
             $arResult['PULL_CONFIG'] = array('CHANNEL_ID' => $arChannel['CHANNEL_ID'], 'LAST_ID' => $arChannel['LAST_ID'], 'PATH' => $arChannel['PATH'], 'PATH_WS' => $arChannel['PATH_WS'], 'METHOD' => $arChannel['METHOD'], 'ERROR' => '');
         }
     }
     // Counters
     $arResult["COUNTERS"] = CUserCounter::GetValues($USER->GetID(), $_POST['SITE_ID']);
     $arResult["ERROR"] = $errorMessage;
     echo CUtil::PhpToJsObject($arResult);
 } else {
     if ($_POST['IM_NOTIFY_LOAD'] == 'Y') {
         $CIMNotify = new CIMNotify();
         $arNotify = $CIMNotify->GetUnreadNotify(array('SPEED_CHECK' => 'N', 'USE_TIME_ZONE' => 'N'));
         if ($arNotify['result']) {
             $arSend['NOTIFY'] = $arNotify['notify'];
             $arSend['UNREAD_NOTIFY'] = $arNotify['unreadNotify'];
             $arSend['FLASH_NOTIFY'] = CIMNotify::GetFlashNotify($arNotify['unreadNotify']);
             $arSend['ERROR'] = '';
             if ($arNotify['maxNotify'] > 0) {
                 $CIMNotify->MarkNotifyRead($arNotify['maxNotify'], true);
             }
         }
         echo CUtil::PhpToJsObject($arSend);
     } else {
         if ($_POST['IM_NOTIFY_HISTORY_LOAD_MORE'] == 'Y') {
             $errorMessage = "";
             $CIMNotify = new CIMNotify();
             $arNotify = $CIMNotify->GetNotifyList(array('PAGE' => $_POST['PAGE'], 'USE_TIME_ZONE' => 'N'));
コード例 #3
0
	public static function GetSpeedCounters()
	{
		$CIMNotify = new CIMNotify();
		$arNotify = $CIMNotify->GetUnreadNotify(Array('USE_TIME_ZONE' => 'N'));
		$arResult['NOTIFY']  = count($arNotify['notify']);

		$CIMMessage = new CIMMessage();
		$arMessage = $CIMMessage->GetUnreadMessage(Array(
			'LOAD_DEPARTMENT' => 'N',
			'FILE_LOAD' => 'N',
			'ORDER' => 'ASC',
		));
		$arResult['MESSAGE'] = count($arMessage['message']);

		$CIMChat = new CIMChat();
		$arMessage = $CIMChat->GetUnreadMessage(Array(
			'LOAD_DEPARTMENT' => 'N',
			'ORDER' => 'ASC',
			'FILE_LOAD' => 'N',
			'USER_LOAD' => 'N',
		));
		$arResult['MESSAGE'] += count($arMessage['message']);

		return $arResult;
	}
コード例 #4
0
ファイル: component.php プロジェクト: ASDAFF/bitrix-5
	else
	{
		$arResult['RECENT'] = false;
		$arResult['CONTACT_LIST'] = Array(
			'users' => Array(),
			'groups' => Array(),
			'userInGroup' => Array(),
			'woGroups' => Array(),
			'woUserInGroup' => Array()
		);
		$arResult['SMILE'] = false;
		$arResult['SMILE_SET'] = false;
	}

	$CIMNotify = new CIMNotify();
	$arResult['NOTIFY'] = $CIMNotify->GetUnreadNotify(Array('GET_ONLY_FLASH' => 'Y', 'USE_TIME_ZONE' => 'N'));
	$arResult['NOTIFY']['flashNotify'] = CIMNotify::GetFlashNotify($arResult['NOTIFY']['unreadNotify']);
	$arResult["NOTIFY_COUNTER"] = $arResult['NOTIFY']['countNotify']; // legacy

	$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;