Esempio n. 1
0
 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;
 }
Esempio n. 2
0
if (!CVoxImplantMain::CheckAccess()) {
    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['VI_ADD']) {
        $arSend['ERROR'] = '';
        CUtil::decodeURIComponent($_POST);
        $viSip = new CVoxImplantSip();
        $result = $viSip->Add(array('TYPE' => strtolower($_POST['TYPE']), 'PHONE_NAME' => $_POST['TITLE'], 'SERVER' => $_POST['SERVER'], 'LOGIN' => $_POST['LOGIN'], 'PASSWORD' => $_POST['PASSWORD']));
        if ($result) {
            $arSend['RESULT'] = $result;
        } else {
            $arSend['ERROR'] = $viSip->GetError()->msg;
        }
        echo CUtil::PhpToJsObject($arSend);
    } else {
        if ($_POST['VI_DELETE'] == 'Y') {
            $arSend['ERROR'] = '';
            $viSip = new CVoxImplantSip();
            $viSip->Delete($_POST['CONFIG_ID']);
            echo CUtil::PhpToJsObject($arSend);
        } else {
            echo CUtil::PhpToJsObject(array('ERROR' => 'UNKNOWN_ERROR'));
        }
    }
} else {
    echo CUtil::PhpToJsObject(array('BITRIX_SESSID' => bitrix_sessid(), 'ERROR' => 'SESSION_ERROR'));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
Esempio n. 3
0
 public static function sipStatus($arParams)
 {
     if (!CVoxImplantMain::CheckAccess()) {
         throw new \Bitrix\Rest\AccessException();
     }
     $arParams = array_change_key_case($arParams, CASE_UPPER);
     $viSip = new CVoxImplantSip();
     $result = $viSip->GetSipRegistrations($arParams['REG_ID']);
     if (!$result) {
         throw new Bitrix\Rest\RestException($viSip->GetError()->msg, $viSip->GetError()->code, CRestServer::STATUS_WRONG_REQUEST);
     }
     return array('REG_ID' => $result->reg_id, 'LAST_UPDATED' => $result->last_updated, 'ERROR_MESSAGE' => $result->error_message, 'STATUS_CODE' => $result->status_code, 'STATUS_RESULT' => $result->status_result);
 }
Esempio n. 4
0
    }
    if ($arResult["ITEM"]["PORTAL_MODE"] == CVoxImplantConfig::MODE_SIP) {
        $viSip = new CVoxImplantSip();
        $arResult["SIP_CONFIG"] = $viSip->Get($arParams["ID"]);
        $arResult["SIP_CONFIG"]['PHONE_NAME'] = $arResult['ITEM']['PHONE_NAME'];
    }
}
if (empty($arResult["ITEM"])) {
    return;
}
if ($_REQUEST["action"] == "save" && check_bitrix_sessid()) {
    $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray();
    $skipSaving = false;
    $arFieldsSip = array();
    if (isset($post['SIP'])) {
        $viSip = new CVoxImplantSip();
        $result = $viSip->Update($arParams["ID"], array('TYPE' => $arResult["SIP_CONFIG"]["TYPE"], 'PHONE_NAME' => $post['SIP']['PHONE_NAME'], 'SERVER' => $post['SIP']['SERVER'], 'LOGIN' => $post['SIP']['LOGIN'], 'PASSWORD' => $post['SIP']['PASSWORD'], 'NEED_UPDATE' => $post['SIP']['NEED_UPDATE']));
        $skipSaving = !$result;
        $arFieldsSip = array('PHONE_NAME' => $post['SIP']['PHONE_NAME'], 'SERVER' => $post['SIP']['SERVER'], 'LOGIN' => $post['SIP']['LOGIN'], 'PASSWORD' => $post['SIP']['PASSWORD']);
    }
    if (IsModuleInstalled('timeman')) {
        $post["TIMEMAN"] = isset($post["TIMEMAN"]) ? 'Y' : 'N';
    } else {
        $post["TIMEMAN"] = 'N';
    }
    if ($post["NO_ANSWER_RULE"] == CVoxImplantIncoming::RULE_PSTN_SPECIFIC) {
        if (strlen($post["FORWARD_NUMBER"]) <= 0) {
            $post["NO_ANSWER_RULE"] = CVoxImplantIncoming::RULE_PSTN;
        } else {
            $post["FORWARD_NUMBER"] = substr($post["FORWARD_NUMBER"], 0, 20);
        }
Esempio n. 5
0
define("NO_AGENT_CHECK", true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
if (!CModule::IncludeModule("voximplant")) {
    echo CUtil::PhpToJsObject(array('ERROR' => 'VI_MODULE_NOT_INSTALLED'));
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
    die;
}
if (!CVoxImplantMain::CheckAccess()) {
    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['VI_SIP_CHECK']) {
        $arSend['ERROR'] = '';
        $viSip = new CVoxImplantSip();
        $result = $viSip->GetSipRegistrations($_POST['REG_ID']);
        if ($result) {
            $arSend = array('REG_ID' => $result->reg_id, 'REG_LAST_UPDATED' => $result->last_updated, 'REG_ERROR_MESSAGE' => $result->error_message, 'REG_CODE' => $result->status_code, 'REG_STATUS' => $result->status_result, 'ERROR' => '');
        } else {
            $arSend['ERROR'] = $viSip->GetError()->msg;
        }
        echo CUtil::PhpToJsObject($arSend);
    } else {
        echo CUtil::PhpToJsObject(array('ERROR' => 'UNKNOWN_ERROR'));
    }
} else {
    echo CUtil::PhpToJsObject(array('BITRIX_SESSID' => bitrix_sessid(), 'ERROR' => 'SESSION_ERROR'));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";