function showConfigs($smarty, $module_name, $local_templates_dir, $pDB, $arrCredentials) { global $arrPermission; $fMaster = new paloFaxMaster($pDB); $arrForm = fieldFrorm(); $oForm = new paloForm($smarty, $arrForm); $oForm->setEditMode(); $smarty->assign("EDIT", in_array('edit', $arrPermission)); if (getParameter("save_default")) { $arrDefault['fax_master'] = $_POST['fax_master']; } else { //obtener el valor de la tarifa por defecto $arrDefault['fax_master'] = $fMaster->getFaxMaster(); if ($arrDefault['fax_master'] === false) { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", _tr("An error has ocurred to retrieved configuration.") . " " . $fMaster->getErrorMsg()); $arrDefault['fax_master'] = ''; } } $smarty->assign("FAXMASTER_MSG", _tr("Write the email address which will receive the notifications of received messages, errors and activity summary of the Fax Server")); $smarty->assign("icon", "web/apps/{$module_name}/images/fax_fax_master.png"); $smarty->assign("APPLY_CHANGES", _tr("Save")); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $strReturn = $oForm->fetchForm("{$local_templates_dir}/fax_master.tpl", _tr("Fax Master Configuration"), $arrDefault); return $strReturn; }
function listParameterFaxMail($smarty, $module_name, $local_templates_dir, $pDB, $credentials) { $arrData = array(); $oFax = new paloFax($pDB); global $arrPermission; $smarty->assign("EDIT", in_array('edit', $arrPermission)); if (getParameter("submit_apply_change")) { $arrParameterFaxMail = $_POST; } else { $arrParameterFaxMail = $oFax->getConfigurationSendingFaxMailOrg($credentials['id_organization']); if ($arrParameterFaxMail === false) { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", "An error has ocurred to retrieved email fax configutaion"); } } // Definición del formulario $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("EDIT_PARAMETERS", _tr("Edit Parameters")); $smarty->assign("icon", "web/apps/{$module_name}/images/fax_email_template.png"); $arrFaxConfig = createForm(); $oForm = new paloForm($smarty, $arrFaxConfig); if (getParameter("submit_apply_change") || getParameter("submit_edit")) { $oForm->setEditMode(); } else { $oForm->setViewMode(); } return $oForm->fetchForm("{$local_templates_dir}/parameterFaxMail.tpl", _tr("Configuration Sending Fax Mail"), $arrParameterFaxMail); }
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 viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $arrOtherDestinations = array(); $action = getParameter("action"); $idOtherDestinations = getParameter("id"); if ($action == "view" || $action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idOtherDestinations)) { $error = _tr("Invalid Other Destination ID"); } else { $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain); $arrOtherDestinations = $pOtherDestinations->getOtherDestinationsById($idOtherDestinations); if ($arrOtherDestinations === false) { $error = _tr($pOtherDestinations->errMsg); } else { if (count($arrOtherDestinations) == 0) { $error = _tr("Other Destination doesn't exist"); } else { if (getParameter("save_edit")) { $arrOtherDestinations = $_POST; } } } } if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { // new, create if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_other_destination")) { $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']; } $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain); if (getParameter("create_other_destination")) { $arrOtherDestinations["destdial"] = ""; $arrOtherDestinations["description"] = ""; } else { $arrOtherDestinations = $_POST; } } $arrFormOrgz = createFieldForm(); $oForm = new paloForm($smarty, $arrFormOrgz); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } //permission $arrAD = $pOtherDestinations->getAdditionalsDestinations(); $smarty->assign("arrAditionalsDestinations", $arrAD); $smarty->assign("EDIT_OD", in_array('edit', $arrPermission)); $smarty->assign("CREATE_OD", in_array('create', $arrPermission)); $smarty->assign("DEL_OD", in_array('delete', $arrPermission)); $smarty->assign("FeatureCodes", _tr("Feature Codes")); $smarty->assign("ShortcutApps", _tr("Shortcut Apps")); $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", $idOtherDestinations); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Other Destinations"), $arrOtherDestinations); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormEliminació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); //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. $dataEliminacióndebases = $pEliminacióndebases->getEliminacióndebasesById($id); if (is_array($dataEliminacióndebases) & count($dataEliminacióndebases) > 0) { $_DATA = $dataEliminacióndebases; } else { $smarty->assign("mb_title", _tr("Error get Data")); $smarty->assign("mb_message", $pEliminacióndebases->errMsg); } } $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("IMG", "images/list.png"); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Eliminación de bases"), $_DATA); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrFill = array(); $action = getParameter("action"); $arrOrgz = array(0 => _tr("Select one Organization")); if ($userLevel1 == "superadmin") { $orgTmp = $pORGZ->getOrganization(array()); } else { $orgTmp = $pORGZ->getOrganization(array("id" => $idOrganization)); } if ($orgTmp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pORGZ->errMsg)); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if (count($orgTmp) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("You haven't created any organization")); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } foreach ($orgTmp as $value) { $arrOrgz[$value["id"]] = $value["name"]; } } $idGroup = getParameter("id"); $arrFill = $_POST; if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idGroup)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid Group")); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if ($userLevel1 == "superadmin") { $arrGroup = $pACL->getGroups($idGroup); } else { $arrGroup = $pACL->getGroups($idGroup, $idOrganization); } } if ($arrGroup === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } elseif (count($arrGroup) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Group doesn't exist")); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } else { if ($arrGroup[0][3] == 1) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Group doesn't exist")); return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization); } $arrFill["group"] = _tr($arrGroup[0][1]); $arrFill["description"] = _tr($arrGroup[0][2]); $arrFill["organization"] = $arrGroup[0][3]; $smarty->assign("GROUP", $arrFill["group"]); $smarty->assign("ORGANIZATION", $arrOrgz[$arrFill["organization"]]); } if (getParameter("save_edit")) { $arrFill["description"] = $_POST["description"]; } } $arrFormGroup = createFieldForm($arrOrgz); $oForm = new paloForm($smarty, $arrFormGroup); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } global $arrPermission; if (in_array('create_group', $arrPermission)) { $smarty->assign("CREATE_GROUP", true); } if (in_array('edit_group', $arrPermission)) { $smarty->assign("EDIT_GROUP", true); } if (in_array('delete_group', $arrPermission)) { $smarty->assign("DELETE_GROUP", true); } $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("icon", "web/apps/{$module_name}/images/system_groups.png"); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); $smarty->assign("USERLEVEL", $userLevel1); $smarty->assign("id_group", $idGroup); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Group"), $arrFill); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormAnnouncement($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $arrAnnouncement = array(); $action = getParameter("action"); $idAnnouncement = getParameter("id_ann"); if ($action == "view" || $action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idAnnouncement)) { $error = _tr("Invalid Announcement ID"); } else { $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pAnnouncement = new paloSantoAnnouncement($pDB, $domain); $arrAnnouncement = $pAnnouncement->getAnnouncementById($idAnnouncement); if ($arrAnnouncement === false) { $error = _tr($pAnnouncement->errMsg); } else { if (count($arrAnnouncement) == 0) { $error = _tr("Announcement doesn't exist"); } else { if (getParameter("save_edit")) { $arrAnnouncement = $_POST; } } } } if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { // new, create if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_announcement")) { $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']; } $pAnnouncement = new paloSantoAnnouncement($pDB, $domain); if (getParameter("create_announcement")) { $arrAnnouncement["description"] = ""; $arrAnnouncement["recording_id"] = "none"; $arrAnnouncement["allow_skip"] = "no"; $arrAnnouncement["return_ivr"] = "no"; $arrAnnouncement["noanswer"] = "no"; $arrAnnouncement["repeat_msg"] = "disable"; $arrAnnouncement["destination"] = ""; $arrAnnouncement["goto"] = ""; } else { $arrAnnouncement = $_POST; } } $goto = $pAnnouncement->getCategoryDefault($domain); if ($goto === false) { $goto = array(); } $res = $pAnnouncement->getDefaultDestination($domain, $arrAnnouncement["goto"]); $destiny = $res == false ? array() : $res; $arrFormOrgz = createFieldForm($goto, $destiny, $pDB, $domain); $oForm = new paloForm($smarty, $arrFormOrgz); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } //permission $smarty->assign("EDIT_ANN", in_array('edit', $arrPermission)); $smarty->assign("CREATE_ANN", in_array('create', $arrPermission)); $smarty->assign("DEL_ANN", 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_ann", $idAnnouncement); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Announcement"), $arrAnnouncement); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormIngresodeBasedeClientes($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pIngresodeBasedeClientes = new paloSantoIngresodeBasedeClientes($pDB); $arrFormIngresodeBasedeClientes = createFieldForm($pDB); if (!is_array($arrFormIngresodeBasedeClientes)) { return $arrFormIngresodeBasedeClientes; } $oForm = new paloForm($smarty, $arrFormIngresodeBasedeClientes); //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. $dataIngresodeBasedeClientes = $pIngresodeBasedeClientes->getIngresodeBasedeClientesById($id); if (is_array($dataIngresodeBasedeClientes) & count($dataIngresodeBasedeClientes) > 0) { $_DATA = $dataIngresodeBasedeClientes; } else { $smarty->assign("mb_title", _tr("Error get Data")); $smarty->assign("mb_message", $pIngresodeBasedeClientes->errMsg); } } $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"); //Editar base $edit_base = getParameter("edit_base"); $id_base = getParameter("id_base"); $id_campania = getParameter("id_campania"); if ($edit_base == "si") { $base = $pIngresodeBasedeClientes->getDatosBase($id_base, $id_campania); $_DATA = $base; $smarty->assign("view_edit", "si"); $smarty->assign("id_campania", $id_campania); $smarty->assign("id_base", $id_base); } $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Ingreso de Base de Clientes"), $_DATA); $content = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoDB.class.php"; include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoACL.class.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); /////conexion a php $pDB = new paloDB($arrConf['elastix_dsn']['acl']); //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']; if (!empty($pDB->errMsg)) { echo "ERROR DE DB: {$pDB->errMsg} <br>"; } $arrData = array(); $pACL = new paloACL($pDB); if (!empty($pACL->errMsg)) { echo "ERROR DE ACL: {$pACL->errMsg} <br>"; } $arrFormElements = array("description" => array("LABEL" => _tr("Description"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => _tr("Group"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); //description id name $contenidoModulo = ""; $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("icon", "modules/{$module_name}/images/system_groups.png"); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); if (isset($_POST['submit_create_group'])) { // Implementar include_once "libs/paloSantoForm.class.php"; $arrFillGroup['group'] = ''; $arrFillGroup['description'] = ''; $oForm = new paloForm($smarty, $arrFormElements); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $arrFillGroup); } else { if (isset($_POST['edit'])) { // Tengo que recuperar la data del usuario $pACL = new paloACL($pDB); $arrGroup = $pACL->getGroups($_POST['id_group']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { if ($arrGroup[0][1] == 'administrator') { $arrGroup[0][1] = _tr('administrator'); } else { if ($arrGroup[0][1] == 'operator') { $arrGroup[0][1] = _tr('operator'); } else { if ($arrGroup[0][1] == 'extension') { $arrGroup[0][1] = _tr('extension'); } } } if ($arrGroup[0][2] == 'total access') { $arrGroup[0][2] = _tr('total access'); } else { if ($arrGroup[0][2] == 'operator') { $arrGroup[0][2] = _tr('operator'); } else { if ($arrGroup[0][2] == 'extension user') { $arrGroup[0][2] = _tr('extension user'); } } } $arrFillGroup['group'] = $arrGroup[0][1]; $arrFillGroup['description'] = $arrGroup[0][2]; // Implementar include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); $oForm->setEditMode(); $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr('Edit Group') . " \"" . $arrFillGroup['group'] . "\"", $arrFillGroup); } } else { if (isset($_POST['submit_save_group'])) { include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $pACL = new paloACL($pDB); // Creo el Grupo $pACL->createGroup($_POST['group'], $_POST['description']); if (!empty($pACL->errMsg)) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST); } else { header("Location: ?menu=grouplist"); } } else { // Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST); } } else { if (isset($_POST['submit_apply_changes'])) { $arrGroup = $pACL->getGroups($_POST['id_group']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { $group = $arrGroup[0][1]; $description = $arrGroup[0][2]; include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); $oForm->setEditMode(); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $pACL = new paloACL($pDB); if (!$pACL->updateGroup($_POST['id_group'], $_POST['group'], $_POST['description'])) { // Ocurrio algun error aqui $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}"); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $_POST); } else { header("Location: ?menu=grouplist"); } } else { // Manejo de Error $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $arrFillGroup['group'] = $_POST['group']; $arrFillGroup['description'] = $_POST['description']; $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $arrFillGroup); } } } else { if (isset($_GET['action']) && $_GET['action'] == "view") { include_once "libs/paloSantoForm.class.php"; $oForm = new paloForm($smarty, $arrFormElements); //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error $oForm->setViewMode(); // Esto es para activar el modo "preview" $arrGroup = $pACL->getGroups($_GET['id']); if (!is_array($arrGroup)) { $contenidoModulo = ''; Header("Location: ?menu={$module_name}"); } else { // Conversion de formato if ($arrGroup[0][1] == 'administrator') { $arrGroup[0][1] = _tr('administrator'); } else { if ($arrGroup[0][1] == 'operator') { $arrGroup[0][1] = _tr('operator'); } else { if ($arrGroup[0][1] == 'extension') { $arrGroup[0][1] = _tr('extension'); } } } if ($arrGroup[0][2] == 'total access') { $arrGroup[0][2] = _tr('total access'); } else { if ($arrGroup[0][2] == 'operator') { $arrGroup[0][2] = _tr('operator'); } else { if ($arrGroup[0][2] == 'extension user') { $arrGroup[0][2] = _tr('extension user'); } } } $arrTmp['group'] = $arrGroup[0][1]; $arrTmp['description'] = $arrGroup[0][2]; $smarty->assign("id_group", htmlspecialchars($_GET['id'], ENT_COMPAT, 'UTF-8')); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("View Group"), $arrTmp); // hay que pasar el arreglo } } else { if (isset($_POST['delete'])) { //- TODO: Validar el id de group if (isset($_POST['id_group']) && $_POST['id_group'] == '1') { // No se puede eliminar al grupo admin $smarty->assign("mb_message", _tr("The administrator group cannot be deleted because is the default Elastix Group. You can delete any other group.")); } else { if ($pACL->HaveUsersTheGroup($_POST['id_group']) == TRUE) { $smarty->assign("mb_message", _tr("The Group have users assigned. You can delete any group that does not have any users assigned in it.")); } else { $pACL->deleteGroup($_POST['id_group']); } } } $nav = getParameter("nav"); $start = getParameter("start"); $total = $pACL->getNumGroups(); $total = $total == NULL ? 0 : $total; $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $oGrid->pagingShow(true); $oGrid->setURL("?menu=grouplist"); $offset = $oGrid->calculateOffset(); $end = $oGrid->getEnd(); $arrGroups = $pACL->getGroupsPaging($limit, $offset); $end = count($arrGroups); $arrData = array(); foreach ($arrGroups as $group) { $arrTmp = array(); if ($group[1] == 'administrator') { $group[1] = _tr('administrator'); } else { if ($group[1] == 'operator') { $group[1] = _tr('operator'); } else { if ($group[1] == 'extension') { $group[1] = _tr('extension'); } } } if ($group[2] == 'total access') { $group[2] = _tr('total access'); } else { if ($group[2] == 'operator') { $group[2] = _tr('operator'); } else { if ($group[2] == 'extension user') { $group[2] = _tr('extension user'); } } } $arrTmp[0] = " <a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>"; //id_group name $arrTmp[1] = $group[2]; //description $arrData[] = $arrTmp; } $arrGrid = array("title" => _tr("Group List"), "icon" => "/modules/{$module_name}/images/system_groups.png", "columns" => array(0 => array("name" => _tr("Group"), "property1" => ""), 1 => array("name" => _tr("Description"), "property1" => ""))); $oGrid->addNew("submit_create_group", _tr("Create New Group")); $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); } } } } } return $contenidoModulo; }
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; }
function viewFormOutbound($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $arrDialPattern = array()) { global $arrPermission; $error = ""; $arrOutbound = array(); $action = getParameter("action"); $idOutbound = getParameter("id_outbound"); if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idOutbound)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid Outbound")); return reportOutbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pOutbound = new paloSantoOutbound($pDB, $domain); $arrOutbound = $pOutbound->getOutboundById($idOutbound); if ($arrOutbound === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pOutbound->errMsg)); return reportOutbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if (count($arrOutbound) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Outbound doesn't exist")); return reportOutbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if ($arrOutbound["outcid_mode"] == "on") { $check_mode = "CHECKED"; } else { $check_mode = ""; } $smarty->assign("CHECKED_MODE", $check_mode); $smarty->assign('j', 0); $smarty->assign('k', 0); $arrAllTrunks = $arrTrunks = $pOutbound->getTrunks(); $arrTrunk = getParameter("arrTrunks"); if (sizeof($arrTrunk) == 0 || $arrTrunk == "" || !isset($arrTrunk)) { $arrTrunkPriority = $pOutbound->getArrTrunkPriority($idOutbound); $smarty->assign('trunks', $arrTrunkPriority); if (is_array($arrAllTrunks) && is_array($arrTrunkPriority)) { $arrDif = array_diff_assoc($arrAllTrunks, $arrTrunkPriority); } else { $arrDif = array(); } $smarty->assign('arrDif', $arrDif); } else { $arrTrunks = array(); $tmp = explode(",", $arrTrunk); $arrTrunk = array_values(array_diff($tmp, array(''))); if (is_array($arrTrunk) && is_array($arrAllTrunks)) { $arrTrunks = array_intersect($arrTrunk, array_keys($arrAllTrunks)); } $arrTrunkPriority = array(); foreach ($arrTrunks as $trunk) { $val = $pOutbound->getTrunkById($trunk); $arrTrunkPriority[$val["trunkid"]] = $val["name"] . "/" . strtoupper($val["tech"]); } $smarty->assign('trunks', $arrTrunkPriority); $arrDif = array_diff_assoc($arrAllTrunks, $arrTrunkPriority); $smarty->assign('arrDif', $arrDif); } if ($action == "view" || getParameter("edit")) { $arrDialPattern = $pOutbound->getArrDestine($idOutbound); } $smarty->assign('items', $arrDialPattern); if (getParameter("save_edit")) { $arrOutbound = $_POST; } } } } else { $arrOutbound = $_POST; $domain = getParameter('organization_add'); //este parametro solo es selecionable cuando es el superadmin quien crea la ruta if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pOutbound = new paloSantoOutbound($pDB, $domain); $domain = $pOutbound->getDomain(); if (empty($domain)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid Organization")); return reportOutbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $smarty->assign('j', 0); $smarty->assign('items', $arrDialPattern); $arrTrunks = array(); //todas las truncales que han sido asignadas a la organizacion $arrAllTrunks = $pOutbound->getTrunks(); //conjunto de id de las truncales que han sido seleccionadas para la ruta $arrTrunk = getParameter("arrTrunks"); $tmp = explode(",", $arrTrunk); $arrTrunk = array_values(array_diff($tmp, array(''))); //verifico que los indices de las truncales dadas existan y que hayan sido asiganados a la organizacion if (is_array($arrTrunk) && is_array($arrAllTrunks)) { $arrTrunks = array_intersect($arrTrunk, array_keys($arrAllTrunks)); } $arrTrunkPriority = array(); foreach ($arrTrunks as $trunk) { $val = $pOutbound->getTrunkById($trunk); $arrTrunkPriority[$val["trunkid"]] = $val["name"] . "/" . strtoupper($val["tech"]); } $smarty->assign('trunks', $arrTrunkPriority); $arrDif = array_diff_assoc($arrAllTrunks, $arrTrunkPriority); $smarty->assign('arrDif', $arrDif); } $arrForm = createFieldForm($pDB, $domain); $oForm = new paloForm($smarty, $arrForm); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } $smarty->assign("EDIT_ROUTE", in_array('edit', $arrPermission)); $smarty->assign("CREATE_ROUTE", in_array('create', $arrPermission)); $smarty->assign("DELETE_ROUTE", in_array('delete', $arrPermission)); //$smarty->assign("ERROREXT",_tr($pTrunk->errMsg)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $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_outbound", $idOutbound); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("CALLERID", _tr("Caller Id")); $smarty->assign("PREPEND", _tr("Prepend")); $smarty->assign("PREFIX", _tr("Prefix")); $smarty->assign("MATCH_PATTERN", _tr("Match Pattern")); $smarty->assign("RULES", _tr("Dial Patterns")); $smarty->assign("GENERAL", _tr("General")); $smarty->assign("TRUNK_SEQUENCE", _tr("Trunk Sequence for Matched Routes")); $smarty->assign("DRAGANDDROP", _tr("Drag and Drop Trunk into Sequence Trunk Area")); $smarty->assign("TRUNKS", _tr("TRUNKS")); $smarty->assign("SEQUENCE", _tr("TRUNKS SEQUENCE")); $smarty->assign("SETTINGS", _tr("Settings")); $smarty->assign("PEERDETAIL", _tr("PEER Details")); $smarty->assign("USERDETAIL", _tr("USER Details")); $smarty->assign("REGISTRATION", _tr("Registration")); $smarty->assign("OUTGOING_SETTINGS", _tr("Outgoing Settings")); $smarty->assign("INCOMING_SETTINGS", _tr("Incoming Settings")); $smarty->assign("OVEREXTEN", _tr("Override Extension")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Outbound Route"), $arrOutbound); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormExten($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pExten = new paloSantoExtensions($pDB); $error = ""; $arrExten = array(); $action = getParameter("action"); $smarty->assign("DIV_VM", "yes"); $idExten = getParameter("id_exten"); if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idExten)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid Exten")); return reportExten($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $arrExten = $pExten->getExtensionById($idExten, $domain); if ($arrExten === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pExten->errMsg)); return reportExten($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if (count($arrExten) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Extension doesn't exist")); return reportExten($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("EXTEN", $arrExten["exten"]); if ($arrExten["technology"] == "iax2") { $tech = "iax2"; $smarty->assign("isIax", TRUE); $smarty->assign("TECHNOLOGY", strtoupper("Iax2")); } elseif ($arrExten["technology"] == "sip") { $tech = "sip"; $smarty->assign("TECHNOLOGY", strtoupper("Sip")); } else { $tech = null; } //comprabar si la extension pertence a un usuario, //si pertenece a un usuario el secret no puede ser modificado $belonguser = extenBelongToUser($pDB, $arrExten["exten"], $arrExten["domain"]); if ($belonguser) { $smarty->assign("USER_EXTEN", false); } else { $smarty->assign("USER_EXTEN", true); } if (getParameter("save_edit")) { $arrExten = $_POST; } $smarty->assign("DISPLAY_VM", "style='display: none;'"); if (isset($arrExten["create_vm"])) { if ($arrExten["create_vm"] == "yes") { $smarty->assign("VALVM", "value='yes'"); $smarty->assign("CHECKED", "checked"); $smarty->assign("DISPLAY_VM", "style='visibility: visible;'"); } else { if ($action == "view") { $smarty->assign("DIV_VM", "no"); } else { $arrVM = $pExten->getVMdefault($domain); $arrExten["vmcontext"] = $arrVM["vmcontext"]; $arrExten["vmattach"] = $arrVM["vmattach"]; $arrExten["vmdelete"] = $arrVM["vmdelete"]; $arrExten["vmsaycid"] = $arrVM["vmsaycid"]; $arrExten["vmenvelope"] = $arrVM["vmenvelope"]; $arrExten["vmemailsubject"] = $arrVM["vmemailsubject"]; $arrExten["vmemailbody"] = $arrVM["vmemailbody"]; $arrExten["vmx_locator"] = "enabled"; $arrExten["vmx_use"] = "both"; $arrExten["vmx_operator"] = "on"; } } } } } } else { $tech = null; $smarty->assign("USER_EXTEN", true); if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_exten")) { $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']; } if (getParameter("create_exten")) { $arrExten["technology"] = "sip"; $arrExten = $pExten->getDefaultSettings($domain, "sip"); } else { $arrExten = $_POST; } if (isset($_POST["create_vm"])) { $smarty->assign("VALVM", "value='yes'"); $smarty->assign("CHECKED", "checked"); } } $arrFormOrgz = createFieldForm($tech); $oForm = new paloForm($smarty, $arrFormOrgz); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); $mostrar = getParameter("mostra_adv"); if (isset($mostrar)) { if ($mostrar == "yes") { $smarty->assign("SHOW_MORE", "style='visibility: visible;'"); $smarty->assign("mostra_adv", "yes"); } else { $smarty->assign("SHOW_MORE", "style='display: none;'"); $smarty->assign("mostra_adv", "no"); } } else { $smarty->assign("SHOW_MORE", "style='display: none;'"); $smarty->assign("mostra_adv", "yes"); } } } //permission $smarty->assign("EDIT_EXTEN", in_array('edit', $arrPermission)); $smarty->assign("CREATE_EXTEN", in_array('create', $arrPermission)); $smarty->assign("DEL_EXTEN", in_array('delete', $arrPermission)); $smarty->assign("ERROREXT", _tr($pExten->errMsg)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $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("VOICEMAIL_SETTINGS", _tr("Voicemail Settings")); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("id_exten", $idExten); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("CREATE_VM", _tr("Enabled Voicemail")); $smarty->assign("DEV_OPTIONS", _tr("Device Settings")); $smarty->assign("ADV_OPTIONS", _tr("Advanced Settings")); $smarty->assign("DICT_OPTIONS", _tr("Dictation Settings")); $smarty->assign("REC_OPTIONS", _tr("Recording Settings")); $smarty->assign("VM_OPTIONS", _tr("Voicemail Settings")); $smarty->assign("EXTENSION", _tr("GENERAL")); $smarty->assign("DEVICE", _tr("DEVICE")); $smarty->assign("VOICEMAIL", _tr("VOICEMAIL")); $smarty->assign("LOCATOR", _tr("Vmx Locator")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Extensions"), $arrExten); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormUser($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrFill = array(); $action = getParameter("action"); $arrOrgz = array(0 => "Select one Organization"); if ($credentials["userlevel"] == "superadmin") { $orgTmp = $pORGZ->getOrganization(array()); } else { $orgTmp = $pORGZ->getOrganization(array("id" => $credentials["id_organization"])); } if ($orgTmp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pORGZ->errMsg)); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } elseif (count($orgTmp) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("You need yo have at least one organization created before you can create a user")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if (($action == "new_user" || $action == "save_new") && count($orgTmp) <= 1) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("It's necesary you create a new organization so you can create new user")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } foreach ($orgTmp as $value) { $arrOrgz[$value["id"]] = $value["name"]; $arrDomains[$value["id"]] = $value["domain"]; } $smarty->assign("ORGANIZATION", htmlentities($orgTmp[0]["name"], ENT_COMPAT, 'UTF-8')); } $idUser = getParameter("id"); $arrFill = $_POST; if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idUser)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid User")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if ($credentials["userlevel"] == "superadmin") { $arrUsers = $pACL->getUsers($idUser); } else { $arrUsers = $pACL->getUsers($idUser, $credentials["id_organization"], null, null); } } if ($arrUsers === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if (count($arrUsers) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("User doesn't exist")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $picture = $pACL->getUserPicture($idUser); if ($picture !== false) { $smarty->assign("ShowImg", 1); } foreach ($arrUsers as $value) { $arrFill["username"] = $value[1]; $arrFill["name"] = $value[2]; $arrFill["password1"] = ""; $arrFill["password2"] = ""; $arrFill["organization"] = $value[4]; $arrFill["group"] = $value[7]; $extu = isset($value[5]) ? $value[5] : _tr("Not assigned yet"); $extf = isset($value[6]) ? $value[6] : _tr("Not assigned yet"); $arrFill["extension"] = $extu; $arrFill["fax_extension"] = $extf; } if ($arrFill["organization"] != 1) { $smarty->assign("ORGANIZATION", htmlentities($arrOrgz[$arrFill["organization"]], ENT_COMPAT, 'UTF-8')); } $smarty->assign("USERNAME", $arrFill["username"]); $nGroup = $pACL->getGroupNameByid($arrFill["group"]); if ($nGroup == "superadmin") { } $nGroup = _tr("NONE"); $smarty->assign("GROUP", $nGroup); $_POST["organization"] = $arrFill["organization"]; //ahora obtenemos las configuraciones de fax dle usuario $pFax = new paloFax($pACL->_DB); $listFaxs = $pFax->getFaxList(array("exten" => $extf, "organization_domain" => $arrDomains[$arrFill["organization"]])); if ($listFaxs != false) { $faxUser = $listFaxs[0]; $arrFill["country_code"] = $faxUser["country_code"]; $arrFill["area_code"] = $faxUser["area_code"]; $arrFill["clid_number"] = $faxUser["clid_number"]; $arrFill["clid_name"] = $faxUser["clid_name"]; } //ahora obtenemos la cuenta del email $arrFill["email_quota"] = $pACL->getUserProp($idUser, "email_quota"); if ($idUser == "1") { $arrFill["email_contact"] = $pACL->getUserProp($idUser, "email_contact"); } $smarty->assign("EMAILQOUTA", $arrFill["email_quota"]); $smarty->assign("EXTENSION", $extu); $smarty->assign("FAX_EXTENSION", $extf); if (getParameter("save_edit")) { $arrFill = $_POST; } } } } if ($credentials["userlevel"] != "superadmin") { $idOrgSel = $credentials["id_organization"]; } else { $idOrgSel = getParameter("organization"); } if (!isset($idOrgSel)) { $idOrgSel = 0; } if ($idOrgSel == 0) { $arrGrupos = array(); } else { $temp = $pACL->getGroupsPaging(null, null, $idOrgSel); if ($temp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls); } foreach ($temp as $value) { $arrGrupos[$value[0]] = $value[1]; } } if (getParameter("create_user")) { $arrFill["country_code"] = $pORGZ->getOrganizationProp($idOrgSel, "country_code"); $arrFill["area_code"] = $pORGZ->getOrganizationProp($idOrgSel, "area_code"); $arrFill["email_quota"] = $pORGZ->getOrganizationProp($idOrgSel, "email_quota"); } $arrFormOrgz = createFieldForm($arrGrupos, $arrOrgz); $oForm = new paloForm($smarty, $arrFormOrgz); $smarty->assign("HEIGHT", "310px"); $smarty->assign("MARGIN_PIC", 'style="margin-top: 40px;"'); $smarty->assign("MARGIN_TAB", ""); if ($action == "view") { $smarty->assign("HEIGHT", "220px"); $smarty->assign("MARGIN_PIC", ""); $smarty->assign("MARGIN_TAB", "margin-top: 10px;"); $oForm->setViewMode(); $arrFill["password1"] = "*****"; $arrFill["password2"] = "*****"; $smarty->assign("HEIGHT", "220px"); } else { if (getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } global $arrPermission; if (in_array('create_user', $arrPermission)) { $smarty->assign("CREATE_USER", true); } if (in_array('edit_user', $arrPermission)) { $smarty->assign("EDIT_USER", true); } if (in_array('delete_user', $arrPermission)) { $smarty->assign("DEL_USER", true); } $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $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("icon", "../web/_common/images/user_info.png"); $smarty->assign("FAX_SETTINGS", _tr("Fax Settings")); $smarty->assign("EMAIL_SETTINGS", _tr("Email Settings")); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("userLevel", $credentials["userlevel"]); $smarty->assign("id_user", $idUser); if (isset($arrUsers[0][1])) { $smarty->assign("isSuperAdmin", $pACL->isUserSuperAdmin($arrUsers[0][1])); } else { $smarty->assign("isSuperAdmin", FALSE); } $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("User"), $arrFill); $content = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormDatosbasicos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pDatosbasicos = new paloSantoDatosbasicos($pDB); $arrFormDatosbasicos = createFieldForm(); $oForm = new paloForm($smarty, $arrFormDatosbasicos); $pDBSqlite = new paloDB("sqlite3:////var/www/db/acl.db"); $pACL = new paloACL($pDBSqlite); if ($pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) { $smarty->assign("esAdmin", true); } else { $smarty->assign("esAdmin", false); } //begin, Form data persistence to errors and other events. $_DATA = $_POST; $action = getParameter("action"); if (isset($_SESSION['ci'])) { // si esta seteado la cedula en la session, procedo a editar $action = "view_edit"; } $id = getParameter("id"); $smarty->assign("ID", $id); //persistence id with input hidden in tpl if ($_GET["ci"]) { $smarty->assign("CI", getParameter("ci")); //persistence ci with input hidden in tpl $smarty->assign("action_edit", "yes"); //persistence ci with input hidden in tpl $_SESSION["ci"] = getParameter("ci"); } else { $smarty->assign("CI", $_SESSION['ci']); //persistence ci with input hidden in tpl } //Clientes Recargables if ($_GET["id_cliente"]) { $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByIdCliente(getParameter("id_cliente")); $smarty->assign("CI", $dataDatosbasicos["ci"]); //persistence ci with input hidden in tpl $smarty->assign("action_edit", "yes"); //persistence ci with input hidden in tpl $_SESSION["id_cliente"] = getParameter("id_cliente"); $_SESSION["ci"] = $dataDatosbasicos["ci"]; } 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. // $dataDatosbasicos = $pDatosbasicos->getDatosbasicosById($id); // Cambiado para editar al cliente de la Sesión //if(!empty($_SESSION["id_campania_cliente_recargable"])){ // $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByIdCampaniaRecargable($_SESSION['id_campania_cliente_recargable']); //}else{ $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByCI($_SESSION['ci']); //} if ($_GET["id_cliente"]) { $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByIdCliente($_SESSION['id_cliente']); $dataDatosbasicos["cedula"] = $dataDatosbasicos["ci"]; } if (is_array($dataDatosbasicos) & count($dataDatosbasicos) > 0) { $_DATA = $dataDatosbasicos; } else { $smarty->assign("mb_title", _tr("Error get Data")); $smarty->assign("mb_message", $pDatosbasicos->errMsg); } } if (empty($_DATA["cedula"])) { $_DATA["cedula"] = getParameter("ci"); } $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("IMG", "images/list.png"); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Datos básicos"), $_DATA); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function _moduleContent(&$smarty, $module_name) { include_once "libs/paloSantoForm.class.php"; include_once "libs/paloSantoFax.class.php"; include_once "libs/paloSantoDB.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']; $contenidoModulo = ''; $arrFormElements = array("name" => array("LABEL" => $arrLang["Virtual Fax Name"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "email" => array("LABEL" => $arrLang["Destination Email"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "email", "VALIDATION_EXTRA_PARAM" => ""), "extension" => array("LABEL" => "{$arrLang['Fax Extension']} (IAX)", "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "numeric", "VALIDATION_EXTRA_PARAM" => ""), "secret" => array("LABEL" => "{$arrLang['Secret']} (IAX)", "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "clid_name" => array("LABEL" => $arrLang["Caller ID Name"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "clid_number" => array("LABEL" => $arrLang["Caller ID Number"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "country_code" => array("LABEL" => $arrLang["Country Code"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "numeric", "VALIDATION_EXTRA_PARAM" => ""), "area_code" => array("LABEL" => $arrLang["Area Code"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "numeric", "VALIDATION_EXTRA_PARAM" => ""), "port" => array("LABEL" => "Port", "REQUIRED" => "no", "INPUT_TYPE" => "HIDDEN", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "dev_id" => array("LABEL" => "DevId", "REQUIRED" => "no", "INPUT_TYPE" => "HIDDEN", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $arrFormElements); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("APPLY_CHANGES", $arrLang["Apply changes"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("DELETE", $arrLang["Delete"]); $smarty->assign("CONFIRM_CONTINUE", $arrLang["Are you sure you wish to continue?"]); $smarty->assign("icon", "/modules/{$module_name}/images/fax_virtual_fax_list.png"); if (isset($_POST['save'])) { if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $oFax = new paloFax(); // TODO: Debo revisar por errores aqui $oFax->createFaxExtension($_POST['name'], $_POST['extension'], $_POST['secret'], $_POST['email'], $_POST['clid_name'], $_POST['clid_number'], $_POST['country_code'], $_POST['area_code']); header("Location: ?menu=faxlist"); } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New Virtual Fax"], $_POST); } } else { if (isset($_POST['apply_changes'])) { $oForm->setEditMode(); if ($oForm->validateForm($_POST)) { // Exito, puedo procesar los datos ahora. $oFax = new paloFax(); $oFax->editFaxExtension($_POST['id_fax'], $_POST['name'], $_POST['extension'], $_POST['secret'], $_POST['email'], $_POST['clid_name'], $_POST['clid_number'], $_POST['dev_id'], $_POST['port'], $_POST['country_code'], $_POST['area_code']); header("Location: ?menu=faxlist"); } else { // Error $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["Edit Virtual Fax"], $_POST); ///////////////////////////////// } } else { if (isset($_POST['delete'])) { //- TODO: Validar el id de fax $oFax = new paloFax(); $oFax->deleteFaxExtensionById($_POST['id_fax']); header("Location: ?menu=faxlist"); } else { if (isset($_POST['edit'])) { //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error // Aqui hago un query por el id de fax $oFax = new paloFax(); $oForm->setEditMode(); // Esto es para activar el modo "edit" $arrFax = $oFax->getFaxById($_GET['id']); $smarty->assign("id_fax", $_GET['id']); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["Edit Virtual Fax"], $arrFax); // hay que pasar el arreglo } else { if (isset($_GET['action']) && $_GET['action'] == "view") { //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error // Aqui hago un query por el id de fax $oFax = new paloFax(); $oForm->setViewMode(); // Esto es para activar el modo "preview" $arrFax = $oFax->getFaxById($_GET['id']); $smarty->assign("id_fax", $_GET['id']); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["View Virtual Fax"], $arrFax); // hay que pasar el arreglo } else { //incializar los valores if (!isset($_POST['name'])) { $_POST['name'] = ''; } if (!isset($_POST['email'])) { $_POST['email'] = ''; } if (!isset($_POST['extension'])) { $_POST['extension'] = ''; } if (!isset($_POST['secret'])) { $_POST['secret'] = ''; } if (!isset($_POST['clid_name'])) { $_POST['clid_name'] = ''; } if (!isset($_POST['clid_number'])) { $_POST['clid_number'] = ''; } if (!isset($_POST['port'])) { $_POST['port'] = ''; } if (!isset($_POST['dev_id'])) { $_POST['dev_id'] = ''; } if (!isset($_POST['country_code'])) { $_POST['country_code'] = ''; } if (!isset($_POST['area_code'])) { $_POST['area_code'] = ''; } $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New Virtual Fax"], $_POST); } } } } } return $contenidoModulo; }
function viewQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $arrQueue = array(); $action = getParameter("action"); $qname = getParameter("qname"); if ($action == "view" || $action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { if (!isset($qname)) { $error = _tr("Invalid Queue"); } else { $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $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 { $smarty->assign("QUEUE", $arrTmp["queue_number"]); if (getParameter("save_edit")) { $arrQueue = $_POST; } else { $arrMember = $pQueue->getQueueMembers($qname); if ($arrMember === false) { $error = _tr("Problems getting queue members. ") . $pQueue->errMsg; $arrMember = array(); } $arrQueue = showQueueSetting($arrTmp, $arrMember); } } } } else { if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_queue")) { $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']; } $pQueue = new paloQueuePBX($pDB, $domain); if (getParameter("create_queue")) { $arrQueue = $pQueue->defaultOptions(); } else { $arrQueue = $_POST; } } if ($error != "") { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $error); return reportQueue($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $category = $pQueue->getCategoryDefault($domain); if ($category === false) { $category = array(); } $res = $pQueue->getDefaultDestination($domain, $arrQueue["category"]); $destiny = $res == false ? array() : $res; $arrForm = createFieldForm($pQueue->getRecordingsSystem($domain), getArrayExtens($pDB, $domain), $category, $destiny, $pQueue->getMoHClass($domain)); $oForm = new paloForm($smarty, $arrForm); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } //permission $smarty->assign("EDIT_QUEUE", in_array('edit', $arrPermission)); $smarty->assign("CREATE_QUEUE", in_array('create', $arrPermission)); $smarty->assign("DEL_QUEUE", in_array('delete', $arrPermission)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $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("qname", $qname); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("GENERAL", _tr("General")); $smarty->assign("MEMBERS", _tr("Queue Members")); $smarty->assign("ADVANCED", _tr("Advanced Options")); $smarty->assign("TIME_OPTIONS", _tr("Timing Options")); $smarty->assign("EMPTY_OPTIONS", _tr("Empty Options")); $smarty->assign("RECORDING", _tr("Recording Options")); $smarty->assign("ANN_OPTIONS", _tr("Announce Options")); $smarty->assign("PER_OPTIONS", _tr("Periodic Announce Options")); $smarty->assign("DEFAULT_DEST", _tr("Default Destination")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Queues"), $arrQueue); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function viewFormInbound($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $arrInbound = array(); $action = getParameter("action"); $idInbound = getParameter("id_inbound"); if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idInbound)) { $error = _tr("Invalid Inbound Route"); } $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pInbound = new paloSantoInbound($pDB, $domain); $arrInbound = $pInbound->getInboundById($idInbound); if ($error == "") { if ($arrInbound === false) { $error = $pInbound->errMsg; } else { if (count($arrInbound) == 0) { $error = _tr("Inbound doesn't exist"); } else { if (getParameter("save_edit")) { $arrInbound = $_POST; } $smarty->assign("fax_detect_act", $arrInbound["fax_detect"]); $smarty->assign("privacy_act", $arrInbound["primanager"]); } } } if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportInbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_inbound")) { $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']; } $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); } if (getParameter("create_inbound")) { $arrInbound["primanager"] = "no"; $arrInbound["fax_detect"] = "no"; $arrInbound["fax_time"] = "4"; $arrInbound["fax_type"] = "fax"; $arrInbound["min_length"] = "3"; $arrInbound["max_attempt"] = "5"; $arrInbound["goto"] = ""; } else { $arrInbound = $_POST; } } $goto = $pInbound->getCategoryDefault($domain); if ($goto === false) { $goto = array(); } $res = $pInbound->getDefaultDestination($domain, $arrInbound["goto"]); $destiny = $res == false ? array() : $res; $arrForm = createFieldForm($goto, $destiny, $pInbound->getFaxExtesion(), $pInbound->getDetectFax(), $pInbound->getMoHClass($domain)); $oForm = new paloForm($smarty, $arrForm); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } $smarty->assign("EDIT_ROUTE", in_array('edit', $arrPermission)); $smarty->assign("CREATE_ROUTE", in_array('create', $arrPermission)); $smarty->assign("DELETE_ROUTE", 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_inbound", $idInbound); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("CALLERID", _tr("Caller Id")); $smarty->assign("SEQUENCE", _tr("TRUNKS SEQUENCE")); $smarty->assign("SETTINGS", _tr("Settings")); $smarty->assign("PEERDETAIL", _tr("PEER Details")); $smarty->assign("USERDETAIL", _tr("USER Details")); $smarty->assign("OVEREXTEN", _tr("Override Extension")); $smarty->assign("CIDPRIORITY", _tr("Cid Priority Route")); $smarty->assign("PRIVACY", _tr("Privacy")); $smarty->assign("PRIVACYMANAGER", _tr("Privacy Manager")); $smarty->assign("SIGNALRING", _tr("Signal Ringing")); $smarty->assign("CIDSOURCE", _tr("CID Lookup Source")); $smarty->assign("FAXDETECT", _tr("Fax Detect")); $smarty->assign("DETECTFAX", _tr("Detect Fax ")); $smarty->assign("LANGUAGE", _tr("Language")); $smarty->assign("SETDESTINATION", _tr("Set Destination")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Inbound Route"), $arrInbound); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function formEditURL($pDB, $smarty, $module_name, $local_templates_dir, $id_url) { // Si se ha indicado cancelar, volver a listado sin hacer nada más if (isset($_POST['cancel'])) { Header("Location: ?menu={$module_name}"); return ''; } $smarty->assign('FRAMEWORK_TIENE_TITULO_MODULO', existeSoporteTituloFramework()); $urls = new externalUrl($pDB); $tuplaURL = NULL; if (!is_null($id_url)) { $tuplaURL = $urls->getURL($id_url); if (!is_array($tuplaURL) || count($tuplaURL) == 0) { $smarty->assign("mb_title", _tr('Unable to read URL')); $smarty->assign("mb_message", _tr('Cannot read URL') . ' - ' . $urls->errMsg); return ''; } } $formCampos = array('description' => array("LABEL" => _tr('URL Description'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", 'ROWS' => 6, 'COLS' => 50, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'urltemplate' => array("LABEL" => _tr('URL Template'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array('size' => 64, 'title' => _tr('TEMPLATE_DESC')), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'active' => array("LABEL" => _tr('Enable use of this template'), "REQUIRED" => "yes", "INPUT_TYPE" => "CHECKBOX", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), 'opentype' => array("LABEL" => _tr('Open URL in'), "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => descOpenType(), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "")); $oForm = new paloForm($smarty, $formCampos); if (!is_null($id_url)) { $oForm->setEditMode(); $smarty->assign('id_url', $id_url); } if (!is_null($tuplaURL)) { if (!isset($_POST['description'])) { $_POST['description'] = $tuplaURL['description']; } if (!isset($_POST['urltemplate'])) { $_POST['urltemplate'] = $tuplaURL['urltemplate']; } if (!isset($_POST['opentype'])) { $_POST['opentype'] = $tuplaURL['opentype']; } if (!isset($_POST['active'])) { $_POST['active'] = $tuplaURL['active'] ? 'on' : 'off'; } } else { if (!isset($_POST['active'])) { $_POST['active'] = 'on'; } } // En esta implementación el formulario trabaja exclusivamente en modo 'input' // y por lo tanto proporciona el botón 'save' $bDoCreate = isset($_POST['save']); $bDoUpdate = isset($_POST['apply_changes']); if ($bDoCreate || $bDoUpdate) { 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); } else { if ($bDoCreate) { $bExito = $urls->createURL($_POST['urltemplate'], $_POST['description'], $_POST['opentype']); } elseif ($bDoUpdate) { $urls->enableURL($id_url, $_POST['active'] != 'off'); $bExito = $urls->updateURL($id_url, $_POST['urltemplate'], $_POST['description'], $_POST['opentype']); } if ($bExito) { header("Location: ?menu={$module_name}"); } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $urls->errMsg); } } } $smarty->assign(array('SAVE' => _tr('Save'), 'CANCEL' => _tr('Cancel'), 'APPLY_CHANGES' => _tr('Apply Changes'))); return $oForm->fetchForm("{$local_templates_dir}/new.tpl", is_null($id_url) ? _tr("New URL") : _tr("Edit URL"), $_POST); }
function viewFormMoH($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $arrFiles = array()) { global $arrPermission; $error = ""; $arrMoH = array(); $action = getParameter("action"); if ($credentials['userlevel'] == 'superadmin') { $pMoH = new paloSantoMoH($pDB, ""); } else { $domain = $credentials['domain']; $pMoH = new paloSantoMoH($pDB, $domain); } $idMoH = getParameter("id_moh"); if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idMoH)) { $error = _tr("Invalid Music on Hold Class"); } $arrMoH = $pMoH->getMoHByClass($idMoH); $smarty->assign('NAME_MOH', $arrMoH["name"]); $smarty->assign('MODE_MOH', $arrMoH["mode_moh"]); if ($error == "") { if ($arrMoH === false) { $error = _tr($pMoH->errMsg); } else { if (count($arrMoH) == 0) { $error = _tr("MoH doesn't exist"); } else { $smarty->assign('j', 0); $smarty->assign('items', $arrMoH["listFiles"]); if (getParameter("save_edit")) { $arrMoH = $_POST; } } } } if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportMoH($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { if ($credentials['userlevel'] == 'superadmin') { $pMoH = new paloSantoMoH($pDB, ""); } else { $pMoH = new paloSantoMoH($pDB, $domain); } $smarty->assign('j', 0); $smarty->assign('items', $arrFiles); $smarty->assign('arrFiles', "1"); $arrMoH = $_POST; } $arrForm = createFieldForm($pMoH->getAudioFormatAsterisk(), $credentials['userlevel'] == 'superadmin'); $oForm = new paloForm($smarty, $arrForm); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } //permission $smarty->assign("EDIT_MOH", in_array("edit", $arrPermission)); $smarty->assign("DEL_MOH", 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_moh", $idMoH); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ADD_FILE", _tr("Add New file")); $max_upload = (int) ini_get('upload_max_filesize'); $max_post = (int) ini_get('post_max_size'); $memory_limit = (int) ini_get('memory_limit'); $upload_mb = min($max_upload, $max_post, $memory_limit) * 1048576; $smarty->assign("max_size", $upload_mb); $smarty->assign("alert_max_size", _tr("File size exceeds the limit. ")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("MoH Route"), $arrMoH); $content = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function formEditAgent($pDB, $smarty, $module_name, $local_templates_dir, $id_agent) { // Si se ha indicado cancelar, volver a listado sin hacer nada más if (isset($_POST['cancel'])) { Header("Location: ?menu={$module_name}"); return ''; } $smarty->assign('FRAMEWORK_TIENE_TITULO_MODULO', existeSoporteTituloFramework()); // Leer los datos de la campaña, si es necesario $arrAgente = NULL; $oAgentes = new Agentes($pDB); if (!is_null($id_agent)) { $arrAgente = $oAgentes->getAgents($id_agent); if (!is_array($arrAgente) || count($arrAgente) == 0) { $smarty->assign("mb_title", 'Unable to read agent'); $smarty->assign("mb_message", 'Cannot read agent - ' . $oAgentes->errMsg); return ''; } } require_once "libs/paloSantoForm.class.php"; $arrFormElements = getFormAgent($smarty, !is_null($id_agent)); // Valores por omisión para primera carga if (is_null($id_agent)) { // Creación de nuevo agente if (!isset($_POST['extension'])) { $_POST['extension'] = ''; } if (!isset($_POST['description'])) { $_POST['description'] = ''; } if (!isset($_POST['password1'])) { $_POST['password1'] = ''; } if (!isset($_POST['password2'])) { $_POST['password2'] = ''; } if (!isset($_POST['eccpwd1'])) { $_POST['eccpwd1'] = ''; } if (!isset($_POST['eccpwd2'])) { $_POST['eccpwd2'] = ''; } } else { // Modificación de agente existente if (!isset($_POST['extension'])) { $_POST['extension'] = $arrAgente['number']; } if (!isset($_POST['description'])) { $_POST['description'] = $arrAgente['name']; } if (!isset($_POST['password1'])) { $_POST['password1'] = $arrAgente['password']; } if (!isset($_POST['password2'])) { $_POST['password2'] = $arrAgente['password']; } if (!isset($_POST['eccpwd1'])) { $_POST['eccpwd1'] = $arrAgente['eccp_password']; } if (!isset($_POST['eccpwd2'])) { $_POST['eccpwd2'] = $arrAgente['eccp_password']; } // Volver opcional el cambio de clave de acceso $arrFormElements['password1']['REQUIRED'] = 'no'; $arrFormElements['password2']['REQUIRED'] = 'no'; } $oForm = new paloForm($smarty, $arrFormElements); if (!is_null($id_agent)) { $oForm->setEditMode(); $smarty->assign("id_agent", $id_agent); } $bDoCreate = isset($_POST['submit_save_agent']); $bDoUpdate = isset($_POST['submit_apply_changes']); if ($bDoCreate || $bDoUpdate) { 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>"; foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } else { foreach (array('extension', 'password1', 'password2', 'description', 'eccpwd1', 'eccpwd2') as $k) { $_POST[$k] = trim($_POST[$k]); } if ($_POST['password1'] != $_POST['password2'] || $bDoCreate && $_POST['password1'] == '') { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The passwords are empty or don't match")); } elseif ($_POST['eccpwd1'] != $_POST['eccpwd2']) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("ECCP passwords don't match")); } elseif (!ereg('^[[:digit:]]+$', $_POST['password1'])) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The passwords aren't numeric values")); } elseif (!ereg('^[[:digit:]]+$', $_POST['extension'])) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Error Agent Number")); } else { $bExito = TRUE; if ($bDoUpdate && $_POST['password1'] == '') { $_POST['password1'] = $arrAgente['password']; } $agente = array(0 => $_POST['extension'], 1 => $_POST['password1'], 2 => $_POST['description'], 3 => $_POST['eccpwd1']); if ($bDoCreate) { $bExito = $oAgentes->addAgent($agente); if (!$bExito) { $smarty->assign("mb_message", "" . _tr("Error Insert Agent") . " " . $oAgentes->errMsg); } } elseif ($bDoUpdate) { $bExito = $oAgentes->editAgent($agente); if (!$bExito) { $smarty->assign("mb_message", "" . _tr("Error Update Agent") . " " . $oAgentes->errMsg); } } if ($bExito) { header("Location: ?menu={$module_name}"); } } } } $smarty->assign('icon', 'images/user.png'); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", is_null($id_agent) ? _tr("New agent") : _tr('Edit agent') . ' "' . $_POST['description'] . '"', $_POST); return $contenidoModulo; }
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 formEditCampaign($pDB, $smarty, $module_name, $local_templates_dir, $id_campaign = NULL) { include_once "libs/paloSantoQueue.class.php"; include_once "modules/form_designer/libs/paloSantoDataForm.class.php"; // Si se ha indicado cancelar, volver a listado sin hacer nada más if (isset($_POST['cancel'])) { Header("Location: ?menu={$module_name}"); return ''; } $smarty->assign('FRAMEWORK_TIENE_TITULO_MODULO', existeSoporteTituloFramework()); // Leer los datos de la campaña, si es necesario $arrCampaign = NULL; $oCamp = new paloSantoCampaignCC($pDB); if (!is_null($id_campaign)) { $arrCampaign = $oCamp->getCampaigns(null, null, $id_campaign); if (!is_array($arrCampaign) || count($arrCampaign) == 0) { $smarty->assign("mb_title", 'Unable to read campaign'); $smarty->assign("mb_message", 'Cannot read campaign - ' . $oCamp->errMsg); return ''; } } // Obtener y conectarse a base de datos de FreePBX $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"; $oDB = new paloDB($dsn); // Leer las troncales que se han definido en FreePBX $arrDataTrunks = array('' => '(' . _tr('By Dialplan') . ')'); $arrTrunks = getTrunks($oDB); //obtener la lista de trunks if (is_array($arrTrunks)) { foreach ($arrTrunks as $trunk) { $arrDataTrunks[$trunk[1]] = $trunk[1]; } } // Leer las colas que se han definido en FreePBX, y quitar las usadas // en campañas entrantes. $arrDataQueues = array(); $oQueue = new paloQueue($oDB); $arrQueues = $oQueue->getQueue(); // Todas las colas, entrantes y salientes if (is_array($arrQueues)) { $query_call_entry = "SELECT queue FROM queue_call_entry WHERE estatus = 'A'"; $arr_call_entry = $pDB->fetchTable($query_call_entry); // Las colas entrantes $colasEntrantes = array(); foreach ($arr_call_entry as $row) { $colasEntrantes[] = $row[0]; } foreach ($arrQueues as $rowQueue) { if (!in_array($rowQueue[0], $colasEntrantes)) { $arrDataQueues[$rowQueue[0]] = $rowQueue[1]; } } } $arrUrlsExternos = array('' => _tr('(No external URL)')) + $oCamp->getExternalUrls(); // Cargar la información de todos los formularios creados y activos $oDataForm = new paloSantoDataForm($pDB); $arrDataForm = $oDataForm->getFormularios(NULL, 'A'); // Impedir mostrar el formulario si no se han definido colas o no // quedan colas libres para usar en campañas salientes. if (count($arrQueues) <= 0) { $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, NULL, NULL, NULL); $oForm = new paloForm($smarty, $formCampos); $smarty->assign('no_queues', 1); } elseif (count($arrDataQueues) <= 0) { $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, NULL, NULL, NULL); $oForm = new paloForm($smarty, $formCampos); $smarty->assign('no_outgoing_queues', 1); } elseif (count($arrDataForm) <= 0) { $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, NULL, NULL, NULL); $oForm = new paloForm($smarty, $formCampos); $smarty->assign('no_forms', 1); } else { $smarty->assign('label_manage_trunks', _tr('Manage Trunks')); $smarty->assign('label_manage_queues', _tr('Manage Queues')); $smarty->assign('label_manage_forms', _tr('Manage Forms')); $smarty->assign('label_manage_external_url', _tr('Manage External URLs')); // Definición del formulario de nueva campaña $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign('LABEL_CALL_FILE', _tr('Call File')); // Valores por omisión para primera carga $arrNoElegidos = array(); // Lista de selección de formularios elegibles $arrElegidos = array(); // Lista de selección de formularios ya elegidos $values_form = NULL; // Selección hecha en el formulario if (is_null($id_campaign)) { if (!isset($_POST['nombre'])) { $_POST['nombre'] = ''; } if (!isset($_POST["context"]) || $_POST["context"] == "") { $_POST["context"] = "from-internal"; } if (!isset($_POST['max_canales']) || $_POST['max_canales'] == '') { $_POST['max_canales'] = 23; } if (!isset($_POST['reintentos']) || $_POST['reintentos'] == '') { $_POST['reintentos'] = 5; } if (!isset($_POST['rte_script'])) { $_POST['rte_script'] = ''; } if (!isset($_POST['values_form'])) { $_POST['values_form'] = ''; } //$_POST['formulario']= explode(",", $_POST['values_form']); $values_form = explode(",", $_POST['values_form']); } else { if (!isset($_POST['nombre'])) { $_POST['nombre'] = $arrCampaign[0]['name']; } if (!isset($_POST['fecha_ini'])) { $_POST['fecha_ini'] = date('d M Y', strtotime($arrCampaign[0]['datetime_init'])); } if (!isset($_POST['fecha_fin'])) { $_POST['fecha_fin'] = date('d M Y', strtotime($arrCampaign[0]['datetime_end'])); } $arrDateTimeInit = explode(":", $arrCampaign[0]['daytime_init']); $arrDateTimeEnd = explode(":", $arrCampaign[0]['daytime_end']); if (!isset($_POST['hora_ini_HH'])) { $_POST['hora_ini_HH'] = isset($arrDateTimeInit[0]) ? $arrDateTimeInit[0] : "00"; } if (!isset($_POST['hora_ini_MM'])) { $_POST['hora_ini_MM'] = isset($arrDateTimeInit[1]) ? $arrDateTimeInit[1] : "00"; } if (!isset($_POST['hora_fin_HH'])) { $_POST['hora_fin_HH'] = isset($arrDateTimeEnd[0]) ? $arrDateTimeEnd[0] : "00"; } if (!isset($_POST['hora_fin_MM'])) { $_POST['hora_fin_MM'] = isset($arrDateTimeEnd[1]) ? $arrDateTimeEnd[1] : "00"; } if (!isset($_POST['reintentos'])) { $_POST['reintentos'] = $arrCampaign[0]['retries']; } if (!isset($_POST['trunk'])) { $_POST['trunk'] = $arrCampaign[0]['trunk']; } if (!isset($_POST['queue'])) { $_POST['queue'] = $arrCampaign[0]['queue']; } if (!isset($_POST['context'])) { $_POST['context'] = $arrCampaign[0]['context']; } if (!isset($_POST['max_canales'])) { $_POST['max_canales'] = $arrCampaign[0]['max_canales']; } //$_POST['script'] = ""; if (!isset($_POST['rte_script'])) { $_POST['rte_script'] = $arrCampaign[0]['script']; } //if (!isset($_POST['formulario'])) $_POST['formulario'] = ""; //if (!isset($_POST['formularios_elegidos'])) $_POST['formularios_elegidos'] = ""; if (!isset($_POST['values_form'])) { $values_form = $oCamp->obtenerCampaignForm($id_campaign); } else { $values_form = explode(",", $_POST['values_form']); } if (!isset($_POST['external_url'])) { $_POST['external_url'] = $arrCampaign[0]['id_url']; } } // rte_script es un HTML complejo que debe de construirse con Javascript. $smarty->assign("rte_script", adaptar_formato_rte($_POST['rte_script'])); // Clasificar los formularios elegidos y no elegidos foreach ($arrDataForm as $key => $form) { if (in_array($form['id'], $values_form)) { $arrElegidos[$form['id']] = $form['nombre']; } else { $arrNoElegidos[$form['id']] = $form['nombre']; } } // Generación del objeto de formulario $formCampos = getFormCampaign($arrDataTrunks, $arrDataQueues, $arrNoElegidos, $arrElegidos, $arrUrlsExternos); $oForm = new paloForm($smarty, $formCampos); if (!is_null($id_campaign)) { $oForm->setEditMode(); $smarty->assign('id_campaign', $id_campaign); } // En esta implementación el formulario trabaja exclusivamente en modo 'input' // y por lo tanto proporciona el botón 'save' $bDoCreate = isset($_POST['save']); $bDoUpdate = isset($_POST['apply_changes']); if ($bDoCreate || $bDoUpdate) { if (!$oForm->validateForm($_POST) || (!isset($_POST['rte_script']) || $_POST['rte_script'] == '')) { // 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}, "; } } if (!isset($_POST['rte_script']) || $_POST['rte_script'] == '') { $strErrorMsg .= _tr("Script"); } $strErrorMsg .= ""; $smarty->assign("mb_message", $strErrorMsg); } elseif ($_POST['max_canales'] <= 0) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('At least 1 used channel must be allowed.')); } elseif ((int) $_POST['reintentos'] <= 0) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Campaign must allow at least one call retry')); } elseif ($bDoCreate && !in_array($_POST['encoding'], mb_list_encodings())) { $smarty->assign("mb_title", _tr('Validation Error')); $smarty->assign("mb_message", _tr('Invalid character encoding')); } elseif ($bDoCreate && empty($_FILES['phonefile']['tmp_name'])) { $smarty->assign("mb_title", _tr('Validation Error')); $smarty->assign("mb_message", _tr('Call file not specified or failed to be uploaded')); } else { $time_ini = $_POST['hora_ini_HH'] . ":" . $_POST['hora_ini_MM']; $time_fin = $_POST['hora_fin_HH'] . ":" . $_POST['hora_fin_MM']; $iFechaIni = strtotime($_POST['fecha_ini']); $iFechaFin = strtotime($_POST['fecha_fin']); $iHoraIni = strtotime($time_ini); $iHoraFin = strtotime($time_fin); if ($iFechaIni == -1 || $iFechaIni === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse start date specification')); } elseif ($iFechaFin == -1 || $iFechaFin === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse end date specification')); } elseif ($iHoraIni == -1 || $iHoraIni === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse start time specification')); } elseif ($iHoraFin == -1 || $iHoraFin === FALSE) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr('Unable to parse end time specification')); } else { if (!$pDB->genQuery("SET AUTOCOMMIT=0")) { $smarty->assign("mb_message", $pDB->errMsg); } else { $bExito = TRUE; if ($bDoCreate) { $id_campaign = $oCamp->createEmptyCampaign($_POST['nombre'], $_POST['max_canales'], $_POST['reintentos'], $_POST['trunk'], $_POST['context'], $_POST['queue'], date('Y-m-d', $iFechaIni), date('Y-m-d', $iFechaFin), $time_ini, $time_fin, $_POST['rte_script'], $_POST['external_url'] == '' ? NULL : (int) $_POST['external_url']); if (is_null($id_campaign)) { $bExito = FALSE; } } elseif ($bDoUpdate) { $bExito = $oCamp->updateCampaign($id_campaign, $_POST['nombre'], $_POST['max_canales'], $_POST['reintentos'], $_POST['trunk'], $_POST['context'], $_POST['queue'], date('Y-m-d', $iFechaIni), date('Y-m-d', $iFechaFin), $time_ini, $time_fin, $_POST['rte_script'], $_POST['external_url'] == '' ? NULL : (int) $_POST['external_url']); } // Introducir o actualizar formularios if ($bExito && isset($_POST['values_form'])) { if ($bDoCreate) { $bExito = $oCamp->addCampaignForm($id_campaign, $_POST['values_form']); } elseif ($bDoUpdate) { $bExito = $oCamp->updateCampaignForm($id_campaign, $_POST['values_form']); } } // Para creación, se introduce lista de valores CSV if ($bExito && !empty($_FILES['phonefile']['tmp_name'])) { // Se puede tardar mucho tiempo en la inserción ini_set('max_execution_time', 3600); $sEncoding = $_POST['encoding']; $bExito = $oCamp->addCampaignNumbersFromFile($id_campaign, $_FILES['phonefile']['tmp_name'], $sEncoding); if ($bExito && $bDoUpdate && $arrCampaign[0]['estatus'] == 'T') { // Agregar números a una campaña terminada debe volverla a activar $oCamp->activar_campaign($id_campaign, 'A'); } } // Confirmar o deshacer la transacción según sea apropiado if ($bExito) { $pDB->genQuery("COMMIT"); header("Location: ?menu={$module_name}"); } else { $pDB->genQuery("ROLLBACK"); $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $oCamp->errMsg); } } $pDB->genQuery("SET AUTOCOMMIT=1"); } } } } $smarty->assign('icon', 'images/kfaxview.png'); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", is_null($id_campaign) ? _tr("New Campaign") : _tr("Edit Campaign") . ' "' . $_POST['nombre'] . '"', $_POST); return $contenidoModulo; }
function viewGeneralSetting($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { global $arrPermission; $error = ""; //obtenemos los datos guardados $pGP = new paloGeneralPBX($pDB); $arrForm = createFieldForm($pGP->getVoicemailTZ()); $oForm = new paloForm($smarty, $arrForm); $arrSettings = $pGP->getGeneralSettings(); if ($arrSettings == false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Error getting default settings. ") . _tr($pGP->errMsg)); } else { $arrCustom = array(); $genSettings = array(); if (getParameter("save_edit")) { $genSettings = $_POST; foreach (array("sip", "iax") as $tech) { if (is_array($_POST[$tech . "_custom_name"])) { foreach (array_keys($_POST[$tech . "_custom_name"]) as $index) { if (!empty($_POST[$tech . "_custom_name"][$index]) && isset($_POST[$tech . "_custom_val"][$index])) { if ($_POST[$tech . "_custom_val"][$index] != "") { $name = strtolower($_POST[$tech . "_custom_name"][$index]); $arrCustom[$tech][] = array("name" => $name, "value" => $_POST[$tech . "_custom_val"][$index]); } } } } } //nap settings if (is_array($_POST['localnetip'])) { $arrLocalNetIP = $_POST['localnetip']; $arrLocalNetMASK = $_POST['localnetmask']; } //codec settings $codecsAlllow = array(); if (is_array($_POST['audioCodec'])) { foreach ($_POST['audioCodec'] as $codec) { $codecsAlllow[] = $codec; } } if (is_array($_POST['videoCodec'])) { foreach ($_POST['videoCodec'] as $codec) { $codecsAlllow[] = $codec; } } $listCodecs = getListCodecs($pGP, implode(",", $codecsAlllow)); } else { foreach ($arrSettings as $tech => $prop) { foreach ($prop as $key => $value) { if ($value["type"] == "custom") { $arrCustom[$tech][] = array("name" => $key, "value" => $value["value"]); } else { $genSettings[$tech . "_" . $key] = $value["value"]; } } } $listCodecs = getListCodecs($pGP, $genSettings["gen_ALLOW_CODEC"]); if (isset($genSettings["sip_nat_type"])) { if ($genSettings["sip_nat_type"] != "public") { $res = $pGP->getNatLocalConfing(); $arrLocalNetIP = $res["ip"]; $arrLocalNetMASK = $res["mask"]; } } } } if (!isset($arrCustom["sip"])) { $arrCustom["sip"][] = array("name" => "", "value" => ""); } if (!isset($arrCustom["iax"])) { $arrCustom["iax"][] = array("name" => "", "value" => ""); } if (!isset($arrLocalNetIP)) { $arrLocalNetIP = array(""); $arrLocalNetMASK = array(""); } $oForm->setEditMode(); //permission $smarty->assign("EDIT_GS", in_array('edit', $arrPermission)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("GENERAL", _tr("General Settings")); $smarty->assign("SIP_GENERAL", _tr("SIP Settings")); $smarty->assign("IAX_GENERAL", _tr("IAX Settings")); $smarty->assign("VM_GENERAL", _tr("Voicemail Settings")); $smarty->assign("QUALIFY", _tr("Qualify Seetings")); $smarty->assign("CODEC", _tr("Codec Selections")); $smarty->assign("REGIS_TIMERS", _tr("Register Timers")); $smarty->assign("OUT_REGIS_TIMERS", _tr("Outbound SIP Registrations")); $smarty->assign("RTP_TIMERS", _tr("RTP Timers")); $smarty->assign("CODEC", _tr("Codecs Negociation")); $smarty->assign("FAX", _tr("T.38 FAX Support")); $smarty->assign("NAT", _tr("NAT Support")); $smarty->assign("localnetIP", $arrLocalNetIP); $smarty->assign("localnetMASK", $arrLocalNetMASK); $smarty->assign("MEDIA_HANDLING", _tr("MEDIA HANDLING")); $smarty->assign("STATUS_NOTIFICATIONS", _tr("Status Notifications")); $smarty->assign("CUSTOM_SET", _tr("Custom Settings")); $smarty->assign("VIDEO_OPTS", _tr("Video Support")); $smarty->assign("JITTER", _tr("Jitter Buffer Settings")); $smarty->assign("EMAIL_VM", _tr("Send Email Settings")); $smarty->assign("ADVANCED", _tr("Advance Settings")); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("sipCustom", $arrCustom["sip"]); $smarty->assign("iaxCustom", $arrCustom["iax"]); $smarty->assign("LOCATION_VM", "Timezones Settings"); $smarty->assign("audioCodec", $listCodecs["audio"]); $smarty->assign("videoCodec", $listCodecs["video"]); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("General Settings"), $genSettings); // $mensaje=showMessageReload($module_name, $arrConf, $pDB, $userLevel1, $userAccount); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function mostrarFormularioModificarBreak(&$smarty, $module_name, $pDB, $local_templates_dir, $id_break) { $bNuevoBreak = is_null($id_break); $smarty->assign(array('SAVE' => $bNuevoBreak ? _tr('Save') : _tr('Apply Changes'))); if (isset($_POST['cancel'])) { Header("Location: ?menu={$module_name}"); return ''; } $smarty->assign('FRAMEWORK_TIENE_TITULO_MODULO', existeSoporteTituloFramework()); // Para modificación, se lee la información del break $oBreaks = new PaloSantoBreaks($pDB); if (!$bNuevoBreak) { $_POST['id_break'] = $id_break; $infoBreak = $oBreaks->getBreaks($id_break); if (!is_array($infoBreak)) { // No se puede recuperar información actual del break $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pDB->errMsg); } elseif (count($infoBreak) <= 0) { // El break no se encuentra Header("Location: ?menu={$module_name}"); return ''; } else { // Se asignan los valores a POST a menos que ya se encuentren valores if (!isset($_POST['nombre'])) { $_POST['nombre'] = $infoBreak[0]['name']; } if (!isset($_POST['descripcion'])) { $_POST['descripcion'] = $infoBreak[0]['description']; } } } $formCampos = array("nombre" => array("LABEL" => _tr("Name Break"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("size" => "40"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "descripcion" => array("LABEL" => _tr("Description Break"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXTAREA", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "ROWS" => "2", "COLS" => "33"), 'id_break' => array('LABEL' => 'id_break', 'REQUIRED' => 'no', 'INPUT_TYPE' => 'HIDDEN', "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]+\$")); $oForm = new paloForm($smarty, $formCampos); $oForm->setEditMode(); // Procesar los cambios realizados if (isset($_POST['save'])) { 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) { $strErrorMsg .= implode(', ', array_keys($arrErrores)); } $smarty->assign("mb_message", $strErrorMsg); } else { $exito = $bNuevoBreak ? $oBreaks->createBreak($_POST['nombre'], $_POST['descripcion']) : $oBreaks->updateBreak($id_break, $_POST['nombre'], $_POST['descripcion']); if ($exito) { header("Location: ?menu={$module_name}"); } else { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $oBreak->errMsg); } } } // Mostrar el formulario con los valores $smarty->assign('icon', 'images/kfaxview.png'); $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $bNuevoBreak ? _tr('New Break') : _tr('Edit Break'), $_POST); return $contenidoModulo; }
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 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 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 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 modificarArchivo($module_name, $smarty, $local_templates_dir, $sDirectorio, $sAccion) { $sNombreArchivo = ''; $sMensajeStatus = ''; if (isset($_POST['Reload'])) { $parameters = array('Command' => "module reload"); $result = AsteriskManagerAPI("Command", $parameters, true); if ($result) { $smarty->assign("mb_title", "MESSAGE"); $smarty->assign("mb_message", _tr("Asterisk has been reloaded")); } else { $smarty->assign("mb_title", "ERROR"); $smarty->assign("mb_message", _tr("Error when connecting to Asterisk Manager")); } } if ($sAccion == 'new') { $smarty->assign('LABEL_COMPLETADO', '.conf'); if (isset($_POST['Guardar'])) { if (!isset($_POST['basename']) || trim($_POST['basename']) == '') { $sMensajeStatus .= _tr('Please write the file name') . '<br/>'; } else { $sNombreArchivo = basename($_POST['basename'] . '.conf'); /* Los datos del archivo se envían desde el navegador con líneas separadas por CRLF que debe ser convertido a LF para estilo Unix */ if (file_put_contents($sDirectorio . $sNombreArchivo, str_replace("\r\n", "\n", $_POST['content'])) === FALSE) { $sMensajeStatus .= _tr("This file doesn't have permisses to write") . '<br/>'; } else { $sMensajeStatus .= _tr("The changes was saved in the file") . '<br/>'; } } } } elseif ($sAccion == 'edit') { $sNombreArchivo = basename(getParameter('file')); if (is_null($sNombreArchivo) || !file_exists($sDirectorio . $sNombreArchivo)) { Header("Location: ?menu={$module_name}"); return ''; } if (isset($_POST['Guardar'])) { /* Los datos del archivo se envían desde el navegador con líneas separadas por CRLF que debe ser convertido a LF para estilo Unix */ if (!is_writable($sDirectorio . $sNombreArchivo) || file_put_contents($sDirectorio . $sNombreArchivo, str_replace("\r\n", "\n", $_POST['content'])) === FALSE) { $sMensajeStatus .= _tr("This file doesn't have permisses to write") . '<br/>'; } else { $sMensajeStatus .= _tr("The changes was saved in the file") . '<br/>'; } } else { if (!is_writable($sDirectorio . $sNombreArchivo)) { $sMensajeStatus .= _tr("This file doesn't have permisses to write") . '<br/>'; } } $sContenido = file_get_contents($sDirectorio . $sNombreArchivo); if ($sContenido === FALSE) { $sMensajeStatus .= _tr("This file doesn't have permisses to read") . '<br/>'; } if (!isset($_POST['content'])) { $_POST['content'] = $sContenido; } $_POST['basename'] = basename($sNombreArchivo); } $oForm = new paloForm($smarty, array('basename' => array('LABEL' => _tr('File'), 'REQUIRED' => 'yes', 'INPUT_TYPE' => 'TEXT', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_TYPE' => 'text', 'VALIDATION_EXTRA_PARAM' => '', 'EDITABLE' => $sAccion == 'new' ? 'yes' : 'no'), 'content' => array('LABEL' => _tr('Content'), 'REQUIRED' => 'no', 'INPUT_TYPE' => 'TEXTAREA', 'INPUT_EXTRA_PARAM' => '', 'VALIDATION_TYPE' => 'text', 'VALIDATION_EXTRA_PARAM' => '', 'ROWS' => 25, 'COLS' => 100))); $oForm->setEditMode(); $smarty->assign('url_edit', construirURL(array('menu' => $module_name, 'action' => $sAccion, 'file' => $sNombreArchivo))); $smarty->assign('url_back', construirURL(array('menu' => $module_name), array('action', 'file', 'nav' => getParameter('nav'), 'page' => getParameter('page')))); $smarty->assign('search', getParameter('search')); $smarty->assign('LABEL_SAVE', _tr('Save')); $smarty->assign('RELOAD_ASTERISK', _tr('Reload Asterisk')); $smarty->assign('LABEL_BACK', _tr('Back')); $smarty->assign('msg_status', $sMensajeStatus); $smarty->assign('icon', "images/user.png"); return $oForm->fetchForm("{$local_templates_dir}/file_editor.tpl", _tr("File Editor"), $_POST); }
function viewFormIVR($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $arrDestine = array()) { global $arrPermission; $error = ""; $arrIvr = array(); $action = getParameter("action"); $idIVR = getParameter("id_ivr"); if ($action == "view" || $action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idIVR)) { $error = _tr("Invalid IVR"); } else { $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pIVR = new paloIvrPBX($pDB, $domain); $arrIVR = $pIVR->getIvrById($idIVR); if ($arrIVR === false) { $error = _tr($pIVR->errMsg); } else { if (count($arrIVR) == 0) { $error = _tr("IVR doesn't exist"); } else { //para que se muestren los destinos $smarty->assign('j', 0); $arrGoTo = $pIVR->getCategoryDefault($domain); $smarty->assign('arrGoTo', $arrGoTo); if ($action == "view" || getParameter("edit")) { $arrDestine = $pIVR->getArrDestine($idIVR); } $smarty->assign('items', $arrDestine); if (getParameter("save_edit")) { $arrIVR = $_POST; } $arrIVR["mesg_invalid"] = is_null($arrIVR["mesg_invalid"]) ? "none" : $arrIVR["mesg_invalid"]; $arrIVR["mesg_timeout"] = is_null($arrIVR["mesg_timeout"]) ? "none" : $arrIVR["mesg_timeout"]; $arrIVR["announcement"] = is_null($arrIVR["announcement"]) ? "none" : $arrIVR["announcement"]; if (isset($arrIVR["retvm"])) { if ($arrIVR["retvm"] == "yes") { $smarty->assign("CHECKED", "checked"); } } if (getParameter("retvm")) { $smarty->assign("CHECKED", "checked"); } } } } } else { if ($credentials['userlevel'] == 'superadmin') { if (getParameter("create_ivr")) { $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']; } $pIVR = new paloIvrPBX($pDB, $domain); //para que se muestren los destinos $smarty->assign('j', 0); $arrGoTo = $pIVR->getCategoryDefault($domain); $smarty->assign('arrGoTo', $arrGoTo); $smarty->assign('items', $arrDestine); if (getParameter("create_ivr")) { $arrIVR["timeout"] = "10"; $arrIVR["loops"] = "2"; $arrIVR["directdial"] = "no"; } else { $arrIVR = $_POST; } } $arrFormOrgz = createFieldForm($pIVR->getRecordingsSystem($domain), $arrGoTo); $oForm = new paloForm($smarty, $arrFormOrgz); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } $smarty->assign("EDIT_IVR", in_array('edit', $arrPermission)); $smarty->assign("CREATE_IVR", in_array('create', $arrPermission)); $smarty->assign("DEL_IVR", in_array('delete', $arrPermission)); $smarty->assign("ERROREXT", _tr($pIVR->errMsg)); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $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_ivr", $idIVR); $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain")); $smarty->assign("ORGANIZATION", $domain); $smarty->assign("RETIVR", _tr("Return to IVR")); $smarty->assign("DIGIT", _tr("Exten")); $smarty->assign("OPTION", _tr("Option")); $smarty->assign("DESTINE", _tr("Destine")); $smarty->assign("GENERAL", _tr("General")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", "IVR", $arrIVR); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }