Exemplo n.º 1
0
function saveMailmanSettings($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials)
{
    $pEmailList = new paloSantoEmailList($pDB);
    if ($credentials['userlevel'] != 'superadmin') {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("You are not authorized to perform this action"));
        return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $emailmailman = getParameter("emailmailman");
    $passwdmailman = getParameter("passwdmailman");
    $repasswdmailman = getParameter("repasswdmailman");
    $arrForm = createFieldForm(array());
    $oForm = new paloForm($smarty, $arrForm);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
        return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        if ($passwdmailman != $repasswdmailman) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Field Password and Retype Password do not match"));
            return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        if (!$pEmailList->createListMailman($emailmailman, $passwdmailman)) {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("Could not be configured Mailman Admin Settings.") . " " . $pEmailList->getError());
            return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        } else {
            $smarty->assign("mb_title", _tr("Message"));
            $smarty->assign("mb_message", _tr("Settings were save successfully"));
            return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    }
}