function CheckModules() { global $APPLICATION; if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus()) { $this->errors[] = GetMessage('VI_CHECK_PULL'); } if (!IsModuleInstalled('im')) { $this->errors[] = GetMessage('VI_CHECK_IM'); } include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php"; if (version_compare("14.9.2", SM_VERSION) == 1) { $this->errors[] = GetMessage('VI_CHECK_MAIN'); } if (IsModuleInstalled('intranet')) { include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intranet/install/version.php"; if (version_compare("14.5.6", $arModuleVersion["VERSION"]) == 1) { $this->errors[] = GetMessage('VI_CHECK_INTRANET'); } } else { $this->errors[] = GetMessage('VI_CHECK_INTRANET_INSTALL'); } if (is_array($this->errors) && !empty($this->errors)) { $APPLICATION->ThrowException(implode("<br>", $this->errors)); return false; } else { return true; } }
public static function AddShared($arMessage, $channelType = 'shared') { if (!CPullOptions::GetQueueServerStatus()) { return false; } $arChannel = CPullChannel::GetChannelShared($channelType); return self::AddByChannel($arChannel['CHANNEL_ID'], $arMessage); }
/** * Return some information about P&P, such as publish url * * @since 14.5.4 * @return array */ protected static function getPullingInfo() { $result = array('enabled' => CModule::IncludeModule('pull') && CPullOptions::ModuleEnable()); if ($result['enabled']) { $result['nginx_used'] = CPullOptions::GetQueueServerStatus(); if ($result['nginx_used']) { $result['server_protocol'] = CPullOptions::GetQueueServerVersion(); $result['publish_url'] = CPullOptions::GetPublishUrl(); $result['pulling_url'] = CPullOptions::GetListenUrl(); $result['pulling_url_secure'] = CPullOptions::GetListenSecureUrl(); $result['websocket_url'] = CPullOptions::GetWebSocketUrl(); $result['websocket_url_secure'] = CPullOptions::GetWebSocketSecureUrl(); } } return $result; }
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; }
public static function SendPullEvent($params) { if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } if (empty($params['COMMAND'])) { return false; } $config = array(); if ($params['COMMAND'] == 'inviteTransfer') { $config = array("callId" => $params['CALL_ID'], "callerId" => $params['CALLER_ID'], "phoneNumber" => $params['PHONE_NAME'], "chatId" => 0, "chat" => array(), "application" => $params['APPLICATION'], "CRM" => $params['CRM']); } else { if ($params['COMMAND'] == 'completeTransfer') { $config = array("callId" => $params['CALL_ID'], "transferUserId" => $params['TRANSFER_USER_ID'], "callDevice" => $params['CALL_DEVICE'], "CRM" => $params['CRM'] ? $params['CRM'] : false); } else { $config["callId"] = $params['CALL_ID']; } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config)); return true; }
die(); } if (intval($USER->GetID()) <= 0) { echo CUtil::PhpToJsObject(Array('ERROR' => 'AUTHORIZE_ERROR')); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php"); die(); } if (check_bitrix_sessid()) { if ($_POST['PULL_GET_CHANNEL'] == 'Y') { $arChannel = CPullChannel::Get($USER->GetId(), $_POST['CACHE'] == 'Y'? true: false, $_POST['CACHE'] == 'Y'? false: true); if (is_array($arChannel)) { $nginxStatus = CPullOptions::GetQueueServerStatus(); $webSocketStatus = CPullOptions::GetWebSocketStatus(); $arChannels = Array($arChannel['CHANNEL_ID']); if ($nginxStatus) { $arChannelShared = CPullChannel::GetShared($_POST['CACHE'] == 'Y'? true: false, $_POST['CACHE'] == 'Y'? false: true); if ($arChannelShared) { $arChannels[] = $arChannelShared['CHANNEL_ID']; if ($arChannel['CHANNEL_DT'] > $arChannelShared['CHANNEL_DT']) $arChannel['CHANNEL_DT'] = $arChannelShared['CHANNEL_DT']; } } if ($_POST['MOBILE'] == 'Y') $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels, true): CPullOptions::GetListenUrl($arChannels, true)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE');
public static function SendPullEvent($params) { if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); $push = array(); if ($params['COMMAND'] == 'start') { $config = array("callId" => $params['CALL_ID'], "callDevice" => $params['CALL_DEVICE'] == 'PHONE' ? 'PHONE' : 'WEBRTC', "external" => $params['EXTERNAL'] ? true : false, "CRM" => $params['CRM'] ? $params['CRM'] : false); } else { if ($params['COMMAND'] == 'hold' || $params['COMMAND'] == 'unhold') { $config = array("callId" => $params['CALL_ID']); } else { if ($params['COMMAND'] == 'timeout') { $config = array("callId" => $params['CALL_ID']); $push['send_immediately'] = 'Y'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID'])); } } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config, 'push' => $push)); return true; }
public static function SendPullEvent($params) { // TODO check $params if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); $push = array(); if ($params['COMMAND'] == 'invite') { $config = array("callId" => $params['CALL_ID'], "callerId" => $params['CALLER_ID'], "phoneNumber" => $params['PHONE_NAME'], "chatId" => 0, "chat" => array(), "typeConnect" => $params['TYPE_CONNECT'], "portalCall" => $params['PORTAL_CALL'] == 'Y' ? true : false, "portalCallUserId" => $params['PORTAL_CALL'] == 'Y' ? $params['PORTAL_CALL_USER_ID'] : 0, "portalCallData" => $params['PORTAL_CALL'] == 'Y' ? $params['PORTAL_CALL_DATA'] : array(), "config" => $params['CONFIG'] ? $params['CONFIG'] : array(), "CRM" => $params['CRM']); $callName = $params['CALLER_ID']; if (isset($params['CRM']['CONTACT']['NAME']) && strlen($params['CRM']['CONTACT']['NAME']) > 0) { $callName = $params['CRM']['CONTACT']['NAME']; } if (isset($params['CRM']['COMPANY']) && strlen($params['CRM']['COMPANY']) > 0) { $callName .= ' (' . $params['CRM']['COMPANY'] . ')'; } else { if (isset($params['CRM']['CONTACT']['POST']) && strlen($params['CRM']['CONTACT']['POST']) > 0) { $callName .= ' (' . $params['CRM']['CONTACT']['POST'] . ')'; } } $push['sub_tag'] = 'VI_CALL_' . $params['CALL_ID']; $push['send_immediately'] = 'Y'; $push['sound'] = 'call.aif'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID']), "androidHighPriority" => true); if ($params['PORTAL_CALL'] == 'Y') { $push['message'] = GetMessage('INCOMING_CALL', array('#NAME#' => $params['PORTAL_CALL_DATA']['users'][$params['PORTAL_CALL_USER_ID']]['name'])); } else { $push['message'] = GetMessage('INCOMING_CALL', array('#NAME#' => $callName)); $push['message'] = $push['message'] . ' ' . GetMessage('CALL_FOR_NUMBER', array('#NUMBER#' => $params['PHONE_NAME'])); } $push['params'] = array('ACTION' => 'VI_CALL_' . $params['CALL_ID'], 'PARAMS' => $config); } else { if ($params['COMMAND'] == 'update_crm') { $config = array("callId" => $params['CALL_ID'], "CRM" => $params['CRM']); } else { if ($params['COMMAND'] == 'timeout' || $params['COMMAND'] == 'answer_self') { $config = array("callId" => $params['CALL_ID']); $push['send_immediately'] = 'Y'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID'])); } } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config, 'push' => $push)); return true; }
public static function GetConfig($userId, $cache = true, $reopen = false, $mobile = false) { $pullConfig = Array(); if (defined('BX_PULL_SKIP_LS')) $pullConfig['LOCAL_STORAGE'] = 'N'; if (IsModuleInstalled('bitrix24')) $pullConfig['BITRIX24'] = 'Y'; $arChannel = CPullChannel::Get($userId, $cache, $reopen); if (is_array($arChannel)) { $nginxStatus = CPullOptions::GetQueueServerStatus(); $webSocketStatus = false; $arChannels = Array($arChannel['CHANNEL_ID']); if ($nginxStatus) { if (defined('BX_PULL_SKIP_WEBSOCKET')) { $pullConfig['WEBSOCKET'] = 'N'; } else { $webSocketStatus = CPullOptions::GetWebSocketStatus(); } $arChannelShared = CPullChannel::GetShared($cache, $reopen); if (is_array($arChannelShared)) { $arChannels[] = $arChannelShared['CHANNEL_ID']; $arChannel['CHANNEL_DT'] = $arChannel['CHANNEL_DT'].'/'.$arChannelShared['CHANNEL_DT']; } } if ($mobile || defined('BX_MOBILE') || defined('BX_PULL_MOBILE')) { $pullConfig['MOBILE'] = 'Y'; $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels, true): CPullOptions::GetListenUrl($arChannels, true)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'); } else { $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels): CPullOptions::GetListenUrl($arChannels)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'); } $pullPathWs = ($nginxStatus && $webSocketStatus? (CMain::IsHTTPS()? CPullOptions::GetWebSocketSecureUrl($arChannels): CPullOptions::GetWebSocketUrl($arChannels)): ''); return $pullConfig+Array( 'CHANNEL_ID' => implode('/', $arChannels), 'CHANNEL_DT' => $arChannel['CHANNEL_DT'], 'LAST_ID' => $arChannel['LAST_ID'], 'PATH' => $pullPath, 'PATH_WS' => $pullPathWs, 'PATH_COMMAND' => defined('BX_PULL_COMMAND_PATH')? BX_PULL_COMMAND_PATH: '', 'METHOD' => ($nginxStatus? 'LONG': 'PULL'), 'REVISION' => PULL_REVISION, 'ERROR' => '', ); } return false; }
public static function SendPullEvent($params) { if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); if ($params['COMMAND'] == 'start') { $config = array("callId" => $params['CALL_ID'], "callDevice" => $params['CALL_DEVICE'] == 'PHONE' ? 'PHONE' : 'WEBRTC', "external" => $params['EXTERNAL'] ? true : false, "CRM" => $params['CRM'] ? $params['CRM'] : false); } else { if ($params['COMMAND'] == 'hold' || $params['COMMAND'] == 'unhold') { $config = array("callId" => $params['CALL_ID']); } else { if ($params['COMMAND'] == 'timeout') { $config = array("callId" => $params['CALL_ID']); } } } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config)); return true; }
public static function SendPullEvent($params) { // TODO check params if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); $push = 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, "portalCall" => $params['PORTAL_CALL'] == 'Y' ? true : false, "portalCallUserId" => $params['PORTAL_CALL'] == 'Y' ? $params['PORTAL_CALL_USER_ID'] : 0, "portalCallData" => $params['PORTAL_CALL'] == 'Y' ? $params['PORTAL_CALL_DATA'] : array(), "config" => $params['CONFIG'] ? $params['CONFIG'] : array(), "CRM" => $params['CRM'] ? $params['CRM'] : array()); $push['send_immediately'] = 'Y'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID'])); } else { if ($params['COMMAND'] == 'timeout') { $config = array("callId" => $params['CALL_ID'], "failedCode" => intval($params['FAILED_CODE'])); $push['send_immediately'] = 'Y'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID'])); } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config, 'push' => $push)); return true; }
</tr> <tr> <td width="40%"></td> <td width="60%"></td> </tr> <tr> <td align="right" width="50%"><?=GetMessage("PULL_OPTIONS_WEBSOCKET")?>:</td> <td><input type="checkbox" size="40" value="Y" <?=(CPullOptions::GetWebSocket()?' checked':'')?> id="config_websocket" name="websocket" <?=(CPullOptions::GetQueueServerStatus() && CPullOptions::GetQueueServerVersion() > 1 ? '': '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::GetQueueServerStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"': '')?></td> </tr> <tr> <td ><?=GetMessage("PULL_OPTIONS_PATH_TO_WEBSOCKET_SECURE")?>:</td> <td><input id="config_path_to_websocket_secure" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetWebSocketSecureUrl())?>" name="path_to_websocket_secure" <?=(!CPullOptions::GetQueueServerStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"': '')?></td> </tr> <tr> <td width="40%"></td> <td width="60%"> <?=GetMessage("PULL_OPTIONS_WEBSOCKET_DESC")?> </td> </tr> <tr> <td width="40%"></td> <td width="60%"></td> </tr> <tr> <td width="40%"></td> <td width="60%"></td> </tr>
?> " name="path_to_websocket" <?php echo !CPullOptions::GetQueueServerStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"' : ''; ?> </td> </tr> <tr> <td ><?php echo GetMessage("PULL_OPTIONS_PATH_TO_LISTENER_SECURE"); ?> :</td> <td><input id="config_path_to_websocket_secure" type="text" size="40" value="<?php echo htmlspecialcharsbx(CPullOptions::GetWebSocketSecureUrl()); ?> " name="path_to_websocket_secure" <?php echo !CPullOptions::GetQueueServerStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"' : ''; ?> </td> </tr> <tr> <td width="40%"></td> <td width="60%"> <?php echo GetMessage("PULL_OPTIONS_WEBSOCKET_DESC"); ?> </td> </tr> <?php if (count($arSites) > 1 || count($arExcludeSites) > 0) { ?> <tr class="heading">
public function SetPhoneActive($userId, $active = false) { $userId = intval($userId); if (!$userId) { return false; } CUserOptions::SetOption('voximplant', 'phone_device_active', $active ? true : false, false, $userId); global $USER, $CACHE_MANAGER; $USER->Update($userId, array('UF_VI_PHONE' => $active ? 'Y' : 'N')); if ($active) { $arUserInfo = $this->GetUserInfo($userId); if (!$arUserInfo['phone_enable']) { $USER->Update($userId, array('UF_VI_PHONE' => 'N')); $CACHE_MANAGER->ClearByTag("USER_NAME_" . $userId); CUserOptions::SetOption('voximplant', 'phone_device_active', false, false, $userId); return false; } } $CACHE_MANAGER->ClearByTag("USER_NAME_" . $userId); if (CModule::IncludeModule('pull') && CPullOptions::GetQueueServerStatus()) { CPullStack::AddByUser($userId, array('module_id' => 'voximplant', 'command' => 'phoneDeviceActive', 'params' => array('active' => $active ? 'Y' : 'N'))); } return true; }
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'] == 'invite') { $config = array("callId" => $params['CALL_ID'], "callerId" => $params['CALLER_ID'], "phoneNumber" => $params['PHONE_NAME'], "chatId" => 0, "chat" => array(), "CRM" => $params['CRM']); } else { if ($params['COMMAND'] == 'update_crm') { $config = array("callId" => $params['CALL_ID'], "CRM" => $params['CRM']); } else { if ($params['COMMAND'] == 'timeout' || $params['COMMAND'] == 'answer_self') { $config = array("callId" => $params['CALL_ID']); } } } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config)); return true; }
public static function GetUserConfig($userId) { $pullConfig = array(); if (defined('BX_PULL_SKIP_LS')) { $pullConfig['LOCAL_STORAGE'] = 'N'; } if (IsModuleInstalled('bitrix24')) { $pullConfig['BITRIX24'] = 'Y'; } $pullChannel = CPullChannel::Get($userId); if (is_array($pullChannel)) { $pullWebSocketStatus = false; $pullNginxStatus = CPullOptions::GetQueueServerStatus(); $pullChannels = array($pullChannel['CHANNEL_ID']); if ($pullNginxStatus) { if (defined('BX_PULL_SKIP_WEBSOCKET')) { $pullWebSocketStatus = false; $pullConfig['WEBSOCKET'] = 'N'; } else { $pullWebSocketStatus = CPullOptions::GetWebSocketStatus(); } $pullChannelShared = CPullChannel::GetShared(); if (is_array($pullChannelShared)) { $pullChannels[] = $pullChannelShared['CHANNEL_ID']; if ($pullChannel['CHANNEL_DT'] > $pullChannelShared['CHANNEL_DT']) { $pullChannel['CHANNEL_DT'] = $pullChannelShared['CHANNEL_DT']; } } } if (defined('BX_MOBILE') || defined('BX_PULL_MOBILE')) { $pullConfig['MOBILE'] = 'Y'; $pullPath = $pullNginxStatus ? CMain::IsHTTPS() ? CPullOptions::GetListenSecureUrl($pullChannels, true) : CPullOptions::GetListenUrl($pullChannels, true) : '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'; } else { $pullPath = $pullNginxStatus ? CMain::IsHTTPS() ? CPullOptions::GetListenSecureUrl($pullChannels) : CPullOptions::GetListenUrl($pullChannels) : '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'; } $pullConfig = $pullConfig + array('CHANNEL_ID' => implode('/', $pullChannels), 'LAST_ID' => $pullChannel['LAST_ID'], 'CHANNEL_DT' => $pullChannel['CHANNEL_DT'], 'PATH' => $pullPath, 'PATH_WS' => $pullNginxStatus && $pullWebSocketStatus ? CMain::IsHTTPS() ? CPullOptions::GetWebSocketSecureUrl($pullChannels) : CPullOptions::GetWebSocketUrl($pullChannels) : '', 'PATH_COMMAND' => defined('BX_PULL_COMMAND_PATH') ? BX_PULL_COMMAND_PATH : '', 'METHOD' => $pullNginxStatus ? 'LONG' : 'PULL'); } return $pullConfig; }