Esempio n. 1
0
 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;
 }
Esempio n. 2
0
<?php

if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
    die;
}
/**
 * @var $arParams array
 * @var $arResult array
 * @var $arResult['NAV_OBJECT'] CAllDBResult
 * @var $APPLICATION CMain
 * @var $USER CUser
 */
$APPLICATION->SetAdditionalCSS("/bitrix/components/bitrix/voximplant.main/templates/.default/telephony.css");
$numbersC = CVoxImplantConfig::GetPortalNumbers();
$portalNumber = CVoxImplantConfig::GetPortalNumber();
$numbers = array('' => GetMessage("VI_NUMBERS_DEFAULT")) + $numbersC;
?>
<div class="bx-vi-block bx-vi-filter">
	<form id="search_form" action="<?php 
echo POST_FORM_ACTION_URI;
?>
" method="GET">
		<input type="hidden" name="act" value="search">
		<span class="filter-field">
			<input name="FILTER" type="text" value="<?php 
echo htmlspecialcharsbx($arResult['FILTER']);
?>
" class="tel-set-inp" placeholder="<?php 
echo GetMessage('VI_NUMBERS_SEARCH');
?>
" />
Esempio n. 3
0
 public function Update($configId, $fields)
 {
     $configId = intval($configId);
     if ($configId <= 0) {
         $this->error = new CVoxImplantError(__METHOD__, 'CONFIG_ID_NULL', GetMessage('VI_SIP_CONFIG_ID_NULL'));
         return false;
     }
     $arUpdate = $this->PrepareFiedls($fields, self::CHECK_UPDATE);
     if (!$arUpdate) {
         return false;
     }
     if (isset($arUpdate['SEARCH_ID'])) {
         $orm = VI\ConfigTable::getList(array('filter' => array('=SEARCH_ID' => $arUpdate['SEARCH_ID'], '!=ID' => $configId)));
         if ($orm->fetch()) {
             $this->error = new CVoxImplantError(__METHOD__, 'SEARCH_ID_EXISTS', GetMessage('VI_SIP_SEARCH_ID_EXISTS'));
             return false;
         }
     }
     if (isset($arUpdate['PHONE_NAME'])) {
         $orm = VI\ConfigTable::getList(array('filter' => array('=PHONE_NAME' => $arUpdate['PHONE_NAME'], '!=ID' => $configId)));
         if ($orm->fetch()) {
             $this->error = new CVoxImplantError(__METHOD__, 'TITLE_EXISTS', GetMessage('VI_SIP_TITLE_EXISTS'));
             return false;
         }
     }
     if (isset($arUpdate['SEARCH_ID'])) {
         $result = \Bitrix\Voximplant\ConfigTable::getById($configId);
         $currentConfig = $result->fetch();
         if ($currentConfig['SEARCH_ID'] == CVoxImplantConfig::GetPortalNumber()) {
             COption::SetOptionString("voximplant", "portal_number", $arUpdate['SEARCH_ID']);
         }
         VI\ConfigTable::update($configId, array('SEARCH_ID' => $arUpdate['SEARCH_ID']));
     }
     if (isset($arUpdate['PHONE_NAME'])) {
         VI\ConfigTable::update($configId, array('PHONE_NAME' => $arUpdate['PHONE_NAME']));
     }
     unset($arUpdate['SEARCH_ID']);
     unset($arUpdate['PHONE_NAME']);
     unset($arUpdate['CONFIG_ID']);
     if (empty($arUpdate)) {
         return true;
     }
     $orm = VI\SipTable::getList(array('filter' => array('=CONFIG_ID' => $configId)));
     $entity = $orm->fetch();
     if (!$entity) {
         $this->error = new CVoxImplantError(__METHOD__, 'CONFIG_NOT_FOUND', GetMessage('VI_SIP_CONFIG_NOT_FOUND'));
         return false;
     }
     VI\SipTable::update($entity['ID'], $arUpdate);
     if (isset($arUpdate['SERVER']) || isset($arUpdate['LOGIN']) || isset($arUpdate['PASSWORD'])) {
         $orm = VI\SipTable::getById($entity['ID']);
         $sipConfig = $orm->fetch();
         if ($entity['SERVER'] != $sipConfig['SERVER'] || $entity['LOGIN'] != $sipConfig['LOGIN'] || $entity['PASSWORD'] != $sipConfig['PASSWORD'] || $fields['NEED_UPDATE'] == 'Y') {
             $this->UpdateSipRegistration($sipConfig['REG_ID'], $sipConfig['SERVER'], $sipConfig['LOGIN'], $sipConfig['PASSWORD']);
         }
     }
     return true;
 }
Esempio n. 4
0
 public function GetUserInfo($userId, $getPhoneAccess = false)
 {
     $userId = intval($userId);
     if ($userId <= 0) {
         $this->error = new CVoxImplantError(__METHOD__, 'USER_ID_NULL', 'UserId is not correct');
         return false;
     }
     $userPassword = '';
     $userBackphone = '';
     $phoneEnable = false;
     $phonePassword = '';
     $arExtParams = array('FIELDS' => array("ID"), 'SELECT' => array('UF_VI_PASSWORD', 'UF_VI_BACKPHONE', 'UF_VI_PHONE', 'UF_VI_PHONE_PASSWORD', 'UF_PHONE_INNER', 'UF_DEPARTMENT'));
     $dbUsers = CUser::GetList($sort_by = '', $dummy = '', array('ID' => $userId), $arExtParams);
     if ($arUser = $dbUsers->Fetch()) {
         if (strlen($arUser['UF_VI_PASSWORD']) > 0) {
             $userPassword = $arUser['UF_VI_PASSWORD'];
         }
         if (strlen($arUser['UF_VI_PHONE_PASSWORD']) > 0) {
             $phonePassword = $arUser['UF_VI_PHONE_PASSWORD'];
         }
         $userInnerPhone = $arUser['UF_PHONE_INNER'];
         $userBackphone = $arUser['UF_VI_BACKPHONE'];
         if ($arUser['UF_VI_PHONE'] == 'Y') {
             $phoneEnable = true;
             $getPhoneAccess = true;
         }
         $arUser['IS_EXTRANET'] = self::IsExtranet($arUser);
         unset($arUser['UF_DEPARTMENT']);
     }
     if ($userPassword == '' || $getPhoneAccess && $phonePassword == '') {
         $result = $this->GetUser($userId, $getPhoneAccess, true);
         if (!$result || $this->GetError()->error) {
             $this->error = new CVoxImplantError(__METHOD__, $this->GetError()->code, $this->GetError()->msg);
             return false;
         }
         $userPassword = $result->result->user_password;
         $phonePassword = $result->result->phone_password;
         global $USER_FIELD_MANAGER;
         $USER_FIELD_MANAGER->Update("USER", $userId, array('UF_VI_PASSWORD' => $userPassword, 'UF_VI_PHONE_PASSWORD' => $phonePassword));
     }
     if ($userBackphone) {
         $portalPhones = CVoxImplantConfig::GetPortalNumbers();
         if (!isset($portalPhones[$userBackphone])) {
             $userBackphone = '';
         }
     }
     if ($userBackphone == '') {
         $userBackphone = CVoxImplantConfig::GetPortalNumber();
         if ($userBackphone == CVoxImplantConfig::LINK_BASE_NUMBER) {
             $userBackphone = '';
         }
     }
     $viAccount = new CVoxImplantAccount();
     return array('call_server' => str_replace('voximplant.com', 'bitrixphone.com', $viAccount->GetCallServer()), 'user_login' => 'user' . $userId, 'user_password' => $userPassword, 'user_backphone' => $userBackphone, 'user_innerphone' => $userInnerPhone, 'phone_enable' => $phoneEnable, 'phone_login' => $phonePassword ? 'phone' . $userId : "", 'phone_password' => $phonePassword, 'user_extranet' => $arUser['IS_EXTRANET']);
 }
Esempio n. 5
0
 public static function AddConfigBySearchId($phone, $country = 'RU')
 {
     $melodyLang = 'EN';
     $country = strtoupper($country);
     if (in_array($country, array('RU', 'UA', 'DE'))) {
         $melodyLang = $country;
     }
     $arFields = array('SEARCH_ID' => $phone, 'PHONE_NAME' => $phone, 'MELODY_LANG' => $melodyLang);
     $result = VI\ConfigTable::add($arFields);
     if ($result) {
         if (CVoxImplantConfig::GetPortalNumber() == CVoxImplantConfig::LINK_BASE_NUMBER) {
             CVoxImplantConfig::SetPortalNumber($arFields['SEARCH_ID']);
         }
     }
     CVoxImplantConfig::SetModeStatus(CVoxImplantConfig::MODE_RENT, true);
     return true;
 }
Esempio n. 6
0
 public static function DeletePhoneConfig($configId)
 {
     $configId = intval($configId);
     $result = VI\ConfigTable::getList(array('select' => array('ID', 'SEARCH_ID'), 'filter' => array('=ID' => $configId)));
     $config = $result->fetch();
     if (!$config) {
         return false;
     }
     $needChangePortalNumber = false;
     VI\ConfigTable::delete($configId);
     if ($config['SEARCH_ID'] == CVoxImplantConfig::GetPortalNumber()) {
         $needChangePortalNumber = true;
     }
     $result = VI\QueueTable::getList(array('select' => array('ID'), 'filter' => array('=CONFIG_ID' => $configId)));
     while ($row = $result->fetch()) {
         VI\QueueTable::delete($row['ID']);
     }
     $firstPhoneNumber = '';
     $result = VI\ConfigTable::getList(array('select' => array('ID', 'SEARCH_ID')));
     while ($row = $result->fetch()) {
         if (!$firstPhoneNumber) {
             $firstPhoneNumber = $row['SEARCH_ID'];
         }
     }
     if (!$firstPhoneNumber) {
         CVoxImplantConfig::SetModeStatus(CVoxImplantConfig::MODE_RENT, false);
     }
     if ($needChangePortalNumber) {
         if ($firstPhoneNumber) {
             CVoxImplantConfig::SetPortalNumber($firstPhoneNumber);
         } else {
             CVoxImplantConfig::SetPortalNumber(CVoxImplantConfig::LINK_BASE_NUMBER);
         }
     }
     return true;
 }