Пример #1
0
function applyChanges($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $action = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $pGP = new paloGeneralPBX($pDB);
    $arrForm = createFieldForm($pGP->getVoicemailTZ());
    $oForm = new paloForm($smarty, $arrForm);
    if (!$oForm->validateForm($_POST)) {
        // Validation basic, not empty and VALIDATION_TYPE
        $smarty->assign("mb_title", _tr("Validation Error"));
        $arrErrores = $oForm->arrErroresValidacion;
        $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>";
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k} [{$v['mensaje']}], ";
            }
        }
        $smarty->assign("mb_message", $strErrorMsg);
    } else {
        $arrProp = getParameterGeneralSettings();
        $pDB->beginTransaction();
        $exito = $pGP->setGeneralSettings($arrProp);
        if ($exito === true) {
            $pDB->commit();
            unset($_POST["save_edit"]);
            if (reloadFiles()) {
                $smarty->assign("mb_title", _tr("MESSAGE"));
                $smarty->assign("mb_message", _tr("Changes have been applied successfully."));
            } else {
                $smarty->assign("mb_title", _tr("ERROR"));
                $msg = _tr("Changes couldn't be applied successfully. ");
                $msg .= $pGP->errMsg;
                $smarty->assign("mb_message", $msg);
            }
        } else {
            $pDB->rollBack();
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Changes couldn't be applied. ") . $pGP->errMsg);
        }
    }
    return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf);
}
Пример #2
0
function reloadAasterisk($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $showMsg = false;
    $continue = false;
    /*if($arrCredentiasls['userlevel']=="other"){
          $smarty->assign("mb_title", _tr("ERROR"));
          $smarty->assign("mb_message",_tr("You are not authorized to perform this action"));
      }*/
    $idOrganization = $credentials['id_organization'];
    if ($credentials['userlevel'] == "superadmin") {
        $idOrganization = getParameter("organization_id");
    }
    if ($idOrganization == 1) {
        return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $query = "select domain from organization where id=?";
    $result = $pDB->getFirstRowQuery($query, false, array($idOrganization));
    if ($result === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Asterisk can't be reloaded. ") . _tr($pDB->errMsg));
        $showMsg = true;
    } elseif (count($result) == 0) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Asterisk can't be reloaded. ") . _tr("Invalid Organization. "));
        $showMsg = true;
    } else {
        $domain = $result[0];
        $continue = true;
    }
    if ($continue) {
        $pAstConf = new paloSantoASteriskConfig($pDB);
        if ($pAstConf->generateDialplan($domain) === false) {
            $pAstConf->setReloadDialplan($domain, true);
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Asterisk can't be reloaded. ") . $pAstConf->errMsg);
            $showMsg = true;
        } else {
            $pAstConf->setReloadDialplan($domain);
            $smarty->assign("mb_title", _tr("MESSAGE"));
            $smarty->assign("mb_message", _tr("Asterisk was reloaded correctly. "));
        }
    }
    return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
}