Esempio n. 1
0
function viewFormConference($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $action = getParameter("action");
    $id_conf = getParameter("id_conf");
    if ($action == "view" || getParameter("edit") || getParameter("save_edit")) {
        if (!isset($id_conf)) {
            $error = _tr("Invalid conference");
        } else {
            $domain = getParameter('organization');
            if ($credentials['userlevel'] != 'superadmin') {
                $domain = $credentials['domain'];
            }
            $pConf = new paloConference($pDB, $domain);
            $Conf = $pConf->getConferenceById($id_conf);
            if ($Conf == false) {
                $error = $pConf->errMsg;
            } else {
                $Conf["confno"] = $Conf["ext_conf"];
                $smarty->assign("CONFNO", $Conf["ext_conf"]);
                if (!empty($Conf["startTime"]) && $Conf["startTime"] != "1900-01-01 12:00:00") {
                    $smarty->assign("SCHEDULE", "on");
                    $Conf["schedule"] = "on";
                }
                if (getParameter("save_edit")) {
                    $Conf = $_POST;
                } else {
                    if (!empty($Conf["startTime"]) && $Conf["startTime"] != "1900-01-01 12:00:00") {
                        $elap = strtotime($Conf["endtime"]) - strtotime($Conf["startTime"]);
                        $Conf["start_time"] = substr($Conf["startTime"], 0, -3);
                        $Conf["duration"] = floor($elap / 3600);
                        $Conf["duration_min"] = floor(fmod($elap, 3600) / 60);
                    }
                    $Conf["record_conf"] = empty($Conf["recordingformat"]) ? 'no' : $Conf["recordingformat"];
                    //adminopts
                    preg_match_all("/^aAs(i){0,1}(r){0,1}(M\\(([[:alnum:]_]+)\\)){0,1}(G\\((.*)\\)){0,1}\$/", $Conf["adminopts"], $match);
                    $Conf["moderator_options_1"] = empty($match[1][0]) ? "off" : "on";
                    $Conf["moderator_options_2"] = empty($match[2][0]) ? "off" : "on";
                    if (empty($match[3][0])) {
                        $Conf["moh"] = "";
                    } else {
                        $Conf["moh"] = $match[4][0];
                    }
                    if (empty($match[5][0])) {
                        $Conf["announce_intro"] = "";
                    } else {
                        $Conf["announce_intro"] = $Conf["intro_record"];
                    }
                    //useropts
                    preg_match_all("/^(i){0,1}(m){0,1}(w){0,1}(r){0,1}(M\\(([[:alnum:]_]+)\\)){0,1}(G\\((.*)\\)){0,1}\$/", $Conf["opts"], $matchu);
                    $Conf["user_options_1"] = empty($matchu[1][0]) ? "off" : "on";
                    $Conf["user_options_2"] = empty($matchu[2][0]) ? "off" : "on";
                    $Conf["user_options_3"] = empty($matchu[3][0]) ? "off" : "on";
                    $Conf["user_options_4"] = empty($matchu[4][0]) ? "off" : "on";
                }
            }
        }
    } else {
        if ($credentials['userlevel'] == 'superadmin') {
            if (getParameter("create_conference")) {
                $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'];
        }
        $pConf = new paloConference($pDB, $domain);
        $domain = $pConf->getDomain();
        if (empty($domain)) {
            $error = _tr("Invalid Organization");
        } else {
            $smarty->assign("SCHEDULE", "on");
            //para que se muestren los destinos
            if (getParameter("create_conference")) {
                $Conf["schedule"] = "off";
                $Conf["duration"] = "1";
                $Conf["duration_min"] = "0";
                $Conf['start_time'] = date("Y-m-d H:i", strtotime(date("Y-m-d H:i") . " + 5 minutes"));
            } else {
                $Conf = $_POST;
            }
        }
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Invalid Action"));
        return reportRG($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $arrRecording = $pConf->getRecordingsSystem($domain);
    $arrForm = createFieldForm($arrRecording, $pConf->getMoHClass($domain));
    $oForm = new paloForm($smarty, $arrForm);
    //permission
    $smarty->assign("EDIT_CONF", in_array('edit_conf', $arrPermission));
    if ($action == "view") {
        $oForm->setViewMode();
    } else {
        if (getParameter("edit") || getParameter("save_edit")) {
            $oForm->setEditMode();
        }
    }
    $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_conf", $id_conf);
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain"));
    $smarty->assign("ORGANIZATION", $domain);
    $smarty->assign("announce", _tr("Announce Join/Leave"));
    $smarty->assign("record", _tr("Record"));
    $smarty->assign("listen_only", _tr("Listen Only"));
    $smarty->assign("wait_for_leader", _tr("Wait for Leader"));
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Conference"), $Conf);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Esempio n. 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 reportRG($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 reportRG($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
}