public function GetStatus() { $ViHttp = new CVoxImplantHttp(); $result = $ViHttp->GetDocumentStatus(); if (!$result) { $this->error = new CVoxImplantError(__METHOD__, $ViHttp->GetError()->code, $ViHttp->GetError()->msg); return false; } $verifications = array(); foreach ($result as $key => $verification) { $regionName = GetMessage('VI_DOCS_COUNTRY_' . $verification->REGION); $regionName = strlen($regionName) > 0 ? $regionName : $verification->REGION; $verifications[$key]['REGION'] = $verification->REGION; $verifications[$key]['REGION_NAME'] = $regionName; $verifications[$key]['STATUS'] = $verification->STATUS; $verifications[$key]['STATUS_NAME'] = GetMessage('VI_DOCS_STATUS_' . $verification->STATUS); if ($verification->STATUS != 'VERIFIED' && $verification->UNVERIFIED_HOLD_UNTIL) { $data = new Bitrix\Main\Type\DateTime($verification->UNVERIFIED_HOLD_UNTIL, 'Y-m-d H:i:s'); $verifications[$key]['UNVERIFIED_HOLD_UNTIL'] = $data->format(Bitrix\Main\Type\Date::getFormat()); } else { $verifications[$key]['UNVERIFIED_HOLD_UNTIL'] = ''; } if (isset($verification->DOCUMENTS)) { foreach ($verification->DOCUMENTS as $document) { $data = new Bitrix\Main\Type\DateTime($document->UPLOADED, 'Y-m-d H:i:s'); $verifications[$key]['DOCUMENTS'][] = array('UPLOADED' => $data->format(Bitrix\Main\Type\DateTime::getFormat()), 'DOCUMENT_ID' => $document->DOCUMENT_ID, 'DOCUMENT_STATUS' => $document->DOCUMENT_STATUS, 'DOCUMENT_STATUS_NAME' => GetMessage('VI_DOCS_DOCUMENT_STATUS_' . $document->DOCUMENT_STATUS), 'IS_INDIVIDUAL' => $document->IS_INDIVIDUAL, 'IS_INDIVIDUAL_NAME' => GetMessage('VI_DOCS_IS_INDIVIDUAL_' . $document->IS_INDIVIDUAL), 'REVIEWER_COMMENT' => $document->REVIEWER_COMMENT); } } } return $verifications; }
public static function RequestService($params) { if (!in_array($params['TYPE'], array(self::OPERATOR_REQUEST_TYPE_TOLLFREE, self::OPERATOR_REQUEST_TYPE_LINE, self::OPERATOR_REQUEST_TYPE_NUMBER, self::OPERATOR_REQUEST_TYPE_CITY, self::OPERATOR_REQUEST_TYPE_CHANGE))) { return false; } $arSend = array('TYPE' => $params['TYPE']); $ViHttp = new CVoxImplantHttp(); $result = $ViHttp->AddServiceOrder($arSend); return $result ? true : false; }
public function UpdateAccountInfo() { $ViHttp = new CVoxImplantHttp(); $result = $ViHttp->GetAccountInfo(); if ($result) { $this->SetAccountName($result->account_name); $this->SetAccountBalance($result->account_balance); $this->SetAccountCurrency($result->account_currency); $this->SetAccountBetaAccess($result->account_beta_access); } else { if ($ViHttp->GetError()->error) { $this->error = new CVoxImplantError(__METHOD__, $ViHttp->GetError()->code, $ViHttp->GetError()->msg); return false; } } return true; }
public static function GetConfigBySearchId($searchId) { if (strlen($searchId) <= 0) { return array('ERROR' => 'Config is`t found for undefined number'); } $orm = VI\ConfigTable::getList(array('filter' => array('=SEARCH_ID' => (string) $searchId))); $config = $orm->fetch(); if (!$config) { $result = array('ERROR' => 'Config is`t found for number: ' . $searchId); } else { $result = $config; $result['PHONE_TITLE'] = $result['PHONE_NAME']; if ($result['PORTAL_MODE'] == self::MODE_SIP) { $viSip = new CVoxImplantSip(); $sipResult = $viSip->Get($config["ID"]); $result['PHONE_NAME'] = preg_replace("/[^0-9\\#\\*]/i", "", $result['PHONE_NAME']); $result['PHONE_NAME'] = strlen($result['PHONE_NAME']) >= 4 ? $result['PHONE_NAME'] : ''; $result['SIP_SERVER'] = $sipResult ? $sipResult['SERVER'] : ''; $result['SIP_LOGIN'] = $sipResult ? $sipResult['LOGIN'] : ''; $result['SIP_PASSWORD'] = $sipResult ? $sipResult['PASSWORD'] : ''; } if (strlen($result['FORWARD_NUMBER']) > 0) { $result["FORWARD_NUMBER"] = NormalizePhone($result['FORWARD_NUMBER'], 1); } if (strlen($result['WORKTIME_DAYOFF_NUMBER']) > 0) { $result["WORKTIME_DAYOFF_NUMBER"] = NormalizePhone($result['WORKTIME_DAYOFF_NUMBER'], 1); } // check work time $result['WORKTIME_SKIP_CALL'] = 'N'; if ($config['WORKTIME_ENABLE'] == 'Y') { $timezone = !empty($config["WORKTIME_TIMEZONE"]) ? new DateTimeZone($config["WORKTIME_TIMEZONE"]) : null; $numberDate = new Bitrix\Main\Type\DateTime(null, null, $timezone); if (!empty($config['WORKTIME_DAYOFF'])) { $daysOff = explode(",", $config['WORKTIME_DAYOFF']); $allWeekDays = array('MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6, 'SU' => 7); $currentWeekDay = $numberDate->format('N'); foreach ($daysOff as $day) { if ($currentWeekDay == $allWeekDays[$day]) { $result['WORKTIME_SKIP_CALL'] = "Y"; } } } if ($result['WORKTIME_SKIP_CALL'] !== "Y" && !empty($config['WORKTIME_HOLIDAYS'])) { $holidays = explode(",", $config['WORKTIME_HOLIDAYS']); $currentDay = $numberDate->format('d.m'); foreach ($holidays as $holiday) { if ($currentDay == $holiday) { $result['WORKTIME_SKIP_CALL'] = "Y"; } } } if ($result['WORKTIME_SKIP_CALL'] !== "Y" && !empty($config['WORKTIME_FROM']) && !empty($config['WORKTIME_TO'])) { $currentTime = $numberDate->format('G.i'); if (!($currentTime >= $config['WORKTIME_FROM'] && $currentTime <= $config['WORKTIME_TO'])) { $result['WORKTIME_SKIP_CALL'] = "Y"; } } if ($result['WORKTIME_SKIP_CALL'] === "Y") { $result['WORKTIME_DAYOFF_MELODY'] = CVoxImplantConfig::GetMelody('WORKTIME_DAYOFF_MELODY', $config['MELODY_LANG'], $config['WORKTIME_DAYOFF_MELODY']); } } if (CVoxImplantHttp::GetPortalType() == CVoxImplantHttp::TYPE_BITRIX24) { $result['PORTAL_URL'] = CVoxImplantHttp::GetServerAddress() . '/settings/info_receiver.php?b24_action=phone&b24_direct=y'; } else { $result['PORTAL_URL'] = CVoxImplantHttp::GetServerAddress() . '/services/telephony/info_receiver.php?b24_direct=y'; } $result['PORTAL_SIGN'] = CVoxImplantHttp::GetPortalSign(); $result['MELODY_WELCOME'] = CVoxImplantConfig::GetMelody('MELODY_WELCOME', $config['MELODY_LANG'], $config['MELODY_WELCOME']); $result['MELODY_VOICEMAIL'] = CVoxImplantConfig::GetMelody('MELODY_VOICEMAIL', $config['MELODY_LANG'], $config['MELODY_VOICEMAIL']); $result['MELODY_HOLD'] = CVoxImplantConfig::GetMelody('MELODY_HOLD', $config['MELODY_LANG'], $config['MELODY_HOLD']); $result['MELODY_WAIT'] = CVoxImplantConfig::GetMelody('MELODY_WAIT', $config['MELODY_LANG'], $config['MELODY_WAIT']); } 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 {
public static function GetPublicFolder() { return CVoxImplantHttp::GetPortalType() == CVoxImplantHttp::TYPE_BITRIX24 ? '/settings/telephony/' : '/services/telephony/'; }
public static function StartCall($userId, $phoneNumber) { $phoneNormalized = CVoxImplantPhone::Normalize($phoneNumber); $userId = intval($userId); if ($userId <= 0 || !$phoneNormalized) { return false; } $call = VI\CallTable::add(array('CALL_ID' => 'temp.' . md5($userId . $phoneNumber) . time(), 'USER_ID' => $userId, 'CALLER_ID' => $phoneNormalized, 'STATUS' => VI\CallTable::STATUS_CONNECTING, 'DATE_CREATE' => new FieldType\DateTime())); $viHttp = new CVoxImplantHttp(); $result = $viHttp->StartOutgoingCall($userId, $phoneNumber); VI\CallTable::update($call->GetId(), array('CALL_ID' => $result->call_id, 'ACCESS_URL' => $result->access_url, 'DATE_CREATE' => new FieldType\DateTime())); self::SendPullEvent(array('COMMAND' => 'outgoing', 'USER_ID' => $userId, 'PHONE_NUMBER' => $phoneNormalized, 'CALL_ID' => $result->call_id, 'CALL_DEVICE' => 'PHONE', 'EXTERNAL' => true)); return $result ? true : false; }
public static function sipConnectorStatus() { if (!CVoxImplantMain::CheckAccess()) { throw new \Bitrix\Rest\AccessException(); } $ViHttp = new CVoxImplantHttp(); $info = $ViHttp->GetSipInfo(); if (!$info || $ViHttp->GetError()->error) { throw new Bitrix\Rest\RestException($ViHttp->GetError()->msg, $ViHttp->GetError()->code, CRestServer::STATUS_WRONG_REQUEST); } $result = array('FREE_MINUTES' => intval($info->FREE), 'PAID' => $info->ACTIVE); if ($info->ACTIVE) { $result['PAID_DATE_END'] = CRestUtil::ConvertDate($info->DATE_END); } return $result; }
public function GetSipRegistrations($regId) { $viHttp = new CVoxImplantHttp(); $result = $viHttp->GetSipRegistrations($regId); if (!$result) { $this->error = new CVoxImplantError(__METHOD__, 'REG_ID_NOT_FOUND', GetMessage('VI_SIP_CONFIG_NOT_FOUND')); return false; } return $result; }
public function GetOnlineUsers() { $ViHttp = new CVoxImplantHttp(); $result = $ViHttp->GetOnlineUsers(); if (!$result || $ViHttp->GetError()->error) { $this->error = new CVoxImplantError(__METHOD__, $ViHttp->GetError()->code, $ViHttp->GetError()->msg); return false; } return $result->result; }
CVoxImplantHistory::WriteToLog($result, 'GET NEXT IN QUEUE'); } } echo json_encode($result); } } } } } } } } } } } else { if ($params['BX_TYPE'] == 'B24' && CVoxImplantHttp::RequestSign($params['BX_TYPE'], md5(implode("|", $params) . "|" . BX24_HOST_NAME)) === $hash || $params['BX_TYPE'] == 'CP' && CVoxImplantHttp::RequestSign($params['BX_TYPE'], md5(implode("|", $params))) === $hash) { if ($params["BX_COMMAND"] != "add_history" && isset($params['PHONE_NUMBER']) && isset($params['ACCOUNT_SEARCH_ID'])) { $params['PHONE_NUMBER'] = $params['ACCOUNT_SEARCH_ID']; } if ($params["BX_COMMAND"] == "add_history") { CVoxImplantHistory::WriteToLog($params, 'PORTAL ADD HISTORY'); if (isset($params['PORTAL_NUMBER']) && isset($params['ACCOUNT_SEARCH_ID'])) { $params['PORTAL_NUMBER'] = $params['ACCOUNT_SEARCH_ID']; } CVoxImplantHistory::Add($params); $ViAccount = new CVoxImplantAccount(); $ViAccount->SetAccountBalance($params["balance"]); echo "200 OK"; } elseif ($params["COMMAND"] == "IncomingGetConfig") { $result = CVoxImplantIncoming::GetConfigBySearchId($params['PHONE_NUMBER']); CVoxImplantHistory::WriteToLog($result, 'PORTAL GET INCOMING CONFIG');
<td width="40%"><?php echo GetMessage("VI_ACCOUNT_BALANCE"); ?> :</td> <td width="60%"><b><?php echo $accountBalance; ?> </b></td> </tr> <tr> <td width="40%"><?php echo GetMessage("VI_ACCOUNT_URL"); ?> :</td> <td width="60%"><input type="text" name="PUBLIC_URL" value="<?php echo htmlspecialcharsbx(CVoxImplantHttp::GetServerAddress()); ?> " /></td> </tr> <tr> <td width="40%"><?php echo GetMessage("VI_ACCOUNT_DEBUG"); ?> :</td> <td width="60%"><input type="checkbox" name="DEBUG_MODE" value="Y" <?php echo COption::GetOptionInt("voximplant", "debug") ? 'checked' : ''; ?> /></td> </tr> <?php if (!IsModuleInstalled('bitrix24')) {
public static function CancelDeactivatePhoneNumber($number) { $result = VI\ConfigTable::getList(array('select' => array('ID'), 'filter' => array('=SEARCH_ID' => (string) $number))); $config = $result->fetch(); if (!$config) { return false; } $viHttp = new CVoxImplantHttp(); $result = $viHttp->CancelDeactivatePhoneNumber($number); if (!$result) { return false; } VI\ConfigTable::update($config['ID'], array('TO_DELETE' => 'N', 'DATE_DELETE' => '')); CAgent::RemoveAgent("CVoxImplantPhone::CheckDeleteAgent(" . $config['ID'] . ");", "voximplant"); return $result; }