public static function GetTemplateJS($arParams, $arTemplate) { global $USER; $ppStatus = 'false'; $ppServerStatus = 'false'; $updateStateInterval = 'auto'; if (CModule::IncludeModule("pull")) { $ppStatus = CPullOptions::ModuleEnable()? 'true': 'false'; $ppServerStatus = CPullOptions::GetNginxStatus()? 'true': 'false'; $updateStateInterval = CPullOptions::GetNginxStatus()? self::GetSessionLifeTime(): 80; if ($updateStateInterval > 100) { if ($updateStateInterval > 3600) $updateStateInterval = 3600; if ($arTemplate['DESKTOP'] == 'true') $updateStateInterval = intval($updateStateInterval/2); else $updateStateInterval = $updateStateInterval-60; } } $diskStatus = CIMDisk::Enabled(); if ($arTemplate['INIT'] == 'Y') { $phoneSipAvailable = 0; $phoneEnabled = self::CheckPhoneStatus(); if ($phoneEnabled && CModule::IncludeModule('voximplant')) { $phoneSipAvailable = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); } $pathToIm = isset($arTemplate['PATH_TO_IM'])? $arTemplate['PATH_TO_IM']: ''; $pathToCall = isset($arTemplate['PATH_TO_CALL'])? $arTemplate['PATH_TO_CALL']: ''; $pathToFile = isset($arTemplate['PATH_TO_FILE'])? $arTemplate['PATH_TO_FILE']: ''; $sJS = " BX.ready(function() { BXIM = new BX.IM(BX('bx-notifier-panel'), { 'mailCount': ".$arTemplate["MAIL_COUNTER"].", 'notifyCount': ".$arTemplate["NOTIFY_COUNTER"].", 'messageCount': ".$arTemplate["MESSAGE_COUNTER"].", 'counters': ".(empty($arTemplate['COUNTERS'])? '{}': CUtil::PhpToJSObject($arTemplate['COUNTERS'])).", 'ppStatus': ".$ppStatus.", 'ppServerStatus': ".$ppServerStatus.", 'updateStateInterval': '".$updateStateInterval."', 'xmppStatus': ".(CIMMessenger::CheckXmppStatusOnline()? 'true': 'false').", 'bitrixNetworkStatus': ".(CIMMessenger::CheckNetworkStatus()? 'true': 'false').", 'bitrix24Status': ".(IsModuleInstalled('bitrix24')? 'true': 'false').", 'bitrix24Admin': ".(CModule::IncludeModule('bitrix24') && CBitrix24::IsPortalAdmin($USER->GetId())? 'true': 'false').", 'bitrix24net': ".(IsModuleInstalled('b24network')? 'true': 'false').", 'bitrixIntranet': ".(IsModuleInstalled('intranet')? 'true': 'false').", 'bitrixXmpp': ".(IsModuleInstalled('xmpp')? 'true': 'false').", 'desktop': ".$arTemplate["DESKTOP"].", 'desktopStatus': ".(CIMMessenger::CheckDesktopStatusOnline()? 'true': 'false').", 'desktopVersion': ".CIMMessenger::GetDesktopVersion().", 'desktopLinkOpen': ".$arTemplate["DESKTOP_LINK_OPEN"].", 'language': '".LANGUAGE_ID."', 'smile': ".CUtil::PhpToJSObject($arTemplate["SMILE"]).", 'smileSet': ".CUtil::PhpToJSObject($arTemplate["SMILE_SET"]).", 'settings': ".CUtil::PhpToJSObject($arTemplate['SETTINGS']).", 'settingsNotifyBlocked': ".(empty($arTemplate['SETTINGS_NOTIFY_BLOCKED'])? '{}': CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])).", 'notify': ".(empty($arTemplate['NOTIFY']['notify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])).", 'unreadNotify' : ".(empty($arTemplate['NOTIFY']['unreadNotify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])).", 'flashNotify' : ".(empty($arTemplate['NOTIFY']['flashNotify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])).", 'countNotify' : ".intval($arTemplate['NOTIFY']['countNotify']).", 'loadNotify' : ".($arTemplate['NOTIFY']['loadNotify']? 'true': 'false').", 'recent': ".CUtil::PhpToJSObject($arTemplate['RECENT']).", 'users': ".(empty($arTemplate['CONTACT_LIST']['users'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])).", 'groups': ".(empty($arTemplate['CONTACT_LIST']['groups'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])).", 'userInGroup': ".(empty($arTemplate['CONTACT_LIST']['userInGroup'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])).", 'woGroups': ".(empty($arTemplate['CONTACT_LIST']['woGroups'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])).", 'woUserInGroup': ".(empty($arTemplate['CONTACT_LIST']['woUserInGroup'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])).", 'chat': ".(empty($arTemplate['CHAT']['chat'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])).", 'userInChat': ".(empty($arTemplate['CHAT']['userInChat'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])).", 'userChatBlockStatus': ".(empty($arTemplate['CHAT']['userChatBlockStatus'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['userChatBlockStatus'])).", 'message' : ".(empty($arTemplate['MESSAGE']['message'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])).", 'files' : ".(empty($arTemplate['MESSAGE']['files'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['files'])).", 'showMessage' : ".(empty($arTemplate['MESSAGE']['usersMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])).", 'unreadMessage' : ".(empty($arTemplate['MESSAGE']['unreadMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])).", 'flashMessage' : ".(empty($arTemplate['MESSAGE']['flashMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])).", 'history' : {}, 'openMessenger' : ".(isset($_GET['IM_DIALOG'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG']))."'": 'false').", 'openHistory' : ".(isset($_GET['IM_HISTORY'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY']))."'": 'false').", 'openNotify' : ".(isset($_GET['IM_NOTIFY']) && $_GET['IM_NOTIFY'] == 'Y'? 'true': 'false').", 'openSettings' : ".(isset($_GET['IM_SETTINGS'])? $_GET['IM_SETTINGS'] == 'Y'? "'true'": "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_SETTINGS']))."'": 'false').", 'currentTab' : '".CUtil::JSEscape($arTemplate['CURRENT_TAB'])."', 'userId': ".$USER->GetID().", 'userEmail': '".CUtil::JSEscape($USER->GetEmail())."', 'webrtc': {'turnServer' : '".CUtil::JSEscape($arTemplate['TURN_SERVER'])."', 'turnServerFirefox' : '".CUtil::JSEscape($arTemplate['TURN_SERVER_FIREFOX'])."', 'turnServerLogin' : '".CUtil::JSEscape($arTemplate['TURN_SERVER_LOGIN'])."', 'turnServerPassword' : '".CUtil::JSEscape($arTemplate['TURN_SERVER_PASSWORD'])."', 'mobileSupport': false, 'phoneEnabled': ".($phoneEnabled? 'true': 'false').", 'phoneSipAvailable': ".($phoneSipAvailable? 'true': 'false')."}, 'disk': {'enable' : ".($diskStatus? 'true': 'false')."}, 'path' : {'profile' : '".CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE'])."', 'profileTemplate' : '".CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'])."', 'mail' : '".CUtil::JSEscape($arTemplate['PATH_TO_USER_MAIL'])."', 'im': '".CUtil::JSEscape($pathToIm)."', 'call': '".CUtil::JSEscape($pathToCall)."', 'file': '".CUtil::JSEscape($pathToFile)."'} }); }); "; } else { $sJS = " BX.ready(function() { BXIM = new BX.IM(BX('bx-notifier-panel'), { 'init': false, 'settings': ".CUtil::PhpToJSObject($arTemplate['SETTINGS']).", 'updateStateInterval': '".$updateStateInterval."', 'desktop': ".$arTemplate["DESKTOP"].", 'ppStatus': ".$ppStatus.", 'ppServerStatus': ".$ppServerStatus.", 'xmppStatus': ".(CIMMessenger::CheckXmppStatusOnline()? 'true': 'false').", 'bitrix24Status': ".(IsModuleInstalled('bitrix24')? 'true': 'false').", 'bitrixIntranet': ".(IsModuleInstalled('intranet')? 'true': 'false').", 'bitrixXmpp': ".(IsModuleInstalled('xmpp')? 'true': 'false').", 'notify' : {}, 'users' : {}, 'userId': ".$USER->GetID().", 'userEmail': '".CUtil::JSEscape($USER->GetEmail())."', 'openMessenger' : ".(isset($_GET['IM_DIALOG'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG']))."'": 'false').", 'openHistory' : ".(isset($_GET['IM_HISTORY'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY']))."'": 'false').", 'openSettings' : ".(isset($_GET['IM_SETTINGS']) && $_GET['IM_SETTINGS'] == 'Y'? "'true'": 'false').", 'disk': {'enable' : '".($diskStatus? 'true': 'false')."'}, 'path' : {'profile' : '".$arTemplate['PATH_TO_USER_PROFILE']."', 'profileTemplate' : '".$arTemplate['PATH_TO_USER_PROFILE_TEMPLATE']."', 'mail' : '".$arTemplate['PATH_TO_USER_MAIL']."'} }); }); "; } return $sJS; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') { return; } if (!CModule::IncludeModule('voximplant')) { return; } $arResult = array(); $arResult['SIP_ENABLE'] = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); $arResult['LIST_SIP_NUMBERS'] = array(); $arResult['LINK_TO_BUY'] = ''; if (IsModuleInstalled('bitrix24')) { if (LANGUAGE_ID != 'kz') { $arResult['LINK_TO_BUY'] = '/settings/license_phone_sip.php'; } $arResult['LINK_TO_DOC'] = in_array(LANGUAGE_ID, array("ru", "kz", "ua", "by")) ? 'https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=52&CHAPTER_ID=02564' : 'https://www.bitrixsoft.com/support/training/course/index.php?COURSE_ID=55&LESSON_ID=6635'; } else { if (LANGUAGE_ID == 'ru') { $arResult['LINK_TO_BUY'] = 'http://www.1c-bitrix.ru/buy/intranet.php#tab-call-link'; } else { if (LANGUAGE_ID == 'ua') { //$arResult['LINK_TO_BUY'] = 'http://www.1c-bitrix.ua/buy/intranet.php#tab-call-link'; } else { if (LANGUAGE_ID == 'kz') { } else { if (LANGUAGE_ID == 'de') { $arResult['LINK_TO_BUY'] = 'https://www.bitrix24.de/prices/calls.php';
public static function GetRecordLimit($mode = false) { $sipConnectorActive = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); $recordLimit = COption::GetOptionInt("voximplant", "record_limit"); if ($recordLimit > 0 && !CVoxImplantAccount::IsPro()) { if ($mode == CVoxImplantConfig::MODE_SIP && $sipConnectorActive) { $recordLimitEnable = false; } else { $recordLimitEnable = true; $recordLimitRemaining = $recordLimit - CGlobalCounter::GetValue('vi_records', CGlobalCounter::ALL_SITES); $result = array('ENABLE' => $recordLimitEnable, 'LIMIT' => $recordLimit, 'REMAINING' => $recordLimitRemaining); } } else { $recordLimitEnable = false; } if (!$recordLimitEnable) { $result = array('ENABLE' => $recordLimitEnable, 'DEMO' => CVoxImplantAccount::IsDemo() && !$sipConnectorActive); } return $result; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') { return; } if (!CModule::IncludeModule('voximplant')) { return; } $ViHttp = new CVoxImplantHttp(); $result = $ViHttp->GetSipInfo(); $arResult = array('FREE' => intval($result->FREE), 'ACTIVE' => $result->ACTIVE, 'DATE_END' => $result->DATE_END); if ($result->ACTIVE != CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP)) { CVoxImplantConfig::SetModeStatus(CVoxImplantConfig::MODE_SIP, $result->ACTIVE ? true : false); } $arResult['LINK_TO_BUY'] = ''; if (IsModuleInstalled('bitrix24')) { if (LANGUAGE_ID != 'kz') { $arResult['LINK_TO_BUY'] = '/settings/license_phone_sip.php'; } } else { if (LANGUAGE_ID == 'ru') { $arResult['LINK_TO_BUY'] = 'http://www.1c-bitrix.ru/buy/intranet.php#tab-call-link'; } else { if (LANGUAGE_ID == 'ua') { $arResult['LINK_TO_BUY'] = 'http://www.1c-bitrix.ua/buy/intranet.php#tab-call-link'; } else { if (LANGUAGE_ID == 'kz') { } else {
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') { return; } if (!CModule::IncludeModule('voximplant')) { return; } $mode = ''; if (in_array($_REQUEST['MODE'], array(CVoxImplantConfig::MODE_LINK, CVoxImplantConfig::MODE_RENT, CVoxImplantConfig::MODE_SIP))) { if (isset($_POST['MODE'])) { $mode = $_POST['MODE']; } else { if (isset($_GET['MODE'])) { $mode = $_GET['MODE']; } } } $arResult = array('MODE_LINK' => CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_LINK), 'MODE_RENT' => CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_RENT), 'MODE_SIP' => CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP), 'MODE_ACTIVE' => $mode); if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) { $this->IncludeComponentTemplate(); } return $arResult;
public static function Add($params) { if (strlen($params["CALL_ID"]) > 0) { $res = VI\CallTable::getList(array('select' => array('ID', 'DATE_CREATE', 'CRM', 'CONFIG_ID', 'USER_ID', 'TRANSFER_USER_ID'), 'filter' => array('=CALL_ID' => $params["CALL_ID"]))); if ($call = $res->fetch()) { VI\CallTable::delete($call['ID']); } } $arFields = array("ACCOUNT_ID" => $params["ACCOUNT_ID"], "APPLICATION_ID" => $params["APPLICATION_ID"], "APPLICATION_NAME" => $params["APPLICATION_NAME"], "INCOMING" => $params["INCOMING"], "CALL_START_DATE" => $call ? $call['DATE_CREATE'] : new Bitrix\Main\Type\DateTime(), "CALL_DURATION" => $params["CALL_DURATION"], "CALL_STATUS" => $params["CALL_STATUS"], "CALL_FAILED_CODE" => $params["CALL_FAILED_CODE"], "CALL_FAILED_REASON" => $params["CALL_FAILED_REASON"], "COST" => $params["COST_FINAL"], "COST_CURRENCY" => $params["COST_CURRENCY"], "CALL_VOTE" => intval($params["CALL_VOTE"]), "CALL_ID" => $params["CALL_ID"], "CALL_CATEGORY" => $params["CALL_CATEGORY"]); if (intval($params["PORTAL_USER_ID"]) > 0) { $arFields["PORTAL_USER_ID"] = intval($params["PORTAL_USER_ID"]); } if (strlen($params["PHONE_NUMBER"]) > 0) { $arFields["PHONE_NUMBER"] = $params["PHONE_NUMBER"]; } if (strlen($params["CALL_DIRECTION"]) > 0) { $arFields["CALL_DIRECTION"] = $params["CALL_DIRECTION"]; } if (strlen($params["PORTAL_NUMBER"]) > 0) { $arFields["PORTAL_NUMBER"] = $params["PORTAL_NUMBER"]; } if (strlen($params["ACCOUNT_SEARCH_ID"]) > 0) { $arFields["PORTAL_NUMBER"] = $params["ACCOUNT_SEARCH_ID"]; } if (strlen($params["CALL_LOG"]) > 0) { $arFields["CALL_LOG"] = $params["CALL_LOG"]; } $orm = Bitrix\VoxImplant\StatisticTable::add($arFields); if (!$orm) { return false; } if ($call && intval($arFields["PORTAL_USER_ID"]) <= 0) { $res = VI\QueueTable::getList(array('select' => array('ID', 'USER_ID'), 'order' => array('LAST_ACTIVITY_DATE' => 'asc'), 'filter' => array('=CONFIG_ID' => $call['CONFIG_ID']), 'limit' => 1)); $queueUser = $res->fetch(); if ($queueUser) { $arFields["PORTAL_USER_ID"] = $queueUser['USER_ID']; } } if (strlen($arFields["PHONE_NUMBER"]) > 0 && $arFields["PORTAL_USER_ID"] > 0 && $params["CALL_FAILED_CODE"] != 423) { $plusSymbol = strlen($arFields["PHONE_NUMBER"]) >= 10 ? '+' : ''; if ($arFields["INCOMING"] == CVoxImplantMain::CALL_OUTGOING) { if ($arFields['CALL_FAILED_CODE'] == '603-S') { $message = GetMessage('VI_OUT_CALL_DECLINE_SELF', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 603) { $message = GetMessage('VI_OUT_CALL_DECLINE', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 486) { $message = GetMessage('VI_OUT_CALL_BUSY', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 480) { $message = GetMessage('VI_OUT_CALL_UNAVAILABLE', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 404 || $arFields['CALL_FAILED_CODE'] == 484) { $message = GetMessage('VI_OUT_CALL_ERROR_NUMBER', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 402) { $message = GetMessage('VI_OUT_CALL_NO_MONEY', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { $message = GetMessage('VI_OUT_CALL_END', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]')); } } } } } } } else { if ($arFields['CALL_FAILED_CODE'] == 304) { if (strlen($params['URL']) > 0) { $subMessage = GetMessage('VI_CALL_VOICEMAIL', array('#LINK_START#' => '[PCH=' . $orm->getId() . ']', '#LINK_END#' => '[/PCH]')); } else { $subMessage = '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]'; } $message = GetMessage('VI_IN_CALL_SKIP', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => $subMessage)); } else { $message = GetMessage('VI_IN_CALL_END', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]')); } } self::SendMessageToChat($arFields["PORTAL_USER_ID"], $arFields["PHONE_NUMBER"], $arFields["INCOMING"], $message); } if ($call['CRM'] == 'Y') { CVoxImplantCrmHelper::UpdateCall($arFields); } if (strlen($params['URL']) > 0) { $attachToCrm = $call['CRM'] == 'Y'; $startDownloadAgent = false; $recordLimit = COption::GetOptionInt("voximplant", "record_limit"); if ($recordLimit > 0 && !CVoxImplantAccount::IsPro()) { $sipConnectorActive = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); if ($params['PORTAL_TYPE'] == CVoxImplantConfig::MODE_SIP && $sipConnectorActive) { $startDownloadAgent = true; } else { $recordMonth = COption::GetOptionInt("voximplant", "record_month"); if (!$recordMonth) { $recordMonth = date('Ym'); COption::SetOptionInt("voximplant", "record_month", $recordMonth); } $recordCount = CGlobalCounter::GetValue('vi_records', CGlobalCounter::ALL_SITES); if ($recordCount < $recordLimit) { CGlobalCounter::Increment('vi_records', CGlobalCounter::ALL_SITES, false); $startDownloadAgent = true; } else { if ($recordMonth < date('Ym')) { COption::SetOptionInt("voximplant", "record_month", date('Ym')); CGlobalCounter::Set('vi_records', 1, CGlobalCounter::ALL_SITES, false); CGlobalCounter::Set('vi_records_skipped', 0, CGlobalCounter::ALL_SITES, false); $startDownloadAgent = true; } else { CGlobalCounter::Increment('vi_records_skipped', CGlobalCounter::ALL_SITES, false); } } CVoxImplantHistory::WriteToLog(array('limit' => $recordLimit, 'saved' => CGlobalCounter::GetValue('vi_records', CGlobalCounter::ALL_SITES), 'skipped' => CGlobalCounter::GetValue('vi_records_skipped', CGlobalCounter::ALL_SITES), 'save to portal' => $startDownloadAgent ? 'Y' : 'N'), 'STATUS OF RECORD LIMIT'); } } else { $startDownloadAgent = true; } if ($startDownloadAgent) { self::DownloadAgent($orm->getId(), $params['URL'], $attachToCrm); } } if (strlen($params["ACCOUNT_PAYED"]) > 0 && in_array($params["ACCOUNT_PAYED"], array('Y', 'N'))) { CVoxImplantAccount::SetPayedFlag($params["ACCOUNT_PAYED"]); } foreach (GetModuleEvents("voximplant", "onCallEnd", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(array('CALL_ID' => $arFields['CALL_ID'], 'CALL_TYPE' => $arFields['INCOMING'], 'PHONE_NUMBER' => $arFields['PHONE_NUMBER'], 'PORTAL_NUMBER' => $arFields['PORTAL_NUMBER'], 'PORTAL_USER_ID' => $arFields['PORTAL_USER_ID'], 'CALL_DURATION' => $arFields['CALL_DURATION'], 'CALL_START_DATE' => $arFields['CALL_START_DATE'], 'COST' => $arFields['COST'], 'COST_CURRENCY' => $arFields['COST_CURRENCY'], 'CALL_FAILED_CODE' => $arFields['CALL_FAILED_CODE'], 'CALL_FAILED_REASON' => $arFields['CALL_FAILED_REASON']))); } return true; }
public static function GetMobileTemplateJS($arParams, $arTemplate) { global $USER; $ppStatus = 'false'; $ppServerStatus = 'false'; $updateStateInterval = 'auto'; if (CModule::IncludeModule("pull")) { $ppStatus = CPullOptions::ModuleEnable() ? 'true' : 'false'; $ppServerStatus = CPullOptions::GetNginxStatus() ? 'true' : 'false'; $updateStateInterval = CPullOptions::GetNginxStatus() ? self::GetSessionLifeTime() : 80; if ($updateStateInterval > 100) { if ($updateStateInterval > 3600) { $updateStateInterval = 3600; } $updateStateInterval = $updateStateInterval - 60; } } $diskStatus = CIMDisk::Enabled(); $phoneSipAvailable = false; $phoneDeviceActive = false; $phoneEnabled = self::CheckPhoneStatus() && CModule::IncludeModule('mobileapp') && \Bitrix\MobileApp\Mobile::getInstance()->isWebRtcSupported(); if ($phoneEnabled && CModule::IncludeModule('voximplant')) { $phoneSipAvailable = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); $phoneDeviceActive = CVoxImplantUser::GetPhoneActive($USER->GetId()); } $mobileAction = isset($arTemplate["ACTION"]) ? $arTemplate["ACTION"] : 'none'; $mobileCallMethod = isset($arTemplate["CALL_METHOD"]) ? $arTemplate["CALL_METHOD"] : 'device'; $userColor = isset($arTemplate['CONTACT_LIST']['users'][$USER->GetID()]['color']) ? $arTemplate['CONTACT_LIST']['users'][$USER->GetID()]['color'] : ''; $sJS = "\n\t\t\tBX.ready(function() {\n\t\t\t\tBXIM = new BX.ImMobile({\n\t\t\t\t\t'mobileAction': '" . $mobileAction . "',\n\t\t\t\t\t'mobileCallMethod': '" . $mobileCallMethod . "',\n\n\t\t\t\t\t'colors': " . (IM\Color::isEnabled() ? CUtil::PhpToJSObject(IM\Color::getSafeColorNames()) : 'false') . ",\n\t\t\t\t\t'mailCount': " . intval($arTemplate["MAIL_COUNTER"]) . ",\n\t\t\t\t\t'notifyCount': " . intval($arTemplate["NOTIFY_COUNTER"]) . ",\n\t\t\t\t\t'messageCount': " . intval($arTemplate["MESSAGE_COUNTER"]) . ",\n\t\t\t\t\t'counters': " . (empty($arTemplate['COUNTERS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['COUNTERS'])) . ",\n\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t'updateStateInterval': '" . $updateStateInterval . "',\n\t\t\t\t\t'openChatEnable': " . (CIMMessenger::CheckEnableOpenChat() ? 'true' : 'false') . ",\n\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixNetwork': " . (CIMMessenger::CheckNetwork() ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixNetwork2': " . (CIMMessenger::CheckNetwork2() ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrix24': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrix24Admin': " . (CModule::IncludeModule('bitrix24') && CBitrix24::IsPortalAdmin($USER->GetId()) ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrix24net': " . (IsModuleInstalled('b24network') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixXmpp': " . (IsModuleInstalled('xmpp') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixMobile': " . (IsModuleInstalled('mobile') ? 'true' : 'false') . ",\n\t\t\t\t\t'desktopStatus': " . (CIMMessenger::CheckDesktopStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t'desktopVersion': " . CIMMessenger::GetDesktopVersion() . ",\n\t\t\t\t\t'language': '" . LANGUAGE_ID . "',\n\n\t\t\t\t\t'smile': " . (empty($arTemplate['SMILE']) ? '{}' : CUtil::PhpToJSObject($arTemplate["SMILE"])) . ",\n\t\t\t\t\t'smileSet': " . (empty($arTemplate['SMILE_SET']) ? '{}' : CUtil::PhpToJSObject($arTemplate["SMILE_SET"])) . ",\n\t\t\t\t\t'settings': " . (empty($arTemplate['SETTINGS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['SETTINGS'])) . ",\n\t\t\t\t\t'settingsNotifyBlocked': " . (empty($arTemplate['SETTINGS_NOTIFY_BLOCKED']) ? '{}' : CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])) . ",\n\n\t\t\t\t\t'notify': " . (empty($arTemplate['NOTIFY']['notify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])) . ",\n\t\t\t\t\t'unreadNotify' : " . (empty($arTemplate['NOTIFY']['unreadNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])) . ",\n\t\t\t\t\t'flashNotify' : " . (empty($arTemplate['NOTIFY']['flashNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])) . ",\n\t\t\t\t\t'countNotify' : " . intval($arTemplate['NOTIFY']['countNotify']) . ",\n\t\t\t\t\t'loadNotify' : " . ($arTemplate['NOTIFY']['loadNotify'] ? 'true' : 'false') . ",\n\n\t\t\t\t\t'recent': " . (empty($arTemplate['RECENT']) && $arTemplate['RECENT'] !== false ? '[]' : CUtil::PhpToJSObject($arTemplate['RECENT'])) . ",\n\t\t\t\t\t'users': " . (empty($arTemplate['CONTACT_LIST']['users']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])) . ",\n\t\t\t\t\t'groups': " . (empty($arTemplate['CONTACT_LIST']['groups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])) . ",\n\t\t\t\t\t'userInGroup': " . (empty($arTemplate['CONTACT_LIST']['userInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])) . ",\n\t\t\t\t\t'woGroups': " . (empty($arTemplate['CONTACT_LIST']['woGroups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])) . ",\n\t\t\t\t\t'woUserInGroup': " . (empty($arTemplate['CONTACT_LIST']['woUserInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])) . ",\n\t\t\t\t\t'chat': " . (empty($arTemplate['CHAT']['chat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])) . ",\n\t\t\t\t\t'userInChat': " . (empty($arTemplate['CHAT']['userInChat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])) . ",\n\t\t\t\t\t'userChatBlockStatus': " . (empty($arTemplate['CHAT']['userChatBlockStatus']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userChatBlockStatus'])) . ",\n\t\t\t\t\t'message' : " . (empty($arTemplate['MESSAGE']['message']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])) . ",\n\t\t\t\t\t'files' : " . (empty($arTemplate['MESSAGE']['files']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['files'])) . ",\n\t\t\t\t\t'showMessage' : " . (empty($arTemplate['MESSAGE']['usersMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])) . ",\n\t\t\t\t\t'unreadMessage' : " . (empty($arTemplate['MESSAGE']['unreadMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])) . ",\n\t\t\t\t\t'flashMessage' : " . (empty($arTemplate['MESSAGE']['flashMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])) . ",\n\t\t\t\t\t'history' : {},\n\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG'])) . "'" : 'false') . ",\n\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY'])) . "'" : 'false') . ",\n\t\t\t\t\t'openNotify' : " . (isset($_GET['IM_NOTIFY']) && $_GET['IM_NOTIFY'] == 'Y' ? 'true' : 'false') . ",\n\t\t\t\t\t'openSettings' : " . (isset($_GET['IM_SETTINGS']) ? $_GET['IM_SETTINGS'] == 'Y' ? "'true'" : "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_SETTINGS'])) . "'" : 'false') . ",\n\n\t\t\t\t\t'currentTab' : '" . ($arTemplate['CURRENT_TAB'] ? CUtil::JSEscape($arTemplate['CURRENT_TAB']) : 0) . "',\n\t\t\t\t\t'generalChatId': " . CIMChat::GetGeneralChatId() . ",\n\t\t\t\t\t'canSendMessageGeneralChat': " . (CIMChat::CanSendMessageToGeneralChat($USER->GetID()) ? 'true' : 'false') . ",\n\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t'userEmail': '" . CUtil::JSEscape($USER->GetEmail()) . "',\n\t\t\t\t\t'userColor': '" . IM\Color::getCode($userColor) . "',\n\t\t\t\t\t'userGender': '" . IM\User::getInstance()->getGender() . "',\n\t\t\t\t\t'userExtranet': " . (IM\User::getInstance()->isExtranet() ? 'true' : 'false') . ",\n\t\t\t\t\t'webrtc': {'turnServer' : '" . (empty($arTemplate['TURN_SERVER']) ? '' : CUtil::JSEscape($arTemplate['TURN_SERVER'])) . "', 'turnServerLogin' : '" . (empty($arTemplate['TURN_SERVER_LOGIN']) ? '' : CUtil::JSEscape($arTemplate['TURN_SERVER_LOGIN'])) . "', 'turnServerPassword' : '" . (empty($arTemplate['TURN_SERVER_PASSWORD']) ? '' : CUtil::JSEscape($arTemplate['TURN_SERVER_PASSWORD'])) . "', 'mobileSupport': " . ($arTemplate['WEBRTC_MOBILE_SUPPORT'] ? 'true' : 'false') . ", 'phoneEnabled': " . ($phoneEnabled ? 'true' : 'false') . ", 'phoneSipAvailable': " . ($phoneSipAvailable ? 'true' : 'false') . "},\n\t\t\t\t\t'disk': {'enable' : " . ($diskStatus ? 'true' : 'false') . "},\n\t\t\t\t\t'path' : {'profile' : '" . (empty($arTemplate['PATH_TO_USER_PROFILE']) ? '' : CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE'])) . "', 'profileTemplate' : '" . (empty($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE']) ? '' : CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'])) . "', 'mail' : '" . (empty($arTemplate['PATH_TO_USER_MAIL']) ? '' : CUtil::JSEscape($arTemplate['PATH_TO_USER_MAIL'])) . "'}\n\t\t\t\t});\n\t\t\t});\n\t\t"; return $sJS; }