public static function GetConfigByUserId($userId) { $userId = intval($userId); if ($userId > 0) { $viUser = new CVoxImplantUser(); $userInfo = $viUser->GetUserInfo($userId); if ($userInfo['user_backphone'] == '') { $userInfo['user_backphone'] = CVoxImplantConfig::LINK_BASE_NUMBER; } } else { $userInfo = array(); $userInfo['user_backphone'] = CVoxImplantConfig::GetPortalNumber(); $userInfo['user_extranet'] = false; } if ($userInfo['user_extranet']) { $result = array('error' => array('code' => 'EXTRANAET', 'msg' => 'Extranet user can not use telephony')); } else { if ($userInfo['user_backphone'] == CVoxImplantPhone::GetLinkNumber() || $userInfo['user_backphone'] == CVoxImplantConfig::LINK_BASE_NUMBER) { $result = self::GetLinkConfig(); } else { $result = CVoxImplantConfig::GetConfigBySearchId($userInfo['user_backphone']); if (isset($result['ERROR']) && strlen($result['ERROR']) > 0) { $result = self::GetLinkConfig(); } } } $result['USER_ID'] = $userId; return $result; }
public static function Invite($callId, $transferUserId) { $transferUserId = intval($transferUserId); if ($transferUserId <= 0) { return false; } $res = VI\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'USER_ID', 'CALLER_ID', 'CRM', 'TRANSFER_USER_ID', 'ACCESS_URL'), 'filter' => array('=CALL_ID' => $callId))); $call = $res->fetch(); if (!$call) { return false; } if ($call['TRANSFER_USER_ID'] > 0) { self::Cancel($callId); } $call['TRANSFER_USER_ID'] = $transferUserId; VI\CallTable::update($call['ID'], array('TRANSFER_USER_ID' => $transferUserId)); $call['USER_HAVE_PHONE'] = 'N'; $res = CVoxImplantUser::GetList(array('select' => array('ID', 'IS_ONLINE_CUSTOM', 'UF_VI_PHONE', 'ACTIVE'), 'filter' => array('=ID' => $call['TRANSFER_USER_ID'], '=ACTIVE' => 'Y'))); if ($userData = $res->fetch()) { $call['USER_HAVE_PHONE'] = $userData['UF_VI_PHONE']; } $command['COMMAND'] = 'inviteTransfer'; $command['OPERATOR_ID'] = $call['USER_ID']; $command['TRANSFER_USER_ID'] = $call['TRANSFER_USER_ID']; $command['USER_HAVE_PHONE'] = $call['USER_HAVE_PHONE']; $http = new \Bitrix\Main\Web\HttpClient(); $http->waitResponse(false); $http->post($call['ACCESS_URL'], json_encode($command)); $crmData = array(); if ($call['CRM'] == 'Y') { $crmData = CVoxImplantCrmHelper::GetDataForPopup($call['CALL_ID'], $call['CALLER_ID'], $transferUserId); } self::SendPullEvent(array('COMMAND' => 'inviteTransfer', 'USER_ID' => $transferUserId, 'CALL_ID' => $call['CALL_ID'], 'CALLER_ID' => $call['CALLER_ID'], 'CRM' => $crmData)); return true; }
$ViMain = new CVoxImplantMain($userId); $ViMain->ClearUserInfo(); $ViMain->ClearAccountInfo(); } else { if ($_POST['COMMAND'] == 'init') { $ViMain = new CVoxImplantMain($userId); $result = $ViMain->GetDialogInfo($_POST['NUMBER']); if ($result) { echo CUtil::PhpToJsObject(array('DIALOG_ID' => $result['DIALOG_ID'], 'HR_PHOTO' => $result['HR_PHOTO'], 'ERROR' => '')); } else { echo CUtil::PhpToJsObject(array('CODE' => $ViMain->GetError()->code, 'ERROR' => $ViMain->GetError()->msg)); } } else { if ($_POST['COMMAND'] == 'deviceStartCall') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); if (CVoxImplantUser::GetPhoneActive($USER->GetId())) { CVoxImplantOutgoing::StartCall($USER->GetId(), $_POST['PARAMS']['NUMBER']); } } else { if ($_POST['COMMAND'] == 'deviceHungup') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantIncoming::SendCommand(array('CALL_ID' => $_POST['PARAMS']['CALL_ID'], 'COMMAND' => CVoxImplantIncoming::RULE_HUNGUP)); } else { if ($_POST['COMMAND'] == 'wait') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantIncoming::SendCommand(array('CALL_ID' => $_POST['PARAMS']['CALL_ID'], 'COMMAND' => CVoxImplantIncoming::RULE_WAIT)); } else { if ($_POST['COMMAND'] == 'answer') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantIncoming::SendCommand(array('CALL_ID' => $_POST['PARAMS']['CALL_ID'], 'COMMAND' => CVoxImplantIncoming::RULE_WAIT)); CVoxImplantIncoming::SendPullEvent(array('COMMAND' => 'answer_self', 'USER_ID' => $userId, 'CALL_ID' => $_POST['PARAMS']['CALL_ID']));
public function GetOneTimeKey($key) { $ViAccount = new CVoxImplantAccount(); $accountName = $ViAccount->GetAccountName(); if (!$accountName) { $this->error = new CVoxImplantError(__METHOD__, $ViAccount->GetError()->code, GetMessage('VI_GET_ACCOUNT_INFO', array('#CODE#' => $ViAccount->GetError()->code))); return false; } $ViUser = new CVoxImplantUser(); $userInfo = $ViUser->GetUserInfo($this->userId); if (!$userInfo) { $this->error = new CVoxImplantError(__METHOD__, $ViUser->GetError()->code, GetMessage('VI_GET_USER_INFO', array('#CODE#' => $ViUser->GetError()->code))); return false; } return md5($key . "|" . md5($userInfo['user_login'] . ":voximplant.com:" . $userInfo['user_password'])); }
public static function GetQueue($params) { $loadQueue = !isset($params['LOAD_QUEUE']) || $params['LOAD_QUEUE'] == 'Y'; $sendInvite = !isset($params['SEND_INVITE']) || $params['SEND_INVITE'] == 'Y'; // TODO check $params $result = array('COMMAND' => CVoxImplantIncoming::RULE_HUNGUP); if (isset($params['CONFIG'])) { $config = $params['CONFIG']; } else { $config = self::GetConfigBySearchId($params['SEARCH_ID']); if (!$config) { $result['COMMAND'] = CVoxImplantIncoming::RULE_HUNGUP; return $result; } $params['CONFIG'] = $config; } if (isset($params['LAST_USER_ID']) && $params['LAST_USER_ID'] > 0) { self::SendPullEvent(array('COMMAND' => 'timeout', 'USER_ID' => intval($params['LAST_USER_ID']), 'CALL_ID' => $params['CALL_ID'], 'MARK' => 'timeout_inc_3')); } $res = CVoxImplantUser::QueuedGetList(array('select' => array('ID', 'USER_ID', 'IS_ONLINE_CUSTOM', 'UF_VI_PHONE' => 'USER.UF_VI_PHONE', 'ACTIVE' => 'USER.ACTIVE'), 'filter' => array('=CONFIG_ID' => $config['ID']), 'order' => array('LAST_ACTIVITY_DATE' => 'asc'))); $findUserId = 0; if ($loadQueue) { CModule::IncludeModule('pull'); while ($queueUser = $res->fetch()) { $orm = \Bitrix\Pull\PushTable::getList(array('select' => array('ID'), 'filter' => array('=USER_ID' => $queueUser['USER_ID']))); $queueUser['USER_HAVE_MOBILE'] = $orm->fetch() ? 'Y' : 'N'; if ($queueUser['IS_ONLINE_CUSTOM'] != 'Y' && $queueUser['UF_VI_PHONE'] != 'Y' && $queueUser['USER_HAVE_MOBILE'] != 'Y' || $queueUser['ACTIVE'] != 'Y') { continue; } if ($config['TIMEMAN'] == "Y" && !CVoxImplantUser::GetActiveStatusByTimeman($queueUser['USER_ID'])) { continue; } else { if (!$findUserId) { VI\QueueTable::update($queueUser['ID'], array('LAST_ACTIVITY_DATE' => new FieldType\DateTime())); $findUserId = $queueUser['ID']; $result['USER_ID'] = $queueUser['USER_ID']; } $result['COMMAND'] = CVoxImplantIncoming::RULE_WAIT; $result['TYPE_CONNECT'] = self::TYPE_CONNECT_QUEUE; $result['USERS'][] = array('USER_ID' => $queueUser['USER_ID'], 'USER_HAVE_PHONE' => $queueUser['UF_VI_PHONE'] == 'Y' ? 'Y' : 'N', 'USER_HAVE_MOBILE' => $queueUser['USER_HAVE_MOBILE']); } } } else { while ($queueUser = $res->fetch()) { if (intval($params['LAST_USER_ID']) == $queueUser['USER_ID']) { continue; } else { self::SendPullEvent(array('COMMAND' => 'timeout', 'USER_ID' => $queueUser['USER_ID'], 'CALL_ID' => $params['CALL_ID'], 'MARK' => 'timeout_inc_4')); } } } if ($findUserId) { if ($sendInvite) { $crmData = array(); foreach ($result['USERS'] as $queueUser) { if ($config['CRM'] == 'Y') { $crmData = CVoxImplantCrmHelper::GetDataForPopup($params['CALL_ID'], $params['CALLER_ID'], $queueUser['USER_ID']); } self::SendPullEvent(array('COMMAND' => 'invite', 'USER_ID' => $queueUser['USER_ID'], 'CALL_ID' => $params['CALL_ID'], 'CALLER_ID' => $params['CALLER_ID'], 'PHONE_NAME' => $config['PHONE_TITLE'], 'TYPE_CONNECT' => $result['TYPE_CONNECT'], 'CONFIG' => array('RECORDING' => $config['RECORDING']), 'CRM' => $crmData)); } } } else { $userId = intval($params['LAST_USER_ID']); if ($userId <= 0) { $res = VI\QueueTable::getList(array('select' => array('ID', 'USER_ID', 'ACTIVE' => 'USER.ACTIVE'), 'order' => array('LAST_ACTIVITY_DATE' => 'asc'), 'filter' => array('=CONFIG_ID' => $config['ID']), 'limit' => 1)); $queueUser = $res->fetch(); if ($queueUser && $queueUser['ACTIVE']) { VI\QueueTable::update($queueUser['ID'], array('LAST_ACTIVITY_DATE' => new FieldType\DateTime())); $userId = $queueUser['USER_ID']; } } if ($config['NO_ANSWER_RULE'] == CVoxImplantIncoming::RULE_PSTN_SPECIFIC) { if (strlen($config['FORWARD_NUMBER']) > 0) { $result['COMMAND'] = CVoxImplantIncoming::RULE_PSTN; $result['PHONE_NUMBER'] = NormalizePhone($config['FORWARD_NUMBER'], 1); $result['USER_ID'] = $userId; } } else { if ($config['NO_ANSWER_RULE'] != CVoxImplantIncoming::RULE_HUNGUP) { $result['COMMAND'] = CVoxImplantIncoming::RULE_VOICEMAIL; $result['USER_ID'] = $userId; if ($config['NO_ANSWER_RULE'] == CVoxImplantIncoming::RULE_PSTN && $userId > 0) { $userPhone = CVoxImplantPhone::GetUserPhone($userId); if ($userPhone) { $result['COMMAND'] = CVoxImplantIncoming::RULE_PSTN; $result['PHONE_NUMBER'] = $userPhone; $result['USER_ID'] = $userId; } } } else { $result['COMMAND'] = CVoxImplantIncoming::RULE_HUNGUP; } } } return $result; }
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) - 10; } else { $updateStateInterval = $updateStateInterval - 60; } } } $diskStatus = CIMDisk::Enabled(); if ($arTemplate['INIT'] == 'Y') { $phonePhoneDirectCall = false; $phoneSipAvailable = 0; $phoneEnabled = self::CheckPhoneStatus(); if ($phoneEnabled && CModule::IncludeModule('voximplant')) { $phoneSipAvailable = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); $phoneDeviceActive = CVoxImplantUser::GetPhoneActive($USER->GetId()); $phoneDeviceCall = 1; //CVoxImplantUser::GetCallByPhone($USER->GetId()); } $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 = "\n\t\t\t\tBX.ready(function() {\n\t\t\t\t\tBXIM = new BX.IM(BX('bx-notifier-panel'), {\n\t\t\t\t\t\t'mailCount': " . $arTemplate["MAIL_COUNTER"] . ",\n\t\t\t\t\t\t'notifyCount': " . $arTemplate["NOTIFY_COUNTER"] . ",\n\t\t\t\t\t\t'messageCount': " . $arTemplate["MESSAGE_COUNTER"] . ",\n\t\t\t\t\t\t'counters': " . (empty($arTemplate['COUNTERS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['COUNTERS'])) . ",\n\t\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t\t'updateStateInterval': '" . $updateStateInterval . "',\n\t\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixNetworkStatus': " . (CIMMessenger::CheckNetworkStatus() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Status': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Admin': " . (CModule::IncludeModule('bitrix24') && CBitrix24::IsPortalAdmin($USER->GetId()) ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24net': " . (IsModuleInstalled('b24network') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixXmpp': " . (IsModuleInstalled('xmpp') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktop': " . $arTemplate["DESKTOP"] . ",\n\t\t\t\t\t\t'desktopStatus': " . (CIMMessenger::CheckDesktopStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktopVersion': " . CIMMessenger::GetDesktopVersion() . ",\n\t\t\t\t\t\t'desktopLinkOpen': " . $arTemplate["DESKTOP_LINK_OPEN"] . ",\n\t\t\t\t\t\t'language': '" . LANGUAGE_ID . "',\n\n\t\t\t\t\t\t'smile': " . CUtil::PhpToJSObject($arTemplate["SMILE"]) . ",\n\t\t\t\t\t\t'smileSet': " . CUtil::PhpToJSObject($arTemplate["SMILE_SET"]) . ",\n\t\t\t\t\t\t'settings': " . CUtil::PhpToJSObject($arTemplate['SETTINGS']) . ",\n\t\t\t\t\t\t'settingsNotifyBlocked': " . (empty($arTemplate['SETTINGS_NOTIFY_BLOCKED']) ? '{}' : CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])) . ",\n\n\t\t\t\t\t\t'notify': " . (empty($arTemplate['NOTIFY']['notify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])) . ",\n\t\t\t\t\t\t'unreadNotify' : " . (empty($arTemplate['NOTIFY']['unreadNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])) . ",\n\t\t\t\t\t\t'flashNotify' : " . (empty($arTemplate['NOTIFY']['flashNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])) . ",\n\t\t\t\t\t\t'countNotify' : " . intval($arTemplate['NOTIFY']['countNotify']) . ",\n\t\t\t\t\t\t'loadNotify' : " . ($arTemplate['NOTIFY']['loadNotify'] ? 'true' : 'false') . ",\n\n\t\t\t\t\t\t'recent': " . CUtil::PhpToJSObject($arTemplate['RECENT']) . ",\n\t\t\t\t\t\t'users': " . (empty($arTemplate['CONTACT_LIST']['users']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])) . ",\n\t\t\t\t\t\t'groups': " . (empty($arTemplate['CONTACT_LIST']['groups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])) . ",\n\t\t\t\t\t\t'userInGroup': " . (empty($arTemplate['CONTACT_LIST']['userInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])) . ",\n\t\t\t\t\t\t'woGroups': " . (empty($arTemplate['CONTACT_LIST']['woGroups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])) . ",\n\t\t\t\t\t\t'woUserInGroup': " . (empty($arTemplate['CONTACT_LIST']['woUserInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])) . ",\n\t\t\t\t\t\t'chat': " . (empty($arTemplate['CHAT']['chat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])) . ",\n\t\t\t\t\t\t'userInChat': " . (empty($arTemplate['CHAT']['userInChat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])) . ",\n\t\t\t\t\t\t'userChatBlockStatus': " . (empty($arTemplate['CHAT']['userChatBlockStatus']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userChatBlockStatus'])) . ",\n\t\t\t\t\t\t'message' : " . (empty($arTemplate['MESSAGE']['message']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])) . ",\n\t\t\t\t\t\t'files' : " . (empty($arTemplate['MESSAGE']['files']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['files'])) . ",\n\t\t\t\t\t\t'showMessage' : " . (empty($arTemplate['MESSAGE']['usersMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])) . ",\n\t\t\t\t\t\t'unreadMessage' : " . (empty($arTemplate['MESSAGE']['unreadMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])) . ",\n\t\t\t\t\t\t'flashMessage' : " . (empty($arTemplate['MESSAGE']['flashMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])) . ",\n\t\t\t\t\t\t'history' : {},\n\t\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openNotify' : " . (isset($_GET['IM_NOTIFY']) && $_GET['IM_NOTIFY'] == 'Y' ? 'true' : 'false') . ",\n\t\t\t\t\t\t'openSettings' : " . (isset($_GET['IM_SETTINGS']) ? $_GET['IM_SETTINGS'] == 'Y' ? "'true'" : "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_SETTINGS'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'currentTab' : '" . CUtil::JSEscape($arTemplate['CURRENT_TAB']) . "',\n\t\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t\t'userEmail': '" . CUtil::JSEscape($USER->GetEmail()) . "',\n\t\t\t\t\t\t'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') . ", 'phoneDeviceActive': '" . ($phoneDeviceActive ? 'Y' : 'N') . "', 'phoneDeviceCall': '" . ($phoneDeviceCall ? 'Y' : 'N') . "'},\n\t\t\t\t\t\t'disk': {'enable' : " . ($diskStatus ? 'true' : 'false') . "},\n\t\t\t\t\t\t'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) . "'}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t"; } else { $sJS = "\n\t\t\t\tBX.ready(function() {\n\t\t\t\t\tBXIM = new BX.IM(BX('bx-notifier-panel'), {\n\t\t\t\t\t\t'init': false,\n\t\t\t\t\t\t'settings': " . CUtil::PhpToJSObject($arTemplate['SETTINGS']) . ",\n\t\t\t\t\t\t'updateStateInterval': '" . $updateStateInterval . "',\n\t\t\t\t\t\t'desktop': " . $arTemplate["DESKTOP"] . ",\n\t\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Status': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixXmpp': " . (IsModuleInstalled('xmpp') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'notify' : {},\n\t\t\t\t\t\t'users' : {},\n\t\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t\t'userEmail': '" . CUtil::JSEscape($USER->GetEmail()) . "',\n\n\t\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openSettings' : " . (isset($_GET['IM_SETTINGS']) && $_GET['IM_SETTINGS'] == 'Y' ? "'true'" : 'false') . ",\n\n\t\t\t\t\t\t'disk': {'enable' : '" . ($diskStatus ? 'true' : 'false') . "'},\n\t\t\t\t\t\t'path' : {'profile' : '" . $arTemplate['PATH_TO_USER_PROFILE'] . "', 'profileTemplate' : '" . $arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'] . "', 'mail' : '" . $arTemplate['PATH_TO_USER_MAIL'] . "'}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t"; } return $sJS; }
public static function QueuedGetList($params) { $query = new \Bitrix\Main\Entity\Query(Bitrix\Voximplant\QueueTable::getEntity()); $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN %s > ' . CVoxImplantUser::GetLastActivityDateAgo() . ' THEN \'Y\' ELSE \'N\' END', array('USER.LAST_ACTIVITY_DATE'))); if (isset($params['select'])) { $query->setSelect($params['select']); } else { $query->addSelect('ID')->addSelect('IS_ONLINE_CUSTOM'); } if (isset($params['filter'])) { $query->setFilter($params['filter']); } if (isset($params['order'])) { $query->setOrder($params['order']); } return $query->exec(); }
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; }
public static function GetNextInQueue($params) { CVoxImplantHistory::WriteToLog($params, '!!!GetNextInQueue'); $fistInQueue = isset($params['FIRST_IN_QUEUE']) && $params['FIRST_IN_QUEUE'] == 'Y'; // TODO check $params $result = array('COMMAND' => CVoxImplantIncoming::RULE_HUNGUP); if (!$fistInQueue) { $res = VI\CallTable::getList(array('select' => array('ID', 'STATUS'), 'filter' => array('=CALL_ID' => $params['CALL_ID']))); $call = $res->fetch(); if ($call['STATUS'] == VI\CallTable::STATUS_CONNECTED) { $result['COMMAND'] = CVoxImplantIncoming::RULE_TALK; return $result; } } if (isset($params['CONFIG'])) { $config = $params['CONFIG']; } else { $config = self::GetConfigBySearchId($params['SEARCH_ID']); if (!$config) { $result['COMMAND'] = CVoxImplantIncoming::RULE_HUNGUP; return $result; } $params['CONFIG'] = $config; } if (isset($params['LAST_USER_ID']) && $params['LAST_USER_ID'] > 0) { self::SendPullEvent(array('COMMAND' => 'timeout', 'USER_ID' => intval($params['LAST_USER_ID']), 'CALL_ID' => $params['CALL_ID'])); } $filter = array('=CONFIG_ID' => $config['ID']); if (isset($params['EXCLUDE_USERS'])) { $excludeUsers = $params['EXCLUDE_USERS']; if (!empty($excludeUsers)) { $filter['!=USER_ID'] = $excludeUsers; } } $res = CVoxImplantUser::QueuedGetList(array('select' => array('ID', 'USER_ID', 'IS_ONLINE_CUSTOM', 'UF_VI_PHONE' => 'USER.UF_VI_PHONE', 'ACTIVE' => 'USER.ACTIVE'), 'filter' => $filter, 'order' => array('LAST_ACTIVITY_DATE' => 'asc'))); $findActiveUser = false; while ($queueUser = $res->fetch()) { if ($queueUser['IS_ONLINE_CUSTOM'] != 'Y' && $queueUser['UF_VI_PHONE'] != 'Y' || $queueUser['ACTIVE'] != 'Y') { continue; } $findActiveUser = true; if ($config['TIMEMAN'] == "Y" && !CVoxImplantUser::GetActiveStatusByTimeman($queueUser['USER_ID'])) { $params['EXCLUDE_USERS'][] = $queueUser['USER_ID']; $params['LAST_USER_ID'] = 0; $result = self::GetNextInQueue($params); } else { VI\QueueTable::update($queueUser['ID'], array('LAST_ACTIVITY_DATE' => new FieldType\DateTime())); $result['COMMAND'] = CVoxImplantIncoming::RULE_WAIT; $result['TYPE_CONNECT'] = self::TYPE_CONNECT_QUEUE; $result['USER_ID'] = $queueUser['USER_ID']; $result['USER_HAVE_PHONE'] = $queueUser['UF_VI_PHONE'] == 'Y' ? 'Y' : 'N'; if (!$fistInQueue) { $crmData = array(); if ($config['CRM'] == 'Y') { $crmData = CVoxImplantCrmHelper::GetDataForPopup($params['CALL_ID'], $params['CALLER_ID'], $queueUser['USER_ID']); } self::SendPullEvent(array('COMMAND' => 'invite', 'USER_ID' => $queueUser['USER_ID'], 'CALL_ID' => $params['CALL_ID'], 'CALLER_ID' => $params['CALLER_ID'], 'PHONE_NAME' => $config['PHONE_TITLE'], 'CRM' => $crmData)); } } break; } if (!$findActiveUser) { $userId = intval($params['LAST_ANSWER_USER_ID']) > 0 ? intval($params['LAST_ANSWER_USER_ID']) : intval($params['LAST_USER_ID']); if ($userId <= 0) { $res = VI\QueueTable::getList(array('select' => array('ID', 'USER_ID', 'ACTIVE' => 'USER.ACTIVE'), 'order' => array('LAST_ACTIVITY_DATE' => 'asc'), 'filter' => array('=CONFIG_ID' => $config['ID']), 'limit' => 1)); $queueUser = $res->fetch(); if ($queueUser && $queueUser['ACTIVE']) { VI\QueueTable::update($queueUser['ID'], array('LAST_ACTIVITY_DATE' => new FieldType\DateTime())); $userId = $queueUser['USER_ID']; } } if ($config['NO_ANSWER_RULE'] != CVoxImplantIncoming::RULE_HUNGUP && (isset($params['LAST_ANSWER_USER_ID']) || isset($params['LAST_USER_ID']))) { $result['COMMAND'] = CVoxImplantIncoming::RULE_VOICEMAIL; $result['USER_ID'] = $userId; if ($config['NO_ANSWER_RULE'] == CVoxImplantIncoming::RULE_PSTN_SPECIFIC) { if (strlen($config['FORWARD_NUMBER']) <= 0) { $config['NO_ANSWER_RULE'] == CVoxImplantIncoming::RULE_PSTN; } else { $result['COMMAND'] = CVoxImplantIncoming::RULE_PSTN; $result['PHONE_NUMBER'] = NormalizePhone($config['FORWARD_NUMBER'], 1); $result['USER_ID'] = $userId; } } if ($config['NO_ANSWER_RULE'] == CVoxImplantIncoming::RULE_PSTN) { $userPhone = CVoxImplantPhone::GetUserPhone($userId); if ($userPhone) { $result['COMMAND'] = CVoxImplantIncoming::RULE_PSTN; $result['PHONE_NUMBER'] = $userPhone; $result['USER_ID'] = $userId; } } } else { $result['COMMAND'] = CVoxImplantIncoming::RULE_HUNGUP; } } return $result; }