function load_theme($ruta_base = '') { require_once $ruta_base . "configs/default.conf.php"; global $arrConf; include_once $ruta_base . "libs/paloSantoDB.class.php"; //conectarse a la base de settings para obtener el thema actual $pDB = new paloDB($arrConf['elastix_dsn']['settings']); if (empty($pDB->errMsg)) { $theme = get_key_settings($pDB, 'theme'); } if (!preg_match('/^\\w+$/', $theme)) { $theme = false; } if ($theme !== false && !is_dir($ruta_base . "themes/{$theme}")) { $theme = false; } //si no se encuentra setear el tema por default if (empty($theme)) { set_key_settings($pDB, 'theme', 'default'); return "default"; } else { return $theme; } }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoTrunk.class.php"; require_once "libs/misc.lib.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $contenido = ''; $msgError = ''; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrConfig = $pConfig->leer_configuracion(false); $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk"; $pDB = new paloDB($dsn); $pDBSetting = new paloDB($arrConf['elastix_dsn']['settings']); $pDBTrunk = new paloDB($arrConfModule['dsn_conn_database_1']); $arrForm = array("default_rate" => array("LABEL" => $arrLang["Default Rate"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""), "default_rate_offset" => array("LABEL" => $arrLang["Default Rate Offset"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $arrForm); $oForm->setViewMode(); //obtener el valor de la tarifa por defecto $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate"); $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset"); $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); if (isset($_POST['edit_default'])) { $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate"); $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset"); $oForm = new paloForm($smarty, $arrForm); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); } else { if (isset($_POST['save_default'])) { $oForm = new paloForm($smarty, $arrForm); $arrDefaultRate['default_rate'] = $_POST['default_rate']; $arrDefaultRate['default_rate_offset'] = $_POST['default_rate_offset']; if ($oForm->validateForm($_POST)) { $bValido = set_key_settings($pDBSetting, 'default_rate', $arrDefaultRate['default_rate']); $bValido = set_key_settings($pDBSetting, 'default_rate_offset', $arrDefaultRate['default_rate_offset']); if (!$bValido) { echo $arrLang["Error when saving default rate"]; } else { header("Location: index.php?menu=billing_setup"); } } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Value for rate is not valid"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate); } } } $arrTrunks = array(); $arrData = array(); $arrTrunksBill = array(); //obtener todos los trunks $oTrunk = new paloTrunk($pDBTrunk); //obtener todos los trunks que son para billing //$arrTrunksBill=array("DAHDI/g0","DAHDI/g1"); getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill); if (isset($_POST['submit_bill_trunks'])) { //obtengo las que estan guardadas y las que ahora no estan $selectedTrunks = isset($_POST['trunksBills']) ? array_keys($_POST['trunksBills']) : array(); if (count($selectedTrunks) > 0) { foreach ($selectedTrunks as $selectedTrunk) { $nuevaListaTrunks[] = base64_decode($selectedTrunk); } } else { $nuevaListaTrunks = array(); } $listaTrunksNuevos = array_diff($nuevaListaTrunks, $arrTrunksBill); $listaTrunksAusentes = array_diff($arrTrunksBill, $nuevaListaTrunks); //tengo que borrar los trunks ausentes //tengo que agregar los trunks nuevos // print_r($listaTrunksNuevos); //print_r($listaTrunksAusentes); if (count($listaTrunksAusentes) > 0) { $bExito = $oTrunk->deleteTrunksBill($listaTrunksAusentes); if (!$bExito) { $msgError = $oTrunk->errMsg; } } if (count($listaTrunksNuevos) > 0) { $bExito = $oTrunk->saveTrunksBill($listaTrunksNuevos); if (!$bExito) { $msgError .= $oTrunk->errMsg; } } if (!empty($msgError)) { $smarty->assign("mb_message", $msgError); } } getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill); $end = count($arrTrunks); if (is_array($arrTrunks)) { foreach ($arrTrunks as $trunk) { $arrTmp = array(); $checked = in_array($trunk[1], $arrTrunksBill) ? "checked" : ""; $arrTmp[0] = "<input type='checkbox' name='trunksBills[" . base64_encode($trunk[1]) . "]' {$checked}>"; $arrTmp[1] = $trunk[1]; $arrData[] = $arrTmp; } } $arrGrid = array("title" => $arrLang["Trunk Bill Configuration"], "icon" => "/modules/{$module_name}/images/reports_billing_setup.png", "width" => "99%", "start" => $end == 0 ? 0 : 1, "end" => $end, "total" => $end, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Trunk"], "property1" => ""))); $oGrid = new paloSantoGrid($smarty); $oGrid->pagingShow(false); $oGrid->customAction('submit_bill_trunks', _tr('Billing Capable')); $trunk_config = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); if (strpos($trunk_config, '<form') === FALSE) { $trunk_config = "<form style='margin-bottom:0;' method='POST' action='?menu=billing_setup'>{$trunk_config}</form>"; } //mostrar los dos formularios $contenido .= $strReturn . $trunk_config; return $contenido; }
function updateStatusFreePBXFrontend($status_fpbx_frontend) { //Actualizar la clave ActivatedFreePBX. $pDBSettings = new paloDB($this->arrConf['elastix_dsn']["settings"]); return set_key_settings($pDBSettings, "activatedFreePBX", $status_fpbx_frontend); }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoForm.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $contenido = ''; $msgError = ''; $pDBSetting = new paloDB($arrConf['dsn_conn_database']); $arrForm = array("fax_master" => array("LABEL" => $arrLang["Fax Master Email"], "REQUIRED" => "yes", "EDITABLE" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[a-zA-Z0-9_.\\-]+@[a-zA-Z0-9_.\\-]+\\.[a-zA-Z0-9_.\\-]+\$")); $oForm = new paloForm($smarty, $arrForm); $oForm->setEditMode(); //obtener el valor de la tarifa por defecto $arrDefault['fax_master'] = get_key_settings($pDBSetting, "fax_master"); $smarty->assign("FAXMASTER_MSG", $arrLang["Write the email address which will receive the notifications of received messages, errors and activity summary of the Fax Server"]); $smarty->assign("icon", "/modules/{$module_name}/images/fax_fax_master.png"); $smarty->assign("APPLY_CHANGES", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/fax_master.tpl", $arrLang["Fax Master Configuration"], $arrDefault); if (isset($_POST['save_default'])) { $oForm = new paloForm($smarty, $arrForm); $arrDefault['fax_master'] = $_POST['fax_master']; $bMostrarError = TRUE; if ($oForm->validateForm($_POST)) { $bMostrarError = FALSE; $bValido = set_key_settings($pDBSetting, 'fax_master', $arrDefault['fax_master']); if (!$bValido) { echo $arrLang["Error when saving Fax Master"]; } else { //guardar en /etc/postfix/virtual $bExito = modificar_archivos_mail($arrDefault['fax_master'], $error); if ($bExito) { header("Location: index.php?menu=faxmaster"); } else { $mensaje = $error; $bMostrarError = TRUE; } } } else { $mensaje = $arrLang["Value for Fax Master is not valid"]; } if ($bMostrarError) { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $mensaje); $smarty->assign("APPLY_CHANGES", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $strReturn = $oForm->fetchForm("{$local_templates_dir}/fax_master.tpl", $arrLang["Fax Master Configuration"], $arrDefault); } } return $strReturn; }
/** * Procedimiento para actualizar el tema actual de elastix * * @param $sTheme Nombre del tema a cambiar * * @return bool true or false si actualizo o no */ function updateTheme($sTheme) { global $arrConf; if (!preg_match('/^\\w+$/', $sTheme)) { $this->errMsg = _tr('Invalid theme'); return false; } if (!is_dir($arrConf['basePath'] . "/themes/{$sTheme}")) { $this->errMsg = _tr('Invalid theme'); return false; } if (set_key_settings($this->_DB, 'theme', $sTheme)) { return true; } else { $this->errMsg = _tr('The theme could not be updated'); return false; } }
function load_version_elastix() { global $elxPath; require_once "{$elxPath}/configs/default.conf.php"; include_once "{$elxPath}/libs/paloSantoDB.class.php"; global $arrConf; //conectarse a la base de settings para obtener la version y release del sistema elastix $pDB = new paloDB($arrConf['elastix_dsn']['elastix']); if (empty($pDB->errMsg)) { $theme = get_key_settings($pDB, 'elastix_version_release'); } //si no se encuentra setear solo ? if (empty($theme)) { set_key_settings($pDB, 'elastix_version_release', '?'); return "?"; } else { return $theme; } }
function _moduleContent(&$smarty, $module_name) { //include module files include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoForm.class.php"; include "configs/languages.conf.php"; include_once "modules/{$module_name}/configs/default.conf.php"; load_language_module($module_name); //global variables global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $error_msg = ''; $msgError = ''; $contenido = ''; $archivos = array(); $langElastix = array(); $arrDefaultRate = array(); $conexionDB = FALSE; //leer los archivos disponibles /* $languages=array( "en"=>"English", "es"=>"Español", "fr"=>"Français", );*/ leer_directorio("lang", $error_msg, $archivos); if (count($archivos) > 0) { foreach ($languages as $lang => $lang_name) { if (in_array("{$lang}.lang", $archivos)) { $langElastix[$lang] = $lang_name; } } } if (count($langElastix) > 0) { //si no me puedo conectar a la base de datos // debo presentar un mensaje en vez del boton cambiar // un $arrForm = array("language" => array("LABEL" => _tr("Select language"), "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $langElastix, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $arrForm); $pDB = new paloDB($arrConf['elastix_dsn']['settings']); if (empty($pDB->errMsg)) { $conexionDB = TRUE; if (isset($_POST['save_language'])) { //guardar el nuevo valor $lang = $_POST['language']; $bExito = set_key_settings($pDB, 'language', $lang); //redirigir a la pagina nuevamente if ($bExito) { header("Location: index.php?menu=language"); } else { $smarty->assign("mb_message", "Error"); } } //obtener el valor de la tarifa por defecto $defLang = get_key_settings($pDB, 'language'); if (empty($defLang)) { $defLang = "en"; } $arrDefaultRate['language'] = $defLang; } else { $msgError = _tr("You can't change language") . '.-' . _tr("ERROR") . ":" . $pDB->errMsg; } // $arrDefaultRate['language']="es"; $smarty->assign("CAMBIAR", _tr("Save")); $smarty->assign("MSG_ERROR", $msgError); $smarty->assign("conectiondb", $conexionDB); $smarty->assign("icon", "modules/{$module_name}/images/system_preferencies_language.png"); $contenido = $oForm->fetchForm("{$local_templates_dir}/language.tpl", _tr("Language"), $arrDefaultRate); } return $contenido; }