本文整理汇总了PHP中CPullStack类的典型用法代码示例。如果您正苦于以下问题:PHP CPullStack类的具体用法?PHP CPullStack怎么用?PHP CPullStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPullStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterUpdateTrigger
/**
* Method will be invoked after an database record updated.
*
* @param array $oldRecord All fields before update.
* @param array $newRecord All fields after update.
*
* @return void
*/
public static function afterUpdateTrigger(array $oldRecord, array $newRecord)
{
if ($oldRecord['TITLE'] !== $newRecord['TITLE']) {
if (\CModule::IncludeModule("pull")) {
$ar = \CIMChat::GetRelationById($newRecord['CHAT_ID']);
foreach ($ar as $rel) {
\CIMContactList::CleanChatCache($rel['USER_ID']);
\CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'chatRename', 'params' => array('chatId' => $newRecord['CHAT_ID'], 'chatTitle' => htmlspecialcharsbx($newRecord['TITLE']))));
}
}
}
if ($oldRecord['AVATAR'] !== $newRecord['AVATAR']) {
if (\CModule::IncludeModule('pull')) {
$avatarImage = \CIMChat::GetAvatarImage($newRecord['AVATAR']);
$ar = \CIMChat::GetRelationById($newRecord['CHAT_ID']);
foreach ($ar as $relation) {
\CIMContactList::CleanChatCache($relation['USER_ID']);
\CPullStack::AddByUser($relation['USER_ID'], array('module_id' => 'im', 'command' => 'chatAvatar', 'params' => array('chatId' => $newRecord['CHAT_ID'], 'chatAvatar' => $avatarImage)));
}
}
}
if ($oldRecord['COLOR'] !== $newRecord['COLOR']) {
if (\CModule::IncludeModule('pull')) {
$ar = \CIMChat::GetRelationById($newRecord['CHAT_ID']);
foreach ($ar as $relation) {
\CIMContactList::CleanChatCache($relation['USER_ID']);
\CPullStack::AddByUser($relation['USER_ID'], array('module_id' => 'im', 'command' => 'chatChangeColor', 'params' => array('chatId' => $newRecord['CHAT_ID'], 'chatColor' => \Bitrix\Im\Color::getColor($newRecord['COLOR']))));
}
}
}
}
示例2: onExecuteStartWriting
function onExecuteStartWriting(\Bitrix\Main\Event $event)
{
$parameters = $event->getParameters();
$userId = $parameters[0];
$dialogId = $parameters[1] . $parameters[2];
if ($userId > 0) {
if (!\Bitrix\Main\Loader::includeModule('pull')) {
return;
}
\CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS');
if (intval($dialogId) > 0) {
\CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
} elseif (substr($dialogId, 0, 4) == 'chat') {
$chatId = substr($dialogId, 4);
$arRelation = \CIMChat::GetRelationById($chatId);
unset($arRelation[$userId]);
$pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId));
\CPullStack::AddByUsers(array_keys($arRelation), $pullMessage);
$orm = \Bitrix\Im\ChatTable::getById($chatId);
$chat = $orm->fetch();
if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
\CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage);
}
}
}
}
示例3: Set
public static function Set($userId, $params)
{
$userId = intval($userId);
if ($userId <= 0) {
return false;
}
if (isset($params['STATUS'])) {
$params['IDLE'] = null;
}
$needToUpdate = false;
$params = self::PrepereFields($params);
$res = IM\StatusTable::getById($userId);
if ($status = $res->fetch()) {
foreach ($params as $key => $value) {
$oldValue = is_object($status[$key]) ? $status[$key]->toString() : $status[$key];
$newValue = is_object($value) ? $value->toString() : $value;
if ($oldValue != $newValue) {
$status[$key] = $value;
$needToUpdate = true;
}
}
if ($needToUpdate) {
IM\StatusTable::update($userId, $params);
}
} else {
$params['USER_ID'] = $userId;
IM\StatusTable::add($params);
$needToUpdate = true;
$status = $params;
}
if ($needToUpdate && self::Enable()) {
CPullStack::AddShared(array('module_id' => 'online', 'command' => 'user_status', 'params' => self::PrepereToPush($status)));
}
return true;
}
示例4: afterUpdateTrigger
/**
* Method will be invoked after an database record updated.
*
* @param array $oldRecord All fields before update.
* @param array $newRecord All fields after update.
*
* @return void
*/
public function afterUpdateTrigger(array $oldRecord, array $newRecord)
{
if ($oldRecord["STATUS"] !== $newRecord["STATUS"]) {
if (\CIMStatus::Enable()) {
\CPullStack::AddShared(array('module_id' => 'online', 'command' => 'user_status', 'expiry' => 120, 'params' => array("USER_ID" => $newRecord["USER_ID"], "STATUS" => $newRecord["STATUS"])));
}
}
}
示例5: Delete
public static function Delete($channelId)
{
global $DB;
$arMessage = array('module_id' => 'pull', 'command' => 'channel_die', 'params' => '');
CPullStack::AddByChannel($channelId, $arMessage);
$strSql = "DELETE FROM b_pull_channel WHERE CHANNEL_ID = '" . $DB->ForSQL($channelId) . "'";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
return true;
}
示例6: AddToStack
public static function AddToStack($tag, $arMessage)
{
global $DB;
$result = false;
$strSql = "SELECT CHANNEL_ID FROM b_pull_watch WHERE TAG = '" . $DB->ForSQL($tag) . "'";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
$result = CPullStack::AddByChannel($arRes['CHANNEL_ID'], $arMessage);
if (!$result) {
break;
}
}
return !$result ? false : true;
}
示例7: afterInsertTrigger
/**
* Method will be invoked after new database record inserted.
*
* @param array $newRecord All fields of inserted record.
*
* @return void
*/
public function afterInsertTrigger(array $newRecord)
{
$id = intval($newRecord['MESSAGE_ID']);
if (!\Bitrix\Main\Loader::includeModule('pull')) {
return;
}
$message = \CIMMessenger::GetById($id, array('WITH_FILES' => 'Y'));
if (!$message) {
return;
}
if ($newRecord['PARAM_NAME'] === 'LIKE' && $newRecord["PARAM_VALUE"]) {
$like = $message['PARAMS']['LIKE'];
$result = \Bitrix\IM\ChatTable::getList(array('filter' => array('=ID' => $message['CHAT_ID'])));
$chat = $result->fetch();
$relations = \CIMMessenger::GetRelationById($id);
if (!isset($relations[$newRecord["PARAM_VALUE"]])) {
return;
}
if ($message['AUTHOR_ID'] > 0 && $message['AUTHOR_ID'] != $newRecord["PARAM_VALUE"]) {
$CCTP = new \CTextParser();
$CCTP->MaxStringLen = 200;
$CCTP->allow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
$message['MESSAGE'] = str_replace('<br />', ' ', $CCTP->convertText($message['MESSAGE']));
$message['MESSAGE'] = preg_replace("/\\[s\\].*?\\[\\/s\\]/i", "", $message['MESSAGE']);
$message['MESSAGE'] = preg_replace("/\\[[bui]\\](.*?)\\[\\/[bui]\\]/i", "\$1", $message['MESSAGE']);
$message['MESSAGE'] = preg_replace("/\\[USER=([0-9]{1,})\\](.*?)\\[\\/USER\\]/i", "\$2", $message['MESSAGE']);
$message['MESSAGE'] = preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [" . GetMessage('IM_QUOTE') . "] ", str_replace(array("#BR#"), array(" "), $message['MESSAGE']));
if (count($message['FILES']) > 0 && strlen($message['MESSAGE']) < 200) {
foreach ($message['FILES'] as $file) {
$file = " [" . GetMessage('IM_MESSAGE_FILE') . ": " . $file['name'] . "]";
if (strlen($message['MESSAGE'] . $file) > 200) {
break;
}
$message['MESSAGE'] .= $file;
}
$message['MESSAGE'] = trim($message['MESSAGE']);
}
$isChat = $chat && strlen($chat['TITLE']) > 0;
$dot = strlen($message['MESSAGE']) >= 200 ? '...' : '';
$message['MESSAGE'] = substr($message['MESSAGE'], 0, 199) . $dot;
$message['MESSAGE'] = strlen($message['MESSAGE']) > 0 ? $message['MESSAGE'] : '-';
$arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $message['AUTHOR_ID'], "FROM_USER_ID" => $newRecord["PARAM_VALUE"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote", "NOTIFY_TAG" => "RATING|IM|" . ($isChat ? 'G' : 'P') . "|" . ($isChat ? $chat['ID'] : $newRecord["PARAM_VALUE"]) . "|" . $id, "NOTIFY_MESSAGE" => GetMessage($isChat ? 'IM_MESSAGE_LIKE' : 'IM_MESSAGE_LIKE_PRIVATE', array('#MESSAGE#' => $message['MESSAGE'], '#TITLE#' => $chat['TITLE'])));
\CIMNotify::Add($arMessageFields);
}
$arPullMessage = array('id' => $id, 'chatId' => $relations[$newRecord["PARAM_VALUE"]]['CHAT_ID'], 'senderId' => $newRecord["PARAM_VALUE"], 'users' => $like);
foreach ($relations as $rel) {
\CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage));
}
}
}
示例8: afterUpdateTrigger
/**
* Method will be invoked after an database record updated.
*
* @param array $oldRecord All fields before update.
* @param array $newRecord All fields after update.
*
* @return void
*/
public function afterUpdateTrigger(array $oldRecord, array $newRecord)
{
if ($newRecord["MESSAGE_TYPE"] === "P" && intval($oldRecord["LAST_ID"]) < intval($newRecord["LAST_ID"])) {
$oldLastRead = $oldRecord["LAST_READ"] instanceof \Bitrix\Main\Type\DateTime ? $oldRecord["LAST_READ"]->getTimestamp() : 0;
$newLastRead = $newRecord["LAST_READ"] instanceof \Bitrix\Main\Type\DateTime ? $newRecord["LAST_READ"]->getTimestamp() : 0;
if ($oldLastRead < $newLastRead) {
if (\Bitrix\Main\Loader::includeModule('pull')) {
$relationList = \Bitrix\IM\RelationTable::getList(array("select" => array("ID", "USER_ID"), "filter" => array("=CHAT_ID" => $newRecord["CHAT_ID"], "!=USER_ID" => $newRecord["USER_ID"])));
if ($relation = $relationList->fetch()) {
\CPullStack::AddByUser($relation['USER_ID'], array('module_id' => 'im', 'command' => 'readMessageApponent', 'params' => array('chatId' => intval($newRecord['CHAT_ID']), 'userId' => intval($newRecord['USER_ID']), 'lastId' => $newRecord['LAST_ID'], 'date' => $newLastRead, 'count' => 1)));
}
}
}
}
}
示例9: SendPullEvent
public static function SendPullEvent($params)
{
// TODO check params
if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) {
return false;
}
$config = array();
if ($params['COMMAND'] == 'outgoing') {
$config = array("callId" => $params['CALL_ID'], "callIdTmp" => $params['CALL_ID_TMP'] ? $params['CALL_ID_TMP'] : '', "callDevice" => $params['CALL_DEVICE'] == 'PHONE' ? 'PHONE' : 'WEBRTC', "phoneNumber" => $params['PHONE_NUMBER'], "external" => $params['EXTERNAL'] ? true : false, "CRM" => $params['CRM'] ? $params['CRM'] : array());
} else {
if ($params['COMMAND'] == 'timeout') {
$config = array("callId" => $params['CALL_ID'], "failedCode" => intval($params['FAILED_CODE']));
}
}
CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config));
return true;
}
示例10: onExecuteStartWriting
function onExecuteStartWriting(\Bitrix\Main\Event $event)
{
$parameters = $event->getParameters();
$userId = $parameters[0];
$dialogId = $parameters[1] . $parameters[2];
if ($userId > 0) {
if (!\Bitrix\Main\Loader::includeModule('pull')) {
return;
}
\CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS');
if (intval($dialogId) > 0) {
\CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
} elseif (substr($dialogId, 0, 4) == 'chat') {
$arRelation = \CIMChat::GetRelationById(substr($dialogId, 4));
foreach ($arRelation as $rel) {
if ($rel['USER_ID'] == $userId) {
continue;
}
\CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
}
}
}
}
示例11: Edit
//.........这里部分代码省略.........
$offset = CCalendar::GetOffset();
$arFields['LOCATION'] = CCalendar::SetLocation($arFields['LOCATION']['OLD'], $arFields['LOCATION']['NEW'], array('dateFrom' => CCalendar::Date($arFields['DT_FROM_TS'] + $offset), 'dateTo' => CCalendar::Date($arFields['DT_TO_TS'] + $offset), 'name' => $arFields['NAME'], 'persons' => count($attendees), 'attendees' => $attendees, 'bRecreateReserveMeetings' => $arFields['LOCATION']['RE_RESERVE'] !== 'N'));
$bSendInvitations = false;
if (!isset($arFields['IS_MEETING']) && isset($arFields['ATTENDEES']) && is_array($arFields['ATTENDEES']) && empty($arFields['ATTENDEES'])) {
$arFields['IS_MEETING'] = false;
}
$attendeesCodes = array();
if ($arFields['IS_MEETING'] && is_array($arFields['MEETING'])) {
if (!empty($arFields['ATTENDEES_CODES'])) {
$attendeesCodes = $arFields['ATTENDEES_CODES'];
$arFields['ATTENDEES_CODES'] = implode(',', $arFields['ATTENDEES_CODES']);
}
// Organizer
$bSendInvitations = $Params['bSendInvitations'] !== false;
$arFields['~MEETING'] = array('HOST_NAME' => $arFields['MEETING']['HOST_NAME'], 'TEXT' => $arFields['MEETING']['TEXT'], 'OPEN' => $arFields['MEETING']['OPEN'], 'NOTIFY' => $arFields['MEETING']['NOTIFY'], 'REINVITE' => $arFields['MEETING']['REINVITE']);
$arFields['MEETING'] = serialize($arFields['~MEETING']);
}
$arReminders = array();
if ($arFields['REMIND'] && is_array($arFields['REMIND'])) {
foreach ($arFields['REMIND'] as $remind) {
if (in_array($remind['type'], array('min', 'hour', 'day'))) {
$arReminders[] = array('type' => $remind['type'], 'count' => floatVal($remind['count']));
}
}
}
$arFields['REMIND'] = count($arReminders) > 0 ? serialize($arReminders) : '';
$AllFields = self::GetFields();
$dbFields = array();
foreach ($arFields as $field => $val) {
if (isset($AllFields[$field]) && $field != "ID") {
$dbFields[$field] = $arFields[$field];
}
}
CTimeZone::Disable();
if ($bNew) {
$ID = CDatabase::Add("b_calendar_event", $dbFields, array('DESCRIPTION', 'MEETING', 'RDATE', 'EXDATE'));
} else {
$ID = $arFields['ID'];
$strUpdate = $DB->PrepareUpdate("b_calendar_event", $dbFields);
$strSql = "UPDATE b_calendar_event SET " . $strUpdate . " WHERE ID=" . IntVal($arFields['ID']);
$DB->QueryBind($strSql, array('DESCRIPTION' => $arFields['DESCRIPTION'], 'MEETING' => $arFields['MEETING'], 'RDATE' => $arFields['RDATE'], 'EXDATE' => $arFields['EXDATE']));
}
CTimeZone::Enable();
if ($bNew && !isset($dbFields['DAV_XML_ID'])) {
$strSql = "UPDATE b_calendar_event SET " . $DB->PrepareUpdate("b_calendar_event", array('DAV_XML_ID' => $ID)) . " WHERE ID=" . IntVal($ID);
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
// Clean links
// Del link from table
if (!$bNew) {
$arAffectedSections = CCalendarEvent::GetCurrentSectionIds($ID);
$DB->Query("DELETE FROM b_calendar_event_sect WHERE EVENT_ID=" . IntVal($ID), false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
} else {
$arAffectedSections = array();
}
$strSections = "0";
foreach ($arFields['SECTIONS'] as $sect) {
if (IntVal($sect) > 0) {
$strSections .= "," . IntVal($sect);
$arAffectedSections[] = IntVal($sect);
}
}
if (count($arAffectedSections) > 0) {
CCalendarSect::UpdateModificationLabel($arAffectedSections);
}
// We don't have any section for this event
// and we have to create default one.
if ($strSections == "0") {
$defCalendar = CCalendarSect::CreateDefault(array('type' => CCalendar::GetType(), 'ownerId' => CCalendar::GetOwnerId()));
$strSections .= "," . IntVal($defCalendar['ID']);
}
// Add links
$strSql = "INSERT INTO b_calendar_event_sect(EVENT_ID, SECT_ID) " . "SELECT " . intVal($ID) . ", ID " . "FROM b_calendar_section " . "WHERE ID in (" . $strSections . ")";
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
$bPull = CModule::IncludeModule("pull");
if ($arFields['IS_MEETING']) {
if (isset($arFields['ATTENDEES'])) {
self::InviteAttendees($ID, $arFields, $arFields['ATTENDEES'], is_array($Params['attendeesStatuses']) ? $Params['attendeesStatuses'] : array(), $bSendInvitations, $userId);
if ($bPull) {
// TODO: CACHE IT!
$attendees = self::GetAttendees($ID);
$attendees = $attendees[$ID];
foreach ($attendees as $user) {
CPullStack::AddByUser($user['USER_ID'], array('module_id' => 'calendar', 'command' => 'event_update', 'params' => array('EVENT' => CCalendarEvent::OnPullPrepareArFields($arFields), 'ATTENDEES' => $attendees, 'NEW' => $bNew ? 'Y' : 'N')));
}
}
}
} else {
if ($bPull) {
CPullStack::AddByUser($userId, array('module_id' => 'calendar', 'command' => 'event_update', 'params' => array('EVENT' => CCalendarEvent::OnPullPrepareArFields($arFields), 'ATTENDEES' => array(), 'NEW' => $bNew ? 'Y' : 'N')));
}
}
// Clean old reminders and add new reminders
self::UpdateReminders(array('id' => $ID, 'reminders' => $arReminders, 'arFields' => $arFields, 'userId' => $userId, 'path' => $path, 'bNew' => $bNew));
if ($arFields['CAL_TYPE'] == 'user' && $arFields['IS_MEETING'] && !empty($attendeesCodes)) {
CCalendarLiveFeed::OnEditCalendarEventEntry($ID, $arFields, $attendeesCodes);
}
CCalendar::ClearCache('event_list');
return $ID;
}
示例12: SendConfigDie
public static function SendConfigDie()
{
$arMessage = array('module_id' => 'pull', 'command' => 'config_die', 'params' => '');
CPullStack::AddBroadcast($arMessage);
}
示例13: Confirm
public function Confirm($ID, $VALUE)
{
global $DB;
$ID = intval($ID);
$strSql = "SELECT M.* FROM b_im_relation R, b_im_message M WHERE M.ID = ".$ID." AND R.USER_ID = ".$this->user_id." AND R.MESSAGE_TYPE = '".IM_MESSAGE_SYSTEM."' AND R.CHAT_ID = M.CHAT_ID AND M.NOTIFY_TYPE = ".IM_NOTIFY_CONFIRM;
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
{
$arRes['RELATION_USER_ID'] = $this->user_id;
if (strlen($arRes['NOTIFY_TAG'])>0)
{
foreach(GetModuleEvents("im", "OnBeforeConfirmNotify", true) as $arEvent)
if (ExecuteModuleEventEx($arEvent, Array($arRes['NOTIFY_MODULE'], $arRes['NOTIFY_TAG'], $VALUE, $arRes))===false)
return false;
}
$strSql = "DELETE FROM b_im_message WHERE ID = ".$ID;
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
//CUserCounter::Decrement($this->user_id, 'im_notify', '**', false);
if (strlen($arRes['NOTIFY_TAG'])>0)
{
foreach(GetModuleEvents("im", "OnAfterConfirmNotify", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array($arRes['NOTIFY_MODULE'], $arRes['NOTIFY_TAG'], $VALUE, $arRes));
}
if (CModule::IncludeModule("pull"))
{
CPullStack::AddByUser($this->user_id, Array(
'module_id' => 'im',
'command' => 'confirmNotify',
'params' => Array(
'chatId' => intval($arRes['CHAT_ID']),
'id' => $ID
),
));
//CIMMessenger::SendBadges($this->user_id);
}
CIMMessenger::SpeedFileDelete($this->user_id, IM_SPEED_NOTIFY);
return true;
}
return false;
}
示例14: Command
public static function Command($chatId, $recipientId, $command, $params = Array())
{
if (!CModule::IncludeModule("pull"))
return false;
$chatId = intval($chatId);
$recipientId = intval($recipientId);
if ($recipientId <= 0 || $chatId <= 0 || empty($command) || !is_array($params))
return false;
global $USER;
$params['senderId'] = $USER->GetID();
$params['chatId'] = $chatId;
$params['command'] = $command;
CPullStack::AddByUser($recipientId, Array(
'module_id' => 'im',
'command' => 'call',
'params' => $params,
));
return true;
}
示例15: SetReadMessage
public function SetReadMessage($fromUserId, $lastId = null)
{
global $DB;
$fromUserId = intval($fromUserId);
if ($fromUserId <= 0) {
return false;
}
$bReadMessage = false;
if ($lastId == null) {
$strSql = "\n\t\t\t\tSELECT MAX(M.ID) ID, M.CHAT_ID\n\t\t\t\tFROM b_im_relation RF\n\t\t\t\t\tINNER JOIN b_im_relation RT on RF.CHAT_ID = RT.CHAT_ID\n\t\t\t\t\tINNER JOIN b_im_message M ON M.ID >= RT.LAST_ID AND M.CHAT_ID = RT.CHAT_ID\n\t\t\t\tWHERE RT.USER_ID = " . $this->user_id . "\n\t\t\t\t\tand RF.USER_ID = " . $fromUserId . "\n\t\t\t\t\tand RT.MESSAGE_TYPE = '" . IM_MESSAGE_PRIVATE . "' and RT.STATUS < " . IM_STATUS_READ . "\n\t\t\t\tGROUP BY M.CHAT_ID";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
$bReadMessage = self::SetLastId(intval($arRes['CHAT_ID']), $this->user_id, $arRes['ID']);
}
$lastId = $arRes['ID'];
} else {
$strSql = "\n\t\t\t\tSELECT RF.CHAT_ID\n\t\t\t\tFROM b_im_relation RF INNER JOIN b_im_relation RT on RF.CHAT_ID = RT.CHAT_ID\n\t\t\t\tWHERE RT.USER_ID = " . $this->user_id . "\n\t\t\t\t\tand RF.USER_ID = " . $fromUserId . "\n\t\t\t\t\tand RT.MESSAGE_TYPE = '" . IM_MESSAGE_PRIVATE . "'";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
$bReadMessage = self::SetLastId(intval($arRes['CHAT_ID']), $this->user_id, intval($lastId));
}
}
if ($bReadMessage) {
CIMMessenger::SpeedFileDelete($this->user_id, IM_SPEED_MESSAGE);
if (CModule::IncludeModule("pull")) {
CPushManager::DeleteFromQueue($this->user_id, 'IM_MESS_' . $fromUserId);
CPullStack::AddByUser($this->user_id, array('module_id' => 'im', 'command' => 'readMessage', 'params' => array('chatId' => intval($arRes['CHAT_ID']), 'senderId' => $this->user_id, 'id' => $fromUserId, 'userId' => $fromUserId, 'lastId' => $lastId)));
}
return true;
}
return false;
}