function _moduleContent(&$smarty, $module_name) { //global variables global $arrConf; global $arrConfModule; $arrConf = array_merge($arrConf, $arrConfModule); //folder path for custom templates $local_templates_dir = getWebDirModule($module_name); $arrFormDHCP = createFieldForm(); $oForm = new paloForm($smarty, $arrFormDHCP); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CONFIGURATION_UPDATE", _tr("Update")); $smarty->assign("SERVICE_START", _tr("Service Start")); $smarty->assign("SERVICE_STOP", _tr("Service Stop")); $smarty->assign("STATUS", _tr("Status")); $smarty->assign("START_RANGE_OF_IPS", _tr("Start range of IPs")); $smarty->assign("END_RANGE_OF_IPS", _tr("End range of IPs")); $smarty->assign("DNS_1", _tr("DNS 1")); $smarty->assign("DNS_2", _tr("DNS 2")); $smarty->assign("WINS", _tr("WINS")); $smarty->assign("GATEWAY", _tr("Gateway")); $smarty->assign("OPTIONAL", _tr("Optional")); $smarty->assign("icon", "web/apps/{$module_name}/images/system_network_dhcp_server.png"); $smarty->assign("OF_1_TO_50000_SECONDS", _tr("Of 1 to 50000 Seconds")); if (isset($_POST["in_iniciar"])) { $accion = "service_start"; } else { if (isset($_POST["in_finalizar"])) { $accion = "service_stop"; } else { if (isset($_POST["in_actualizar_conf_red"])) { $accion = "service_update"; } else { $accion = "service_show"; } } } $content = ""; switch ($accion) { case "service_start": $content = serviceStartDHCP($smarty, $module_name, $local_templates_dir, $oForm); break; case "service_stop": $content = serviceStopDHCP($smarty, $module_name, $local_templates_dir, $oForm); break; case "service_update": $content = serviceUpdateDHCP($smarty, $module_name, $local_templates_dir, $oForm); break; default: //service_show $content = serviceShowDHCP($smarty, $module_name, $local_templates_dir, $oForm); break; } return $content; }
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 viewFormFestival($smarty, $module_name, $local_templates_dir, $arrConf) { $pFestival = new paloSantoFestival(); $arrFormFestival = createFieldForm(); $oForm = new paloForm($smarty, $arrFormFestival); $_DATA = $_POST; if ($pFestival->isFestivalActivated()) { $_DATA["status"] = "on"; } else { $_DATA["status"] = "off"; } $smarty->assign("SAVE", _tr("Save")); $smarty->assign("icon", "web/apps/{$module_name}/images/pbx_tools_festival.png"); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Festival"), $_DATA); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function formCurrency($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang) { $pCurrency = new paloSantoCurrency($pDB); $arrFormCurrency = createFieldForm($arrLang); $oForm = new paloForm($smarty, $arrFormCurrency); //CARGAR CURRENCY GUARDADO $curr = loadCurrentCurrency($pDB); if ($curr == false) { $curr = "\$"; } $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("icon", "modules/{$module_name}/images/system_preferences_currency.png"); $_POST['currency'] = $curr; $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", $arrLang["Currency"], $_POST); $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }
function formCurrency($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { global $arrPermission; $arrFormCurrency = createFieldForm(); $oForm = new paloForm($smarty, $arrFormCurrency); //CARGAR CURRENCY GUARDADO $curr = loadCurrentCurrency($pDB); if ($curr == false) { $curr = "\$"; } $smarty->assign("SAVE", _tr("Save")); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("icon", "web/apps/{$module_name}/images/system_preferences_currency.png"); $_POST['currency'] = $curr; if (in_array('edit', $arrPermission)) { $smarty->assign('EDIT_CURR', true); } $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Currency"), $_POST); $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }
function saveNewKey($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrAST, $arrAMP) { $arrFormNew = createFieldForm($pDB); $arrValues['id'] = getParameter("Extension"); $arrValues['key'] = getParameter("Current_Secret"); $arrValues['new_key'] = getParameter("New_Secret"); $confirmation = getParameter("Confirm_New_Secret"); $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']); $pACL = new paloACL($pDB2); $oForm = new paloForm($smarty, $arrFormNew); if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $pWeakKeys = new paloSantoWeakKeys($pDB); $device = $pWeakKeys->getWeakKeyById($arrValues['id']); if (!$pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) { if ($arrValues['key'] != $device['data']) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("The Current Secret is invalid")); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } } if ($arrValues['new_key'] != $confirmation) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("The New Secret does not match with the Confirmation Secret")); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $mensaje = getMensaje($arrValues['id'], $arrValues['new_key']); if ($mensaje != "OK") { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $mensaje); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } if (!$pWeakKeys->saveNewKey($arrValues, $device['tech'])) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pWeakKeys->errMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $data_connection = array('host' => $arrConf['AMI_HOST'], 'user' => $arrConf['AMI_USER'], 'password' => $arrConf['AMI_PASS']); $pLoadExtension = new paloSantoLoadExtension($pDB); if (!$pLoadExtension->do_reloadAll($data_connection, $arrAST, $arrAMP)) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pLoadExtension->errMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("Successful Secret Update")); return reportWeakKeys($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function viewFormCrearcampaña($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pCrearcampaña = new paloSantoCrearcampaña($pDB); $arrFormCrearcampaña = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormCrearcampaña); if (!is_array($arrFormCrearcampaña)) { // Si no es un arreglo, debe haber un error. $smarty->assign("mb_title", "Error"); // hago print de un string, no de un Array. $smarty->assign("mb_message", "<br>No es posible regestionar la campaña.<br>" . $arrFormCrearcampaña); return ""; } //begin, Form data persistence to errors and other events. $_DATA = $_POST; $action = getParameter("action"); $id = getParameter("id"); $smarty->assign("ID", $id); //persistence id with input hidden in tpl if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("save_edit")) { $oForm->setEditMode(); } } //end, Form data persistence to errors and other events. if ($action == "view" || $action == "view_edit") { // the action is to view or view_edit. $dataCrearcampaña = $pCrearcampaña->getCrearcampañaById($id); if (is_array($dataCrearcampaña) & count($dataCrearcampaña) > 0) { $_DATA = $dataCrearcampaña; } else { $smarty->assign("mb_title", _tr("Error get Data")); $smarty->assign("mb_message", $pCrearcampaña->errMsg); } } elseif ($_POST['save_edit'] != "Editar") { // si no está en modo view_edit, toca colocar la fecha de hoy en ambos campos $_DATA['fecha_inicio'] = date("Y-m-d"); $_DATA['fecha_fin'] = date("Y-m-d"); } $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("IMG", "images/list.png"); $smarty->assign("CAMPANIA_PADRE", $_DATA['nombre']); // La regestión hereda todo de la campaña padre. $smarty->assign("fecha_inicio", $_DATA['fecha_inicio']); $smarty->assign("fecha_fin", $_DATA['fecha_fin']); $smarty->assign("id_form", $_DATA['id_form']); $smarty->assign("script", $_DATA['script']); $_DATA['nombre'] = ""; // Para que aparezca en blanco el input del nombre if (isset($_POST['save_edit']) && $_POST['save_edit'] == "Editar") { $pCrearcampaña->actualizarCampania($_DATA); Header("Location: index.php?menu=hispana_listado_campanias"); } $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Regestionar campaña"), $_DATA); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function saveNewAnnouncement($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $continue = true; $success = false; $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien hace la accion if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pAnnouncement = new paloSantoAnnouncement($pDB, $domain); $arrFormOrgz = createFieldForm(array(), array(), $pDB, $domain); $oForm = new paloForm($smarty, $arrFormOrgz); $description = trim(getParameter('description')); 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); return viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } elseif (count(explode("\n", $description)) > 1) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid description text")); return viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if ($pAnnouncement->validateDestine($domain, getParameter("destination")) == false) { $error = _tr("You must select a default destination."); $continue = false; } if ($continue) { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["description"] = $description; $arrProp["recording_id"] = getParameter("recording_id"); $arrProp["allow_skip"] = getParameter("allow_skip"); $arrProp["return_ivr"] = getParameter("return_ivr"); $arrProp["noanswer"] = getParameter("noanswer"); $arrProp["repeat_msg"] = getParameter("repeat_msg"); $arrProp["goto"] = getParameter("goto"); $arrProp['destination'] = getParameter("destination"); } if ($continue) { $pDB->beginTransaction(); $success = $pAnnouncement->createNewAnnouncement($arrProp); if ($success) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pAnnouncement->errMsg; } } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Announcement has been created successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); $content = reportAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function saveNewCrearcampaña($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pCrearcampaña = new paloSantoCrearcampaña($pDB); $arrFormCrearcampaña = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormCrearcampaña); 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormCrearcampaña($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { // si no hay error de validación, procedo a guardar la campaña $msg = $pCrearcampaña->guardarCampaña($_POST); $smarty->assign("mb_title", _tr("Mensaje:")); $smarty->assign("mb_message", $msg); $content = viewFormCrearcampaña($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } return $content; }
function saveRules($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $arrValues = array(); $str_error = ""; $arrFormNew = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormNew); $id = getParameter("id"); $arrValues['id'] = $id; if ($id == "") { $state = "new"; } else { $state = "edit"; } //************************************************************************************************************ //** TRAFFIC ** //************************************************************************************************************ $arrValues['traffic'] = getParameter("id_traffic"); if ($arrValues['traffic'] == "INPUT") { $arrValues['interface_in'] = getParameter("interface_in"); if (strlen($arrValues['interface_in']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_in" : ", interface_in"; } $arrValues['interface_out'] = null; } else { if ($arrValues['traffic'] == "OUTPUT") { $arrValues['interface_out'] = getParameter("interface_out"); if (strlen($arrValues['interface_out']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_out" : ", interface_out"; } $arrValues['interface_in'] = null; } else { if ($arrValues['traffic'] == "FORWARD") { $arrValues['interface_in'] = getParameter("interface_in"); if (strlen($arrValues['interface_in']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_in" : ", interface_in"; } $arrValues['interface_out'] = getParameter("interface_out"); if (strlen($arrValues['interface_out']) == 0) { $str_error .= strlen($str_error) == 0 ? "interface_out" : ", interface_out"; } } } } //************************************************************************************************************ //** SOURCE ** //************************************************************************************************************ $arrValues['ip_source'] = getParameter("ip_source"); $arrValues['mask_source'] = getParameter("mask_source"); $arrValues['ip_destin'] = getParameter("ip_destin"); $arrValues['mask_destin'] = getParameter("mask_destin"); //************************************************************************************************************ //** PROTOCOL ** //************************************************************************************************************ $arrValues['protocol'] = getParameter("id_protocol"); if ($arrValues['protocol'] == 'TCP' || $arrValues['protocol'] == 'UDP') { $arrValues['port_in'] = getParameter("port_in"); if (strlen($arrValues['port_in']) == 0) { $str_error .= strlen($str_error) == 0 ? "port_in" : ", port_in"; } $arrValues['port_out'] = getParameter("port_out"); if (strlen($arrValues['port_out']) == 0) { $str_error .= strlen($str_error) == 0 ? "port_out" : ", port_out"; } $arrValues['type_icmp'] = null; $arrValues['id_ip'] = null; $arrValues['state'] = ""; } else { if ($arrValues['protocol'] == 'ICMP') { $arrValues['port_in'] = null; $arrValues['port_out'] = null; $arrValues['state'] = ""; $arrValues['type_icmp'] = getParameter("type_icmp"); if (strlen($arrValues['type_icmp']) == 0) { $str_error .= strlen($str_error) == 0 ? "type" : ", type"; } $arrValues['id_ip'] = null; } else { if ($arrValues['protocol'] == 'IP') { $arrValues['port_in'] = null; $arrValues['port_out'] = null; $arrValues['type_icmp'] = null; $arrValues['state'] = ""; $arrValues['id_ip'] = getParameter("id_ip"); if (strlen($arrValues['id_ip']) == 0) { $str_error .= strlen($str_error) == 0 ? "id" : ", id"; } } else { if ($arrValues['protocol'] == 'STATE') { $arrValues['port_in'] = null; $arrValues['port_out'] = null; $arrValues['type_icmp'] = null; $arrValues['id_ip'] = null; $established = getParameter("established"); $related = getParameter("related"); if ($established == "on") { $arrValues['state'] = "Established"; if ($related == "on") { $arrValues['state'] .= ",Related"; } } else { if ($related == "on") { $arrValues['state'] = "Related"; } else { $str_error .= strlen($str_error) == 0 ? _tr("You have to select at least one state") : ", " . _tr("You have to select at least one state"); } } } else { $arrValues['port_in'] = ""; $arrValues['port_out'] = ""; $arrValues['type_icmp'] = ""; $arrValues['id_ip'] = ""; $arrValues['state'] = ""; } } } } //************************************************************************************************************ //** TARGET ** //************************************************************************************************************ $arrValues['target'] = getParameter("target"); if (strlen($arrValues['target']) == 0) { $str_error .= strlen($str_error) == 0 ? "target" : ", target"; } $arrValues['orden'] = getParameter("orden"); //********************** //MENSSAGE ERROR //********************** if (strlen($str_error) != 0) { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", $str_error); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } else { if ($arrValues['mask_source'] > 32 || $arrValues['mask_destin'] > 32) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The bit masks must be values less than 33")); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } else { if ($arrValues['ip_source'] != "0.0.0.0" && $arrValues['ip_source'] != "" && $arrValues['mask_source'] == "0" || $arrValues['ip_destin'] != "0.0.0.0" && $arrValues['ip_destin'] != "" && $arrValues['mask_destin'] == "0") { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Wrong Mask")); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } } } $arrValues['ip_source'] = $arrValues['ip_source'] == "" ? "0.0.0.0" : $arrValues['ip_source']; $arrValues['ip_destin'] = $arrValues['ip_destin'] == "" ? "0.0.0.0" : $arrValues['ip_destin']; $ipOrigen = explode(".", $arrValues['ip_source']); $ipDestino = explode(".", $arrValues['ip_destin']); if ($ipOrigen[0] > 255 || $ipOrigen[1] > 255 || $ipOrigen[2] > 255 || $ipOrigen[3] > 255 || $ipDestino[0] > 255 || $ipDestino[1] > 255 || $ipDestino[2] > 255 || $ipDestino[3] > 255) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Wrong value for ip")); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } $arrValues['mask_source'] = $arrValues['ip_source'] == "0.0.0.0" ? "0" : $arrValues['mask_source']; $arrValues['mask_destin'] = $arrValues['ip_destin'] == "0.0.0.0" ? "0" : $arrValues['mask_destin']; $pNet = new paloNetwork(); $oPalo = new paloSantoRules($pDB); if ($arrValues['ip_source'] != "0.0.0.0" && $arrValues['mask_source'] != "" && $arrValues['ip_source'] != "") { $arrValues['ip_source'] = $pNet->getNetAdress($arrValues['ip_source'], $arrValues['mask_source']); } if ($arrValues['ip_destin'] != "0.0.0.0" && $arrValues['mask_destin'] != "" && $arrValues['ip_destin'] != "") { $arrValues['ip_destin'] = $pNet->getNetAdress($arrValues['ip_destin'], $arrValues['mask_destin']); } if ($id == "") { if ($oPalo->saveRule($arrValues) == true) { $smarty->assign("mb_title", "MESSAGE"); $smarty->assign("mb_message", _tr("Successful Save")); } else { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", $oPalo->errMsg); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } } else { if ($oPalo->updateRule($arrValues, $id) == true) { $smarty->assign("mb_title", "MESSAGE"); $smarty->assign("mb_message", _tr("Successful Update")); } else { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", $oPalo->errMsg); return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state); } } return reportRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function saveNewOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $success = false; $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien hace la accion if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain); $arrFormOrgz = createFieldForm(); $oForm = new paloForm($smarty, $arrFormOrgz); 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); return viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["description"] = getParameter("description"); $arrProp["destdial"] = getParameter("destdial"); $pDB->beginTransaction(); $success = $pOtherDestinations->createNewOtherDestinations($arrProp); if ($success) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pOtherDestinations->errMsg; } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Other Destination has been created successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); $content = reportOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function deleteEliminacióndebases($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEliminacióndebases = new paloSantoEliminacióndebases($pDB); $arrFormEliminacióndebases = createFieldForm($pEliminacióndebases); $oForm = new paloForm($smarty, $arrFormEliminacióndebases); 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormEliminacióndebases($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { $pEliminacióndebases->eliminarBase($_POST['base_de_clientes']); Header("Location: index.php?menu=hispana_base_lista"); } return $content; }
function saveNewFTPBackup($smarty, $module_name, $local_templates_dir, &$pDB) { $pFTPBackup = new paloSantoFTPBackup($pDB); $oForm = new paloForm($smarty, createFieldForm()); 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) { $strErrorMsg .= implode(', ', array_keys($arrErrores)); } $smarty->assign("mb_message", $strErrorMsg); } else { $server = getParameter("server"); $port = getParameter("port"); $user = getParameter("user"); $password = getParameter("password"); $path = getParameter("pathServer"); //deben estar llenos todos los campos if ($server && $port && $user && $password && $path) { $r = $pFTPBackup->asignarCredencialesFTP($server, $port, $user, $password, $path); if (!$r) { $smarty->assign("mb_message", $pFTPBackup->errMsg); } } else { $smarty->assign("mb_message", _tr('Error to save')); } } return viewFormFTPBackup($smarty, $module_name, $local_templates_dir, $pDB); }
function saveNewMoH($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $continue = true; $success = false; if ($credentials['userlevel'] == 'superadmin') { $pMoH = new paloSantoMoH($pDB, ""); } else { $domain = $credentials['domain']; $pMoH = new paloSantoMoH($pDB, $domain); } $arrFormOrgz = createFieldForm(array(), $credentials['userlevel'] == 'superadmin'); $oForm = new paloForm($smarty, $arrFormOrgz); 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); return viewFormMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $name = getParameter("name"); if ($name == "") { $error = _tr("Field 'Name' can't be empty."); $continue = false; } elseif (getParameter("mode_moh") == 'custom' && $credentials['userlevel'] != 'superadmin') { $error = _tr('Creation of custom MOH restricted to superadmin'); $continue = FALSE; } if ($continue) { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["name"] = getParameter("name"); $arrProp["mode"] = getParameter("mode_moh"); $arrProp["application"] = getParameter("application"); $arrProp["sort"] = getParameter("sort"); $arrProp["format"] = getParameter("format"); } if ($continue) { $pDB->beginTransaction(); $success = $pMoH->createNewMoH($arrProp); if ($success) { $pDB->commit(); if ($arrProp["mode"] == "files") { $pMoH->uploadFile($arrProp["name"]); } } else { $pDB->rollBack(); } $error .= $pMoH->errMsg; } } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("New MoH Class has been created successfully") . " " . $error); $content = reportMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function saveEditBaseDeClientes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pIngresodeBasedeClientes = new paloSantoIngresodeBasedeClientes($pDB); $arrFormIngresodeBasedeClientes = createFieldForm($pDB); $oForm = new paloForm($smarty, $arrFormIngresodeBasedeClientes); 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormIngresodeBasedeClientes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { $arrResult = $pIngresodeBasedeClientes->actualizarCampaniaRecarga($_POST); header("location: ?menu=hispana_listado_recarga"); } return $content; }
function saveThemes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $uid) { $oThemes = new PaloSantoThemes($pDB); $arr_themes = $oThemes->getThemes("/var/www/html/admin/web/themes/"); $formThemes = createFieldForm($arr_themes); $oForm = new paloForm($smarty, $formThemes); $exito = $oThemes->updateTheme($_POST['themes'], $uid); if ($exito) { if ($oThemes->smartyRefresh($_SERVER['DOCUMENT_ROOT'])) { header("Location: index.php?menu=themes_system"); die; } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("The smarty cache could not be deleted")); } } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $oThemes->errMsg); } return formThemes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $uid); }
function saveEditQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $exito = false; $qname = getParameter("qname"); $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien hace la accion if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } if (!isset($qname)) { $error = _tr("Queue doesn't exist"); } else { $pQueue = new paloQueuePBX($pDB, $domain); $arrTmp = $pQueue->getQueueByName($qname); if ($arrTmp === false) { $error = _tr("Error with database connection. ") . $pQueue->errMsg; } elseif (count($arrTmp) == false) { $error = _tr("Queue doesn't exist"); } else { $arrForm = createFieldForm(array(), array(), array(), array(), array()); $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); return viewQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $password = getParameter("password_detail"); if (isset($password)) { if (!preg_match("/^[0-9]*\$/", $password)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Password must only contain digits.")); return viewQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } $arrMembers = array('dynamic_members' => getParameter("dynamic_members"), 'static_members' => getParameter("static_members")); $pDB->beginTransaction(); $arrProp = queueParams(); $arrProp["name"] = $qname; $exito = $pQueue->updateQueue($arrProp, $arrMembers); if ($exito) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pQueue->errMsg; } } } if ($exito) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Queue has been edited successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); } return reportQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); }
function saveDHCP_Configuration($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $update = FALSE) { $pDHCP_Configuration = new paloSantoDHCP_Configuration($pDB); $arrFormDHCP_Configuration = createFieldForm(); $oForm = new paloForm($smarty, $arrFormDHCP_Configuration); if ($update) { $oForm->setEditMode(); } $smarty->assign("REQUIRED_FIELD", _tr('Required field')); $smarty->assign("SAVE", _tr('Save')); $smarty->assign("EDIT", _tr('Edit')); $smarty->assign("CANCEL", _tr('Cancel')); $smarty->assign("icon", "modules/{$module_name}/images/system_network_assign_ip_address.png"); $smarty->assign("ID", getParameter('id')); if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr('Assign IP Address to Host'), $_POST); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; } else { $arrDhcpPost = array(); $hostname = getParameter("hostname"); if (preg_match("/^([a-zA-Z]+)[[:space:]]+([a-zA-Z]+)\$/", $hostname, $arrReg)) { $arrDhcpPost['hostname'] = $arrReg[1] . "_" . $arrReg[2]; } else { $arrDhcpPost['hostname'] = getParameter("hostname"); } $arrDhcpPost['ipaddress'] = getParameter("ipaddress"); $arrDhcpPost['macaddress'] = getParameter("macaddress"); if ($update) { $id = getParameter("id"); $r = $pDHCP_Configuration->actualizarIpFija($id, $arrDhcpPost['hostname'], $arrDhcpPost['ipaddress'], $arrDhcpPost['macaddress']); } else { $r = $pDHCP_Configuration->insertarIpFija($arrDhcpPost['hostname'], $arrDhcpPost['ipaddress'], $arrDhcpPost['macaddress']); } if (!$r) { $smarty->assign("mb_message", $pDHCP_Configuration->errMsg); $smarty->assign("REQUIRED_FIELD", _tr('Required field')); $smarty->assign("SAVE", _tr('Save')); $smarty->assign("CANCEL", _tr('Cancel')); $smarty->assign("icon", "modules/{$module_name}/images/system_network_assign_ip_address.png"); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr('Assign IP Address to Host'), $_POST); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; } else { header("Location: ?menu={$module_name}&action=show"); } } }
function viewFormTC($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $arrRG = array(); $action = getParameter("action"); $idTC = getParameter("id_tc"); if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idTC)) { $error = _tr("Invalid Time Conditions"); } else { $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pTC = new paloSantoTC($pDB, $domain); $arrTC = $pTC->getTCById($idTC); if ($arrTC === false) { $error = _tr($pTC->errMsg); } else { if (count($arrTC) == 0) { $error = _tr("TC doesn't exist"); } else { if (getParameter("save_edit")) { $arrTC = $_POST; } } } } if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportTC($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_tc")) { $domain = getParameter('organization_add'); //este parametro solo es selecionable cuando es el superadmin quien crea la ruta } else { $domain = getParameter('organization'); } } else { $domain = $credentials['domain']; } $pTC = new paloSantoTC($pDB, $domain); if (getParameter("create_tc")) { $arrTC["goto_m"] = ""; $arrTC["goto_f"] = ""; } else { $arrTC = $_POST; } } $goto = $pTC->getCategoryDefault($domain); if ($goto === false) { $goto = array(); } $res1 = $pTC->getDefaultDestination($domain, $arrTC["goto_m"]); $destiny1 = $res1 == false ? array() : $res1; $res2 = $pTC->getDefaultDestination($domain, $arrTC["goto_f"]); $destiny2 = $res2 == false ? array() : $res2; $arrForm = createFieldForm($goto, $destiny1, $destiny2, $pTC->getTimeGroup()); $oForm = new paloForm($smarty, $arrForm); if ($action == "view") { $oForm->setViewMode(); } else { if (getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } //permission $smarty->assign("EDIT_TC", in_array('edit', $arrPermission)); $smarty->assign("CREATE_TC", in_array('create', $arrPermission)); $smarty->assign("DEL_TC", in_array('delete', $arrPermission)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("OPTIONS", _tr("Options")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("id_tc", $idTC); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("SETDESTINATION_M", _tr("Destination If Match")); $smarty->assign("SETDESTINATION_F", _tr("Destination If Fail")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("TC Route"), $arrTC); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function saveNewGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $group = getParameter("group"); $description = getParameter("description"); $idOrgzSel = getParameter("organization"); if ($userLevel1 != "superadmin") { $idOrgzSel = $idOrganization; } $arrFormGroup = createFieldForm(array()); $oForm = new paloForm($smarty, $arrFormGroup); if (isset($idOrgzSel)) { 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if ($idOrgzSel == 0 || $idOrgzSel == 1) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("You must select a organization")); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if ($pACL->createGroup($group, $description, $idOrgzSel)) { $smarty->assign("mb_title", _tr("MESSSAGE")); $smarty->assign("mb_message", _tr("Group was created sucessfully")); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } } } } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("You must select a organization")); return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } }
function applyChanges($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $action = ""; $pORGZ = new paloSantoOrganization($pDB); $pGP = new paloGeneralPBX($pDB); $arrForm = createFieldForm($pGP->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 = $pGP->setGeneralSettings($arrProp); if ($exito === true) { $pDB->commit(); unset($_POST["save_edit"]); if (reloadFiles()) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Changes have been applied successfully.")); } else { $smarty->assign("mb_title", _tr("ERROR")); $msg = _tr("Changes couldn't be applied successfully. "); $msg .= $pGP->errMsg; $smarty->assign("mb_message", $msg); } } else { $pDB->rollBack(); $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Changes couldn't be applied. ") . $pGP->errMsg); } } return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function viewFormTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $arrItems = array()) { global $arrPermission; $error = ""; $arrTG = array(); $action = getParameter("action"); $idTG = getParameter("id_tg"); if ($action == "edit" || getParameter("save_edit")) { if (!isset($idTG)) { $error = _tr("Invalid Time Group"); } else { $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pTG = new paloSantoTG($pDB, $domain); $arrTG = $pTG->getTGById($idTG); if ($arrTG === false) { $error = _tr($pTG->errMsg); } else { if (count($arrTG) == 0) { $error = _tr("TG doesn't exist"); } else { $smarty->assign('j', 0); if (getParameter("save_edit")) { $arrTG = $_POST; } if ($action == "edit") { $pTG->getParametersTG($idTG, $smarty); } } } } if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportTG($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_tg")) { $domain = getParameter('organization_add'); //este parametro solo es selecionable cuando es el superadmin quien crea la ruta } else { $domain = getParameter('organization'); } } else { $domain = $credentials['domain']; } $pTG = new paloSantoTG($pDB, $domain); $smarty->assign('j', 1); if (getParameter("create_tg")) { $smarty->assign('j', 1); $smarty->assign('arrItems', $arrItems); } else { $smarty->assign('j', 0); $arrTG = $_POST; } } $arrForm = createFieldForm($smarty); $oForm = new paloForm($smarty, $arrForm); if ($action == "edit" || getParameter("save_edit")) { $oForm->setEditMode(); } //permission $smarty->assign("EDIT_TG", in_array('edit', $arrPermission)); $smarty->assign("CREATE_TG", in_array('create', $arrPermission)); $smarty->assign("DEL_TG", in_array('delete', $arrPermission)); //$smarty->assign("ERROREXT",_tr($pTrunk->errMsg)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("OPTIONS", _tr("Options")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("id_tg", $idTG); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("ADD_GROUP", _tr("Add Conditions")); $smarty->assign("DELETE_GROUP", _tr("Delete Conditions")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("TG Route"), $arrTG); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, $update = FALSE) { $arrFormadress_book = createFieldForm($arrLang); $pACL = new paloACL($pDB_2); $id_user = $pACL->getIdUser($_SESSION["elastix_user"]); $padress_book = new paloAdressBook($pDB); $oForm = new paloForm($smarty, $arrFormadress_book); $id = isset($_GET['id']) ? $_GET['id'] : (isset($_POST['id']) ? $_POST['id'] : ""); if (isset($_POST["edit"]) || $update == TRUE) { $oForm->setEditMode(); if ($padress_book->isEditablePublicContact($id, $id_user)) { $smarty->assign("Commit", 1); $smarty->assign("SAVE", $arrLang["Save"]); } else { $smarty->assign("Commit", 0); $smarty->assign("SAVE", $arrLang["Save"]); } } else { $oForm->setViewMode(); $smarty->assign("Edit", 1); if ($padress_book->isEditablePublicContact($id, $id_user)) { $smarty->assign("Edit", 1); $smarty->assign("EditW", 0); } else { $smarty->assign("Edit", 0); $smarty->assign("EditW", 0); } } $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("title", $arrLang["Address Book"]); $smarty->assign("FirstName", $arrLang["First Name"]); $smarty->assign("LastName", $arrLang["Last Name"]); $smarty->assign("PhoneNumber", $arrLang["Phone Number"]); $smarty->assign("Email", $arrLang["Email"]); $smarty->assign("address", $arrLang["Address"]); $smarty->assign("company", $arrLang["Company"]); $smarty->assign("notes", $arrLang["Notes"]); $smarty->assign("picture", $arrLang["picture"]); $smarty->assign("private_contact", $arrLang["Private Contact"]); $smarty->assign("public_contact", $arrLang["Public Contact"]); if (isset($_POST['address_book_options']) && $_POST['address_book_options'] == 'address_from_csv') { $smarty->assign("check_csv", "checked"); } else { $smarty->assign("check_new_contact", "checked"); } $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("label_file", $arrLang["File"]); $smarty->assign("DOWNLOAD", $arrLang["Download Address Book"]); $smarty->assign("HeaderFile", $arrLang["Header File Address Book"]); $smarty->assign("AboutContacts", $arrLang["About Address Book"]); $smarty->assign("style_address_options", "style='display:none'"); $smarty->assign("idPhoto", $id); $contactData = $padress_book->contactData($id, $id_user); if ($contactData) { $smarty->assign("ID", $id); } else { $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $arrLang["Not_allowed_contact"]); return report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } if ($contactData['status'] == 'isPrivate') { $smarty->assign("check_isPrivate", "checked"); } else { if ($contactData['status'] == 'isPublic') { $smarty->assign("check_isPublic", "checked"); } else { $smarty->assign("check_isPrivate", "checked"); } } $arrData['name'] = isset($_POST['name']) ? $_POST['name'] : $contactData['name']; $arrData['last_name'] = isset($_POST['last_name']) ? $_POST['last_name'] : $contactData['last_name']; $arrData['telefono'] = isset($_POST['telefono']) ? $_POST['telefono'] : $contactData['telefono']; $arrData['email'] = isset($_POST['email']) ? $_POST['email'] : $contactData['email']; $arrData['address'] = isset($_POST['address']) ? $_POST['address'] : $contactData['address']; $arrData['company'] = isset($_POST['company']) ? $_POST['company'] : $contactData['company']; $arrData['notes'] = isset($_POST['notes']) ? $_POST['notes'] : $contactData['notes']; $arrData['picture'] = isset($_POST['picture']) ? $_POST['picture'] : $contactData['picture']; $arrData['status'] = isset($_POST['status']) ? $_POST['status'] : $contactData['status']; $smarty->assign("ShowImg", 1); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new_adress_book.tpl", $arrLang["Address Book"], $arrData); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }
function saveNewList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pEmailList = new paloSantoEmailList($pDB); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('domain'); } else { $domain = $credentials['domain']; } $namelist = getParameter("namelist"); $namelist = strtolower($namelist); $password = getParameter("password"); $passwordconfirm = getParameter("passwordconfirm"); $emailadmin = getParameter("emailadmin"); $arrForm = createFieldForm(array()); $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); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } //validaciones if ($password != $passwordconfirm) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The Password List and Confirm Password List do not match")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $pDB->beginTransaction(); if (!$pEmailList->createEmailList($domain, $namelist, $password, $emailadmin)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("List could not be created.") . " " . $pEmailList->getError()); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $pDB->commit(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("The List was created successfully ")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } }
function saveNewInbound($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $error = ""; $continue = true; $success = false; $domain = getParameter('organization'); //este parametro solo es selecionable cuando es el superadmin quien crea la ruta if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pInbound = new paloSantoInbound($pDB, $domain); $domain = $pInbound->getDomain(); if (empty($domain)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid Organization")); return reportInbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $goto = $pInbound->getCategoryDefault($domain); if ($goto === false) { $goto = array(); } $res = $pInbound->getDefaultDestination($domain, getParameter("goto")); $destiny = $res == false ? array() : $res; $arrFormOrgz = createFieldForm($goto, $destiny, $pInbound->getFaxExtesion(), $pInbound->getDetectFax(), $pInbound->getMoHClass($domain)); $oForm = new paloForm($smarty, $arrFormOrgz); 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); return viewFormInbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $description = getParameter("description"); if ($description == "") { $error = _tr("Description can not be empty."); $continue = false; } if ($pInbound->validateDestine($domain, getParameter("destination")) == false) { $error = _tr("You must select a destination for this inbound."); $continue = false; } if ($continue) { //seteamos un arreglo con los parametros configurados $arrProp = array(); $arrProp["description"] = getParameter("description"); $arrProp['did_number'] = getParameter("did_number"); $arrProp['cid_number'] = getParameter("cid_number"); //$arrProp['cid_priority'] = (getParameter("cid_priority")) ? "on" : "off"; $arrProp['alertinfo'] = getParameter("alertinfo"); $arrProp['cid_prefix'] = getParameter("cid_prefix"); $arrProp['moh'] = getParameter("moh"); $arrProp['ringing'] = getParameter("ringing"); $arrProp['delay_answer'] = getParameter("delay_answer"); $arrProp['primanager'] = getParameter("primanager"); if ($arrProp['primanager'] == "yes") { $arrProp['max_attempt'] = getParameter("max_attempt"); $arrProp['min_length'] = getParameter("min_length"); } $arrProp['fax_detect'] = getParameter('fax_detect'); if ($arrProp['fax_detect'] == "yes") { $arrProp['fax_type'] = getParameter('fax_type'); $arrProp['fax_time'] = getParameter('fax_time'); $arrProp['fax_destiny'] = getParameter('fax_destiny'); } $arrProp['language'] = getParameter("language"); $arrProp['goto'] = getParameter("goto"); $arrProp['destination'] = getParameter("destination"); $arrProp['domain'] = $domain; } if ($continue) { $pDB->beginTransaction(); $success = $pInbound->createNewInbound($arrProp); if ($success) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pInbound->errMsg; } } if ($success) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Inbound has been created successfully")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); $content = reportInbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormInbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }
function saveDomain($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang) { $pEmail = new paloEmail($pDB); $arrFormElements = createFieldForm($arrLang); $oForm = new paloForm($smarty, $arrFormElements); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); 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}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = $oForm->fetchForm("{$local_templates_dir}/form_domain.tpl", $arrLang["New Domain"], $_POST); } else { $pDB->beginTransaction(); $bExito = create_email_domain($pDB, $error); if (!$bExito) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $error); $content = $oForm->fetchForm("{$local_templates_dir}/form_domain.tpl", $arrLang["New Domain"], $_POST); } else { $pDB->commit(); $smarty->assign("mb_message", _tr("Domain has been created")); $content = viewFormDomain($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang); } } return $content; }
function view_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk, $update = FALSE) { $arrFormadress_book = createFieldForm($pDB); $padress_book = new paloAdressBook($pDB); $oForm = new paloForm($smarty, $arrFormadress_book); $id = getParameter('id'); if (isset($_POST["edit"]) || $update == TRUE) { $oForm->setEditMode(); $smarty->assign("Commit", 1); $smarty->assign("SAVE", "Sửa"); } else { $oForm->setViewMode(); $smarty->assign("Edit", 1); } $smarty->assign("icon", "modules/{$module_name}/images/address_book.png"); $smarty->assign("EDIT", "Sửa"); $smarty->assign("title", "Thông tin khách hàng"); $smarty->assign("SAVE", "Lưu"); $smarty->assign("CANCEL", "Đóng"); $smarty->assign("REQUIRED_FIELD", "Bắt buộc"); $contactData = $padress_book->contactData($id); if ($contactData) { $smarty->assign("ID", $id); } else { $smarty->assign("mb_title", "Lỗi"); $smarty->assign("mb_message", 'Không cho phép xem'); return report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk); } if ($contactData['type'] == '0') { $smarty->assign("check_0", "checked"); } elseif ($contactData['type'] == '1') { $smarty->assign("check_1", "checked"); } elseif ($contactData['type'] == '2') { $smarty->assign("check_2", "checked"); } else { $smarty->assign("check_3", "checked"); } // get contact list to show in smarty $smarty->assign("CONTACT", $contactData['contact']); // get phone list foreach ($contactData['number'] as $v) { $arr_phone .= $v . "\n"; } $arrData['firstname'] = $contactData['firstname']; $arrData['lastname'] = $contactData['lastname']; $arrData['company'] = $contactData['company']; $arrData['email'] = $contactData['email']; $arrData['cmnd'] = $contactData['cmnd']; $arrData['passport'] = $contactData['passport']; $arrData['birthday'] = date("d-m-Y", strtotime($contactData['birthday'])); $arrData['birthplace'] = $contactData['birthplace']; $arrData['address'] = $contactData['address']; $arrData['membership'] = $contactData['membership']; $arrData['sale'] = $contactData['sale']; $arrData['booker'] = $contactData['agent_id']; $arrData['accountant'] = $contactData['accountant']; $arrData['payment_type'] = $contactData['payment_type']; $arrData['customer_code'] = $contactData['customer_code']; // for company customer $arrData['company_name'] = $contactData['firstname']; $arrData['company_booker'] = $contactData['agent_id']; $arrData['company_code'] = $contactData['customer_code']; $arrData['company_pay_type'] = $contactData['payment_type']; $arrData['company_sale'] = $contactData['sale']; $arrData['company_accountant'] = $contactData['accountant']; $arrData['company_address'] = $contactData['address']; $arrData['company_membership'] = $contactData['membership']; $arrData['phone'] = $arr_phone; $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new_adress_book.tpl", "Thông tin khách hàng", $arrData); $contenidoModulo = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }
function reportReportCall($smarty, $module_name, $local_templates_dir, &$pDB_cdr, &$pDB_billing, $arrConf, $arrLang) { $pReportCall = new paloSantoReportCall($pDB_cdr, $pDB_billing); //PARAMETERS $type = getParameter("option_fil"); $value_tmp = getParameter("value_fil"); $date_ini_tmp = getParameter("date_from"); $date_end_tmp = getParameter("date_to"); $order_by_tmp = getParameter("order_by"); $order_type_tmp = getParameter("order_type"); $action = getParameter("nav"); $start = getParameter("start"); $value = isset($value_tmp) ? $value_tmp : ""; $order_by = isset($order_by_tmp) ? $order_by_tmp : 1; $order_type = isset($order_type_tmp) ? $order_type_tmp : "asc"; $date_from = isset($date_ini_tmp) ? $date_ini_tmp : date("d M Y"); $date_to = isset($date_end_tmp) ? $date_end_tmp : date("d M Y"); $date_ini = translateDate($date_from) . " 00:00:00"; $date_end = translateDate($date_to) . " 23:59:59"; //********************************** //begin grid parameters $oGrid = new paloSantoGrid($smarty); $limit = 40; $total = $pReportCall->ObtainNumberDevices($type, $value); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->calculatePagination($action, $start); $offset = $oGrid->getOffsetValue(); $end = $oGrid->getEnd(); $urlFields = array('menu' => $module_name, 'option_fil' => $type, 'value_fil' => $value, 'date_from' => $date_from, 'date_to' => $date_to); $url = construirUrl($urlFields, array('nav', 'start')); $urlFields['order_by'] = $order_by; $urlFields['order_type'] = $order_type; $smarty->assign("order_by", $order_by); $smarty->assign("order_type", $order_type); $arrData = null; $arrResult = $pReportCall->ObtainReportCall($limit, $offset, $date_ini, $date_end, $type, $value, $order_by, $order_type); $order_type = $order_type == "desc" ? "asc" : "desc"; if (is_array($arrResult) && $total > 0) { foreach ($arrResult as $key => $val) { $ext = $val['extension']; $arrTmp[0] = $ext; $arrTmp[1] = $val['user_name']; $arrTmp[2] = $val['num_incoming_call']; $arrTmp[3] = $val['num_outgoing_call']; $arrTmp[4] = "<label style='color: green;' title='{$val['duration_incoming_call']} {$arrLang['seconds']}'>" . $pReportCall->Sec2HHMMSS($val['duration_incoming_call']) . "</label>"; $arrTmp[5] = "<label style='color: green;' title='{$val['duration_outgoing_call']} {$arrLang['seconds']}'>" . $pReportCall->Sec2HHMMSS($val['duration_outgoing_call']) . "</label>"; $arrTmp[6] = "<a href='javascript: popup_ventana(\"?menu={$module_name}&action=graph&rawmode=yes&ext={$ext}&dini={$date_ini}&dfin={$date_end}\");'>" . "" . $arrLang['Call Details'] . "</a>"; $arrData[] = $arrTmp; } } $img = "<img src='images/flecha_{$order_type}.png' border='0' align='absmiddle'>"; $leyend_1 = "<a class='link_summary_off' href='{$url}&order_by=1&order_type=asc'>{$arrLang["Extension"]}</a>"; $leyend_2 = "<a class='link_summary_off' href='{$url}&order_by=2&order_type=asc'>{$arrLang["User name"]}</a>"; $leyend_3 = "<a class='link_summary_off' href='{$url}&order_by=3&order_type=asc'>{$arrLang["Num. Incoming Calls"]}</a>"; $leyend_4 = "<a class='link_summary_off' href='{$url}&order_by=4&order_type=asc'>{$arrLang["Num. Outgoing Calls"]}</a>"; $leyend_5 = "<a class='link_summary_off' href='{$url}&order_by=5&order_type=asc'>{$arrLang["Sec. Incoming Calls"]}</a>"; $leyend_6 = "<a class='link_summary_off' href='{$url}&order_by=6&order_type=asc'>{$arrLang["Sec. Outgoing Calls"]}</a>"; if ($order_by == 1) { $leyend_1 = "<a class='link_summary_on' href='{$url}&order_by=1&order_type={$order_type}'>{$arrLang["Extension"]} {$img}</a>"; } else { if ($order_by == 2) { $leyend_2 = "<a class='link_summary_on' href='{$url}&order_by=2&order_type={$order_type}'>{$arrLang["User name"]} {$img}</a>"; } else { if ($order_by == 3) { $leyend_3 = "<a class='link_summary_on' href='{$url}&order_by=3&order_type={$order_type}'>{$arrLang["Num. Incoming Calls"]} {$img}</a>"; } else { if ($order_by == 4) { $leyend_4 = "<a class='link_summary_on' href='{$url}&order_by=4&order_type={$order_type}'>{$arrLang["Num. Outgoing Calls"]} {$img}</a>"; } else { if ($order_by == 5) { $leyend_5 = "<a class='link_summary_on' href='{$url}&order_by=5&order_type={$order_type}'>{$arrLang["Sec. Incoming Calls"]} {$img}</a>"; } else { if ($order_by == 6) { $leyend_6 = "<a class='link_summary_on' href='{$url}&order_by=6&order_type={$order_type}'>{$arrLang["Sec. Outgoing Calls"]} {$img}</a>"; } } } } } } $arrGrid = array("title" => $arrLang["Summary by Extension"], "icon" => "images/list.png", "width" => "100%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $urlFields, "columns" => array(0 => array("name" => $leyend_1, "property1" => ""), 1 => array("name" => $leyend_2, "property1" => ""), 2 => array("name" => $leyend_3, "property1" => ""), 3 => array("name" => $leyend_4, "property1" => ""), 4 => array("name" => $leyend_5, "property1" => ""), 5 => array("name" => $leyend_6, "property1" => ""), 6 => array("name" => $arrLang["Details"], "property1" => ""))); //begin section filter $arrFormFilterReportCall = createFieldForm($arrLang); $oFilterForm = new paloForm($smarty, $arrFormFilterReportCall); $_POST['option_fil'] = $type; $_POST['value_fil'] = $value; $_POST['date_from'] = $date_from; $_POST['date_to'] = $date_to; $smarty->assign("SHOW", $arrLang["Show"]); if ($_POST["date_from"] === "") { $_POST["date_from"] = " "; } if ($_POST['date_to'] === "") { $_POST['date_to'] = " "; } $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $date_from . ", " . _tr("End Date") . " = " . $date_to, $_POST, array("date_from" => date("d M Y"), "date_to" => date("d M Y")), true); $valueType = ""; if (!is_null($type)) { if ($type == "Ext") { $valueType = _tr("Extension"); } else { $valueType = _tr("User"); } } $oGrid->addFilterControl(_tr("Filter applied: ") . $valueType . " = " . $value, $_POST, array("option_fil" => "Ext", "value_fil" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); //end section filter $oGrid->showFilter(trim($htmlFilter)); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang); return $contenidoModulo; }
function saveNewEmailRelay($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $arrFormEmailRelay = createFieldForm(); $oForm = new paloForm($smarty, $arrFormEmailRelay); if (!$oForm->validateForm($_POST)) { $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 { $pEmailRelay = new paloSantoEmailRelay($pDB); $arrData['relayhost'] = rtrim(getParameter('relayhost')); $arrData['port'] = rtrim(getParameter('port')); $arrData['user'] = rtrim(getParameter('user')); $arrData['password'] = rtrim(getParameter('password')); $arrData['status'] = rtrim(getParameter('status')); $arrData['autentification'] = getParameter('autentification'); if ($arrData['status'] != 'on') { $arrData['status'] = 'off'; } $SMTP_Server = rtrim(getParameter('SMTP_Server')); if ($SMTP_Server != "custom") { if ($arrData['user'] == "" || $arrData['password'] == "") { $varErrors = ""; if ($arrData['user'] == "") { $varErrors = _tr("Username") . ", "; } if ($arrData['password'] == "") { $varErrors .= " " . _tr("Password"); } $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>" . $varErrors; $smarty->assign("mb_message", $strErrorMsg); $content = viewFormEmailRelay($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); return $content; } } $tls_enabled = $arrData['autentification'] == "on" ? true : false; $auth_enabled = $arrData['user'] != "" && $arrData['password'] != ""; $isOK = $arrData['status'] == 'on' ? $pEmailRelay->checkSMTP($arrData['relayhost'], $arrData['port'], $arrData['user'], $arrData['password'], $auth_enabled, $tls_enabled) : true; if (is_array($isOK)) { //hay errores al tratar de verificar datos $errors = $isOK["ERROR"]; $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($errors)); $content = viewFormEmailRelay($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); return $content; } $pEmailRelay->setStatus($arrData['status']); $ok = $pEmailRelay->processUpdateConfiguration($arrData); if ($ok) { $smarty->assign("mb_title", _tr("Result transaction")); $smarty->assign("mb_message", _tr("Configured successful")); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pEmailRelay->errMsg); } } $content = viewFormEmailRelay($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); return $content; }
function formAntispam($smarty, $module_name, $local_templates_dir, $arrLang, $arrLangModule, $arrConf, $arrConfModule) { $arrFormConference = createFieldForm($arrLang, $arrLangModule); $oForm = new paloForm($smarty, $arrFormConference); $smarty->assign("LEGEND", $arrLang["Legend"]); $smarty->assign("UPDATE", $arrLang["Save"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("icon", "modules/{$module_name}/images/email_antispam.png"); $objAntispam = new paloSantoAntispam($arrConfModule['path_postfix'], $arrConfModule['path_spamassassin'], $arrConfModule['file_master_cf'], $arrConfModule['file_local_cf']); $activated = $objAntispam->isActiveSpamFilter(); if ($activated) { $arrData['status'] = "on"; $smarty->assign("statusSpam", "active"); } else { $arrData['status'] = "off"; $smarty->assign("statusSpam", "desactive"); } $val = $objAntispam->getTimeDeleteSpam(); if ($val != '') { $arrData['time_spam'] = $val; } $statusSieve = $activated && $val != '' ? 'on' : 'off'; $arrData['politica'] = $statusSieve == 'on' ? 'capturar_spam' : 'marcar_asusto'; $smarty->assign("statusSieve", $statusSieve); $valueRequiredHits = $objAntispam->getValueRequiredHits(); $arrData['levelNUM'] = $valueRequiredHits['level']; $arrData['header'] = $valueRequiredHits['header']; $smarty->assign("levelNUM", $arrData['levelNUM']); $smarty->assign("level", $arrLang['Level']); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", $arrLangModule["Antispam"], $arrData); $contenidoModulo = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }