コード例 #1
0
ファイル: im_contact_list.php プロジェクト: ASDAFF/bxApiDocs
	public static function GetRecentList($arParams = Array())
	{
		global $DB, $USER;

		$bLoadUnreadMessage = isset($arParams['LOAD_UNREAD_MESSAGE']) && $arParams['LOAD_UNREAD_MESSAGE'] == 'Y'? true: false;
		$bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N'? false: true;
		$bSmiles = isset($arParams['USE_SMILES']) && $arParams['USE_SMILES'] == 'N'? false: true;

		$nameTemplate = COption::GetOptionString("im", "user_name_template", "#LAST_NAME# #NAME#", SITE_ID);
		$nameTemplateSite = CSite::GetNameFormat(false);
		$nameOfSite = CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()? "ex": false;
		$bIntranetEnable = IsModuleInstalled('intranet') && CModule::IncludeModule('intranet')? true: false;

		$arRecent = Array();
		$arUsers = Array();

		$cache_ttl = 2592000;
		$cache_id = $GLOBALS['USER']->GetID();
		$cache_dir = '/bx/imc/rec'.CIMMessenger::GetCachePath($cache_id);
		$obCache = new CPHPCache();
		if($obCache->InitCache($cache_ttl, $cache_id, $cache_dir))
		{
			$ar = $obCache->GetVars();
			$arRecent = $ar['recent'];
			$arUsers = $ar['users'];
		}
		else
		{
			if (!$bTimeZone)
				CTimeZone::Disable();
			$strSql = "
				SELECT
					R.ITEM_TYPE, R.ITEM_ID,
					R.ITEM_MID M_ID, M.AUTHOR_ID M_AUTHOR_ID, M.MESSAGE M_MESSAGE, ".$DB->DatetimeToTimestampFunction('M.DATE_CREATE')." M_DATE_CREATE,
					C.TITLE C_TITLE, C.AUTHOR_ID C_OWNER_ID,
					U.LOGIN, U.NAME, U.LAST_NAME, U.PERSONAL_PHOTO, U.SECOND_NAME, U.PERSONAL_BIRTHDAY, U.PERSONAL_GENDER
				FROM
				b_im_recent R
				LEFT JOIN b_user U ON R.ITEM_TYPE = '".IM_MESSAGE_PRIVATE."' AND R.ITEM_ID = U.ID
				LEFT JOIN b_im_chat C ON R.ITEM_TYPE = '".IM_MESSAGE_GROUP."' AND R.ITEM_ID = C.ID
				LEFT JOIN b_im_message M ON R.ITEM_MID = M.ID
				WHERE R.USER_ID = ".$USER->GetId();
			if (!$bTimeZone)
				CTimeZone::Enable();

			$toDelete = Array();
			$CCTP = new CTextParser();
			$CCTP->MaxStringLen = 255;
			$CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => ($bSmiles? "Y": "N"), "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			while ($arRes = $dbRes->GetNext(true, false))
			{
				$arRes['ITEM_TYPE'] = trim($arRes['ITEM_TYPE']);
				if ($arRes['M_DATE_CREATE']+2592000 < time())
				{
					$toDelete[$arRes['ITEM_TYPE']][] = $arRes['ITEM_ID'];
					continue;
				}

				$itemId = $arRes['ITEM_ID'];
				$item = Array(
					'TYPE' => $arRes['ITEM_TYPE'],
					'MESSAGE' => Array(
						'id' => $arRes['M_ID'],
						'senderId' => $arRes['M_AUTHOR_ID'],
						'date' => $arRes['M_DATE_CREATE'],
						'text' => $CCTP->convertText(preg_replace("/\[s\].*?\[\/s\]/i", "", $arRes['M_MESSAGE']))
					)
				);
				$item['MESSAGE']['text'] = preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" "," ", " ", " "), $item['MESSAGE']['text']), "<img>"));
				if ($arRes['ITEM_TYPE'] == IM_MESSAGE_PRIVATE)
				{
					$arUsers[] = $arRes['ITEM_ID'];
					$arFileTmp = CFile::ResizeImageGet(
						$arRes["PERSONAL_PHOTO"],
						array('width' => 58, 'height' => 58),
						BX_RESIZE_IMAGE_EXACT,
						false
					);

					$item['USER'] = Array(
						'id' => $arRes['ITEM_ID'],
						'name' => CUser::FormatName($nameTemplateSite, $arRes, true, false),
						'nameList' => CUser::FormatName($nameTemplate, $arRes, true, false),
						'avatar' => empty($arFileTmp['src'])? '/bitrix/js/im/images/blank.gif': $arFileTmp['src'],
						'gender' => $arRes['PERSONAL_GENDER'] == 'F'? 'F': 'M',
						'status' => 'offline',
						'birthday' => $arRes['PERSONAL_BIRTHDAY'],
						'profile' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('im', 'path_to_user_profile', "", $nameOfSite), array("user_id" => $arRes["ITEM_ID"]))
					);
				}
				else
				{
					$itemId = 'chat'.$itemId;
					$item['CHAT'] = Array(
						'id' => $arRes['ITEM_ID'],
						'name' => $arRes["C_TITLE"],
						'owner' => $arRes["C_OWNER_ID"],
					);
				}
				$arRecent[$itemId] = $item;
			}
			// remove old entity
			if (!empty($toDelete))
			{
				if (isset($toDelete[IM_MESSAGE_PRIVATE]))
					self::DeleteRecent($toDelete[IM_MESSAGE_PRIVATE]);
				if (isset($toDelete[IM_MESSAGE_GROUP]))
					self::DeleteRecent($toDelete[IM_MESSAGE_GROUP], true);
			}
			if($obCache->StartDataCache())
				$obCache->EndDataCache(Array('recent' => $arRecent, 'users' => $arUsers));
		}

		$arOnline = self::GetStatus(Array('ID' => array_values($arUsers)));
		foreach ($arRecent as $key => $value)
		{
			if ($value['TYPE'] != IM_MESSAGE_PRIVATE)
				continue;

			$arRecent[$key]['USER']['birthday'] = $bIntranetEnable? CIntranetUtils::IsToday($value['USER']['birthday']): false;
			$arRecent[$key]['USER']['status'] = isset($arOnline['users'][$value['USER']['id']])? 'online': 'offline';
		}

		if ($bLoadUnreadMessage)
		{
			$CIMMessage = new CIMMessage(false, Array(
				'hide_link' => true
			));

			$ar = $CIMMessage->GetUnreadMessage(Array(
				'LOAD_DEPARTMENT' => 'N',
				'ORDER' => 'ASC',
				'GROUP_BY_CHAT' => 'Y',
				'USE_TIME_ZONE' => $bTimeZone? 'Y': 'N',
				'USE_SMILES' => $bSmiles? 'Y': 'N'
			));
			foreach ($ar['message'] as $data)
			{
				if (!isset($arRecent[$data['senderId']]))
				{
					$arRecent[$data['senderId']] = Array(
						'TYPE' => IM_MESSAGE_PRIVATE,
						'USER' => $ar['users'][$data['senderId']]
					);
				}
				$arRecent[$data['senderId']]['MESSAGE'] = Array(
					'id' => $data['id'],
					'senderId' => $data['senderId'],
					'date' => $data['date'],
					'text' => preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" ", " ", " ", " "), $data['text']), "<img>"))
				);

				$arRecent[$data['senderId']]['COUNTER'] = $data['counter'];
			}

			$CIMChat = new CIMChat(false, Array(
				'hide_link' => true
			));

			$ar = $CIMChat->GetUnreadMessage(Array(
				'ORDER' => 'ASC',
				'GROUP_BY_CHAT' => 'Y',
				'USER_LOAD' => 'N',
				'USE_SMILES' => $bSmiles? 'Y': 'N',
				'USE_TIME_ZONE' => $bTimeZone? 'Y': 'N'
			));
			foreach ($ar['message'] as $data)
			{
				if (!isset($arRecent['chat'.$data['recipientId']]))
				{
					$arRecent['chat'.$data['recipientId']] = Array(
						'TYPE' => IM_MESSAGE_GROUP,
						'CHAT' => $ar['chat']
					);
				}
				$arRecent['chat'.$data['recipientId']]['MESSAGE'] = Array(
					'id' => $data['id'],
					'senderId' => $data['senderId'],
					'date' => $data['date'],
					'text' => $data['text']
				);
				$arRecent['chat'.$data['recipientId']]['COUNTER'] = $data['counter'];
			}
		}

		if (!empty($arRecent))
		{
			sortByColumn(
				$arRecent,
				array(
					'COUNTER' => array(SORT_NUMERIC, SORT_DESC),
					'MESSAGE' => array(SORT_NUMERIC, SORT_DESC)
				),
				array(
					'COUNTER' => function($counter){ return !is_null($counter); },
					'MESSAGE' => function($recent){ return $recent['date']; }
				),
				null, true
			);
		}

		return $arRecent;
	}
コード例 #2
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;
	}
コード例 #3
0
 public static function GetRecentList($arParams = array())
 {
     global $DB, $USER;
     $bLoadUnreadMessage = isset($arParams['LOAD_UNREAD_MESSAGE']) && $arParams['LOAD_UNREAD_MESSAGE'] == 'Y' ? true : false;
     $bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N' ? false : true;
     $bSmiles = isset($arParams['USE_SMILES']) && $arParams['USE_SMILES'] == 'N' ? false : true;
     $userId = isset($arParams['USER_ID']) ? $arParams['USER_ID'] : $USER->GetId();
     $nameTemplate = self::GetUserNameTemplate(SITE_ID);
     $nameTemplateSite = CSite::GetNameFormat(false);
     $bIntranetEnable = IsModuleInstalled('intranet') && CModule::IncludeModule('intranet') ? true : false;
     $arRecent = array();
     $arUsers = array();
     $bColorEnabled = IM\Color::isEnabled();
     $cache_ttl = 2592000;
     $cache_id = 'im_recent_v8_' . $userId . '_' . $bColorEnabled;
     $cache_dir = '/bx/imc/recent' . CIMMessenger::GetCachePath($userId);
     $obCache = new CPHPCache();
     if ($obCache->InitCache($cache_ttl, $cache_id, $cache_dir)) {
         $ar = $obCache->GetVars();
         $arRecent = $ar['recent'];
         $arUsers = $ar['users'];
     } else {
         if (!$bTimeZone) {
             CTimeZone::Disable();
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tR.ITEM_TYPE, R.ITEM_ID,\n\t\t\t\t\tR.ITEM_MID M_ID, M.AUTHOR_ID M_AUTHOR_ID, M.ID M_ID, M.CHAT_ID M_CHAT_ID, M.MESSAGE M_MESSAGE, " . $DB->DatetimeToTimestampFunction('M.DATE_CREATE') . " M_DATE_CREATE,\n\t\t\t\t\tC.TITLE C_TITLE, C.AUTHOR_ID C_OWNER_ID, C.ENTITY_TYPE C_ENTITY_TYPE, C.AVATAR C_AVATAR, C.CALL_NUMBER C_CALL_NUMBER, C.EXTRANET CHAT_EXTRANET, C.COLOR CHAT_COLOR, C.TYPE CHAT_TYPE,\n\t\t\t\t\tU.LOGIN, U.NAME, U.LAST_NAME, U.PERSONAL_PHOTO, U.SECOND_NAME, U.PERSONAL_BIRTHDAY, U.PERSONAL_GENDER, U.EXTERNAL_AUTH_ID, U.WORK_POSITION,\n\t\t\t\t\tC1.USER_ID RID\n\t\t\t\tFROM\n\t\t\t\tb_im_recent R\n\t\t\t\tLEFT JOIN b_user U ON R.ITEM_TYPE = '" . IM_MESSAGE_PRIVATE . "' AND R.ITEM_ID = U.ID\n\t\t\t\tLEFT JOIN b_im_chat C ON R.ITEM_TYPE != '" . IM_MESSAGE_PRIVATE . "' AND R.ITEM_ID = C.ID\n\t\t\t\tLEFT JOIN b_im_message M ON R.ITEM_MID = M.ID\n\t\t\t\tLEFT JOIN b_im_relation C1 ON C1.CHAT_ID = C.ID AND C1.USER_ID = " . $userId . "\n\t\t\t\tWHERE R.USER_ID = " . $userId;
         if (!$bTimeZone) {
             CTimeZone::Enable();
         }
         $toDelete = array();
         $arMessageId = array();
         $CCTP = new CTextParser();
         $CCTP->MaxStringLen = 255;
         $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => $bSmiles ? "Y" : "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($arRes = $dbRes->GetNext(true, false)) {
             $arRes['ITEM_TYPE'] = trim($arRes['ITEM_TYPE']);
             if ($arRes['ITEM_TYPE'] == IM_MESSAGE_OPEN) {
                 if (intval($arRes['RID']) <= 0 && IM\User::getInstance($userId)->isExtranet()) {
                     continue;
                 }
             } else {
                 if ($arRes['ITEM_TYPE'] == IM_MESSAGE_CHAT) {
                     if (intval($arRes['RID']) <= 0) {
                         continue;
                     }
                 }
             }
             $arMessageId[] = $arRes['M_ID'];
             if ($arRes['M_DATE_CREATE'] + 2592000 < time()) {
                 $toDelete[$arRes['ITEM_TYPE']][] = $arRes['ITEM_ID'];
                 continue;
             }
             $itemId = $arRes['ITEM_ID'];
             $item = array('TYPE' => $arRes['ITEM_TYPE'], 'MESSAGE' => array('id' => $arRes['M_ID'], 'chatId' => $arRes['M_CHAT_ID'], 'senderId' => $arRes['M_AUTHOR_ID'], 'date' => $arRes['M_DATE_CREATE'], 'text' => $CCTP->convertText(preg_replace("/\\[s\\].*?\\[\\/s\\]/i", "", $arRes['M_MESSAGE']))));
             $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>"));
             if ($arRes['ITEM_TYPE'] == IM_MESSAGE_PRIVATE) {
                 $arUsers[] = $arRes['ITEM_ID'];
                 $arFileTmp = CFile::ResizeImageGet($arRes["PERSONAL_PHOTO"], array('width' => 58, 'height' => 58), BX_RESIZE_IMAGE_EXACT, false, false, true);
                 $item['USER'] = array('id' => $arRes['ITEM_ID'], 'name' => CUser::FormatName($nameTemplateSite, $arRes, true, false), 'nameList' => CUser::FormatName($nameTemplate, $arRes, true, false), 'workPosition' => $arRes['WORK_POSITION'], 'color' => self::GetUserColor($arRes["ID"], $arRes['PERSONAL_GENDER'] == 'M' ? 'M' : 'F'), 'avatar' => empty($arFileTmp['src']) ? '/bitrix/js/im/images/blank.gif' : $arFileTmp['src'], 'status' => 'offline', 'birthday' => $arRes['PERSONAL_BIRTHDAY'], 'gender' => $arRes['PERSONAL_GENDER'] == 'F' ? 'F' : 'M', 'extranet' => false, 'network' => $arRes['EXTERNAL_AUTH_ID'] == self::NETWORK_AUTH_ID, 'phoneDevice' => false, 'profile' => CIMContactList::GetUserPath($arRes["ITEM_ID"]));
             } else {
                 $chatType = $arRes["ITEM_TYPE"] == IM_MESSAGE_OPEN ? 'open' : 'chat';
                 if ($arRes["C_ENTITY_TYPE"] == 'CALL') {
                     $chatType = 'call';
                 }
                 $itemId = 'chat' . $itemId;
                 $item['CHAT'] = array('id' => $arRes['ITEM_ID'], 'name' => $arRes["C_TITLE"], 'color' => $arRes["CHAT_COLOR"] == "" ? IM\Color::getColorByNumber($arRes['ITEM_ID']) : IM\Color::getColor($arRes['CHAT_COLOR']), 'avatar' => CIMChat::GetAvatarImage($arRes["C_AVATAR"]), 'extranet' => $arRes["CHAT_EXTRANET"] == "" ? "" : ($arRes["CHAT_EXTRANET"] == "Y" ? true : false), 'owner' => $arRes["C_OWNER_ID"], 'type' => $chatType, 'messageType' => $arRes['CHAT_TYPE'], 'call_number' => $arRes["C_CALL_NUMBER"]);
             }
             $arRecent[$itemId] = $item;
         }
         $params = CIMMessageParam::Get($arMessageId);
         foreach ($arRecent as $key => $value) {
             if (isset($params[$value['MESSAGE']['id']])) {
                 if (count($params[$value['MESSAGE']['id']]['FILE_ID']) > 0 && strlen(trim($arRecent[$key]['MESSAGE']['text'])) <= 0) {
                     $arRecent[$key]['MESSAGE']['text'] = "[" . GetMessage('IM_FILE') . "]";
                 }
                 $arRecent[$key]['MESSAGE']['params'] = $params[$value['MESSAGE']['id']];
             }
         }
         if (!empty($toDelete)) {
             if (isset($toDelete[IM_MESSAGE_PRIVATE])) {
                 self::DeleteRecent($toDelete[IM_MESSAGE_PRIVATE]);
             }
             if (isset($toDelete[IM_MESSAGE_CHAT])) {
                 self::DeleteRecent($toDelete[IM_MESSAGE_CHAT], true);
             }
             if (isset($toDelete[IM_MESSAGE_OPEN])) {
                 self::DeleteRecent($toDelete[IM_MESSAGE_OPEN], true);
             }
         }
         $bExtranetEnable = IsModuleInstalled('extranet');
         $bVoximplantEnable = IsModuleInstalled('voximplant');
         if ($bExtranetEnable || $bVoximplantEnable) {
             $arUserPhone = array();
             $arUserDepartment = array();
             $arSelectParams = array();
             if ($bExtranetEnable) {
                 $arSelectParams[] = 'UF_DEPARTMENT';
             }
             if ($bVoximplantEnable) {
                 $arSelectParams[] = 'UF_VI_PHONE';
             }
             $dbUsers = CUser::GetList($sort_by = array('last_name' => 'asc'), $dummy = '', array('ID' => $userId . "|" . implode('|', $arUsers)), array('FIELDS' => array("ID"), 'SELECT' => $arSelectParams));
             while ($arUser = $dbUsers->GetNext(true, false)) {
                 $arUserPhone[$arUser['ID']] = $arUser['UF_VI_PHONE'] == 'Y';
                 $arUserDepartment[$arUser['ID']] = self::IsExtranet($arUser);
             }
             foreach ($arRecent as $key => $value) {
                 if (isset($value['USER'])) {
                     $arRecent[$key]['USER']['extranet'] = $arUserDepartment[$value['USER']['id']];
                     $arRecent[$key]['USER']['phoneDevice'] = $arUserPhone[$value['USER']['id']];
                 }
             }
         }
         if ($obCache->StartDataCache()) {
             $obCache->EndDataCache(array('recent' => $arRecent, 'users' => $arUsers));
         }
     }
     $arOnline = CIMStatus::GetList(array('ID' => array_values($arUsers), 'GET_OFFLINE' => 'Y'));
     foreach ($arRecent as $key => $value) {
         if ($value['TYPE'] != IM_MESSAGE_PRIVATE) {
             continue;
         }
         $arRecent[$key]['USER']['birthday'] = $bIntranetEnable ? CIntranetUtils::IsToday($value['USER']['birthday']) : false;
         $arRecent[$key]['USER']['status'] = isset($arOnline['users'][$value['USER']['id']]) ? $arOnline['users'][$value['USER']['id']]['status'] : 'offline';
         $arRecent[$key]['USER']['idle'] = isset($arOnline['users'][$value['USER']['id']]) ? $arOnline['users'][$value['USER']['id']]['idle'] : 0;
         $arRecent[$key]['USER']['mobileLastDate'] = isset($arOnline['users'][$value['USER']['id']]) ? $arOnline['users'][$value['USER']['id']]['mobileLastDate'] : 0;
         if ($arOnline['users'][$value['USER']['id']]['color']) {
             $arRecent[$key]['USER']['color'] = $arOnline['users'][$value['USER']['id']]['color'];
         }
     }
     if ($bLoadUnreadMessage) {
         $CIMMessage = new CIMMessage(false, array('HIDE_LINK' => 'Y'));
         $ar = $CIMMessage->GetUnreadMessage(array('LOAD_DEPARTMENT' => 'N', 'ORDER' => 'ASC', 'GROUP_BY_CHAT' => 'Y', 'USE_TIME_ZONE' => $bTimeZone ? 'Y' : 'N', 'USE_SMILES' => $bSmiles ? 'Y' : 'N'));
         foreach ($ar['message'] as $data) {
             if (!isset($arRecent[$data['senderId']])) {
                 $arRecent[$data['senderId']] = array('TYPE' => IM_MESSAGE_PRIVATE, 'USER' => $ar['users'][$data['senderId']]);
             }
             $arRecent[$data['senderId']]['MESSAGE'] = array('id' => $data['id'], 'senderId' => $data['senderId'], 'date' => $data['date'], 'text' => preg_replace('#\\-{54}.+?\\-{54}#s', " [" . GetMessage('IM_QUOTE') . "] ", strip_tags(str_replace(array("<br>", "<br/>", "<br />", "#BR#"), array(" ", " ", " ", " "), $data['text']), "<img>")));
             $arRecent[$data['senderId']]['COUNTER'] = $data['counter'];
         }
         $CIMChat = new CIMChat(false, array('HIDE_LINK' => 'Y'));
         $ar = $CIMChat->GetUnreadMessage(array('ORDER' => 'ASC', 'GROUP_BY_CHAT' => 'Y', 'USER_LOAD' => 'N', 'FILE_LOAD' => 'N', 'USE_SMILES' => $bSmiles ? 'Y' : 'N', 'USE_TIME_ZONE' => $bTimeZone ? 'Y' : 'N'));
         foreach ($ar['message'] as $data) {
             if (!isset($arRecent['chat' . $data['recipientId']])) {
                 $arRecent['chat' . $data['recipientId']] = array('TYPE' => $ar['messageType'] ? $ar['messageType'] : IM_MESSAGE_CHAT, 'CHAT' => $ar['chat']);
             }
             $arRecent['chat' . $data['recipientId']]['MESSAGE'] = array('id' => $data['id'], 'senderId' => $data['senderId'], 'date' => $data['date'], 'text' => $data['text']);
             $arRecent['chat' . $data['recipientId']]['COUNTER'] = $data['counter'];
         }
     }
     if (!empty($arRecent)) {
         sortByColumn($arRecent, array('COUNTER' => array(SORT_NUMERIC, SORT_DESC), 'MESSAGE' => array(SORT_NUMERIC, SORT_DESC)), array('COUNTER' => array(__CLASS__, 'GetRecentListSortCounter'), 'MESSAGE' => array(__CLASS__, 'GetRecentListSortMessage')), null, true);
     }
     return $arRecent;
 }
コード例 #4
0
ファイル: im.ajax.php プロジェクト: k-kalashnikov/geekcon_new
 if ($arMessage['result']) {
     CIMMessage::GetFlashMessage($arMessage['unreadMessage']);
     $readMessageUserId = $_POST['TAB'];
     if ($bOpenMessenger && intval($readMessageUserId) > 0) {
         CIMMessenger::SetCurrentTab($readMessageUserId);
     }
     $arSend['MESSAGE'] = $arMessage['message'];
     $arSend['UNREAD_MESSAGE'] = CIMMessenger::CheckXmppStatusOnline() ? array() : $arMessage['unreadMessage'];
     $arSend['USERS_MESSAGE'] = $arMessage['usersMessage'];
     $arSend['USERS'] = $arMessage['users'];
     $arSend['USER_IN_GROUP'] = $arMessage['userInGroup'];
     $arSend['WO_USER_IN_GROUP'] = $arMessage['woUserInGroup'];
     $arSend['ERROR'] = '';
 }
 $CIMChat = new CIMChat();
 $arMessage = $CIMChat->GetUnreadMessage(array('USE_TIME_ZONE' => 'N', 'ORDER' => 'ASC'));
 if ($arMessage['result']) {
     CIMMessage::GetFlashMessage($arMessage['unreadMessage']);
     $readMessageUserId = $_POST['TAB'];
     if ($bOpenMessenger && intval($readMessageUserId) > 0) {
         CIMMessenger::SetCurrentTab($readMessageUserId);
     }
     foreach ($arMessage['message'] as $id => $ar) {
         $ar['recipientId'] = 'chat' . $ar['recipientId'];
         $arSend['MESSAGE'][$id] = $ar;
     }
     foreach ($arMessage['usersMessage'] as $chatId => $ar) {
         $arSend['USERS_MESSAGE']['chat' . $chatId] = $ar;
     }
     if (!CIMMessenger::CheckXmppStatusOnline()) {
         foreach ($arMessage['unreadMessage'] as $chatId => $ar) {
コード例 #5
0
				'GROUP_BY_CHAT' => 'Y',
			));
			$arResult['COUNTER_MESSAGES'] = count($arMessage['message']);

			$arUnread = Array();
			foreach ($arMessage['message'] as $data)
			{
				$arUnread[$data['senderId']]['MESSAGE'] = $data;
				$arUnread[$data['senderId']]['USER'] = $arMessage['users'][$data['senderId']];
			}

			$CIMChat = new CIMChat();
			$arMessage = $CIMChat->GetUnreadMessage(Array(
				'SPEED_CHECK' => 'N',
				'LOAD_DEPARTMENT' => 'N',
				'ORDER' => 'ASC',
				'GROUP_BY_CHAT' => 'Y',
				'FILE_LOAD' => 'N',
				'USER_LOAD' => 'N',
			));

			$arResult['COUNTER_MESSAGES'] += count($arMessage['message']);

			foreach ($arMessage['message'] as $data)
			{
				$arUnread['chat'.$data['recipientId']]['MESSAGE'] = $data;
				$arUnread['chat'.$data['recipientId']]['CHAT'] = $arMessage['chat'][$data['recipientId']];
			}

			uasort($arUnread, create_function('$a, $b', 'if($a["MESSAGE"]["date"] < $b["MESSAGE"]["date"] ) return 1; elseif($a["MESSAGE"]["date"]  > $b["MESSAGE"]["date"] ) return -1; else return 0;'));
			$arResult['COUNTER_UNREAD_MESSAGES'] = $arUnread;
		}