function SaveOrUpdateCurrency($idOrganization, $curr) { $pORGZ = new paloSantoOrganization($this->_DB); $r = $pORGZ->setOrganizationProp($idOrganization, 'currency', $curr); if (!$r) { $this->errMsg = $pORGZ->errMsg; } return $r; }
function reportCDR($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials) { global $arrPermission; $error = ''; $pCDR = new paloSantoCDR($pDB); $pORGZ = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]); $pPBX = new paloAsteriskDB($arrConf['elastix_dsn']["elastix"]); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $date_start = getParameter('date_start'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_start)) { $date_start = date("d M Y"); } $date_end = getParameter('date_end'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_end)) { $date_end = date("d M Y"); } $src = getParameter("src"); if (isset($src) && $src != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($src); if ($expression === false) { $src = ''; } } $dst = getParameter("dst"); if (isset($dst) && $dst != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($dst); if ($expression === false) { $dst = ''; } } $src_channel = getParameter("src_channel"); $dst_channel = getParameter("dst_channel"); $calltype = getParameter("calltype"); $arrCallType = array("all" => _tr("ALL"), 'incoming' => _tr('Incoming'), 'outgoing' => _tr("Outgoing")); $calltype = array_key_exists($calltype, $arrCallType) ? $calltype : "all"; $status = getParameter("status"); $arrStatus = array("all" => _tr("ALL"), 'ANSWERED' => _tr('ANSWERED'), 'BUSY' => _tr("BUSY"), 'FAILED' => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")); $status = array_key_exists($status, $arrStatus) ? $status : "all"; $accountcode = getParameter('accountcode'); $url['menu'] = $module_name; $url['organization'] = $paramFiltro['organization'] = $domain; $url['date_start'] = $paramFiltro['date_start'] = $date_start; $url['date_end'] = $paramFiltro['date_end'] = $date_end; $url['src'] = $paramFiltro['src'] = $src; $url['dst'] = $paramFiltro['dst'] = $dst; $url['src_channel'] = $paramFiltro['src_channel'] = $src_channel; $url['dst_channel'] = $paramFiltro['dst_channel'] = $dst_channel; $url['calltype'] = $paramFiltro['calltype'] = $calltype; $url['status'] = $paramFiltro['status'] = $status; $url['accountcode'] = $paramFiltro['accountcode'] = $accountcode; //permission $delete = in_array("delete", $arrPermission); $export = in_array("export", $arrPermission); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("CDR Report")); $oGrid->pagingShow(true); if ($export) { $oGrid->enableExport(); // enable export. $oGrid->setNameFile_Export(_tr("CDRReport")); } $oGrid->setURL($url); if ($delete && !$oGrid->isExportAction()) { $arrColumns[] = "<input type='checkbox' name='cdrcheckall' class='cdrcheckall' id='cdrcheckall' onclick='jqCheckAll(this.id)';>"; } if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Date"); $arrColumns[] = _tr("Source"); if ($credentials['userlevel'] != 'superadmin') { $arrColumns[] = _tr("Ring Group"); } $arrColumns[] = _tr("Destination"); $arrColumns[] = _tr("Src. Channel"); $arrColumns[] = _tr("Account Code"); $arrColumns[] = _tr("Dst. Channel"); $arrColumns[] = _tr("Call Direction"); $arrColumns[] = _tr("Status"); $arrColumns[] = _tr("Duration"); $oGrid->setColumns($arrColumns); //get NumCDR $total = $pCDR->getNumCDR($paramFiltro); if ($total === false) { $total = 0; $error = _tr("An error has ocurred to retrieve CDR data") . " " . "DATABASE ERROR"; } $arrData = array(); $arrResult = array(); if ($total != 0) { if ($oGrid->isExportAction()) { if (!$export) { $arrData = _tr('INVALID ACTION'); } else { $arrResult = $pCDR->listarCDRs($paramFiltro); } } else { $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrResult = $pCDR->listarCDRs($paramFiltro, $limit, $offset); } } if ($arrResult === false) { $error = _tr('CDR data could not be retrieved.') . " " . "DATABASE ERROR"; } else { foreach ($arrResult as $value) { $arrTmp = array(); if ($delete && !$oGrid->isExportAction()) { $arrTmp[] = "<input type='checkbox' name='crdDel[]' class='cdrdelete' value='{$value['6']}' />"; } if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = isset($arrOrgz[$value[11]]) ? $arrOrgz[$value[11]] : ''; } $arrTmp[] = $value[0]; //calldate $arrTmp[] = $value[1]; //src if ($credentials['userlevel'] != "superadmin") { $arrTmp[] = $value[10]; } //rg_name $arrTmp[] = $value[2]; //dst $arrTmp[] = $value[3]; //channel $arrTmp[] = $value[9]; //accountcode $arrTmp[] = $value[4]; //dst_channel if ($value[12] == "1" || $value[13] == "1") { //call_type $arrTmp[] = $value[12] == "1" ? "outgoing" : "incoming"; } else { $arrTmp[] = ""; } $arrTmp[] = $value[5]; //disposition $iDuracion = $value[8]; //billsec $iSec = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iSec) / 60); $iMin = $iDuracion % 60; $iDuracion = (int) (($iDuracion - $iMin) / 60); $sTiempo = "{$value[8]}s"; if ($value[8] >= 60) { if ($iDuracion > 0) { $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)"; } elseif ($iMin > 0) { $sTiempo .= " ({$iMin}m {$iSec}s)"; } } $arrTmp[] = $sTiempo; $arrData[] = $arrTmp; } } $oGrid->setData($arrData); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } //begin section filter $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "delete", _tr("Delete Selected"), false); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST['date_start'] = $paramFiltro['date_start']; $_POST['date_end'] = $paramFiltro['date_end']; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $paramFiltro['date_start'] . ", " . _tr("End Date") . " = " . $paramFiltro['date_end'], $paramFiltro, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); //DATE START - DATE END $_POST["src"] = $src; // source $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source") . " = " . $src, $_POST, array("src" => "")); $_POST["dst"] = $dst; // destination $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination") . " = " . $dst, $_POST, array("dst" => "")); $_POST["src_channel"] = $src_channel; // source channel $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source Channel") . " = " . $src_channel, $_POST, array("src_channel" => "")); $_POST["dst_channel"] = $dst_channel; // destination channel $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination Channel") . " = " . $dst_channel, $_POST, array("dst_channel" => "")); $_POST["calltype"] = $calltype; // call type $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Call Destination") . " = " . $arrCallType[$calltype], $_POST, array("calltype" => "all"), true); $_POST["status"] = $status; // call status $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Call Status") . " = " . $arrStatus[$status], $_POST, array("status" => "all"), true); $_POST["accountcode"] = $accountcode; // destination channel $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Account Code") . " = " . $dst, $_POST, array("accountcode" => "")); $arrForm = createFieldFilter($arrOrgz, $arrCallType, $arrStatus); $oFilterForm = new paloForm($smarty, $arrForm); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); $content = $oGrid->fetchGrid(); return $content; }
function reportTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $name = getParameter('name'); $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; //name $pTG = new paloSantoTG($pDB, $domain); $total = $pTG->getNumTG($domain, $name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => "all"); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pTG->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Time Groups List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Name"); $oGrid->setColumns($arrColum); $arrTG = array(); $arrData = array(); if ($total != 0) { $arrTG = $pTG->getTGs($domain, $name, $limit, $offset); } if ($arrTG === false) { $error = _tr("Error to obtain Time Groups") . $pTG->errMsg; $arrTG = array(); } $arrData = array(); foreach ($arrTG as $tg) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$tg["organization_domain"]]; } $arrTmp[] = " <a href='?menu={$module_name}&action=edit&id_tg=" . $tg['id'] . "&organization={$tg['organization_domain']}'>" . $tg['name'] . "</a>"; $arrData[] = $arrTmp; } if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Time Group"), array_slice($arrOrgz, 1), $selected = null, "create_tg", $onchange_select = null); } else { $oGrid->addNew("create_tg", _tr("ADD Time Group")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Time Condition Group") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
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 reportMoH($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $name = getParameter("name"); if ($credentials['userlevel'] == "superadmin") { $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $url["menu"] = $module_name; $url["organization"] = $domain; $url["name"] = $name; $pMoH = new paloSantoMoH($pDB, $domain); $total = $pMoH->getNumMoH($domain, $name); if ($total === false) { $error = $pMoH->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('MoH Class List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Name"); $arrColum[] = _tr("Type"); $arrColum[] = _tr("Sort"); $arrColum[] = _tr("Directory"); $arrColum[] = _tr("Aplication"); $oGrid->setColumns($arrColum); $arrMoH = array(); $arrData = array(); if ($total != 0) { $arrMoH = $pMoH->getMoHs($domain, $name, $limit, $offset); } if ($arrMoH === false) { $error = _tr("Error to obtain MoH Class") . $pMoH->errMsg; $arrMoH = array(); } $arrData = array(); foreach ($arrMoH as $moh) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { if (empty($moh["organization_domain"])) { $arrTmp[] = ""; $arrTmp[] = " <a href='?menu={$module_name}&action=view&id_moh=" . $moh["name"] . "'>" . $moh["description"] . "</a>"; } else { $arrTmp[] = $arrOrgz[$moh["organization_domain"]]; $arrTmp[] = $moh["description"]; } } else { $arrTmp[] = " <a href='?menu={$module_name}&action=view&id_moh=" . $moh["name"] . "'>" . $moh["description"] . "</a>"; } $arrTmp[] = $moh["mode"]; $arrTmp[] = $moh["sort"]; $arrTmp[] = $moh["directory"]; $arrTmp[] = $moh["application"]; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if (in_array("create", $arrPermission)) { $oGrid->addNew("create_moh", _tr("Create New Class MoH")); } if ($credentials['userlevel'] == "superadmin") { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); return $contenidoModulo; }
function getSelected(&$pDB, $userLevel1) { $jsonObject = new PaloSantoJSON(); $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrData = array(); if ($userLevel1 != "superadmin") { $jsonObject->set_error("You are not authorized to perform this action. "); } else { $idOrg = getParameter("idOrg"); //validamos que la organization exista $orgTmp = $pORGZ->getOrganization(array("id" => $idOrg)); //valido que al menos exista una organizacion creada if ($orgTmp === false) { $jsonObject->set_error(_tr($pORGZ->errMsg)); } elseif (count($orgTmp) <= 0) { $jsonObject->set_error(_tr("Organization doesn't exist")); } else { //obtengo los recursos asignados a la organizacion $arrResourceOrg = $pACL->getResourcesByOrg($idOrg); if ($arrResourceOrg === false) { $jsonObject->set_error(_tr($pACL->errMsg)); } else { foreach ($arrResourceOrg as $resource) { $arrData[] = $resource["id"]; } $jsonObject->set_message($arrData); } } } return $jsonObject->createJSON(); }
function getExtensionById($id, $domain = null) { global $arrConf; $arrExtension = array(); $where = ""; if (!preg_match('/^[[:digit:]]+$/', "{$id}")) { $this->errMsg = "Extension ID must be numeric"; return false; } $param = array($id); if (isset($domain)) { if (!preg_match("/^(([[:alnum:]-]+)\\.)+([[:alnum:]])+\$/", $domain)) { $this->errMsg = "Invalid domain format"; return false; } else { $where = " and organization_domain=?"; $param[] = $domain; } } $query = "SELECT tech, exten, outboundcid, rt, record_in, record_out, organization_domain, voicemail, device, clid_name, clid_number,alias,elxweb_device,enable_chat from extension where id=? {$where}"; $result = $this->_DB->getFirstRowQuery($query, true, $param); if ($result === false) { $this->errMsg = $this->_DB->errMsg; return false; } elseif (count($result) > 0) { //get organization_code $org_code = $this->getOrganizationCode($result["organization_domain"]); if ($org_code === false) { return false; } $arrExtension["technology"] = $result["tech"]; $arrExtension["exten"] = $result["exten"]; $arrExtension["clid_name"] = $result["clid_name"]; $arrExtension["clid_number"] = $result["clid_number"]; $arrExtension["ring_timer"] = $result["rt"]; $arrExtension["record_in"] = $result["record_in"]; $arrExtension["record_out"] = $result["record_out"]; $arrExtension["out_clid"] = $result["outboundcid"]; $arrExtension["alias"] = $result["alias"]; $arrExtension["elxweb_device"] = $result["elxweb_device"]; $arrExtension["enable_chat"] = $result["enable_chat"]; //obtenemos las caracteristicas de voicemail de la extension en caso de que este tenga creada uno if (isset($result["voicemail"]) && $result["voicemail"] != "novm") { $query = "SELECT * from voicemail where mailbox=? and organization_domain=?"; $voicemail = $this->_DB->getFirstRowQuery($query, true, array($result["exten"], $result["organization_domain"])); if ($voicemail == false) { $arrExtension["create_vm"] = "no"; if ($voicemail === false) { $this->errMsg .= _tr("Error getting voicemail") . $this->_DB->errMsg; } } else { $arrExtension["create_vm"] = "yes"; $option = ""; foreach ($voicemail as $key => $value) { switch ($key) { case "password": $arrExtension["vmpassword"] = $value; break; case "email": $arrExtension["vmemail"] = $value; break; case "attach": $arrExtension["vmattach"] = $value; break; case "saycid": $arrExtension["vmsaycid"] = $value; break; case "deletevoicemail": $arrExtension["vmdelete"] = $value; break; case "envelope": $arrExtension["vmenvelope"] = $value; break; case "context": $arrExtension["vmcontext"] = substr_replace($value, '', 0, strlen($org_code) + 1); //eliminamos la parte del string que contiene el codigo de la organization break; case "emailsubject": $arrExtension["vmemailsubject"] = $value; break; case "emailbody": $arrExtension["vmemailbody"] = $value; break; case "mailbox": break; case "fullname": break; default: if (isset($value)) { if ($key != "uniqueid" && $key != "organization_domain" && $key != "stamp" && $key != "dialout" && $key != "callback") { $option .= "{$key}={$value}|"; } if ($key == "dialout" || $key == "callback" || $key == "exitcontext") { $option .= "{$key}=" . substr($arrExten["vmcontext"], 16) . "|"; } } } $arrExtension["vmoptions"] = empty($option) ? "" : substr($option, 0, -1); } } } //obtenemos las otras caracticas de la configuracion del dispositivo if ($result["tech"] == "iax2") { $queryDev = "SELECT context,dial,host,type,allow,disallow,port,qualify,accountcode,deny,permit,language,amaflags,"; $queryDev .= "defaultip,username,mohinterpret,mohsuggest,transfer,requirecalltoken,mask,jitterbuffer,forcejitterbuffer,"; $queryDev .= "codecpriority,qualifysmoothing,qualifyfreqok,qualifyfreqnotok,encryption,timezone,sendani,adsi from iax where name=? and organization_domain=?"; } elseif ($result["tech"] == "sip") { $queryDev = "SELECT context,dial,host,type,allow,disallow,port,qualify,accountcode,deny,permit,language,amaflags,"; $queryDev .= "defaultip,username,mohinterpret,mohsuggest,dtmfmode,nat,allowtransfer,namedcallgroup,namedpickupgroup,"; $queryDev .= "mailbox,vmexten,defaultuser,useragent,directmedia,sendrpid,trustrpid,transport,callcounter,busylevel,subscribecontext,videosupport,maxcallbitrate,"; $queryDev .= "qualifyfreq,rtptimeout,rtpholdtimeout,rtpkeepalive,progressinband,g726nonstandard,vmexten from sip where name=? and organization_domain=?"; } else { $this->errMsg .= _tr("Invalid Technology"); return false; } if (isset($queryDev)) { $device = $this->_DB->getFirstRowQuery($queryDev, true, array($result["device"], trim($result["organization_domain"]))); if ($device == false) { $this->errMsg .= _tr("Error getting device settings") . $this->_DB->errMsg; return false; } else { foreach ($device as $key => $value) { if (isset($value)) { if ($key == "namedcallgroup" || $key == "namedpickupgroup" || $key == "context" || $key == 'subscribecontext') { $arrExtension[$key] = substr_replace($value, '', 0, strlen($org_code) + 1); } else { $arrExtension[$key] = $value; } } } } } $arrExtension["domain"] = $result["organization_domain"]; $arrExtension["device"] = $result["device"]; $pORGZ = new paloSantoOrganization($arrConf['elastix_dsn']['elastix']); $orgTmp = $pORGZ->getOrganizationByDomain_Name($result["organization_domain"]); if ($orgTmp != false) { $astMang = AsteriskManagerConnect($errorM); if ($astMang == false) { $this->errMsg .= $errorM; return false; } else { $familia = "EXTUSER/" . $orgTmp["code"] . "/" . $result["exten"]; $arrExtension["call_waiting"] = $astMang->database_get("CW/" . $orgTmp["code"], $result["exten"]) == "ENABLED" ? "yes" : "no"; $arrExtension["screen"] = $astMang->database_get($familia, "screen"); $enDictate = $astMang->database_get($familia . "/dictate", "enabled"); $arrExtension["dictate"] = $enDictate == "enabled" ? "yes" : "no"; $arrExtension["dictformat"] = $astMang->database_get($familia . "/dictate", "format"); $arrExtension["dictemail"] = $astMang->database_get($familia . "/dictate", "email"); //vmx_locator options $vmx_unavail = $astMang->database_get("{$familia}/vmx/unavail", "state"); $vmx_busy = $astMang->database_get("{$familia}/vmx/busy", "state"); if ($vmx_unavail == "enabled" || $vmx_busy == "enabled") { $arrExtension["vmx_locator"] = "enabled"; } else { $arrExtension["vmx_locator"] = "disabled"; } if ($vmx_unavail == "enabled" && $vmx_busy == "enabled") { $arrExtension["vmx_use"] = "both"; } else { if ($vmx_unavail == "enabled") { $arrExtension["vmx_use"] = "unavailable"; } else { $arrExtension["vmx_use"] = "busy"; } } $arrExtension["vmx_extension_0"] = $astMang->database_get($familia . "/vmx/0", "ext"); if (isset($arrExtension["vmx_extension_0"]) && $arrExtension["vmx_extension_0"] != "") { $arrExtension["vmx_operator"] = "off"; } else { $arrExtension["vmx_operator"] = "on"; } $arrExtension["vmx_extension_1"] = $astMang->database_get($familia . "/vmx/1", "ext"); $arrExtension["vmx_extension_2"] = $astMang->database_get($familia . "/vmx/2", "ext"); } } } return $arrExtension; }
function applyChanges($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $action = ""; //conexion elastix.db $pORGZ = new paloSantoOrganization($pDB); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $tmpORG = $pORGZ->getOrganization(array()); $arrOrgz = array(); foreach ($tmpORG as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } if (count($arrOrgz) > 0) { if (!isset($arrOrgz[$domain])) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Organization doesn't exist")); return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } else { $domain = $credentials['domain']; } $pGPBX = new paloGlobalsPBX($pDB, $domain); $arrTone = $pGPBX->getToneZonePBX(); $arrMOH = $pGPBX->getMoHClass($domain); $arrForm = createFieldForm($arrTone, $arrMOH, $pGPBX->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 = $pGPBX->setGeneralSettings($arrProp); if ($exito === true) { $pDB->commit(); $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("Changes applied successfully. ")); //mostramos el mensaje para crear los archivos de ocnfiguracion $pAstConf = new paloSantoASteriskConfig($pDB); $pAstConf->setReloadDialplan($domain, true); } else { $pDB->rollBack(); $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Changes couldn't be applied. ") . $pGPBX->errMsg); } } return viewGeneralSetting($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); }
function get_language() { global $elxPath; require_once "{$elxPath}/configs/default.conf.php"; include "{$elxPath}/configs/languages.conf.php"; include_once "{$elxPath}/libs/paloSantoOrganization.class.php"; global $arrConf; $lang = ""; $pdB = new paloDB($arrConf['elastix_dsn']['elastix']); $pACL = new paloACL($pdB); $pOrgz = new paloSantoOrganization($pdB); $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $uid = $pACL->getIdUser($user); if (empty($pDB->errMsg)) { if ($uid === false) { $lang = $pOrgz->getOrganizationProp(1, 'language'); } else { $lang = $pACL->getUserProp($uid, 'language'); } } //si no se encuentra tomar del archivo de configuracion if (empty($lang) || $lang === false) { $lang = isset($arrConf['language']) ? $arrConf['language'] : "en"; } //verificar que exista en el arreglo de idiomas, sino por defecto en if (!array_key_exists($lang, $languages)) { $lang = "en"; } return $lang; }
function HTTP_PUT() { global $arrConf; $jsonObject = new PaloSantoJSON(); if (!$this->isSuperAdmin()) { $this->invalidCredentials($jsonObject); return $jsonObject->createJSON(); } $this->setSession(); if (!$this->validateContentType($jsonObject)) { return $jsonObject->createJSON(); } $validOrgs = array(); $domainOrgs = array(); if (is_array($this->arrIdOrgs)) { foreach ($this->arrIdOrgs as $idOrg) { if ($this->validateIdOrg($idOrg) && $idOrg != "1") { $validOrgs[] = $idOrg; } elseif (preg_match("/^(([[:alnum:]-]+)\\.)+([[:alnum:]])+\$/", $idOrg)) { $domainOrgs[] = $idOrg; } } } else { $this->methodNoAllowed(array("GET")); exit; } $putvars = $state = null; parse_str(file_get_contents('php://input'), $putvars); if (isset($putvars["state"])) { if ($putvars["state"] == "suspend" || $putvars["state"] == "unsuspend" || $putvars["state"] == "terminate") { $state = $putvars["state"]; } } if (is_null($state)) { $this->errMsg = "Field state bad value. Supported values are (suspend|unsuspend|terminate)"; $this->badRequest($jsonObject); return $jsonObject->createJSON(); } $pOrg = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]); if (count($domainOrgs) > 0) { foreach ($domainOrgs as $domain) { $result = $pOrg->getIdOrgByDomain($domain); if ($result != false) { $validOrgs = $result["id"]; } } } if (count($validOrgs) == 0) { //ningun id pasado en la peticion es valido. Devolvemos 404 not found $this->resourceNotExis($jsonObject); return $jsonObject->createJSON(); } if ($pOrg->getbunchOrganizationState($validOrgs) == false) { $this->resourceNotExis($jsonObject); return $jsonObject->createJSON(); } $result = $pOrg->changeStateOrganization($validOrgs, $state); if ($result == false) { $this->error = $pOrg->errMsg; $this->errSever($jsonObject); return $jsonObject->createJSON(); } else { header('HTTP/1.1 200 Ok'); $jsonObject->set_status("OK"); $jsonObject->set_message("State of request organizations have been updated successfully"); return $jsonObject->createJSON(); } }
function reportConference($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $error = ""; $date = date("Y-m-d H:i"); $state_conf = getParameter("state_conf"); $name_conf = getParameter("name_conf"); $type_conf = getParameter("type_conf"); if (empty($state_conf)) { $state_conf = "all"; } if (empty($type_conf)) { $type_conf = "both"; } if (is_null($name_conf)) { $name_conf = ""; } if ($credentials['userlevel'] == "superadmin") { $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $url['menu'] = $module_name; $url["state_conf"] = $state_conf; $url["name_conf"] = $name_conf; $url["type_conf"] = $type_conf; $url['date'] = $date; $pconference = new paloConference($pDB, $domain); $total = $pconference->getTotalConference($domain, $date, $state_conf, $type_conf, $name_conf); if ($total === false) { $error = $pconference->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Conference')); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); //permission $delete = in_array("delete_conf", $arrPermission); $create = in_array("create_conf", $arrPermission); $edit = in_array("edit_conf", $arrPermission); $invite_part = in_array("admin_conference_participant", $arrPermission); if ($delete) { $arrColum[] = _tr(""); } $arrColum[] = _tr("Name"); $arrColum[] = _tr("Room Number"); $arrColum[] = _tr("Period"); $arrColum[] = _tr("Participants / MaxUsers"); $arrColum[] = _tr("Status"); $oGrid->setColumns($arrColum); $arrData = array(); $arrconference = array(); if ($total != 0) { $arrconference = $pconference->getConferesPagging($domain, $date, $limit, $offset, $state_conf, $type_conf, $name_conf); } $session = getSession(); if ($arrconference === false) { $error = _tr("Error getting conference data.") . $pconference->errMsg; } else { foreach ($arrconference as $conf) { $arrTmp = array(); if ($delete) { $arrTmp[] = "<input type='checkbox' name='confdel[]' value='{$conf['bookid']}'/>"; //delete } if ($edit) { $arrTmp[] = "<a href='?menu={$module_name}&action=view&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}'>" . htmlentities($conf["name"], ENT_QUOTES, "UTF-8") . "</a>"; //name } else { $arrTmp[] = htmlentities($conf["name"], ENT_QUOTES, "UTF-8"); } $arrTmp[] = $conf["ext_conf"]; //roomnumber $perid = "No Set"; if (!empty($conf["startTime"]) && $conf["startTime"] != "1900-01-01 12:00:00") { $perid = $conf["startTime"] . " - " . $conf["endtime"]; } $arrTmp[] = $perid; //period $max = empty($conf["maxusers"]) ? "unlimited" : $conf["maxusers"]; $participants = "<spam class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max} </spam>"; $status = "<spam class='conf_status'></spam>"; if ($perid != "No Set") { $date = time(); if ($date >= strtotime($conf["startTime"]) && $date <= strtotime($conf["endtime"])) { if ($invite_part) { $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>"; } $status = "<spam class='conf_status' style='color:green'/>" . _tr("In Progress") . "</spam>"; } else { if ($date < strtotime($conf["startTime"])) { $status = "<spam class='conf_status'>" . _tr("Future") . "</spam>"; } else { $status = "<spam class='conf_status'>" . _tr("Past") . "</spam>"; } } } else { if ($invite_part) { $participants = "<a href='?menu={$module_name}&action=current_conf&id_conf={$conf['bookid']}&organization={$conf['organization_domain']}' class='conf_memb' id='{$conf['bookid']}'>" . $conf["members"] . " / {$max}</a>"; } } $arrTmp[] = $participants; $arrTmp[] = $status; $arrData[] = $arrTmp; //se usa para comprobar si ha habido cambios en el estado de las conferencias $session['conference']["conf_list"][$conf['bookid']] = array($participants, $status); } } //se escribe en session el estado actual de las conferencias putSession($session); //filters $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if ($create) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Conference"), array_slice($arrOrgz, 1), $selected = null, "create_conference", $onchange_select = null); } else { $oGrid->addNew("create_conference", _tr("ADD Conference")); } } if ($delete) { $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete")); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } //arreglo usado para formar los elementos del filtro $arrState = array("all" => _tr("All"), "past" => _tr("Past Conference"), "current" => _tr("Current Conference"), "future" => _tr("Future Conference")); $arrType = array("both" => _tr("Both"), "yes" => _tr("Schedule"), "no" => _tr("No Schedule")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrState[$state_conf], $state_conf, array("state_conf" => "all"), true); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Name") . " = " . $name_conf, $name_conf, array("name_conf" => "")); $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Type") . " = " . $arrType[$type_conf], $type_conf, array("type_conf" => "both"), true); $smarty->assign("SHOW", _tr("Show")); $arrFormElements = createFieldFilter($arrState, $arrType, $arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $contenidoModulo .= "<input type='hidden' name='grid_limit' id='grid_limit' value='{$limit}'>"; $contenidoModulo .= "<input type='hidden' name='grid_offset' id='grid_offset' value='{$offset}'>"; $contenidoModulo .= "<input type='hidden' name='conf_action' id='conf_action' value='report'>"; $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportRG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $rg_name = getParameter("rg_name"); $pRG = new paloSantoRG($pDB, $domain); $rg_number = getParameter("rg_number"); if (isset($rg_number) && $rg_number != '') { $expression = $pRG->getRegexPatternFromAsteriskPattern($rg_number); if ($expression === false) { $rg_number = ''; } } $url['menu'] = $module_name; $url['organization'] = $domain; $url['rg_number'] = $rg_number; //ring group number $url['rg_name'] = $rg_name; //ring group number $total = $pRG->getNumRG($domain, $rg_number, $rg_name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pRG->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('RG List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Number"); $arrColum[] = _tr("Name"); $arrColum[] = _tr("Strategy"); $arrColum[] = _tr("Ring Time"); $arrColum[] = _tr("Ignore CF"); $arrColum[] = _tr("Skip Busy Extensions"); $arrColum[] = _tr("Default Destination"); $oGrid->setColumns($arrColum); $arrRG = array(); $arrData = array(); if ($total != 0) { $arrRG = $pRG->getRGs($domain, $rg_number, $rg_name, $limit, $offset); } if ($arrRG === false) { $error = _tr("Error to obtain Ring Groups") . $pRG->errMsg; $arrRG = array(); } foreach ($arrRG as $rg) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$rg["organization_domain"]]; } $arrTmp[] = " <a href='?menu=ring_group&action=view&id_rg=" . $rg['id'] . "&organization={$rg['organization_domain']}'>" . $rg['rg_number'] . "</a>"; $arrTmp[] = htmlentities($rg["rg_name"], ENT_QUOTES, "UTF-8"); $arrTmp[] = $rg["rg_strategy"]; $arrTmp[] = $rg["rg_time"]; $arrTmp[] = $rg["rg_cf_ignore"]; $arrTmp[] = $rg["rg_skipbusy"]; $arrTmp[] = $rg["destination"]; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Ring Group"), array_slice($arrOrgz, 1), $selected = null, "create_rg", $onchange_select = null); } else { $oGrid->addNew("create_rg", _tr("ADD Ring Group")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["rg_number"] = $rg_number; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Number") . " = " . $rg_number, $_POST, array("rg_number" => "")); $_POST["rg_name"] = $rg_name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Name") . " = " . $rg_name, $_POST, array("rg_name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportMonitoring($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ''; $pMonitoring = new paloSantoMonitoring($pDB); $pORGZ = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]); $pPBX = new paloAsteriskDB($arrConf['elastix_dsn']["elastix"]); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); $domain = empty($domain) ? 'all' : $domain; $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $domain = $credentials['domain']; } $date_start = getParameter('date_start'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_start)) { $date_start = date("d M Y"); } $date_end = getParameter('date_end'); if (!preg_match("/^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$/", $date_end)) { $date_end = date("d M Y"); } $arrType = array("" => "", "conference" => _tr("Conference"), "group" => _tr("Group"), "queue" => _tr("Queue"), 'incoming' => _tr('Incoming'), 'outgoing' => _tr("Outgoing")); $type = getParameter("type"); $type = array_key_exists($type, $arrType) ? $type : ""; $source = getParameter("source"); if (isset($source) && $source != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($source); if ($expression === false) { $source = ''; } } $destination = getParameter("destination"); if (isset($destination) && $destination != '') { $expression = $pPBX->getRegexPatternFromAsteriskPattern($destination); if ($expression === false) { $destination = ''; } } $url['menu'] = $module_name; $url['organization'] = $arrProp['organization'] = $domain; $url['date_start'] = $arrProp['date_start'] = $date_start; $url['date_end'] = $arrProp['date_end'] = $date_end; $url['source'] = $arrProp['source'] = $source; $url['destination'] = $arrProp['destination'] = $destination; $url['type'] = $arrProp['type'] = $type; //permission $delete = in_array("delete", $arrPermission); $export = in_array("export", $arrPermission); //begin grid parameters $oGrid = new paloSantoGrid($smarty); $oGrid->setTitle(_tr("Monitoring")); $oGrid->setIcon("web/apps/{$module_name}/images/pbx_monitoring.png"); $oGrid->pagingShow(true); // show paging section. if ($export) { $oGrid->enableExport(); } // enable export. $oGrid->setNameFile_Export(_tr("Monitoring")); $oGrid->setURL($url); if ($delete && !$oGrid->isExportAction()) { $arrColumns[] = ""; } if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr('organization'); } $arrColumns[] = _tr("Date"); $arrColumns[] = _tr("Time"); $arrColumns[] = _tr("Source"); $arrColumns[] = _tr("Destination"); $arrColumns[] = _tr("Duration"); $arrColumns[] = _tr("Type"); $arrColumns[] = _tr("File"); if (!$oGrid->isExportAction()) { $arrColumns[] = ""; //to display audio } $oGrid->setColumns($arrColumns); $totalMonitoring = $pMonitoring->getNumMonitoring($arrProp); if ($totalMonitoring === false) { $error = _tr('Recordings could not be retrieved.') . " " . "DATABASE ERROR"; $totalMonitoring = 0; } $arrData = array(); $arrResult = array(); if ($totalMonitoring != 0) { if ($oGrid->isExportAction()) { $arrResult = $pMonitoring->getMonitoring($arrProp); } else { $limit = 20; $total = $totalMonitoring; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $arrProp['limit'] = $limit; $arrProp['offset'] = $offset; $arrResult = $pMonitoring->getMonitoring($arrProp); } } if ($arrResult === false) { $error = _tr('Recordings could not be retrieved.') . " " . "DATABASE ERROR"; } else { if ($oGrid->isExportAction()) { if (!$export) { $arrData = _tr('INVALID ACTION'); } foreach ($arrResult as $monitoring) { $arrTmp = array(); if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = isset($arrOrgz[$monitoring['organization_domain']]) ? $arrOrgz[$monitoring['organization_domain']] : ''; } $arrTmp[] = date('d M Y', strtotime($monitoring['calldate'])); //date $arrTmp[] = date('H:i:s', strtotime($monitoring['calldate'])); //time $arrTmp[] = $monitoring['src']; //source $arrTmp[] = $monitoring['dst']; //destination $arrTmp[] = SecToHHMMSS($monitoring['duration']); //duration $namefile = basename($monitoring['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($monitoring['toout'] == '1') { $arrTmp[] = $arrType['outgoing']; } elseif ($monitoring['fromout'] == '1') { $arrTmp[] = $arrType['incoming']; } else { if ($namefile[0] == 'g') { $arrTmp[] = $arrType['group']; } elseif ($namefile[0] == 'q') { $arrTmp[] = $arrType['queue']; } elseif (strpos($namefile, "meetme-conf") !== false) { $arrTmp[] = $arrType['conference']; } else { $arrTmp[] = ""; } } $arrTmp[] = $namefile; $arrData[] = $arrTmp; } } else { $i = 0; foreach ($arrResult as $monitoring) { $arrTmp = array(); if ($delete) { $arrTmp[] = "<input type='checkbox' name='recordDel[]' value='{$monitoring['uniqueid']}' />"; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = isset($arrOrgz[$monitoring['organization_domain']]) ? $arrOrgz[$monitoring['organization_domain']] : ''; } $arrTmp[] = date('d M Y', strtotime($monitoring['calldate'])); //date $arrTmp[] = date('H:i:s', strtotime($monitoring['calldate'])); //time $arrTmp[] = $monitoring['src']; //source $arrTmp[] = $monitoring['dst']; //destination $arrTmp[] = SecToHHMMSS($monitoring['duration']); //duration $namefile = basename($monitoring['userfield']); $namefile = str_replace("audio:", "", $namefile); if ($monitoring['toout'] == '1') { $arrTmp[] = $arrType['outgoing']; } elseif ($monitoring['fromout'] == '1') { $arrTmp[] = $arrType['incoming']; } else { if ($namefile[0] == 'g') { $arrTmp[] = $arrType['group']; } elseif ($namefile[0] == 'q') { $arrTmp[] = $arrType['queue']; } elseif (strpos($namefile, "meetme-conf") !== false) { $arrTmp[] = $arrType['conference']; } else { $arrTmp[] = ""; } } if ($namefile == 'deleted') { $arrTmp[] = $namefile; $arrTmp[] = ""; } else { $explod_name = explode(".", $namefile); $ext = array_pop($explod_name); if ($ext == 'gsm' || $ext == 'WAV') { $div_display = "<a href=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&id={$monitoring['uniqueid']}&rawmode=yes',350,100)\"><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/></a> "; } else { $div_display = "<div class='single' id='{$i}' style='display:inline;'><span data-src='index.php?menu={$module_name}&action=download&id={$monitoring['uniqueid']}&rawmode=yes'><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/> </span></div>"; } $download = "<a href='index.php?menu={$module_name}&action=download&id={$monitoring['uniqueid']}&rawmode=yes'>" . $namefile . "</a>"; $arrTmp[] = $div_display . $download; $arrTmp[] = "<audio></audio>"; } $i++; $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } //begin section filter $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($delete) { $oGrid->deleteList(_tr("Are you sure you want to delete?"), "delete", _tr("Delete Selected"), false); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true); } $_POST['date_start'] = $arrProp['date_start']; $_POST['date_end'] = $arrProp['date_end']; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrProp['date_start'] . ", " . _tr("End Date") . " = " . $arrProp['date_end'], $arrProp, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true); //DATE START - DATE END $_POST["type"] = $type; // type $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type") . " = " . $arrType[$type], $_POST, array("type" => "")); $_POST["source"] = $source; // source $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Source") . " = " . $source, $_POST, array("source" => "")); $_POST["destination"] = $destination; // destination $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Destination") . " = " . $source, $_POST, array("destination" => "")); $arrForm = createFieldFilter($arrOrgz, $arrType); $oFilterForm = new paloForm($smarty, $arrForm); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); //end section filter $content = $oGrid->fetchGrid(); return $content; }
private function trunkOrganization($id_trunk, $arrOrg) { global $arrConf; $pDB2 = new paloDB($arrConf['elastix_dsn']['elastix']); $pORGZ = new paloSantoOrganization($pDB2); $arrTmp = $pORGZ->getOrganization(array()); $arrOrgz = array(); foreach ($arrTmp as $value) { if (!empty($value["domain"])) { $arrOrgz[$value["domain"]] = $value["domain"]; } } $query = "INSERT into trunk_organization(trunkid,organization_domain) values (?,?)"; //obtenemos las oraganizacion seleccionadas $orgs = explode(",", $arrOrg); foreach ($orgs as $value) { if ($value != "") { if (in_array($value, $arrOrgz)) { if ($this->_DB->genQuery($query, array($id_trunk, $value)) == false) { $this->errMsg .= _tr("Organization in trunk couldn't be setted. ") . $this->_DB->errMsg; return false; } } } } return true; }
function reportExten($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pExten = new paloSantoExtensions($pDB); $pORGZ = new paloSantoOrganization($pDB); $error = ''; $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $extension = getParameter("extension"); if (isset($extension) && $extension != '') { $pPBX = new paloAsteriskDB($pDB); $expression = $pPBX->getRegexPatternFromAsteriskPattern($extension); if ($expression === false) { $extension = ''; } } $url['menu'] = $module_name; $url['organization'] = $domain; $url['extension'] = $extension; $total = $pExten->getNumExtensions($domain, $extension); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pExten->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Extensions List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Extension"); $arrColum[] = _tr("Caller ID"); $arrColum[] = _tr("Technology"); $arrColum[] = _tr("Device"); $arrColum[] = _tr("Context"); $arrColum[] = _tr("User"); $arrColum[] = _tr("Voicemail"); $arrColum[] = _tr("Recording In") . " / " . _tr("Recording Out"); $oGrid->setColumns($arrColum); $arrExtens = array(); $arrData = array(); if ($total != 0) { $arrExtens = $pExten->getExtensions($domain, $extension, $limit, $offset); } if ($arrExtens === false) { $error = _tr("Error to obtain extensions") . $pExten->errMsg; $arrExtens = array(); } else { foreach ($arrExtens as $exten) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$exten["organization_domain"]]; } $arrTmp[] = " <a href='?menu=extensions&action=view&id_exten=" . $exten['id'] . "&organization={$exten['organization_domain']}'>" . $exten["exten"] . "</a>"; $arrTmp[] = $exten['clid_name'] . " <{$exten['clid_number']}>"; $arrTmp[] = strtoupper($exten['tech']); $arrTmp[] = $exten['device']; $arrTmp[] = $exten['context']; $query = "Select username from acl_user where extension=? and id_group in (select g.id from acl_group g join organization o on g.id_organization=o.id where o.domain=?)"; $result = $pDB->getFirstRowQuery($query, false, array($exten["exten"], $exten["organization_domain"])); if ($result != false) { $arrTmp[] = $result[0]; } else { $arrTmp[] = _tr("Nobody"); } if (isset($exten["voicemail"])) { if ($exten["voicemail"] != "novm") { $arrTmp[] = "yes"; } else { $arrTmp[] = "no"; } } else { $arrTmp[] = "no"; } $arrTmp[] = _tr($exten["record_in"]) . " / " . _tr($exten["record_out"]); $arrData[] = $arrTmp; } } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("Create New Extension"), array_slice($arrOrgz, 1), $selected = null, "create_exten", $onchange_select = null); } else { $oGrid->addNew("create_exten", _tr("Create New Extension")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["extension"] = $extension; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Extension") . " = " . $extension, $_POST, array("extension" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function form_Recordings($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pRecording = new paloSantoRecordings($pDB); $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $domain = ''; if ($credentials['userlevel'] != 'superadmin') { $arrOrgz = array(); $domain = $credentials["domain"]; $extension = $pRecording->Obtain_Extension_Current_User(); } else { $domain = getParameter('organization'); $arrOrgz = array("" => _tr("-- Any (To the system) --")); $pORGZ = new paloSantoOrganization($pDB); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } $extension = ''; } if (isset($_POST['option_record']) && $_POST['option_record'] == 'by_file') { $smarty->assign("check_file", "checked"); } else { $smarty->assign("check_record", "checked"); } $arrForm = createFieldForm($arrOrgz); $oForm = new paloForm($smarty, $arrForm); $smarty->assign("recording_name_Label", _tr("Record Name")); $smarty->assign("overwrite_record", _tr("This record Name already exists. Do you want to Overwrite it?")); $smarty->assign("record_Label", _tr("File Upload")); $smarty->assign("record_on_extension", _tr("Record On Extension")); $smarty->assign("Record", _tr("Record")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("INFO", _tr("Press REC and start your recording. Once you have finished recording you must press ·STOP or hangup the phone") . "."); $smarty->assign("NAME", _tr("You do not need to add an extension to the record name") . "."); $smarty->assign("icon", "web/apps/{$module_name}/images/recording.png"); $smarty->assign("module_name", $module_name); $smarty->assign("file_upload", _tr("File Upload")); $smarty->assign("record", _tr("Record")); $smarty->assign("ext", _tr("Extension")); $smarty->assign("system", _tr("System")); $smarty->assign("exten", _tr("Extension")); $smarty->assign("EXTENSION", $extension); $smarty->assign("checking", _tr("Checking Name...")); $smarty->assign("dialing", _tr("Dialing...")); $smarty->assign("domain", $domain); $smarty->assign("confirm_dialog", _tr("This Record Name already exists.")); $smarty->assign("success_record", _tr("Record was saved succesfully.")); $smarty->assign("cancel_record", _tr("Record was canceled.")); $smarty->assign("hangup", _tr("Hang up.")); $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. ")); $smarty->assign("USERLEVEL", $credentials['userlevel']); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Recordings"), $_POST); $contenidoModulo = "<form enctype='multipart/form-data' method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $contenidoModulo; }
function reportOutbound($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials, $reorderRoute = false) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $error = ""; $arrOrgz = array(); $domain = getParameter("organization"); $name = getParameter("name"); // outbound name $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; if ($credentials['userlevel'] == "superadmin") { if (isset($domain) && $domain != "all") { $pOutbound = new paloSantoOutbound($pDB, $domain); } else { $pOutbound = new paloSantoOutbound($pDB, ""); } $total = $pOutbound->getNumOutbound($domain, $name); $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $pOutbound = new paloSantoOutbound($pDB, $domain); $total = $pOutbound->getNumOutbound($domain, $name); } if ($total === false) { $error = $pOutbound->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $arrGrid = array("title" => _tr('Outbound Routes List'), "url" => $url, "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total); $arrColumns = array(); $arrColumns[] = _tr("Order"); $arrColumns[] = _tr("Route Name"); if ($credentials['userlevel'] == "superadmin") { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Route CID"); $arrColumns[] = _tr("Route Password"); $arrColumns[] = _tr("Time Group"); $oGrid->setColumns($arrColumns); $arrOutbound = array(); $arrData = array(); if ($total != 0) { $arrOutbound = $pOutbound->getOutbounds($domain, $name, $limit, $offset); } if ($arrOutbound === false) { $error = _tr("Error to obtain outbounds") . $pOutbound->errMsg; $arrOutbound = array(); } $create = in_array('create', $arrPermission); $edit = in_array('edit', $arrPermission); foreach ($arrOutbound as $outbound) { $arrTmp = array(); if ($edit) { $arrTmp[] = fieldOrden($arrOutbound, $outbound["seq"], $outbound["id"], $outbound["organization_domain"]); } else { $arrTmp[] = $outbound["seq"]; } $arrTmp[] = " <a href='?menu=outbound_route&action=view&id_outbound=" . $outbound['id'] . "&organization={$outbound["organization_domain"]}'>" . htmlentities($outbound['routename'], ENT_QUOTES, "UTF-8") . "</a>"; if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$outbound["organization_domain"]]; } $arrTmp[] = $outbound["outcid"]; $arrTmp[] = $outbound["routepass"]; if (isset($outbound["time_group_id"])) { $query = "SELECT name from time_group where id=?"; $result = $pDB->getFirstRowQuery($query, true, array($outbound["time_group_id"])); if ($result != false) { $arrTmp[] = $result["name"]; } else { $arrTmp[] = ""; } } $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Outbound Route"), array_slice($arrOrgz, 1), $selected = null, "create_outbound", $onchange_select = null); } else { $oGrid->addNew("create_outbound", _tr("ADD Outbound Route")); } } if ($credentials['userlevel'] == "superadmin") { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["name"] = $name; //outbound_route name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function viewFormTrunk($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pTrunk = new paloSantoTrunk($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrTrunks = array(); $action = getParameter("action"); $idTrunk = getParameter("id_trunk"); if ($action == "view" || $action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idTrunk)) { $error = _tr("Invalid Trunk"); } else { $arrTrunks = $pTrunk->getTrunkById($idTrunk); if ($arrTrunks === false) { $error = _tr($pTrunk->errMsg); } else { if (count($arrTrunks) == 0) { $error = _tr("Trunk doesn't exist"); } else { if ($error != "") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); return reportTrunks($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $tech = $arrTrunks["general_tech"]; $smarty->assign('j', 0); if ($action == "view" || getParameter("edit")) { $arrDialPattern = $pTrunk->getArrDestine($idTrunk); $smarty->assign('items', $arrDialPattern); } //$smarty->assign('items',$arrDialPattern); if (getParameter("save_edit")) { if (isset($_POST["general_select_orgs"])) { $smarty->assign("ORGS", $_POST["general_select_orgs"]); } $arrTrunks = $_POST; } else { $select_orgs = implode(",", $arrTrunks["general_select_orgs"]); if (isset($arrTrunks["general_select_orgs"])) { $smarty->assign("ORGS", $select_orgs . ","); } } if ($arrTrunks["general_sec_call_time"] == "yes") { $smarty->assign("SEC_TIME", "yes"); } if ($action == "view") { $smarty->assign("ORGS", $select_orgs); } } } } } else { //save_new $tech = getParameter("tech_trunk"); $arrDialPattern = getParameter("arrDestine"); $tmpstatus = explode(",", $arrDialPattern); $arrDialPattern = array_values(array_diff($tmpstatus, array(''))); $tmp_dial = array(); foreach ($arrDialPattern as $pattern) { $prepend = getParameter("general_prepend_digit" . $pattern); $prefix = getParameter("general_pattern_prefix" . $pattern); $pattern = getParameter("general_pattern_pass" . $pattern); $tmp_dial[] = array(0, $prefix, $pattern, $prepend); } $smarty->assign('j', 0); $smarty->assign('items', $tmp_dial); if (getParameter("create_trunk")) { $arrTrunks1 = $pTrunk->getDefaultConfig($tech, "peer"); $arrTrunks2 = $pTrunk->getDefaultConfig($tech, "user"); $arrTrunks = array_merge($arrTrunks1, $arrTrunks2); } else { if (isset($_POST["general_select_orgs"])) { $smarty->assign("ORGS", $_POST["general_select_orgs"]); } $arrTrunks = $_POST; } } $smarty->assign("EDIT", in_array('edit', $arrPermission)); $smarty->assign("DELETE", in_array('delete', $arrPermission)); if ($error != "") { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $error . " " . $pTrunk->errMsg); return reportTrunks($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $arrTmp = $pORGZ->getOrganization(array()); $arrOrgz = array(0 => _tr("--pickup organizations--")); foreach ($arrTmp as $value) { $arrOrgz[$value["domain"]] = $value["domain"]; } $arrForm = createFieldForm($tech, $arrOrgz); $oForm = new paloForm($smarty, $arrForm); $smarty->assign("arrAttributes", $arrForm); if ($action == "view") { $oForm->setViewMode(); } else { if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); $mostra_adv["peer"] = getParameter("mostra_adv_peer"); $mostra_adv["user"] = getParameter("mostra_adv_peer"); foreach ($mostra_adv as $km => $vm) { if (isset($vm)) { if ($vm == "yes") { $smarty->assign("SHOW_MORE_" . strtoupper($km), "style='visibility: visible;'"); $smarty->assign("mostra_adv_{$km}", "yes"); } else { $smarty->assign("SHOW_MORE_" . strtoupper($km), "style='display: none;'"); $smarty->assign("mostra_adv_{$km}", "no"); } } else { $smarty->assign("SHOW_MORE_" . strtoupper($km), "style='display: none;'"); $smarty->assign("mostra_adv_{$km}", "yes"); } } } } if ($tech == "dahdi") { $smarty->assign("NAME_CHANNEL", _tr("DAHDI Channel")); } else { $smarty->assign("NAME_CHANNEL", _tr("CUSTOM Channel")); } $smarty->assign("TECH", strtoupper($tech)); $smarty->assign("PEER_Details", _tr("Peer Details")); $smarty->assign("ADV_OPTIONS", _tr("Advanced Settings")); $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_trunk", $idTrunk); $smarty->assign("tech_trunk", $tech); $smarty->assign("PREPEND", _tr("Prepend")); $smarty->assign("PREFIX", _tr("Prefix")); $smarty->assign("MATCH_PATTERN", _tr("Match Pattern")); $smarty->assign("RULES", _tr("Dialed Number Manipulation Rules")); $smarty->assign("GENERAL", _tr("General")); $smarty->assign("SETTINGS", _tr("Peer Settings")); $smarty->assign("REGISTRATION", _tr("Registration")); $smarty->assign("SEC_SETTINGS", _tr("Security Settings")); $smarty->assign("ORGANIZATION_PERM", _tr("Organizations Allowed")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("Trunk") . " " . strtoupper($tech), $arrTrunks); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function setUserPassword() { global $arrConf; include_once "libs/paloSantoACL.class.php"; include_once "libs/paloSantoOrganization.class.php"; $old_pass = getParameter("oldPassword"); $new_pass = getParameter("newPassword"); $new_repass = getParameter("newRePassword"); $arrResult = array(); $arrResult['status'] = FALSE; if ($old_pass == "") { $arrResult['msg'] = _tr("Please write your current password."); return $arrResult; } if ($new_pass == "" || $new_repass == "") { $arrResult['msg'] = _tr("Please write the new password and confirm the new password."); return $arrResult; } if ($new_pass != $new_repass) { $arrResult['msg'] = _tr("The new password doesn't match with retype new password."); return $arrResult; } //verificamos que la nueva contraseña sea fuerte if (!isStrongPassword($new_pass)) { $arrResult['msg'] = _tr("The new password can not be empty. It must have at least 10 characters and contain digits, uppers and little case letters"); return $arrResult; } $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $pDB = new paloDB($arrConf['elastix_dsn']['elastix']); $pACL = new paloACL($pDB); $uid = $pACL->getIdUser($user); if ($uid === FALSE) { $arrResult['msg'] = _tr("Please your session id does not exist. Refresh the browser and try again."); } else { // verificando la clave vieja $val = $pACL->authenticateUser($user, md5($old_pass)); if ($val === TRUE) { $pORG = new paloSantoOrganization($pDB); $status = $pORG->changeUserPassword($user, $new_pass); if ($status) { $arrResult['status'] = TRUE; $arrResult['msg'] = _tr("Elastix password has been changed."); $_SESSION['elastix_pass'] = md5($new_pass); $_SESSION['elastix_pass2'] = $new_pass; } else { $arrResult['msg'] = _tr("Impossible to change your Elastix password.") . " " . $pORG->errMsg; } } else { $arrResult['msg'] = _tr("Impossible to change your Elastix password. User does not exist or password is wrong"); } } return $arrResult; }
function listarFaxes(&$smarty, $module_name, $local_templates_dir, $pDB, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $smarty->assign(array('SEARCH' => _tr('Search'))); $smarty->assign('USERLEVEL', $credentials['userlevel']); $arrOrgz = array(0 => "all"); $organization = getParameter('organization'); if ($credentials['userlevel'] == 'superadmin') { if (empty($organization)) { $organization = 0; } if ($pORGZ->getNumOrganization(array()) > 0) { foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["id"]] = $value["name"]; } } } else { $tmpOrg = $pORGZ->getOrganizationById($credentials['id_organization']); $arrOrgz[$tmpOrg["id"]] = $tmpOrg['name']; $organization = $credentials['id_organization']; } $oFax = new paloFaxVisor($pDB); // Generación del filtro $oFilterForm = new paloForm($smarty, getFormElements($arrOrgz)); // Parámetros base y validación de parámetros $url = array('menu' => $module_name); $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All'); foreach (array_keys($paramFiltro) as $k) { if (!is_null(getParameter($k))) { $paramFiltro[$k] = getParameter($k); } } $oGrid = new paloSantoGrid($smarty); $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out')); if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $organization; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$organization], $_POST, array("organization" => 0), true); //organization } $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => "")); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL)); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro); if (!$oFilterForm->validateForm($paramFiltro)) { $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion)))); $paramFiltro = $paramFiltroBase; } $url = array_merge($url, $paramFiltro); $oGrid->setTitle(_tr("Fax Viewer")); $oGrid->setIcon("web/apps/{$module_name}/images/kfaxview.png"); $oGrid->pagingShow(true); // show paging section. $oGrid->setURL($url); $arrData = NULL; if ($organization == 0) { $total = $oFax->obtener_cantidad_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); } else { $total = $oFax->obtener_cantidad_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']); } if ($total === false) { $total = 0; $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } $delete = in_array('delete_fax', $arrPermission); $edit = in_array('edit_fax', $arrPermission); $limit = 20; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); if ($delete) { $columns[] = "<input type='checkbox' class='checkall'/>"; } if ($credentials['userlevel'] == 'superadmin') { $columns[] = _tr('Organization'); } $columns[] = _tr('Type'); $columns[] = _tr('File'); $columns[] = _tr('Fax Cid Name'); $columns[] = _tr('Fax Cid Number'); $columns[] = _tr('Fax Destiny'); $columns[] = _tr('Fax Date'); $columns[] = _tr('Status'); if ($edit) { $columns[] = _tr('Options'); } $oGrid->setColumns($columns); if ($total > 0) { if ($organization == 0) { $arrResult = $oFax->obtener_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); } else { $arrResult = $oFax->obtener_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']); } if (!is_array($arrResult)) { $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg)); } else { foreach ($arrResult as $fax) { foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax') as $k) { $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8'); } $doc = explode(".", $fax['pdf_file']); $iddoc = $doc[0]; $arrTmp = array(); if ($delete) { $arrTmp[] = '<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />'; } if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = 'ttt'; } //$arrOrg[$fax['id_organization']]; $arrTmp[] = _tr($fax['type']); $arrTmp[] = strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file']; $arrTmp[] = $fax['company_name']; $arrTmp[] = $fax['company_fax']; $arrTmp[] = $fax['destiny_name'] . " - " . $fax['destiny_fax']; $arrTmp[] = $fax['date']; $arrTmp[] = _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']); if ($edit) { $arrTmp[] = "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>"; } $arrData[] = $arrTmp; } } } $oGrid->setData($arrData); if ($delete) { $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete")); } $oGrid->showFilter($htmlFilter); return $oGrid->fetchGrid(); }
function reportGroupPermission($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrGroups = array(); $arrOrgz = array(); $idOrgFil = getParameter("idOrganization"); if ($credentials['userlevel'] == "superadmin") { $orgTmp = $pORGZ->getOrganization(array()); if ($orgTmp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pORGZ->errMsg)); } elseif (count($orgTmp) == 0) { $smarty->assign("mb_title", _tr("MESSAGE")); $msg = _tr("You haven't created any organization"); $smarty->assign("mb_message", $msg); } else { //si el usuario a selecionado una organizacion comprobamos que esta exista //caso contrario procedemos a sellecionar la primera disponible $flag = false; foreach ($orgTmp as $value) { $arrOrgz[$value["id"]] = $value["name"]; if ($value["id"] == $idOrgFil) { $flag = true; } } if (!$flag) { $idOrgFil = $orgTmp[0]['id']; } } } else { $idOrgFil = $credentials['id_organization']; $orgTmp = $pORGZ->getOrganizationById($idOrgFil); if ($orgTmp == false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieved organization data")); } else { $arrOrgz = $orgTmp; } } if (count($arrOrgz) > 0) { //que se un arreglo y que tenga al menos una organizacion $groupTmp = $pACL->getGroupsPaging(null, null, $idOrgFil); if ($groupTmp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); } else { foreach ($groupTmp as $value) { $arrGroups[$value[0]] = $value[1]; } } } $filter_group = getParameter("filter_group"); if (count($arrGroups) > 0) { if (empty($filter_group)) { //seleccionamos el primer grupo de la lista de grupos $filter_group = $groupTmp[0][0]; } //valido que el grupo pertenzca a la organizacion if ($pACL->getGroups($filter_group, $idOrgFil) == false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid Group")); $filter_group = $groupTmp[0][0]; } } $filter_resource = getParameter("filter_resource"); $lang = get_language(); if ($lang != "en") { if (isset($filter_resource)) { if (trim($filter_resource) != "") { global $arrLang; $filter_value = strtolower(trim($filter_resource)); $parameter_to_find[] = $filter_value; //parametro de busqueda sin traduccion foreach ($arrLang as $key => $value) { $langValue = strtolower(trim($value)); if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) { if (strpos($langValue, $filter_value) !== FALSE) { $parameter_to_find[] = $key; } } } } } } if (isset($filter_resource)) { $parameter_to_find[] = $filter_resource; } else { $parameter_to_find = null; } $totalGroupPermission = 0; if (count($arrGroups) > 0) { $arrResourceOrg = $pACL->getResourcesByOrg($idOrgFil, $parameter_to_find); if ($arrResourceOrg === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieved Resources")); } else { $totalGroupPermission = count($arrResourceOrg); } } //begin grid parameters $oGrid = new paloSantoGrid($smarty); $limit = 25; $total = $totalGroupPermission; $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url['menu'] = $module_name; $url['idOrganization'] = $idOrgFil; $url['filter_group'] = $filter_group; $url['filter_resource'] = $filter_resource; $arrData = $arrResourceActions = $arrPermisos = array(); $error = false; if (count($arrGroups) > 0 && $totalGroupPermission > 0) { $arrResource = array_slice($arrResourceOrg, $offset, $limit); $idGroup = $filter_group; foreach ($arrResource as $resource) { $listResource[] = $resource['id']; //lista de id de los recursos que queremos consulta $listResDes[$resource['id']] = $resource['description']; } //las acciones que tiene cada drecurso $arrResourceActions = $pACL->getResourcesActions($listResource); if ($arrResourceActions === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieved Resources Actions")); $error = true; } //los premisos que tiene el grupo $arrPermisos = $pACL->loadGroupPermissions($idGroup, $listResource); if ($arrPermisos === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieved Group Permissions")); $error = true; } } $max_actions = 0; $isAdministrator = $pACL->getGroupNameByid($idGroup) == _tr("administrator") ? true : false; if ($totalGroupPermission > 0 && !$error) { foreach ($arrResourceActions as $resource => $actions) { $arrTmp = array(); $arrTmp[] = _tr($listResDes[$resource]); $disabled = ""; if ($isAdministrator && ($resource == 'grouplist' || $resource == 'userlist' || $resource == 'group_permission')) { $disabled = "disabled='disabled'"; } //dentro del modulo organizacion ahi acciones que unicamente las puede realizar el superadmin //por lo tando no deben aparecer listadas if ($resource == "organization") { $actions = array_diff($actions, array('change_org_status', 'create_org', 'delete_org', 'edit_DID')); } elseif ($resource == "dashboard") { $actions = array('access'); } elseif ($resource == 'cdrreport') { $actions = array('access', 'export'); } if (count($actions) > $max_actions) { $max_actions = count($actions); } $desactivar = false; if (isset($arrPermisos[$resource])) { //grupo no tiene nigun permiso if (!in_array('access', $arrPermisos[$resource])) { $desactivar = true; } } else { $desactivar = true; $arrPermisos[$resource] = array(); } foreach ($actions as $action) { $class = 'other_act'; if ($action == 'access') { $class = 'access_act'; } elseif ($desactivar) { $disabled = "disabled='disabled'"; } $checked0 = ''; //chequeamos si la accion se encuentra en la lista de acciones permitidas en el recurso if (in_array($action, $arrPermisos[$resource])) { $checked0 = "checked"; } $arrTmp[] = "<input type='checkbox' class='{$class}' {$disabled} name='groupPermission[" . $resource . "][{$action}]' {$checked0}> {$action}"; } $arrData[] = $arrTmp; } } $oGrid->setTitle(_tr("Group Permission")); $oGrid->setURL($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $arrColumn[] = _tr("Resource"); for ($i = 1; $i <= $max_actions; $i++) { $act = _tr("Action"); $arrColumn[] = "{$act}" . " {$i}"; } $oGrid->setColumns($arrColumn); //begin section filter $arrFormFilter = createFieldFilter($arrGroups); $oFilterForm = new paloForm($smarty, $arrFormFilter); $smarty->assign("SHOW", _tr("Show")); $smarty->assign("limit_apply", htmlspecialchars($limit, ENT_COMPAT, 'UTF-8')); $smarty->assign("offset_apply", htmlspecialchars($offset, ENT_COMPAT, 'UTF-8')); $smarty->assign("resource_apply", htmlentities($filter_resource)); $_POST["filter_group"] = htmlspecialchars($filter_group, ENT_COMPAT, 'UTF-8'); $_POST["filter_resource"] = htmlspecialchars($filter_resource, ENT_COMPAT, 'UTF-8'); $_POST["idOrganization"] = $idOrgFil; if (count($arrOrgz) > 0) { global $arrPermission; if (in_array('edit_permission', $arrPermission)) { $oGrid->addSubmitAction("apply", _tr("Save")); } if ($credentials['userlevel'] == "superadmin") { $oGrid->addComboAction("idOrganization", _tr("Organization"), $arrOrgz, $idOrgFil, "report"); } $nameGroup = isset($arrGroups[$filter_group]) ? $arrGroups[$filter_group] : ""; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Group") . " = {$nameGroup}", $_POST, array("filter_group" => $groupTmp[0][0]), true); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Resource") . " = {$filter_resource}", $_POST, array("filter_resource" => "")); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("You haven't created any organization")); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); //end grid parameters return $contenidoModulo; }
function reportDID($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pDID = new paloDidPBX($pDB); $pORGZ = new paloSantoOrganization($pDB); $error = ""; $did_number = getParameter("did_number"); // did number $status = getParameter("status"); // asignado o sin asignar $country = getParameter("country"); // pais al que pertence el did $domain = getParameter("organization"); // did que se encuentran asigandos a dicha organizacion $url['menu'] = $module_name; if (isset($did_number) && $did_number != '') { $expression = $pDID->getRegexPatternFromAsteriskPattern($did_number); if ($expression === false) { $did_number = ''; } } $status = empty($status) ? 'all' : $status; $domain = empty($domain) ? 'all' : $domain; $url['did_number'] = $did_number; $url['status'] = $status; $url['country'] = $country; $url['organization'] = $domain; $total = 0; $total = $pDID->getTotalDID($domain, $did_number, $country, $status); if ($total === false) { $error = $pDID->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url = "?menu={$module_name}"; $arrGrid = array("title" => _tr('DID List'), "url" => $url, "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, 'columns' => array(array("name" => _tr("DID")), array("name" => _tr("Organization Domain")), array("name" => _tr("Type")), array("name" => _tr("Country")), array("name" => _tr("Country Code / Area Code")))); $arrData = array(); $arrDID = array(); if ($total != 0) { $arrDID = $pDID->getDIDs($domain, $did_number, $country, $status, $limit, $offset); } if ($arrDID === false) { $error = _tr("Error to obtain DID") . $pDID->errMsg; $arrData = array(); } else { //si es un usuario solo se ve su didsion //si es un administrador ve todas las didsiones foreach ($arrDID as $did) { $arrTmp[0] = " <a href='?menu=did&action=view&id_did=" . $did['id'] . "'>" . $did['did'] . "</a>"; $arrTmp[1] = $did["organization_domain"]; $arrTmp[2] = $did["type"]; $arrTmp[3] = $did["country"]; $arrTmp[4] = $did["country_code"] . " / " . $did["area_code"]; $arrData[] = $arrTmp; } } if (in_array('create', $arrPermission)) { $oGrid->addNew("create_did", _tr("New DID")); } $_POST["did_number"] = $did_number; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("DID Number") . " = " . $did_number, $_POST, array("did_number" => "")); $arrStatus = array("all" => _tr('All'), "free" => _tr("No Assigned"), "busy" => _tr('Assigned')); $_POST["status"] = $status; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Status") . " = " . $arrStatus[$status], $_POST, array("status" => _tr("all")), true); $_POST["country"] = $country; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Country") . " = " . $country, $_POST, array("country" => "")); $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); //organization $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='search'>"); $arrFormElements = createFieldFilter($arrOrgz, $arrStatus); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $content = $oGrid->fetchGrid($arrGrid, $arrData); return $content; }
function reportQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $queue_name = getParameter("queue_name"); $pQueue = new paloQueuePBX($pDB, $domain); $queue_number = getParameter("queue_number"); if (isset($queue_number) && $queue_number != '') { $expression = $pQueue->getRegexPatternFromAsteriskPattern($queue_number); if ($expression === false) { $queue_number = ''; } } $url['menu'] = $module_name; $url['organization'] = $domain; $url['queue_number'] = $queue_number; //queue_number $url['queue_name'] = $queue_name; //queue_name $total = $pQueue->getTotalQueues($domain, $queue_number, $queue_name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pQueue->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Queues List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); if ($credentials['userlevel'] == 'superadmin') { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Queue Number"); $arrColumns[] = _tr("Queue Name"); $arrColumns[] = _tr("Password"); $arrColumns[] = _tr("Record Call"); $arrColumns[] = _tr("Strategy"); $arrColumns[] = _tr("Timeout Queue"); $arrColumns[] = _tr("Timeout Agent"); $oGrid->setColumns($arrColumns); $arrData = array(); $arrQueues = array(); if ($total != 0) { $arrQueues = $pQueue->getQueues($domain, $queue_number, $queue_name, $limit, $offset); } if ($arrQueues === false) { $error = _tr("Error getting queue data. ") . $pQueue->errMsg; } else { foreach ($arrQueues as $queue) { $arrTmp = array(); if ($credentials['userlevel'] == 'superadmin') { $arrTmp[] = $arrOrgz[$queue['organization_domain']]; } $queunumber = $queue["queue_number"]; $arrTmp[] = " <a href='?menu=queues&action=view&qname=" . $queue['name'] . "&organization={$queue['organization_domain']}'>" . $queunumber . "</a>"; $arrTmp[] = htmlentities($queue["description"], ENT_QUOTES, "UTF-8"); $arrTmp[] = $queue["password_detail"]; $arrTmp[] = isset($queue["monitor_format"]) ? "yes" : "no"; $arrTmp[] = $queue["strategy"]; $arrTmp[] = $queue["timeout_detail"] == "0" ? "unlimited" : $queue["timeout_detail"]; $arrTmp[] = $queue["timeout"]; /*$result=getInfoQueue(); $arrTmp[6]=$result["logged"]; $arrTmp[6]=$result["free"];*/ $arrData[] = $arrTmp; } } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("Create New Queue"), array_slice($arrOrgz, 1), $selected = null, "create_queue", $onchange_select = null); } else { $oGrid->addNew("create_queue", _tr("Create New Queue")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["queue_number"] = $queue_number; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Number") . " = " . $queue_number, $_POST, array("queue_number" => "")); $_POST["queue_name"] = $queue_name; // patter to filter estension number $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Name") . " = " . $queue_name, $_POST, array("queue_name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function delete_org_2($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $jsonObject = new PaloSantoJSON(); $idOrgs = getParameter("idOrgs"); //el susperadmin es el unico autorizado a borrar una organizacion if ($credentials['userlevel'] != "superadmin") { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("You are not authorized to perform this action")); return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $arrOrgs = array_diff(explode(",", $idOrgs), array("")); if (!is_array($arrOrgs) || count($arrOrgs) == 0) { $jsonObject->set_error(_tr("Err: Any valid organization has been selected")); return $jsonObject->createJSON(); } $pOrg = new paloSantoOrganization($pDB); if ($pOrg->deleteOrganization($arrOrgs)) { $jsonObject->set_message($pOrg->errMsg); } else { $jsonObject->set_error($pOrg->errMsg); } return $jsonObject->createJSON(); }
function reportANI($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $smarty->assign("SHOW_DIV_ERROR", "0"); //FIXED: can show div error message with javascript $smarty->assign("mb_message", "hide"); //FIXED: can show div error message with javascript $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $ani_prefix = getParameter("ani_prefix"); $pANI = new paloSantoANI($pDB, $domain); $url['menu'] = $module_name; $url['organization'] = $domain; $url['ani_prefix'] = $ani_prefix; $total = $pANI->getNumANI($domain, $ani_prefix); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pANI->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('ANI List')); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Trunk Name"); $arrColum[] = _tr("Prefix ANI"); $oGrid->setColumns($arrColum); $arrANI = array(); $arrData = array(); if ($total != 0) { $arrANI = $pANI->getANI($domain, $ani_prefix, $limit, $offset); } if ($arrANI === false) { $error = _tr("Error to obtain ANI") . $pANI->errMsg; $arrANI = array(); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); $smarty->assign("SHOW_DIV_ERROR", "1"); } foreach ($arrANI as $row) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$row["organization_domain"]]; } $arrTmp[] = $row["name"]; $arrTmp[] = "<input type='text' style='width:60px; text-align:center;' id='text#{$row['organization_domain']}#{$row['trunkid']}' value='{$row['ani_prefix']}' /> \n <input type='button' id='button#{$row['organization_domain']}#{$row['trunkid']}' value='" . _tr("Save") . "' />"; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) == 0) { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); $smarty->assign("SHOW_DIV_ERROR", "1"); } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["ani_prefix"] = $ani_prefix; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("ANI Prefix") . " = " . $ani_prefix, $_POST, array("ani_prefix" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); return $oGrid->fetchGrid(array(), $arrData); }
function reportIVR($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $name = getParameter("name"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $url['menu'] = $module_name; $url['organization'] = $domain; $url['name'] = $name; if ($credentials['userlevel'] == "superadmin") { if (isset($domain) && $domain != "all") { $pIVR = new paloIvrPBX($pDB, $domain); } else { $pIVR = new paloIvrPBX($pDB, ""); } $total = $pIVR->getTotalIvr($domain, $name); $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } else { $arrOrgz = array(); $pIVR = new paloIvrPBX($pDB, $domain); $total = $pIVR->getTotalIvr($domain, $name); } if ($total === false) { $error = $pIVR->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Ivrs List')); $oGrid->setUrl($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); if ($credentials['userlevel'] == "superadmin") { $arrColumns[] = _tr("Organization"); } $arrColumns[] = _tr("Ivr Name"); $arrColumns[] = _tr("Timeout"); $arrColumns[] = _tr("Enable Call Extensions"); $arrColumns[] = _tr("# Loops"); $oGrid->setColumns($arrColumns); $arrData = array(); $arrIVR = array(); if ($total != 0) { $arrIVR = $pIVR->getIvrs($domain, $name, $limit, $offset); } if ($arrIVR === false) { $error = _tr("Error getting ivr data.") . $pIVR->errMsg; } else { foreach ($arrIVR as $ivr) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$ivr['organization_domain']]; } $arrTmp[] = " <a href='?menu={$module_name}&action=view&id_ivr=" . $ivr['id'] . "&organization={$ivr["organization_domain"]}'>" . htmlentities($ivr["name"], ENT_QUOTES, "UTF-8") . "</a>"; $arrTmp[] = $ivr["timeout"]; $arrTmp[] = $ivr["directdial"]; $arrTmp[] = $ivr["loops"]; $arrData[] = $arrTmp; } } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("Create New IVR"), array_slice($arrOrgz, 1), $selected = null, "create_ivr", $onchange_select = null); } else { $oGrid->addNew("create_ivr", _tr("Create New IVR")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true); } $_POST["name"] = $name; //ivr name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function reportOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $error = ""; $pORGZ = new paloSantoOrganization($pDB); $domain = getParameter("organization"); $domain = empty($domain) ? 'all' : $domain; if ($credentials['userlevel'] != "superadmin") { $domain = $credentials['domain']; } $other_destination_name = getParameter("other_destination_name"); $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain); $url['menu'] = $module_name; $url['organization'] = $domain; $url['other_destination_name'] = $other_destination_name; $total = $pOtherDestinations->getNumOtherDestinations($domain, $other_destination_name); $arrOrgz = array(); if ($credentials['userlevel'] == "superadmin") { $arrOrgz = array("all" => _tr("all")); foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["domain"]] = $value["name"]; } } if ($total === false) { $error = $pOtherDestinations->errMsg; $total = 0; } $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('Other Destinations List')); //$oGrid->setIcon('url de la imagen'); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $oGrid->setURL($url); $arrColum = array(); if ($credentials['userlevel'] == "superadmin") { $arrColum[] = _tr("Organization"); } $arrColum[] = _tr("Other Destination Name"); $arrColum[] = _tr("Dial Destination"); $oGrid->setColumns($arrColum); $arrOtherDestinations = array(); $arrData = array(); if ($total != 0) { $arrOtherDestinations = $pOtherDestinations->getOtherDestinations($domain, $other_destination_name, $limit, $offset); } if ($arrOtherDestinations === false) { $error = _tr("Error to obtain Other Destinations") . $pOtherDestinations->errMsg; $arrOtherDestinations = array(); } foreach ($arrOtherDestinations as $row) { $arrTmp = array(); if ($credentials['userlevel'] == "superadmin") { $arrTmp[] = $arrOrgz[$row["organization_domain"]]; } $arrTmp[] = " <a href='?menu={$module_name}&action=view&id=" . $row['id'] . "&organization={$row['organization_domain']}'>" . htmlentities($row["description"], ENT_QUOTES, "UTF-8") . "</a>"; $arrTmp[] = $row["destdial"]; $arrData[] = $arrTmp; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>"); if ($pORGZ->getNumOrganization(array()) >= 1) { if (in_array('create', $arrPermission)) { if ($credentials['userlevel'] == 'superadmin') { $oGrid->addComboAction("organization_add", _tr("ADD Other Destination"), array_slice($arrOrgz, 1), $selected = null, "create_other_destination", $onchange_select = null); } else { $oGrid->addNew("create_other_destination", _tr("ADD Other Destination")); } } if ($credentials['userlevel'] == 'superadmin') { $_POST["organization"] = $domain; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true); } $_POST["other_destination_name"] = $other_destination_name; // name $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Other Destination Name") . " = " . $other_destination_name, $_POST, array("other_destination_name" => "")); $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module")); } if ($error != "") { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", $error); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }
function getGroups(&$pDB, $arrCredentiasls) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $jsonObject = new PaloSantoJSON(); $idOrgSel = getParameter("idOrganization"); $arrGrupos = array(); if ($idOrgSel == 0) { $arrGrupos = array(); } else { if ($arrCredentiasls['userlevel'] != 'superadmin') { if ($idOrgSel != $arrCredentiasls['id_organization']) { $jsonObject->set_error("Invalid Action"); $arrGrupos = array(); } } else { $arrGrupos[0] = array("country_code", $pORGZ->getOrganizationProp($idOrgSel, "country_code")); $arrGrupos[1] = array("area_code", $pORGZ->getOrganizationProp($idOrgSel, "area_code")); $arrGrupos[2] = array("email_quota", $pORGZ->getOrganizationProp($idOrgSel, "email_quota")); $temp = $pACL->getGroupsPaging(null, null, $idOrgSel); if ($temp === false) { $jsonObject->set_error(_tr($pACL->errMsg)); } else { $i = 3; foreach ($temp as $value) { $arrGrupos[$i] = array($value[0], $value[1]); $i++; } } } } $jsonObject->set_message($arrGrupos); return $jsonObject->createJSON(); }
function viewFormEmaillist($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pORGZ = new paloSantoOrganization($pDB); $pEmailList = new paloSantoEmailList($pDB); //no se puede editar una lista una vez que ha sido creada //la unica accion que existe es observar la configuracion de la lista $idList = getParameter("id"); $action = getParameter("action"); $arrDominios = array(); if ($action == 'view_list') { //comprabamos que la lista exista if (empty($idList)) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Invalid Email List")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if ($credentials['userlevel'] == 'superadmin') { $emailList = $pEmailList->getEmailList($idList); } else { $emailList = $pEmailList->getEmailList($idList, $credentials['domain']); } if ($emailList == false) { $smarty->assign("mb_title", _tr("Error")); $error = $emailList === false ? _tr("Couldn't be retrieved Email List data") : _tr("Email List does not exist"); $smarty->assign("mb_message", $error); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("DOMAIN", $emailList['organization_domain']); $smarty->assign("LIST_NAME", htmlentities($emailList['listname'], ENT_QUOTES, "UTF-8")); $smarty->assign("LIST_ADMIN_USER", $emailList['mailadmin']); } } } else { //queremos crear una nueva lista if ($credentials['userlevel'] == 'superadmin') { foreach ($pORGZ->getOrganization(array()) as $value) { $arrDominios[$value["domain"]] = $value["domain"]; } } //se comprueba que el mailman haya sido configurado por primera vez $MailmanListCreated = $pEmailList->isMailmanListCreated(); if (is_null($MailmanListCreated)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $pEmailList->getError()); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } elseif (!$MailmanListCreated) { $smarty->assign("StatusNew", 1); $smarty->assign("Mailman_Setting", _tr("Mailman Admin Settings")); if ($credentials['userlevel'] != 'superadmin') { //solo el superadmin puede hacer esta accion $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("A new List can be added because some configurations are missed. Please contact with Elastix Admisnistrator")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } } } $arrFormEmaillist = createFieldForm($arrDominios); $oForm = new paloForm($smarty, $arrFormEmaillist); if ($action == 'view_list') { $oForm->setViewMode(); } if (in_array('delete_list', $arrPermission)) { $smarty->assign("DELETE_LIST", true); } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("List_Setting", _tr("New List Settings")); $smarty->assign("icon", "web/apps/{$module_name}/images/email.png"); $smarty->assign("idList", $idList); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("New Email List"), $_POST); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function setConfigurationSendingFaxMailOrg($idOrg, $remite, $remitente, $subject, $content) { require_once "/usr/share/elastix/libs/paloSantoOrganization.class.php"; $bExito = false; $pORG = new paloSantoOrganization($this->_DB); $arrayProp = array("fax_remite" => $remite, "fax_remitente" => $remitente, "fax_subject" => $subject, "fax_content" => $content); $arrProp = array_diff($arrayProp, array('')); foreach ($arrayProp as $key => $value) { $bExito = $pORG->setOrganizationProp($idOrg, $key, $value, "fax"); if ($bExito === false) { break; } } return $bExito; }