function formLanguage($smarty, $module_name, $local_templates_dir, $arrConf, $pACL, $uid) { global $arrPermission; $lang = get_language(); $error_msg = ''; $archivos = array(); $langElastix = array(); $contenido = ''; $msgError = ''; $arrDefaultRate = array(); $conexionDB = FALSE; include "configs/languages.conf.php"; //este archivo crea el arreglo language que contine los idiomas soportados //por elastix leer_directorio("/usr/share/elastix/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) { $arrFormLanguage = createFieldForm($langElastix); $oForm = new paloForm($smarty, $arrFormLanguage); if (empty($pACL->errMsg)) { $conexionDB = TRUE; } else { $msgError = _tr("You can't change language") . '.-' . _tr("ERROR") . ":" . $pACL->errMsg; } // $arrDefaultRate['language']="es"; $smarty->assign("CAMBIAR", _tr("Save")); $smarty->assign("MSG_ERROR", $msgError); $smarty->assign("conectiondb", $conexionDB); $smarty->assign("icon", "web/apps/{$module_name}/images/system_preferencies_language.png"); if (in_array('edit', $arrPermission)) { $smarty->assign('EDIT_LANG', true); } //obtener el valor del lenguage por defecto $defLang = $pACL->getUserProp($uid, 'language'); if (empty($defLang) || $defLang === false) { $defLang = "en"; } $arrDefault['language'] = $defLang; $htmlForm = $oForm->fetchForm("{$local_templates_dir}/language.tpl", _tr("Language"), $arrDefault); $contenido = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; } return $contenido; }
function handleJSON_getUserProfile($smarty, $module_name) { include_once "libs/paloSantoForm.class.php"; include "configs/languages.conf.php"; //este archivo crea el arreglo language que contine los idiomas soportados //por elastix Header('Content-Type: application/json'); $arrCredentials = getUserCredentials($_SESSION['elastix_user']); $lang = get_language(); $error_msg = ''; $archivos = array(); $langElastix = array(); global $arrConf; $ERROR = ''; $pDB = new paloDB($arrConf['elastix_dsn']["elastix"]); $pACL = new paloACL($pDB); $jsonObject = new PaloSantoJSON(); $dataProfile = getDataProfile($pDB, $ERROR); if ($dataProfile === FALSE) { $smarty->assign("MSG_ERROR_FIELD", getErrorMsg()); $jsonObject->set_error(getErrorMsg()); return $jsonObject->createJSON(); } $extension = "{$dataProfile['exten']}/{$dataProfile['device']}"; leer_directorio("/usr/share/elastix/lang", $error_msg, $archivos); if (count($archivos) > 0) { foreach ($languages as $lang => $lang_name) { if (in_array("{$lang}.lang", $archivos)) { $langElastix[$lang] = $lang_name; } } } $selectedLanguage = $pACL->getUserProp($arrCredentials['idUser'], "language"); if ($selectedLanguage === FALSE) { $jsonObject->set_error(_tr("Invalid Language")); return $jsonObject->createJSON(); } $smarty->assign("TITLE_POPUP", _tr("My Profile ")); $smarty->assign("SAVE_POPUP", _tr("Save changes")); $smarty->assign("CHANGE_PASSWD_POPUP", _tr("Change Password")); $smarty->assign("userProfile_label", _tr("User")); $smarty->assign("userProfile", $dataProfile['username']); $smarty->assign("extenProfile_label", _tr("Extension")); $smarty->assign("extenProfile", $extension); $smarty->assign("faxProfile_label", _tr("Fax")); $smarty->assign("faxProfile", $dataProfile['fax_extension']); $smarty->assign("nameProfile", $dataProfile['name']); $smarty->assign('ID_PICTURE', $arrCredentials['idUser']); $smarty->assign('DeleteImage', _tr('Delete Image')); $dataProfile['languageProfile'] = $selectedLanguage; $arrFormFilter = createProfileForm($langElastix); $oFilterForm = new paloForm($smarty, $arrFormFilter); $htmlFilter = $oFilterForm->fetchForm("/var/www/html/web/themes/elastix3/_common/profile_uf.tpl", _tr('My Profile'), $dataProfile); $jsonObject = new PaloSantoJSON(); $jsonObject->set_message($htmlFilter); return $jsonObject->createJSON(); }
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; }