本文整理汇总了PHP中CPullOptions::GetPushStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP CPullOptions::GetPushStatus方法的具体用法?PHP CPullOptions::GetPushStatus怎么用?PHP CPullOptions::GetPushStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPullOptions
的用法示例。
在下文中一共展示了CPullOptions::GetPushStatus方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SendBadges
public static function SendBadges($userID)
{
return false;
if (!(CModule::IncludeModule('pull') && CPullOptions::GetPushStatus()))
return false;
$arPush = Array();
if (!is_array($userID))
$userID = Array(intval($userID));
global $DB;
if (empty($userID))
return false;
foreach ($userID as $key => $userId)
$userID[$key] = intval($userId);
$CPushManager = new CPushManager();
$sql = "SELECT SUM(CNT) CNT, USER_ID
FROM b_user_counter
WHERE USER_ID IN (".implode(',', $userID).") and SITE_ID = '**' and CODE IN ('im_notify_v2', 'im_message_v2', 'im_chat_v2')
GROUP BY USER_ID";
$res = $DB->Query($sql);
while($row = $res->Fetch())
{
$CPushManager->AddQueue(Array('USER_ID' => $row['USER_ID'], 'BADGE' => $row['CNT'], 'SEND_IMMEDIATELY' => 'Y'));
}
return true;
}
示例2: SendAgent
public static function SendAgent()
{
global $DB;
if (!CPullOptions::GetPushStatus()) {
return false;
}
$count = 0;
$maxId = 0;
$pushLimit = 70;
$arPush = array();
$sqlDate = "";
$dbType = strtolower($DB->type);
if ($dbType == "mysql") {
$sqlDate = " WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 15 SECOND) ";
} else {
if ($dbType == "mssql") {
$sqlDate = " WHERE DATE_CREATE < dateadd(SECOND, -15, getdate()) ";
} else {
if ($dbType == "oracle") {
$sqlDate = " WHERE DATE_CREATE < SYSDATE-(1/24/60/60*15) ";
}
}
}
$strSql = $DB->TopSql("SELECT ID, USER_ID, MESSAGE, PARAMS, BADGE, APP_ID FROM b_pull_push_queue" . $sqlDate, 280);
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
if ($arRes['BADGE'] == '') {
unset($arRes['BADGE']);
}
$arPush[$count][] = $arRes;
if ($pushLimit <= count($arPush[$count])) {
$count++;
}
$maxId = $maxId < $arRes['ID'] ? $arRes['ID'] : $maxId;
}
if ($maxId > 0) {
$strSql = "DELETE FROM b_pull_push_queue WHERE ID <= " . $maxId;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
$CPushManager = new CPushManager();
foreach ($arPush as $arStack) {
$CPushManager->SendMessage($arStack);
}
$strSql = "SELECT COUNT(ID) CNT FROM b_pull_push_queue";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
global $pPERIOD;
if ($arRes['CNT'] > 280) {
$pPERIOD = 10;
return "CPushManager::SendAgent();";
} else {
if ($arRes['CNT'] > 0) {
$pPERIOD = 30;
return "CPushManager::SendAgent();";
}
}
}
return false;
}
示例3: 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)
{
$arParams = array();
$chatId = $newRecord['CHAT_ID'];
$arRel = \CIMChat::GetRelationById($chatId);
$arFields['MESSAGE_TYPE'] = '';
foreach ($arRel as $rel) {
$arFields['MESSAGE_TYPE'] = $rel["MESSAGE_TYPE"];
break;
}
$arFields['PARAMS'] = array();
$arFields['FILES'] = array();
//CUserCounter::Increment($arFields['TO_USER_ID'], 'im_message_v2', '**', false);
if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE) {
foreach ($arRel as $rel) {
if ($rel['USER_ID'] == $newRecord['AUTHOR_ID']) {
$arFields['FROM_USER_ID'] = $rel['USER_ID'];
} else {
$arFields['TO_USER_ID'] = $rel['USER_ID'];
}
}
\CIMContactList::SetRecent(array('ENTITY_ID' => $arFields['TO_USER_ID'], 'MESSAGE_ID' => $newRecord['ID'], 'CHAT_TYPE' => IM_MESSAGE_PRIVATE, 'USER_ID' => $arFields['FROM_USER_ID']));
\CIMContactList::SetRecent(array('ENTITY_ID' => $arFields['FROM_USER_ID'], 'MESSAGE_ID' => $newRecord['ID'], 'CHAT_TYPE' => IM_MESSAGE_PRIVATE, 'USER_ID' => $arFields['TO_USER_ID']));
if (\CModule::IncludeModule('pull')) {
$pullMessage = array('module_id' => 'im', 'command' => 'message', 'params' => \CIMMessage::GetFormatMessage(array('ID' => $newRecord['ID'], 'CHAT_ID' => $chatId, 'TO_USER_ID' => $arFields['TO_USER_ID'], 'FROM_USER_ID' => $arFields['FROM_USER_ID'], 'SYSTEM' => $newRecord['NOTIFY_EVENT'] == 'private_system' ? 'Y' : 'N', 'MESSAGE' => $newRecord['MESSAGE'], 'DATE_CREATE' => time(), 'PARAMS' => $arFields['PARAMS'], 'FILES' => $arFields['FILES'])));
$pullMessageTo = $pullMessage;
if (\CPullOptions::GetPushStatus()) {
if (\CIMSettings::GetNotifyAccess($arFields["TO_USER_ID"], 'im', 'message', \CIMSettings::CLIENT_PUSH)) {
$pushParams = \CIMMessenger::PreparePushForPrivate(array('FROM_USER_ID' => $arFields['FROM_USER_ID'], 'MESSAGE' => $newRecord['MESSAGE'], 'SYSTEM' => $arFields['SYSTEM'], 'FILES' => $arFields['FILES']));
$pullMessageTo = array_merge($pullMessage, $pushParams);
}
}
\CPullStack::AddByUser($arFields['TO_USER_ID'], $pullMessageTo);
\CPullStack::AddByUser($arFields['FROM_USER_ID'], $pullMessage);
\CPushManager::DeleteFromQueueBySubTag($arFields['FROM_USER_ID'], 'IM_MESS');
//self::SendBadges($arFields['TO_USER_ID']);
}
} else {
if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_CHAT || $arFields['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) {
foreach ($arRel as $relation) {
\CIMContactList::SetRecent(array('ENTITY_ID' => $relation['CHAT_ID'], 'MESSAGE_ID' => $newRecord['ID'], 'CHAT_TYPE' => $relation['MESSAGE_TYPE'], 'USER_ID' => $relation['USER_ID']));
}
if (\CModule::IncludeModule('pull')) {
$pullMessage = array('module_id' => 'im', 'command' => 'messageChat', 'params' => \CIMMessage::GetFormatMessage(array('ID' => $newRecord['ID'], 'CHAT_ID' => $chatId, 'TO_CHAT_ID' => $chatId, 'FROM_USER_ID' => $newRecord['AUTHOR_ID'], 'MESSAGE' => $newRecord['MESSAGE'], 'SYSTEM' => $newRecord['AUTHOR_ID'] > 0 ? 'N' : 'Y', 'DATE_CREATE' => time(), 'PARAMS' => $arFields['PARAMS'], 'FILES' => $arFields['FILES'])));
$chat = \Bitrix\Im\ChatTable::getById($chatId);
$chatData = $chat->fetch();
if ($chatData && \CPullOptions::GetPushStatus()) {
$pushParams = \CIMMessenger::PreparePushForChat(array('CHAT_ID' => $chatId, 'CHAT_TITLE' => $chatData['TITLE'], 'FROM_USER_ID' => $newRecord['AUTHOR_ID'], 'MESSAGE' => $newRecord['MESSAGE'], 'SYSTEM' => $newRecord['AUTHOR_ID'] > 0 ? 'N' : 'Y', 'FILES' => $arFields['FILES']));
$pullMessage = array_merge($pullMessage, $pushParams);
}
$pullUsers = array();
$pullUsersSkip = array();
foreach ($arRel as $rel) {
$pullUsers[] = $rel['USER_ID'];
if ($rel['USER_ID'] == $newRecord['AUTHOR_ID']) {
$pullUsersSkip[] = $rel['USER_ID'];
\CPushManager::DeleteFromQueueBySubTag($newRecord['AUTHOR_ID'], 'IM_MESS');
} else {
if ($rel['NOTIFY_BLOCK'] == 'Y' || !\CIMSettings::GetNotifyAccess($rel['USER_ID'], 'im', $arFields['MESSAGE_TYPE'] == IM_MESSAGE_OPEN ? 'openChat' : 'chat', \CIMSettings::CLIENT_PUSH)) {
$pullUsersSkip[] = $rel['USER_ID'];
}
}
}
$pullMessage['push']['skip_users'] = $pullUsersSkip;
\CPullStack::AddByUsers($pullUsers, $pullMessage);
if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) {
\CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage);
}
/* TODO uncomment after fix mantis:66363
\CIMMessenger::SendMention(Array(
'CHAT_ID' => $chatId,
'CHAT_TITLE' => $chatData['TITLE'],
'CHAT_RELATION' => $arRel,
'CHAT_TYPE' => $chatData['TYPE'],
'MESSAGE' => $newRecord['MESSAGE'],
'FILES' => $arFields['FILES'],
'FROM_USER_ID' => $newRecord['AUTHOR_ID'],
));
*/
//\CIMMessenger::SendBadges($usersForBadges);
foreach (\GetModuleEvents("im", "OnAfterMessagesAdd", true) as $arEvent) {
\ExecuteModuleEventEx($arEvent, array($newRecord['ID'], $newRecord));
}
}
}
}
}
示例4: Invite
public static function Invite($arParams)
{
$arConfig['CHAT_ID'] = intval($arParams['CHAT_ID']);
if ($arConfig['CHAT_ID'] <= 0) {
return false;
}
global $DB, $USER;
$arConfig['RECIPIENT_ID'] = intval($arParams['RECIPIENT_ID']);
$arConfig['USER_ID'] = intval($arParams['USER_ID']) > 0 ? intval($arParams['USER_ID']) : IntVal($USER->GetID());
$arConfig['VIDEO'] = isset($arParams['VIDEO']) && $arParams['VIDEO'] == 'N' ? 'N' : 'Y';
$arChat = CIMChat::GetChatData(array('ID' => $arConfig['CHAT_ID']));
if (empty($arChat['chat'])) {
return false;
}
$arConfig['CALL_TO_GROUP'] = $arChat['chat'][$arConfig['CHAT_ID']]['type'] == IM_MESSAGE_GROUP;
$arConfig['STATUS_TYPE'] = intval($arChat['chat'][$arConfig['CHAT_ID']]['call']);
if (!$arConfig['CALL_TO_GROUP'] && !IsModuleInstalled('intranet') && CIMSettings::GetPrivacy(CIMSettings::PRIVACY_CALL, $arConfig['RECIPIENT_ID']) == CIMSettings::PRIVACY_RESULT_CONTACT && CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed() && !CSocNetUserRelations::IsFriends($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'])) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage('IM_ERROR_CALL_PRIVACY'), "ERROR_FROM_PRIVACY");
return false;
}
if ($arConfig['STATUS_TYPE'] != IM_CALL_NONE) {
if ($arConfig['CALL_TO_GROUP']) {
self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_START_", $arConfig['USER_ID'], true);
}
$strSql = "UPDATE b_im_relation SET CALL_STATUS = " . IM_CALL_STATUS_ANSWER . " WHERE CHAT_ID = " . $arConfig['CHAT_ID'] . " AND USER_ID = " . $arConfig['USER_ID'];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$arUserData = CIMContactList::GetUserData(array('ID' => $arChat['userInChat'][$arConfig['CHAT_ID']], 'DEPARTMENT' => 'N', 'HR_PHOTO' => 'Y'));
$arConfig['USER_DATA']['USERS'] = $arUserData['users'];
$arConfig['USER_DATA']['HR_PHOTO'] = $arUserData['hrphoto'];
foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) {
if ($userId != $arConfig['USER_ID'] && in_array($callStatus, array(IM_CALL_STATUS_WAIT, IM_CALL_STATUS_ANSWER))) {
$arUserToConnect[$userId] = $callStatus;
}
}
$arConfig['USERS_CONNECT'] = $arUserToConnect;
$arSend['users'] = $arUserData['users'];
$arSend['hrphoto'] = $arUserData['hrphoto'];
$arSend['video'] = $arConfig['VIDEO'] == 'Y' ? true : false;
$arSend['callToGroup'] = $arConfig['CALL_TO_GROUP'];
$arSend['chat'] = $arChat['chat'];
$arSend['userChatBlockStatus'] = $arChat['userChatBlockStatus'];
$arSend['userInChat'] = $arChat['userInChat'];
foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) {
if ($userId != $arConfig['USER_ID'] && !in_array($callStatus, array(IM_CALL_STATUS_DECLINE))) {
self::Command($arConfig['CHAT_ID'], $userId, 'invite_join', $arSend);
}
}
} else {
if ($arConfig['CALL_TO_GROUP']) {
self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_INIT_", $arConfig['USER_ID'], true);
}
$strSql = "UPDATE b_im_chat SET CALL_TYPE = " . ($arConfig['VIDEO'] == 'Y' ? IM_CALL_VIDEO : IM_CALL_AUDIO) . " WHERE ID = " . $arConfig['CHAT_ID'];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSql = "UPDATE b_im_relation SET CALL_STATUS = " . IM_CALL_STATUS_ANSWER . " WHERE CHAT_ID = " . $arConfig['CHAT_ID'] . " AND USER_ID = " . $arConfig['USER_ID'];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$arUserToConnect = array();
foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) {
if ($userId != $arConfig['USER_ID']) {
$arUserToConnect[$userId] = $callStatus;
}
}
$arUserData = CIMContactList::GetUserData(array('ID' => $arChat['userInChat'][$arConfig['CHAT_ID']], 'DEPARTMENT' => 'N', 'HR_PHOTO' => 'Y'));
$arSend['users'] = $arUserData['users'];
$arSend['hrphoto'] = $arUserData['hrphoto'];
$arSend['video'] = $arConfig['VIDEO'] == 'Y' ? true : false;
$arSend['callToGroup'] = $arConfig['CALL_TO_GROUP'];
$arSend['chat'] = $arChat['chat'];
$arSend['userChatBlockStatus'] = $arChat['userChatBlockStatus'];
$arSend['userInChat'] = $arChat['userInChat'];
foreach ($arUserToConnect as $userId => $callStatus) {
self::Command($arConfig['CHAT_ID'], $userId, 'invite', $arSend);
}
$arConfig['USER_DATA']['USERS'] = $arUserData['users'];
$arConfig['USER_DATA']['HR_PHOTO'] = $arUserData['hrphoto'];
if (!$arConfig['CALL_TO_GROUP'] && CModule::IncludeModule('pull') && CPullOptions::GetPushStatus()) {
$arSelect = array("ID", "LAST_NAME", "NAME", "LOGIN", "SECOND_NAME");
$dbUsers = CUser::GetList($sort_by = false, $dummy = '', array('ID' => $USER->GetID()), array('FIELDS' => $arSelect));
if ($arUser = $dbUsers->GetNext(true, false)) {
$sName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
$pushText = GetMessage('IM_CALL_INVITE', array('#USER_NAME#' => $sName));
} else {
$pushText = GetMessage('IM_CALL_INVITE', array('#USER_NAME#' => GetMessage('IM_CALL_INVITE_NA')));
}
$CPushManager = new CPushManager();
foreach ($arUserToConnect as $sendTouserId => $callStatus) {
$CPushManager->AddQueue(array('USER_ID' => $sendTouserId, 'MESSAGE' => $pushText, 'EXPIRY' => 0, 'PARAMS' => 'IMINV_' . $USER->GetID() . "_" . time(), 'APP_ID' => 'Bitrix24', 'SOUND' => 'call.aif', 'SEND_IMMEDIATELY' => 'Y'));
}
}
}
foreach (GetModuleEvents("im", "OnCallStart", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($arConfig));
}
return $arConfig;
}
示例5: SendAgent
public static function SendAgent()
{
global $DB;
if (!CPullOptions::GetPushStatus()) {
return false;
}
$count = 0;
$maxId = 0;
$pushLimit = 70;
$arPush = array();
$sqlDate = "";
$dbType = strtolower($DB->type);
if ($dbType == "mysql") {
$sqlDate = " WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 15 SECOND) ";
} else {
if ($dbType == "mssql") {
$sqlDate = " WHERE DATE_CREATE < dateadd(SECOND, -15, getdate()) ";
} else {
if ($dbType == "oracle") {
$sqlDate = " WHERE DATE_CREATE < SYSDATE-(1/24/60/60*15) ";
}
}
}
$strSql = $DB->TopSql("SELECT ID, USER_ID, MESSAGE, PARAMS FROM b_pull_push_queue" . $sqlDate, 280);
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $dbRes->Fetch()) {
$arPush[$count][] = $arRes;
if ($pushLimit <= count($arPush[$count])) {
$count++;
}
$maxId = $maxId < $arRes['ID'] ? $arRes['ID'] : $maxId;
}
foreach ($arPush as $arStack) {
$CPushManager = new CPushManager();
$CPushManager->SendMessage($arStack, defined('PULL_PUSH_SANDBOX') ? true : false);
}
if ($maxId > 0) {
$strSql = "DELETE FROM b_pull_push_queue WHERE ID <= " . $maxId;
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
$strSql = "SELECT COUNT(ID) CNT FROM b_pull_push_queue";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
if ($arRes['CNT'] > 280) {
CAgent::RemoveAgent("CPushManager::SendAgent();", "pull");
CAgent::AddAgent("CPushManager::SendAgent();", "pull", "N", 15, "", "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset() + 15, "FULL"));
} else {
if ($arRes['CNT'] > 0) {
return "CPushManager::SendAgent();";
}
}
}
return false;
}
示例6: End
public static function End($arParams)
{
$arConfig['CHAT_ID'] = intval($arParams['CHAT_ID']);
if ($arConfig['CHAT_ID'] <= 0) {
return false;
}
global $DB, $USER;
$arConfig['USER_ID'] = intval($arParams['USER_ID']) > 0 ? intval($arParams['USER_ID']) : IntVal($USER->GetID());
$arConfig['RECIPIENT_ID'] = intval($arParams['RECIPIENT_ID']);
$arChat = CIMChat::GetChatData(array('ID' => $arConfig['CHAT_ID']));
if (empty($arChat['chat'])) {
return false;
}
$arUserToConnect = array();
$acceptUserExists = false;
foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) {
if ($userId != $arConfig['USER_ID'] && in_array($callStatus, array(IM_CALL_STATUS_WAIT, IM_CALL_STATUS_ANSWER))) {
if ($callStatus == IM_CALL_STATUS_ANSWER) {
$acceptUserExists = true;
}
$arUserToConnect[] = $userId;
}
}
if (!$acceptUserExists || empty($arUserToConnect) || count($arUserToConnect) == 1) {
$arConfig['CLOSE_CONNECT'] = true;
$strSql = "UPDATE b_im_chat SET CALL_TYPE = " . IM_CALL_NONE . " WHERE ID = " . $arConfig['CHAT_ID'];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSql = "UPDATE b_im_relation SET CALL_STATUS = " . IM_CALL_STATUS_NONE . " WHERE CHAT_ID = " . $arConfig['CHAT_ID'];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
} else {
$arConfig['CLOSE_CONNECT'] = false;
$strSql = "UPDATE b_im_relation SET CALL_STATUS = " . IM_CALL_STATUS_DECLINE . " WHERE CHAT_ID = " . $arConfig['CHAT_ID'] . " AND USER_ID = " . $arConfig['USER_ID'];
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
$arConfig['CALL_TO_GROUP'] = $arChat['chat'][$arConfig['CHAT_ID']]['type'] == IM_MESSAGE_GROUP;
if ($arParams['REASON'] == 'decline') {
if ($arConfig['CALL_TO_GROUP']) {
if ($arParams['ACTIVE'] == 'Y') {
self::MessageToChat($arConfig['CHAT_ID'], $arConfig['CLOSE_CONNECT'] ? "IM_CALL_CHAT_CLOSE_" : "IM_CALL_CHAT_END_", $arConfig['USER_ID'], true);
} else {
self::MessageToChat($arConfig['CHAT_ID'], $arConfig['CLOSE_CONNECT'] ? "IM_CALL_CHAT_CLOSE_" : "IM_CALL_CHAT_G_DECLINE_", $arConfig['USER_ID'], true);
}
} else {
if ($arParams['ACTIVE'] == 'Y') {
self::MessageToPrivate($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'], "IM_CALL_CHAT_END");
} else {
self::MessageToPrivate($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'], "IM_CALL_CHAT_DECLINE_", true);
}
}
} else {
if ($arParams['REASON'] == 'busy') {
if ($arConfig['CALL_TO_GROUP']) {
self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_G_BUSY_", $arConfig['USER_ID'], true);
} else {
self::MessageToPrivate($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'], "IM_CALL_CHAT_BUSY_", true);
}
} else {
if ($arParams['REASON'] == 'waitTimeout') {
if ($arConfig['CALL_TO_GROUP']) {
self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_TIMEOUT");
} else {
self::MessageToPrivate($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'], "IM_CALL_CHAT_WAIT", $arConfig['RECIPIENT_ID'], false);
}
} else {
if ($arParams['REASON'] == 'errorOffline') {
if ($arConfig['CALL_TO_GROUP']) {
self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_TIMEOUT");
} else {
self::MessageToPrivate($arConfig['RECIPIENT_ID'], $arConfig['USER_ID'], "IM_CALL_CHAT_OFFLINE", true, false);
}
} else {
if ($arParams['REASON'] == 'errorAccess') {
if ($arConfig['CALL_TO_GROUP']) {
self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_ERROR_", $arConfig['USER_ID'], true);
} else {
self::MessageToPrivate($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'], "IM_CALL_CHAT_ERROR", true, false);
}
}
}
}
}
}
$arSend = array();
$arSend['callToGroup'] = $arConfig['CALL_TO_GROUP'];
$arSend['closeConnect'] = $arConfig['CLOSE_CONNECT'];
if (isset($arParams['VIDEO'])) {
$arSend['video'] = $arParams['VIDEO'] == 'Y' ? true : false;
}
foreach ($arUserToConnect as $userId) {
self::Command($arConfig['CHAT_ID'], $userId, $arParams['REASON'], $arSend);
}
if ($arParams['REASON'] == 'decline') {
self::Command($arConfig['CHAT_ID'], $arConfig['USER_ID'], 'decline_self', $arSend);
self::Command($arConfig['CHAT_ID'], $arConfig['RECIPIENT_ID'], 'end_call', $arSend);
if (false && !$arConfig['CALL_TO_GROUP'] && CModule::IncludeModule('pull') && CPullOptions::GetPushStatus()) {
$CPushManager = new CPushManager();
$CPushManager->AddQueue(array('USER_ID' => $arConfig['USER_ID'], 'EXPIRY' => 0, 'APP_ID' => 'Bitrix24', 'SEND_IMMEDIATELY' => 'Y'));
}
}
return true;
//.........这里部分代码省略.........
示例7: Add
//.........这里部分代码省略.........
if ($chatId <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_MESSAGE_CREATE"), "CHAT_ID");
return false;
}
$strSql = "INSERT INTO b_im_relation (CHAT_ID, MESSAGE_TYPE, USER_ID, STATUS) VALUES (" . $chatId . ",'" . IM_MESSAGE_PRIVATE . "'," . $arFields['FROM_USER_ID'] . ", " . ($bConvert ? 2 : 0) . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSql = "INSERT INTO b_im_relation (CHAT_ID, MESSAGE_TYPE, USER_ID, STATUS) VALUES (" . $chatId . ",'" . IM_MESSAGE_PRIVATE . "'," . $arFields['TO_USER_ID'] . ", " . ($bConvert ? 2 : 0) . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
if ($chatId > 0) {
$arParams = array();
$arParams['CHAT_ID'] = $chatId;
$arParams['AUTHOR_ID'] = intval($arFields['AUTHOR_ID']);
$arParams['MESSAGE'] = trim($arFields['MESSAGE']);
$arParams['MESSAGE_OUT'] = trim($arFields['MESSAGE_OUT']);
$arParams['NOTIFY_MODULE'] = $arFields['NOTIFY_MODULE'];
$arParams['NOTIFY_EVENT'] = 'private';
if (isset($arFields['IMPORT_ID'])) {
$arParams['IMPORT_ID'] = intval($arFields['IMPORT_ID']);
}
if (isset($arFields['MESSAGE_DATE'])) {
$arParams['DATE_CREATE'] = $arFields['MESSAGE_DATE'];
} else {
$arParams['~DATE_CREATE'] = $DB->CurrentTimeFunction();
}
$messageID = IntVal($DB->Add("b_im_message", $arParams, array('MESSAGE', 'MESSAGE_OUT')));
CIMContactList::SetRecent($arFields['TO_USER_ID'], $messageID, false, $arFields['FROM_USER_ID']);
CIMContactList::UpdateRecent($arFields['FROM_USER_ID'], $messageID, false, $arFields['TO_USER_ID']);
if (!$bConvert) {
if (CModule::IncludeModule("pull")) {
$arParams['FROM_USER_ID'] = $arFields['FROM_USER_ID'];
$arParams['TO_USER_ID'] = $arFields['TO_USER_ID'];
$pushText = '';
if (CPullOptions::GetPushStatus()) {
$arSelect = array("ID", "LAST_NAME", "NAME", "LOGIN", "SECOND_NAME");
$dbUsers = CUser::GetList($sort_by = false, $dummy = '', array('ID' => $arParams['FROM_USER_ID']), array('FIELDS' => $arSelect));
if ($arUser = $dbUsers->GetNext(true, false)) {
$sName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
$pushText = $sName . ': ' . $arParams['MESSAGE'];
}
}
$arPullTo = array('module_id' => 'im', 'command' => 'message', 'params' => CIMMessage::GetFormatMessage(array('ID' => $messageID, 'TO_USER_ID' => $arParams['TO_USER_ID'], 'FROM_USER_ID' => $arParams['FROM_USER_ID'], 'MESSAGE' => $arParams['MESSAGE'], 'DATE_CREATE' => time())), 'push_params' => 'IM_MESS_' . $arParams['FROM_USER_ID'], 'push_tag' => 'IM_MESS_' . $arParams['FROM_USER_ID'], 'push_text' => $pushText);
$arPullFrom = $arPullTo;
unset($arPullFrom['push_text']);
CPullStack::AddByUser($arParams['TO_USER_ID'], $arPullTo);
CPullStack::AddByUser($arParams['FROM_USER_ID'], $arPullFrom);
}
$strSql = "\n\t\t\t\t\t\tUPDATE b_im_relation SET STATUS = '" . IM_STATUS_UNREAD . "'\n\t\t\t\t\t\tWHERE USER_ID = " . $arFields['TO_USER_ID'] . " AND MESSAGE_TYPE = '" . IM_MESSAGE_PRIVATE . "' AND CHAT_ID = " . $chatId;
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
foreach (GetModuleEvents("im", "OnAfterMessagesAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(intval($messageID), $arFields));
}
}
return $messageID;
} else {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_MESSAGE_CREATE"), "CHAT_ID");
return false;
}
} else {
if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_GROUP) {
$chatId = 0;
$systemMessage = false;
if (isset($arFields['SYSTEM']) && $arFields['SYSTEM'] == 'Y' && intval($arFields['FROM_USER_ID']) <= 0) {
$strSql = "\n\t\t\t\t\tSELECT C.ID CHAT_ID, C.TITLE CHAT_TITLE, C.AUTHOR_ID CHAT_AUTHOR_ID\n\t\t\t\t\tFROM b_im_chat C\n\t\t\t\t\tWHERE C.ID = " . intval($arFields['TO_CHAT_ID']) . "\n\t\t\t\t";
$systemMessage = true;
} else {
示例8: function
<td><input id="config_path_to_listener" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenUrl())?>" name="path_to_listener" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
</tr>
<?/*
<tr>
<td width="40%"><nobr><?=GetMessage("PULL_OPTIONS_WEBSOCKET")?></nobr>:</td>
<td width="60%"><input id="config_websocket" type="checkbox" size="40" value="Y" <?=(CPullOptions::GetWebSocketStatus()?' checked':'')?> name="websocket" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
</tr>
<tr>
<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_WEBSOCKET")?>:</td>
<td><input id="config_path_to_websocket" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetWebSocketUrl())?>" name="path_to_websocket" <?=(!CPullOptions::GetNginxStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"': '')?></td>
</tr>
*/?>
<?if (IsModuleInstalled('mobileapp')):?>
<tr>
<td align="right" width="50%"><?=GetMessage("PULL_OPTIONS_PUSH")?>:</td>
<td><input type="checkbox" size="40" value="Y" <?=(CPullOptions::GetPushStatus()?' checked':'')?> name="push"></td>
</tr>
<?endif;?>
<?$tabControl->Buttons();?>
<script language="JavaScript">
BX.bind(BX('config_nginx'), 'change', function(){
if (this.checked)
{
if (confirm("<?=GetMessageJS("PULL_OPTIONS_NGINX_CONFIRM")?>"))
{
BX('config_path_to_publish').disabled = false;
BX('config_path_to_listener').disabled = false;
BX('config_path_to_websocket').disabled = false;
BX('config_websocket').disabled = false;
BX('config_websocket').checked = true;
}
示例9: GetMessage
</td>
</tr>
<?php
}
?>
<tr>
<td width="40%"></td>
<td width="60%"></td>
</tr>
<tr>
<td align="right" width="50%"><?php
echo GetMessage("PULL_OPTIONS_PUSH");
?>
:</td>
<td><input type="checkbox" size="40" value="Y" <?php
echo CPullOptions::GetPushStatus() ? ' checked' : '';
?>
name="push"></td>
</tr>
<tr>
<td width="40%"></td>
<td width="60%"></td>
</tr>
<tr>
<td width="40%"><nobr><?php
echo GetMessage("PULL_OPTIONS_NGINX");
?>
</nobr>:</td>
<td width="60%"><input id="config_nginx" type="checkbox" size="40" value="Y" <?php
echo CPullOptions::GetQueueServerStatus() ? ' checked' : '';
?>
示例10: SendBadges
public static function SendBadges($userID)
{
if (!(CModule::IncludeModule('pull') && CPullOptions::GetPushStatus()))
return false;
$arPush = Array();
if (!is_array($userID))
$userID = Array(intval($userID));
global $DB;
if (empty($userID))
return false;
foreach ($userID as $key => $userId)
$userID[$key] = intval($userId);
$sql = "SELECT SUM(CNT) CNT, USER_ID
FROM b_user_counter
WHERE USER_ID IN (".implode(',', $userID).") and SITE_ID = '**' and CODE IN ('im_notify', 'im_message', 'im_chat')
GROUP BY USER_ID";
$res = $DB->Query($sql);
while($row = $res->Fetch())
$arPush[] = Array('USER_ID' => $row['USER_ID'], 'BADGE' => $row['CNT']);
$CPushManager = new CPushManager();
$CPushManager->SendMessage($arPush, defined('PULL_PUSH_SANDBOX')? true: false);
}