- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_messenger.php
- Класс: CIMMessenger
- Вызов: CIMMessenger::StartWriting
static function StartWriting($dialogId, $userId = false, $userName = "", $byEvent = false, $linesSilentMode = false)
{
$userId = intval($userId);
if ($userId <= 0)
{
global $USER;
$userId = intval($USER->GetID());
}
if (mb_substr($dialogId, 0, 4) == 'chat')
{
}
else if ($dialogId == $userId)
{
return false;
}
else
{
$dialogId = intval($dialogId);
}
if (!$userName)
{
$userName = BitrixImUser::getInstance($userId)->getFullName();
}
if ($userId > 0 && $dialogId <> '' && CModule::IncludeModule("pull"))
{
$chat = Array();
$relation = Array();
if (mb_substr($dialogId, 0, 4) == 'chat')
{
$orm = BitrixImModelChatTable::getById(mb_substr($dialogId, 4));
$chat = $orm->fetch();
$arRelation = CIMChat::GetRelationById(mb_substr($dialogId, 4), false, true, false);
$relation = $arRelation;
if ($chat['ENTITY_TYPE'] != 'LIVECHAT' && !isset($arRelation[$userId]))
{
return false;
}
unset($arRelation[$userId]);
$pullMessage = Array(
'module_id' => 'im',
'command' => 'startWriting',
'expiry' => 60,
'params' => Array(
'dialogId' => $dialogId,
'userId' => $userId,
'userName' => $userName
),
'extra' => BitrixImCommon::getPullExtra()
);
$chatId = $chat['ID'];
$entityType = $chat['ENTITY_TYPE'];
$entityId = $chat['ENTITY_ID'];
if ($chat['ENTITY_TYPE'] == 'LINES')
{
foreach ($arRelation as $rel)
{
if ($rel["EXTERNAL_AUTH_ID"] == 'imconnector')
{
unset($arRelation[$rel["USER_ID"]]);
}
}
}
BitrixPullEvent::add(array_keys($arRelation), $pullMessage);
if ($chat['TYPE'] == IM_MESSAGE_OPEN || $chat['TYPE'] == IM_MESSAGE_OPEN_LINE)
{
CPullWatch::AddToStack('IM_PUBLIC_'.$chatId, $pullMessage);
}
}
else if (intval($dialogId) > 0)
{
BitrixPullEvent::add($dialogId, Array(
'module_id' => 'im',
'command' => 'startWriting',
'expiry' => 60,
'params' => Array(
'dialogId' => $userId,
'userId' => $userId,
'userName' => $userName
),
'extra' => BitrixImCommon::getPullExtra()
));
}
foreach(GetModuleEvents("im", "OnStartWriting", true) as $arEvent)
{
ExecuteModuleEventEx($arEvent, array(array(
'DIALOG_ID' => $dialogId,
'CHAT' => $chat,
'RELATION' => $relation,
'USER_ID' => $userId,
'USER_NAME' => $userName,
'BY_EVENT' => $byEvent,
'LINES_SILENT_MODE' => $linesSilentMode
)));
}
return true;
}
return false;
}