当前位置: 首页>>代码示例>>PHP>>正文


PHP paloForm::validateForm方法代码示例

本文整理汇总了PHP中paloForm::validateForm方法的典型用法代码示例。如果您正苦于以下问题:PHP paloForm::validateForm方法的具体用法?PHP paloForm::validateForm怎么用?PHP paloForm::validateForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paloForm的用法示例。


在下文中一共展示了paloForm::validateForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: applyChnageParameterFaxMail

function applyChnageParameterFaxMail($smarty, $module_name, $local_templates_dir, $pDB, $credentials)
{
    $arrFaxConfig = createForm();
    $oForm = new paloForm($smarty, $arrFaxConfig);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("ERROR"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
    } else {
        $oFax = new paloFax($pDB);
        if ($oFax->setConfigurationSendingFaxMailOrg($credentials['id_organization'], $_POST['fax_remite'], $_POST['fax_remitente'], $_POST['fax_subject'], $_POST['fax_content'])) {
            $smarty->assign("mb_title", _tr("Message"));
            $smarty->assign("mb_message", _tr("Changes were applied successfully."));
        } else {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Changes could not be applied.") . " " . $oFax->errMsg);
        }
    }
    return listParameterFaxMail($smarty, $module_name, $local_templates_dir, $pDB, $credentials);
}
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:27,代码来源:index.php

示例2: generateWav

function generateWav($smarty, $module_name, $local_templates_dir)
{
    $arrFormConference = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormConference);
    if (!$oForm->validateForm($_POST)) {
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}, ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        $contenidoModulo = form_TexttoWav($smarty, $module_name, $local_templates_dir);
    } else {
        $smarty->assign("GENERATE", _tr("Generate"));
        $smarty->assign("BACK", _tr("Back"));
        $smarty->assign("icon", "web/apps/{$module_name}/images/pbx_tools_text_to_wav.png");
        $smarty->assign("FORMATO", getParameter('format'));
        $smarty->assign("DOWNLOAD", _tr("Download File"));
        $path = "var";
        $smarty->assign("PATH", $path);
        $format = getParameter('format');
        $message = stripslashes(trim(getParameter('message')));
        $message = substr($message, 0, 1024);
        $oTextToWap = new paloSantoTexttoWav();
        $execute = $oTextToWap->outputTextWave($format, $message);
        if ($execute) {
            /* Cortar la salida en este lugar. Evita lidiar con rawmode sólo 
             * para caso de éxito */
            die;
        } else {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", $oTextToWap->errMsg);
        }
        $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Text to Wav"), $_POST);
        $contenidoModulo = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    }
    return $contenidoModulo;
}
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:41,代码来源:index.php

示例3: formularioModificarCola

function formularioModificarCola($pDB, $smarty, $module_name, $local_templates_dir, $idCola)
{
    require_once "libs/paloSantoForm.class.php";
    require_once "libs/paloSantoQueue.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(array('FRAMEWORK_TIENE_TITULO_MODULO' => existeSoporteTituloFramework(), 'icon' => 'images/kfaxview.png', 'SAVE' => _tr('guardar'), 'CANCEL' => _tr('cancelar'), 'id_queue' => $idCola));
    // Leer todas las colas disponibles
    $dsnAsterisk = generarDSNSistema('asteriskuser', 'asterisk');
    $oDBAsterisk = new paloDB($dsnAsterisk);
    $oQueue = new paloQueue($oDBAsterisk);
    $arrQueues = $oQueue->getQueue();
    if (!is_array($arrQueues)) {
        $smarty->assign("mb_title", _tr('Unable to read queues'));
        $smarty->assign("mb_message", _tr('Cannot read queues') . ' - ' . $oQueue->errMsg);
        $arrQueues = array();
    }
    $oColas = new paloSantoColaEntrante($pDB);
    // Leer todos los datos de la cola entrante, si es necesario
    $arrColaEntrante = NULL;
    if (!is_null($idCola)) {
        $arrColaEntrante = $oColas->leerColas($idCola);
        if (!is_array($arrColaEntrante) || count($arrColaEntrante) == 0) {
            $smarty->assign("mb_title", _tr('Unable to read incoming queue'));
            $smarty->assign("mb_message", _tr('Cannot read incoming queue') . ' - ' . $oColas->errMsg);
            return '';
        }
    }
    /* Para nueva cola, se deben remover las colas ya usadas. Para cola 
     * modificada, sólo se muestra la cola que ya estaba asignada. */
    if (is_null($idCola)) {
        // Filtrar las colas que ya han sido usadas
        $arrFilterQueues = $oColas->filtrarColasUsadas($arrQueues);
    } else {
        // Colocar sólo la información de la cola asignada
        $arrFilterQueues = array();
        foreach ($arrQueues as $tuplaQueue) {
            if ($tuplaQueue[0] == $arrColaEntrante[0]['queue']) {
                $arrFilterQueues[] = $tuplaQueue;
            }
        }
    }
    $arrDataQueues = array();
    foreach ($arrFilterQueues as $tuplaQueue) {
        $arrDataQueues[$tuplaQueue[0]] = $tuplaQueue[1];
    }
    // Valores por omisión para primera carga
    if (is_null($idCola)) {
        if (!isset($_POST['select_queue']) && count($arrFilterQueues) > 0) {
            $_POST['select_queue'] = $arrFilterQueues[0][0];
        }
        if (!isset($_POST['rte_script'])) {
            $_POST['rte_script'] = '';
        }
    } else {
        $_POST['select_queue'] = $arrColaEntrante[0]['queue'];
        if (!isset($_POST['rte_script'])) {
            $_POST['rte_script'] = $arrColaEntrante[0]['script'];
        }
    }
    // rte_script es un HTML complejo que debe de construirse con Javascript.
    $smarty->assign("rte_script", adaptar_formato_rte($_POST['rte_script']));
    // Generación del objeto de formulario
    $form_campos = array("script" => array("LABEL" => _tr('Script'), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "", "VALIDATION_EXTRA_PARAM" => ""), 'select_queue' => array("REQUIRED" => "yes", "LABEL" => is_null($idCola) ? _tr('Select Queue') . ' :' : _tr('Queue'), "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrDataQueues, "VALIDATION_TYPE" => "numeric", "VALIDATION_EXTRA_PARAM" => ""));
    $oForm = new paloForm($smarty, $form_campos);
    // Ejecutar el guardado de los cambios
    if (isset($_POST['save'])) {
        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);
        } else {
            $bExito = $oColas->iniciarMonitoreoCola($_POST['select_queue'], $_POST['rte_script']);
            if (!$bExito) {
                $smarty->assign("mb_title", _tr('Unable to save incoming queue'));
                $smarty->assign("mb_message", $oColas->errMsg);
            } else {
                Header("Location: ?menu={$module_name}");
            }
        }
    }
    return $oForm->fetchForm("{$local_templates_dir}/form.tpl", is_null($idCola) ? _tr('Select Queue') : _tr('Edit Queue'), null);
}
开发者ID:hardikk,项目名称:HNH,代码行数:97,代码来源:index.php

示例4: _moduleContent

function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoDB.class.php";
    include_once "libs/paloSantoForm.class.php";
    include_once "libs/paloSantoConfig.class.php";
    include_once "libs/paloSantoTrunk.class.php";
    require_once "libs/misc.lib.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $contenido = '';
    $msgError = '';
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrConfig = $pConfig->leer_configuracion(false);
    $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk";
    $pDB = new paloDB($dsn);
    $pDBSetting = new paloDB($arrConf['elastix_dsn']['settings']);
    $pDBTrunk = new paloDB($arrConfModule['dsn_conn_database_1']);
    $arrForm = array("default_rate" => array("LABEL" => $arrLang["Default Rate"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""), "default_rate_offset" => array("LABEL" => $arrLang["Default Rate Offset"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "float", "VALIDATION_EXTRA_PARAM" => ""));
    $oForm = new paloForm($smarty, $arrForm);
    $oForm->setViewMode();
    //obtener el valor de la tarifa por defecto
    $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate");
    $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset");
    $smarty->assign("EDIT", $arrLang["Edit"]);
    $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
    $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate);
    if (isset($_POST['edit_default'])) {
        $arrDefaultRate['default_rate'] = get_key_settings($pDBSetting, "default_rate");
        $arrDefaultRate['default_rate_offset'] = get_key_settings($pDBSetting, "default_rate_offset");
        $oForm = new paloForm($smarty, $arrForm);
        $smarty->assign("CANCEL", $arrLang["Cancel"]);
        $smarty->assign("SAVE", $arrLang["Save"]);
        $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
        $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate);
    } else {
        if (isset($_POST['save_default'])) {
            $oForm = new paloForm($smarty, $arrForm);
            $arrDefaultRate['default_rate'] = $_POST['default_rate'];
            $arrDefaultRate['default_rate_offset'] = $_POST['default_rate_offset'];
            if ($oForm->validateForm($_POST)) {
                $bValido = set_key_settings($pDBSetting, 'default_rate', $arrDefaultRate['default_rate']);
                $bValido = set_key_settings($pDBSetting, 'default_rate_offset', $arrDefaultRate['default_rate_offset']);
                if (!$bValido) {
                    echo $arrLang["Error when saving default rate"];
                } else {
                    header("Location: index.php?menu=billing_setup");
                }
            } else {
                // Error
                $smarty->assign("mb_title", $arrLang["Validation Error"]);
                $smarty->assign("mb_message", $arrLang["Value for rate is not valid"]);
                $smarty->assign("CANCEL", $arrLang["Cancel"]);
                $smarty->assign("SAVE", $arrLang["Save"]);
                $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
                $strReturn = $oForm->fetchForm("{$local_templates_dir}/default_rate.tpl", $arrLang["Default Rate Configuration"], $arrDefaultRate);
            }
        }
    }
    $arrTrunks = array();
    $arrData = array();
    $arrTrunksBill = array();
    //obtener todos los trunks
    $oTrunk = new paloTrunk($pDBTrunk);
    //obtener todos los trunks que son para billing
    //$arrTrunksBill=array("DAHDI/g0","DAHDI/g1");
    getTrunksBillFiltrado($pDB, $oTrunk, $arrConfig, $arrTrunks, $arrTrunksBill);
    if (isset($_POST['submit_bill_trunks'])) {
        //obtengo las que estan guardadas y las que ahora no estan
        $selectedTrunks = isset($_POST['trunksBills']) ? array_keys($_POST['trunksBills']) : array();
        if (count($selectedTrunks) > 0) {
            foreach ($selectedTrunks as $selectedTrunk) {
                $nuevaListaTrunks[] = base64_decode($selectedTrunk);
            }
        } else {
            $nuevaListaTrunks = array();
        }
        $listaTrunksNuevos = array_diff($nuevaListaTrunks, $arrTrunksBill);
        $listaTrunksAusentes = array_diff($arrTrunksBill, $nuevaListaTrunks);
        //tengo que borrar los trunks ausentes
        //tengo que agregar los trunks nuevos
//.........这里部分代码省略.........
开发者ID:hardikk,项目名称:HNH,代码行数:101,代码来源:index.php

示例5: saveNewOtherDestinations

function saveNewOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $error = "";
    $success = false;
    $domain = getParameter('organization');
    //este parametro solo es selecionable cuando es el superadmin quien hace la accion
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials['domain'];
    }
    $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain);
    $arrFormOrgz = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormOrgz);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        return viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        //seteamos un arreglo con los parametros configurados
        $arrProp = array();
        $arrProp["description"] = getParameter("description");
        $arrProp["destdial"] = getParameter("destdial");
        $pDB->beginTransaction();
        $success = $pOtherDestinations->createNewOtherDestinations($arrProp);
        if ($success) {
            $pDB->commit();
        } else {
            $pDB->rollBack();
        }
        $error .= $pOtherDestinations->errMsg;
    }
    if ($success) {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("Other Destination has been created successfully"));
        //mostramos el mensaje para crear los archivos de ocnfiguracion
        $pAstConf = new paloSantoASteriskConfig($pDB);
        $pAstConf->setReloadDialplan($domain, true);
        $content = reportOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", $error);
        $content = viewFormOtherDestinations($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    return $content;
}
开发者ID:Neo2SHYAlien,项目名称:elastix-mt-gui,代码行数:52,代码来源:index.php

示例6: createFieldForm

function deleteEliminacióndebases($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pEliminacióndebases = new paloSantoEliminacióndebases($pDB);
    $arrFormEliminacióndebases = createFieldForm($pEliminacióndebases);
    $oForm = new paloForm($smarty, $arrFormEliminacióndebases);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}, ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        $content = viewFormEliminacióndebases($smarty, $module_name, $local_templates_dir, $pDB, $arrConf);
    } else {
        $pEliminacióndebases->eliminarBase($_POST['base_de_clientes']);
        Header("Location: index.php?menu=hispana_base_lista");
    }
    return $content;
}
开发者ID:veraveramanolo,项目名称:cpc2c_uio,代码行数:23,代码来源:index.php

示例7: saveNewGroup

function saveNewGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $group = getParameter("group");
    $description = getParameter("description");
    $idOrgzSel = getParameter("organization");
    if ($userLevel1 != "superadmin") {
        $idOrgzSel = $idOrganization;
    }
    $arrFormGroup = createFieldForm(array());
    $oForm = new paloForm($smarty, $arrFormGroup);
    if (isset($idOrgzSel)) {
        if (!$oForm->validateForm($_POST)) {
            // Validation basic, not empty and VALIDATION_TYPE
            $smarty->assign("mb_title", _tr("Validation Error"));
            $arrErrores = $oForm->arrErroresValidacion;
            $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
            if (is_array($arrErrores) && count($arrErrores) > 0) {
                foreach ($arrErrores as $k => $v) {
                    $strErrorMsg .= "{$k}, ";
                }
            }
            $smarty->assign("mb_message", $strErrorMsg);
            return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization);
        } else {
            if ($idOrgzSel == 0 || $idOrgzSel == 1) {
                $smarty->assign("mb_title", _tr("Validation Error"));
                $smarty->assign("mb_message", _tr("You must select a organization"));
                return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization);
            } else {
                if ($pACL->createGroup($group, $description, $idOrgzSel)) {
                    $smarty->assign("mb_title", _tr("MESSSAGE"));
                    $smarty->assign("mb_message", _tr("Group was created sucessfully"));
                    return reportGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization);
                } else {
                    $smarty->assign("mb_title", _tr("ERROR"));
                    $smarty->assign("mb_message", _tr($pACL->errMsg));
                    return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization);
                }
            }
        }
    } else {
        $smarty->assign("mb_title", _tr("Validation Error"));
        $smarty->assign("mb_message", _tr("You must select a organization"));
        return viewFormGroup($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $userLevel1, $userAccount, $idOrganization);
    }
}
开发者ID:lordbasex,项目名称:elastix-gui,代码行数:48,代码来源:index.php

示例8: saveRules


//.........这里部分代码省略.........
                            $arrValues['state'] .= ",Related";
                        }
                    } else {
                        if ($related == "on") {
                            $arrValues['state'] = "Related";
                        } else {
                            $str_error .= strlen($str_error) == 0 ? _tr("You have to select at least one state") : ", " . _tr("You have to select at least one state");
                        }
                    }
                } else {
                    $arrValues['port_in'] = "";
                    $arrValues['port_out'] = "";
                    $arrValues['type_icmp'] = "";
                    $arrValues['id_ip'] = "";
                    $arrValues['state'] = "";
                }
            }
        }
    }
    //************************************************************************************************************
    //** TARGET **
    //************************************************************************************************************
    $arrValues['target'] = getParameter("target");
    if (strlen($arrValues['target']) == 0) {
        $str_error .= strlen($str_error) == 0 ? "target" : ", target";
    }
    $arrValues['orden'] = getParameter("orden");
    //**********************
    //MENSSAGE ERROR
    //**********************
    if (strlen($str_error) != 0) {
        $smarty->assign("mb_title", "ERROR");
        $smarty->assign("mb_message", $str_error);
        return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
    }
    if (!$oForm->validateForm($_POST)) {
        // Falla la validación básica del formulario
        $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>";
        $arrErrores = $oForm->arrErroresValidacion;
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> ";
            }
        }
        $smarty->assign("mb_title", _tr("Validation Error"));
        $smarty->assign("mb_message", $strErrorMsg);
        return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
    } else {
        if ($arrValues['mask_source'] > 32 || $arrValues['mask_destin'] > 32) {
            $smarty->assign("mb_title", _tr("Validation Error"));
            $smarty->assign("mb_message", _tr("The bit masks must be values less than 33"));
            return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
        } else {
            if ($arrValues['ip_source'] != "0.0.0.0" && $arrValues['ip_source'] != "" && $arrValues['mask_source'] == "0" || $arrValues['ip_destin'] != "0.0.0.0" && $arrValues['ip_destin'] != "" && $arrValues['mask_destin'] == "0") {
                $smarty->assign("mb_title", _tr("Validation Error"));
                $smarty->assign("mb_message", _tr("Wrong Mask"));
                return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
            }
        }
    }
    $arrValues['ip_source'] = $arrValues['ip_source'] == "" ? "0.0.0.0" : $arrValues['ip_source'];
    $arrValues['ip_destin'] = $arrValues['ip_destin'] == "" ? "0.0.0.0" : $arrValues['ip_destin'];
    $ipOrigen = explode(".", $arrValues['ip_source']);
    $ipDestino = explode(".", $arrValues['ip_destin']);
    if ($ipOrigen[0] > 255 || $ipOrigen[1] > 255 || $ipOrigen[2] > 255 || $ipOrigen[3] > 255 || $ipDestino[0] > 255 || $ipDestino[1] > 255 || $ipDestino[2] > 255 || $ipDestino[3] > 255) {
        $smarty->assign("mb_title", _tr("Validation Error"));
        $smarty->assign("mb_message", _tr("Wrong value for ip"));
        return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
    }
    $arrValues['mask_source'] = $arrValues['ip_source'] == "0.0.0.0" ? "0" : $arrValues['mask_source'];
    $arrValues['mask_destin'] = $arrValues['ip_destin'] == "0.0.0.0" ? "0" : $arrValues['mask_destin'];
    $pNet = new paloNetwork();
    $oPalo = new paloSantoRules($pDB);
    if ($arrValues['ip_source'] != "0.0.0.0" && $arrValues['mask_source'] != "" && $arrValues['ip_source'] != "") {
        $arrValues['ip_source'] = $pNet->getNetAdress($arrValues['ip_source'], $arrValues['mask_source']);
    }
    if ($arrValues['ip_destin'] != "0.0.0.0" && $arrValues['mask_destin'] != "" && $arrValues['ip_destin'] != "") {
        $arrValues['ip_destin'] = $pNet->getNetAdress($arrValues['ip_destin'], $arrValues['mask_destin']);
    }
    if ($id == "") {
        if ($oPalo->saveRule($arrValues) == true) {
            $smarty->assign("mb_title", "MESSAGE");
            $smarty->assign("mb_message", _tr("Successful Save"));
        } else {
            $smarty->assign("mb_title", "ERROR");
            $smarty->assign("mb_message", $oPalo->errMsg);
            return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
        }
    } else {
        if ($oPalo->updateRule($arrValues, $id) == true) {
            $smarty->assign("mb_title", "MESSAGE");
            $smarty->assign("mb_message", _tr("Successful Update"));
        } else {
            $smarty->assign("mb_title", "ERROR");
            $smarty->assign("mb_message", $oPalo->errMsg);
            return newRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrValues, $state);
        }
    }
    return reportRules($smarty, $module_name, $local_templates_dir, $pDB, $arrConf);
}
开发者ID:hardikk,项目名称:HNH,代码行数:101,代码来源:index.php

示例9: mostrarFormularioModificarBreak

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;
}
开发者ID:hardikk,项目名称:HNH,代码行数:60,代码来源:index.php

示例10: saveDomain

function saveDomain($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang)
{
    $pEmail = new paloEmail($pDB);
    $arrFormElements = createFieldForm($arrLang);
    $oForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("CANCEL", $arrLang["Cancel"]);
    $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}, ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        $content = $oForm->fetchForm("{$local_templates_dir}/form_domain.tpl", $arrLang["New Domain"], $_POST);
    } else {
        $pDB->beginTransaction();
        $bExito = create_email_domain($pDB, $error);
        if (!$bExito) {
            $pDB->rollBack();
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", $error);
            $content = $oForm->fetchForm("{$local_templates_dir}/form_domain.tpl", $arrLang["New Domain"], $_POST);
        } else {
            $pDB->commit();
            $smarty->assign("mb_message", _tr("Domain has been created"));
            $content = viewFormDomain($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang);
        }
    }
    return $content;
}
开发者ID:hardikk,项目名称:HNH,代码行数:36,代码来源:index.php

示例11: formEditCampaign


//.........这里部分代码省略.........
            //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);
开发者ID:hardikk,项目名称:HNH,代码行数:67,代码来源:index.php

示例12: reportMissedCalls

function reportMissedCalls($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $pACL, $arrConf)
{
    ini_set('max_execution_time', 3600);
    $pCallingReport = new paloSantoMissedCalls($pDB);
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $date_start = getParameter("date_start");
    $date_end = getParameter("date_end");
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Missed Calls"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("Missed Calls"));
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    $date_start = isset($date_start) ? $date_start : date("d M Y") . ' 00:00';
    $date_end = isset($date_end) ? $date_end : date("d M Y") . ' 23:59';
    $_POST['date_start'] = $date_start;
    $_POST['date_end'] = $date_end;
    $parmFilter = array("date_start" => $date_start, "date_end" => $date_end);
    if (!$oFilterForm->validateForm($parmFilter)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $date_start = date("d M Y") . ' 00:00';
        $date_end = date("d M Y") . ' 23:59';
    }
    $url = array_merge($url, array('date_start' => $date_start, 'date_end' => $date_end));
    $oGrid->setURL($url);
    $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Destination"), _tr("Time since last call"), _tr("Number of attempts"), _tr("Status"));
    $oGrid->setColumns($arrColumns);
    $arrData = null;
    $date_start_format = date('Y-m-d H:i:s', strtotime($date_start . ":00"));
    $date_end_format = date('Y-m-d H:i:s', strtotime($date_end . ":59"));
    // Para usuarios que no son administradores, se restringe a los CDR de la
    // propia extensión
    $sExtension = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']) ? '' : $pACL->getUserExtension($_SESSION['elastix_user']);
    $total = $pCallingReport->getNumCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension);
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
        $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension);
        $arrData = $pCallingReport->showDataReport($arrResult, $total);
        $size = count($arrData);
        $oGrid->setData($arrData);
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $arrResult = $pCallingReport->getCallingReport($date_start_format, $date_end_format, $filter_field, $filter_value, $sExtension);
        $arrData = $pCallingReport->showDataReport($arrResult, $total);
        if ($pCallingReport->errMsg != '') {
            $smarty->assign('mb_message', $pCallingReport->errMsg);
        }
        //recalculando el total para la paginación
        $size = count($arrData);
        $oGrid->setTotal($size);
        $offset = $oGrid->calculateOffset();
        //echo $size." : ".$offset;
        $arrResult = $pCallingReport->getDataByPagination($arrData, $limit, $offset);
        $oGrid->setData($arrResult);
    }
    //begin section filter
    $smarty->assign("SHOW", _tr("Show"));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:73,代码来源:index.php

示例13: formEditAgent

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"));
//.........这里部分代码省略.........
开发者ID:hardikk,项目名称:HNH,代码行数:101,代码来源:index.php

示例14: formEditURL

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);
}
开发者ID:hardikk,项目名称:HNH,代码行数:76,代码来源:index.php

示例15: saveNewAnnouncement

function saveNewAnnouncement($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $error = "";
    $continue = true;
    $success = false;
    $domain = getParameter('organization');
    //este parametro solo es selecionable cuando es el superadmin quien hace la accion
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials['domain'];
    }
    $pAnnouncement = new paloSantoAnnouncement($pDB, $domain);
    $arrFormOrgz = createFieldForm(array(), array(), $pDB, $domain);
    $oForm = new paloForm($smarty, $arrFormOrgz);
    $description = trim(getParameter('description'));
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        return viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } elseif (count(explode("\n", $description)) > 1) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Invalid description text"));
        return viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        if ($pAnnouncement->validateDestine($domain, getParameter("destination")) == false) {
            $error = _tr("You must select a default destination.");
            $continue = false;
        }
        if ($continue) {
            //seteamos un arreglo con los parametros configurados
            $arrProp = array();
            $arrProp["description"] = $description;
            $arrProp["recording_id"] = getParameter("recording_id");
            $arrProp["allow_skip"] = getParameter("allow_skip");
            $arrProp["return_ivr"] = getParameter("return_ivr");
            $arrProp["noanswer"] = getParameter("noanswer");
            $arrProp["repeat_msg"] = getParameter("repeat_msg");
            $arrProp["goto"] = getParameter("goto");
            $arrProp['destination'] = getParameter("destination");
        }
        if ($continue) {
            $pDB->beginTransaction();
            $success = $pAnnouncement->createNewAnnouncement($arrProp);
            if ($success) {
                $pDB->commit();
            } else {
                $pDB->rollBack();
            }
            $error .= $pAnnouncement->errMsg;
        }
    }
    if ($success) {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("Announcement has been created successfully"));
        //mostramos el mensaje para crear los archivos de ocnfiguracion
        $pAstConf = new paloSantoASteriskConfig($pDB);
        $pAstConf->setReloadDialplan($domain, true);
        $content = reportAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", $error);
        $content = viewFormAnnouncement($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    return $content;
}
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:72,代码来源:index.php


注:本文中的paloForm::validateForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。