function setParameterUserExtension($domain, $type, $exten, $secret, $fullname, $email)
 {
     $pDevice = new paloDevice($domain, $type, $this->_DB);
     if ($pDevice->errMsg != "") {
         $this->errMsg = _tr("Error getting settings from extension user") . $pDevice->errMsg;
         return false;
     }
     $pGPBX = new paloGlobalsPBX($this->_DB, $domain);
     $arrProp["elastix_user"] = strstr($email, '@', true);
     $arrProp = array();
     $arrProp["fullname"] = $fullname;
     //$arrProp["elastix_user"]=strstr($email, '@', true);
     //en un futuro se tiene pensado usar como name para el dispositivo de usario su username
     //$arrProp["name"]=$exten;
     $arrProp["name"] = strstr($email, '@', true);
     $arrProp["exten"] = $exten;
     $arrProp['secret'] = $secret;
     $arrProp["vmpassword"] = $exten;
     $arrProp["vmemail"] = $email;
     $arrProp["record_in"] = "on_demand";
     $arrProp["record_out"] = "on_demand";
     $arrProp["callwaiting"] = "no";
     $arrProp["rt"] = $pGPBX->getGlobalVar("RINGTIMER");
     $arrProp["create_vm"] = $pGPBX->getGlobalVar("CREATE_VM");
     $result = $pDevice->tecnologia->getDefaultSettings($domain);
     $arrOpt = array_merge($result, $arrProp);
     if (empty($arrOpt["context"])) {
         $arrOpt["context"] = "from-internal";
     }
     if (empty($arrOpt["host"])) {
         $arrOpt["host"] = "dynamic";
     }
     $arrOpt["create_elxweb_device"] = "yes";
     //a esto se le agrega el codigo de la organizacion
     $arrOpt["alias"] = strstr($email, '@', true);
     //$arrOpt["alias"]=$exten;
     return $arrOpt;
 }
 private function setGeneralSettingFirstTime($domain, $codeOrg, $country)
 {
     require_once "apps/general_settings/libs/paloSantoGlobalsPBX.class.php";
     include_once "libs/paloSantoPBX.class.php";
     global $arrConf;
     $source_file = "/var/www/elastixdir/asteriskconf/globals.conf";
     $pGlobals = new paloGlobalsPBX($this->_DB, $domain);
     $res = $pGlobals->insertDBGlobals($country);
     if ($res == false) {
         $this->errMsg = $pGlobals->errMsg;
         return false;
     }
     $reslng = $pGlobals->getGlobalVar("LANGUAGE");
     if ($reslng != false) {
         $language = $reslng;
     }
     //sip , iax , voicemail
     //llenado de tablas tech_settings usando como referencia lo configurado en tech_general
     $psip = new paloSip($this->_DB);
     $piax = new paloIax($this->_DB);
     $pvoicemail = new paloVoicemail($this->_DB);
     foreach (array("sip", "iax", "voicemail") as $tech) {
         if ($tech == "voicemail") {
             $query = "SELECT * from " . $tech . "_general";
             $arrConfig = $this->_DB->getFirstRowQuery($query, true);
         } else {
             $query = "SELECT property_name, property_val from " . $tech . "_general";
             $arrConfig = $this->_DB->fetchTable($query, true);
         }
         if ($arrConfig === false) {
             $this->errMsg = $this->_DB->errMsg;
             return false;
         } elseif (count($arrConfig) == 0) {
             $this->errMsg = _tr("Don't exist default parameters ") . $tech . "_general";
             return false;
         }
         $arrSettings = array();
         foreach ($arrConfig as $key => $value) {
             if ($tech == "voicemail") {
                 if (isset($value) && $value != "") {
                     $arrSettings[$key] = $value;
                 }
             } else {
                 if (isset($value["property_val"]) && $value["property_val"] != "") {
                     $arrSettings[$value["property_name"]] = $value["property_val"];
                 }
             }
         }
         $arrSettings["organization_domain"] = $domain;
         $arrSettings["code"] = $codeOrg;
         if (!empty($language)) {
             $arrSettings["language"] = $language;
         }
         $result = ${"p" . $tech}->insertDefaultSettings($arrSettings);
         if ($result == false) {
             $this->errMsg = ${"p" . $tech}->errMsg;
             return false;
         }
     }
     //settings de la organizacion que crearan cierto plan de marcado por default
     //una ruta de salida por default
     $query = "insert into outbound_route (routename,outcid_mode,mohsilence,seq,organization_domain) VALUES (?,?,?,?,?)";
     if ($this->_DB->genQuery($query, array("out_9", "off", "default", "1", $domain)) == false) {
         $this->errMsg = "Error creating outbound_route. " . $this->_DB->errMsg;
         return false;
     }
     //obtenemos el id de la ruta creada
     $result = $this->_DB->getFirstRowQuery("SELECT LAST_INSERT_ID()", false);
     if ($result != false) {
         $outboundid = $result[0];
         $query = "insert into outbound_route_dialpattern (outbound_route_id,prefix,match_pattern,seq) VALUES (?,?,?,?)";
         if ($this->_DB->genQuery($query, array($outboundid, "9", ".", "1")) == false) {
             $this->errMsg = "Error creating outbound_route. " . $this->_DB->errMsg;
             return false;
         }
     }
     //TODO:falta asignarle una truncal de salida. Esto no se puede hacer porque aun no se le
     //ha permitido salida por ninguna truncal a la organizacion
     return true;
 }
 function getDefaultSettings($domain, $tech)
 {
     require_once "apps/general_settings/libs/paloSantoGlobalsPBX.class.php";
     $arrExtension = array();
     $queryV = "SELECT attach,context,deletevoicemail,saycid,envelope,emailsubject,emailbody from voicemail_settings where organization_domain=?";
     $resultV = $this->_DB->getFirstRowQuery($queryV, true, array($domain));
     if ($resultV == false) {
         $this->errMsg .= _tr("Error getting voicemail default settings") . $this->_DB->errMsg;
     } else {
         $arrExtension["vmcontext"] = isset($resultV["context"]) ? $resultV["context"] : null;
         $arrExtension["vmattach"] = isset($resultV["attach"]) ? $resultV["attach"] : null;
         $arrExtension["vmdelete"] = isset($resultV["deletevoicemail"]) ? $resultV["deletevoicemail"] : null;
         $arrExtension["vmsaycid"] = isset($resultV["saycid"]) ? $resultV["saycid"] : null;
         $arrExtension["vmenvelope"] = isset($resultV["envelope"]) ? $resultV["envelope"] : null;
         $arrExtension["vmemailsubject"] = isset($resultV["emailsubject"]) ? $resultV["emailsubject"] : null;
         $arrExtension["vmemailbody"] = isset($resultV["emailbody"]) ? $resultV["emailbody"] : null;
     }
     $arrExtension["vmx_locator"] = "disabled";
     $arrExtension["vmx_use"] = "both";
     $arrExtension["vmx_operator"] = "on";
     $pGPBX = new paloGlobalsPBX($this->_DB, $domain);
     $arrExtension["ring_timer"] = $pGPBX->getGlobalVar("RINGTIMER");
     $arrExtension["language"] = $pGPBX->getGlobalVar("LANGUAGE");
     return $arrExtension;
 }
Пример #4
0
function applyChanges($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $action = "";
    //conexion elastix.db
    $pORGZ = new paloSantoOrganization($pDB);
    if ($credentials['userlevel'] == 'superadmin') {
        $domain = getParameter('organization');
        $tmpORG = $pORGZ->getOrganization(array());
        $arrOrgz = array();
        foreach ($tmpORG as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
        if (count($arrOrgz) > 0) {
            if (!isset($arrOrgz[$domain])) {
                $smarty->assign("mb_title", _tr("ERROR"));
                $smarty->assign("mb_message", _tr("Organization doesn't exist"));
                return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
            }
        } else {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
            return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    } else {
        $domain = $credentials['domain'];
    }
    $pGPBX = new paloGlobalsPBX($pDB, $domain);
    $arrTone = $pGPBX->getToneZonePBX();
    $arrMOH = $pGPBX->getMoHClass($domain);
    $arrForm = createFieldForm($arrTone, $arrMOH, $pGPBX->getVoicemailTZ());
    $oForm = new paloForm($smarty, $arrForm);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
    } else {
        $arrProp = getParameterGeneralSettings();
        $pDB->beginTransaction();
        $exito = $pGPBX->setGeneralSettings($arrProp);
        if ($exito === true) {
            $pDB->commit();
            $smarty->assign("mb_title", _tr("MESSAGE"));
            $smarty->assign("mb_message", _tr("Changes applied successfully. "));
            //mostramos el mensaje para crear los archivos de ocnfiguracion
            $pAstConf = new paloSantoASteriskConfig($pDB);
            $pAstConf->setReloadDialplan($domain, true);
        } else {
            $pDB->rollBack();
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Changes couldn't be applied. ") . $pGPBX->errMsg);
        }
    }
    return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
}