exit; } else { $user = urlencode(substr($_POST['input_user'], 0, 20)); if (!$pACL->getIdUser($_POST['input_user'])) { // not exists user? writeLOG("audit.log", "LOGIN {$user}: Authentication Failure to Web Interface login. Invalid user {$user} from {$_SERVER['REMOTE_ADDR']}."); } else { writeLOG("audit.log", "LOGIN {$user}: Authentication Failure to Web Interface login. Failed password for {$user} from {$_SERVER['REMOTE_ADDR']}."); } // Debo hacer algo aquí? } } // 2) Autentico usuario if (isset($_SESSION['elastix_user']) && isset($_SESSION['elastix_pass']) && $pACL->authenticateUser($_SESSION['elastix_user'], $_SESSION['elastix_pass'])) { $idUser = $pACL->getIdUser($_SESSION['elastix_user']); $pMenu = new paloMenu($arrConf['elastix_dsn']['elastix']); //obtenemos los menu a los que el usuario tiene acceso $arrMenuFiltered = $pMenu->filterAuthorizedMenus($idUser, 'yes'); $id_organization = $pACL->getIdOrganizationUser($idUser); if ($id_organization == false) { die("Error to retrieve User Info. " . $pACL->errMsg); } $_SESSION['elastix_organization'] = $id_organization; if (!is_array($arrMenuFiltered)) { $arrMenuFiltered = array(); } //traducir el menu al idioma correspondiente foreach ($arrMenuFiltered as $idMenu => $arrMenuItem) { $arrMenuFiltered[$idMenu]['description'] = _tr($arrMenuItem['description']); } //variables de smarty usadas en los templates
function searchModulesByName() { include_once "libs/JSON.php"; include_once "modules/group_permission/libs/paloSantoGroupPermission.class.php"; $json = new Services_JSON(); $pGroupPermission = new paloSantoGroupPermission(); $name = getParameter("name_module_search"); $result = array(); $arrIdMenues = array(); $lang = get_language(); global $arrLang; // obteniendo los id de los menus permitidos global $arrConf; $pACL = new paloACL($arrConf['elastix_dsn']['acl']); $pMenu = new paloMenu($arrConf['elastix_dsn']['menu']); $arrSessionPermissions = $pMenu->filterAuthorizedMenus($pACL->getIdUser($_SESSION['elastix_user'])); $arrIdMenues = array(); foreach ($arrSessionPermissions as $key => $value) { $arrIdMenues[] = $value['id']; // id, IdParent, Link, Name, Type, order_no, HasChild } $parameter_to_find = array(); // arreglo con los valores del name dada la busqueda // el metodo de busqueda de por nombre sera buscando en el arreglo de lenguajes y obteniendo su $key para luego buscarlo en la base de // datos menu.db if ($lang != "en") { // entonces se adjunta la busqueda con el arreglo de lenguajes en ingles foreach ($arrLang as $key => $value) { $langValue = strtolower(trim($value)); $filter_value = strtolower(trim($name)); if ($filter_value != "") { if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) { if (strpos($langValue, $filter_value) !== FALSE) { $parameter_to_find[] = $key; } } } } } $parameter_to_find[] = $name; // buscando en la base de datos acl.db tabla acl_resource con el campo description if (empty($parameter_to_find)) { $arrResult = $pGroupPermission->ObtainResources(25, 0, $name); } else { $arrResult = $pGroupPermission->ObtainResources(25, 0, $parameter_to_find); } foreach ($arrResult as $key2 => $value2) { // leyendo el resultado del query if (in_array($value2["name"], $arrIdMenues)) { $arrMenu['caption'] = _tr($value2["description"]); $arrMenu['value'] = $value2["name"]; $result[] = $arrMenu; } } header('Content-Type: application/json'); return $json->encode($result); }
function mostrar_menu() { global $arrLangModule; global $arrConf; $jsonObject = new PaloSantoJSON(); $respuesta = array(); $level = getParameter("level"); $parent_1_existing = getParameter("parent_1_existing"); $parent_2_existing = getParameter("parent_2_existing"); $id_parent = getParameter("id_parent"); //Nivel 2 if ($level == 0) { //Padre nivel 1 SI existe if ($parent_1_existing == 0) { $pDB_menu = new paloDB($arrConf['elastix_dsn']['menu']); if (!empty($pDB_menu->errMsg)) { $jsonObject->set_error("ERROR DE DB: {$pDB_menu->errMsg}"); return $jsonObject->createJSON(); } $pMenu = new paloMenu($pDB_menu); $arrMenuOptions = $pMenu->getRootMenus(); $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left'>"; $parent_Menu .= "<select name='parent_module' id='parent_module'>"; foreach ($arrMenuOptions as $key => $valor) { $parent_Menu .= "<option value='{$key}'>{$valor}</option>"; } $parent_Menu .= "</select>"; $parent_Menu .= "</td>"; } else { $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left' width='21%'><input type='text' name='parent_1_name' id='parent_1_name' value='' onkeyup='generateId(this,\"parent_1_id\")'></td>"; $parent_Menu .= "<td align='left' width='11%'><b>{$arrLangModule["Level 1 Parent Id"]}: </b></td>"; $parent_Menu .= "<td align='left'><i id='parent_1_id'></i></td>"; } $respuesta["parent_menu_1"] = $parent_Menu; $respuesta["level2_exist"] = ""; $respuesta["parent_menu_2"] = ""; $respuesta["label_level2"] = ""; } else { //Padre nivel 1 SI existe if ($parent_1_existing == 0) { //Padre nivel 2 SI existe if ($parent_2_existing == 0) { require_once 'libs/paloSantoNavigation.class.php'; $pMenu = new paloMenu($arrConf['elastix_dsn']['menu']); $arrMenu = $pMenu->cargar_menu(); $smarty = NULL; $pNav = new paloSantoNavigation($arrMenu, $smarty); $arrMenuOptions = $pNav->getArrSubMenu($id_parent); if (is_array($arrMenuOptions)) { $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td>"; $parent_Menu2 .= "<select name='parent_module_2' id='parent_module_2'>"; foreach ($arrMenuOptions as $key => $valor) { $parent_Menu2 .= "<option value='{$key}'>{$valor['Name']}</option>"; } $parent_Menu2 .= "</select>"; $parent_Menu2 .= "</td>"; $parent_Menu2 .= "<td></td><td></td><td></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; } } else { if ($parent_2_existing == 1) { $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td align='left' width='21%'><input type='text' name='parent_2_name' id='parent_2_name' value='' onkeyup='generateId(this,\"parent_2_id\")'></td>"; $parent_Menu2 .= "<td align='left' width='11%'><b>{$arrLangModule["Level 2 Parent Id"]}: </b></td>"; $parent_Menu2 .= "<td align='left'><i id='parent_2_id'></i></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; } else { $pDB_menu = new paloDB($arrConf['elastix_dsn']['menu']); if (!empty($pDB_menu->errMsg)) { $jsonObject->set_error("ERROR DE DB: {$pDB_menu->errMsg}"); return $jsonObject->createJSON(); } $pMenu = new paloMenu($pDB_menu); $arrMenuOptions = $pMenu->getRootMenus(); $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left'>"; $parent_Menu .= "<select name='parent_module' id='parent_module' onchange='mostrar_menu()'>"; foreach ($arrMenuOptions as $key => $valor) { $parent_Menu .= "<option value='{$key}'>{$valor}</option>"; } $parent_Menu .= "</select>"; $parent_Menu .= "</td>"; $parent_Menu .= "<td></td><td></td><td></td>"; $respuesta["parent_menu_1"] = $parent_Menu; //$respuesta->addAssign("parent_menu_1","innerHTML", ""); $parent_exist = "<b>{$arrLangModule["Level 2 Parent Exists"]}: <span class='required'>*</span></b>"; $respuesta["label_level2"] = $parent_exist; $parent_option = "<select id='parent_2_existing_option' name='parent_2_existing_option' onchange='mostrar_menu()'>"; $parent_option .= "<option value='{$arrLangModule["Yes"]}'>{$arrLangModule["Yes"]}</option>"; $parent_option .= "<option value='{$arrLangModule["No"]}' selected='selected'>{$arrLangModule["No"]}</option>"; $parent_option .= "</select>"; $respuesta["level2_exist"] = $parent_option; $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td align='left' width='22%'><input type='text' name='parent_2_name' id='parent_2_name' value='' onkeyup='generateId(this,\"parent_2_id\")'></td>"; $parent_Menu2 .= "<td align='left' width='11%'><b>{$arrLangModule["Level 2 Parent Id"]}: </b></td>"; $parent_Menu2 .= "<td align='left'><i id='parent_2_id'></i></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; } } } else { $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left' width='22%'><input type='text' name='parent_1_name' id='parent_1_name' value='' onkeyup='generateId(this,\"parent_1_id\")'></td>"; $parent_Menu .= "<td align='left' width='11%'><b>{$arrLangModule["Level 1 Parent Id"]}: </b></td>"; $parent_Menu .= "<td align='left'><i id='parent_1_id'></i></td>"; $respuesta["parent_menu_1"] = $parent_Menu; $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td align='left' width='22%'><input type='text' name='parent_2_name' id='parent_2_name' value='' onkeyup='generateId(this,\"parent_2_id\")'></td>"; $parent_Menu2 .= "<td align='left' width='11%'><b>{$arrLangModule["Level 2 Parent Id"]}: </b></td>"; $parent_Menu2 .= "<td align='left'><i id='parent_2_id'></i></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; $respuesta["level2_exist"] = ""; $respuesta["label_level2"] = ""; } } $jsonObject->set_message($respuesta); return $jsonObject->createJSON(); }
| The Initial Developer of the Original Code is PaloSanto Solutions | +----------------------------------------------------------------------+ $Id: frameLeft.php,v 1.2 2007/09/07 23:05:29 gcarrillo Exp $ */ include_once "../libs/paloSantoTree.class.php"; include_once "../libs/paloSantoDB.class.php"; include_once "../libs/paloSantoACL.class.php"; include_once "../libs/misc.lib.php"; include_once "../configs/default.conf.php"; include_once "../libs/paloSantoMenu.class.php"; load_default_timezone(); session_name("elastixSession"); session_start(); global $arrConf; $pDB = new paloDB($arrConf['elastix_dsn']['acl']); $pDBMenu = new paloDB($arrConf['elastix_dsn']['elastix']); $pMenu = new paloMenu($pDBMenu); $arrMenu = $pMenu->cargar_menu(); if (!empty($pDB->errMsg)) { echo "ERROR DE DB: {$pDB->errMsg} <br>"; } $pACL = new paloACL($pDB); $arrTmp = array(); if (!empty($_SESSION['elastix_user'])) { $idUser = $pACL->getIdUser($_SESSION['elastix_user']); //- TODO: Mejorar el siguiente bloque. Seguro debe de haber una forma mas //- eficiente de hacerlo //- Primero me barro todos los submenus foreach ($arrMenu as $idMenu => $arrMenuItem) { if (!empty($arrMenuItem['IdParent'])) { if ($pACL->isUserAuthorizedById($idUser, "access", $idMenu)) { $arrSubmenu[$idMenu] = $arrMenuItem;
function searchModulesByName() { global $arrConf; include_once "libs/paloSantoACL.class.php"; include_once "libs/JSON.php"; include_once "apps/group_permission/libs/paloSantoGroupPermission.class.php"; $json = new Services_JSON(); $pGroupPermission = new paloSantoGroupPermission(); $name = getParameter("name_module_search"); $result = array(); $arrIdMenues = array(); $lang = get_language(); global $arrLang; // obteniendo los id de los menus permitidos $pACL = new paloACL($arrConf['elastix_dsn']['elastix']); $pMenu = new paloMenu($arrConf['elastix_dsn']['elastix']); //antes de obtener el listado de los modulos debemos determinar //si la interfaz desde la cual se esta llamando a los metodos es administrativa o //es de usuario final. $tmpPath = explode("/", $arrConf['basePath']); if ($tmpPath[count($tmpPath) - 1] == 'admin') { $administrative = "yes"; } else { $administrative = "no"; } $org_access = null; if (!$pACL->isUserSuperAdmin($_SESSION['elastix_user'])) { $org_access = 'yes'; } $arrSessionPermissions = $pMenu->filterAuthorizedMenus($pACL->getIdUser($_SESSION['elastix_user']), $administrative); if (!is_array($arrSessionPermissions)) { $arrSessionPermissions = array(); } $arrIdMenues = array(); foreach ($arrSessionPermissions as $key => $value) { $arrIdMenues[] = $value['id']; // id, IdParent, Link, Type, order_no, HasChild } $parameter_to_find = array(); // arreglo con los valores del name dada la busqueda // el metodo de busqueda de por nombre sera buscando en el arreglo de lenguajes y obteniendo su $key para luego buscarlo en la base de // datos menu.db if ($lang != "en") { // entonces se adjunta la busqueda con el arreglo de lenguajes en ingles foreach ($arrLang as $key => $value) { $langValue = strtolower(trim($value)); $filter_value = strtolower(trim($name)); if ($filter_value != "") { if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) { if (strpos($langValue, $filter_value) !== FALSE) { $parameter_to_find[] = $key; } } } } } $parameter_to_find[] = $name; // buscando en la base de datos acl.db tabla acl_resource con el campo description if (empty($parameter_to_find)) { $arrResult = $pACL->getListResources(25, 0, $name, $org_access, $administrative); } else { $arrResult = $pACL->getListResources(25, 0, $parameter_to_find, $org_access, $administrative); } foreach ($arrResult as $key2 => $value2) { // leyendo el resultado del query if (in_array($value2["id"], $arrIdMenues)) { $arrMenu['caption'] = _tr($value2["description"]); $arrMenu['value'] = $value2["id"]; $result[] = $arrMenu; } } header('Content-Type: application/json'); return $json->encode($result); }
function mostrar_menu($level, $id_module_level_1, $id_module_level_2, $id_module_level_3) { require_once 'libs/paloSantoMenu.class.php'; global $arrLangModule; global $arrConf; $respuesta = new xajaxResponse(); //Nivel 1 if ($level == 1) { $respuesta->addAssign("level_2", "innerHTML", ""); $respuesta->addAssign("level_3", "innerHTML", ""); } //Nivel 2 if ($level == 2 || $level == 3) { require_once 'libs/paloSantoNavigation.class.php'; $pMenu = new paloMenu($arrConf['elastix_dsn']['menu']); $arrMenu = $pMenu->cargar_menu(); $smarty = NULL; $pNav = new paloSantoNavigation($arrMenu, $smarty); $arrMenuLevel_2 = $pNav->getArrSubMenu($id_module_level_1); $level_2 = "<td align='left'><b>{$arrLangModule["Level 2"]}:</b></td>"; $level_2 .= "<td>"; $level_2 .= "<select onchange='mostrar_menu()' name='module_level_2' id='module_level_2'>"; $tmp_level_2 = ""; $tmp_id_module_level_2 = ""; $i = 0; foreach ($arrMenuLevel_2 as $key => $valor) { if ($i == 0) { $tmp_id_module_level_2 = $key; } if ($key == $id_module_level_2) { $tmp_level_2 = $key; $level_2 .= "<option value='{$key}' selected>{$valor['Name']}</option>"; } else { $level_2 .= "<option value='{$key}'>{$valor['Name']}</option>"; } $i++; } if ($tmp_level_2 == "") { $id_module_level_2 = $tmp_id_module_level_2; } $level_2 .= "</select>"; $level_2 .= "</td>"; $respuesta->addAssign("level_2", "innerHTML", $level_2); $respuesta->addAssign("level_3", "innerHTML", ""); } //Nivel 3 if ($level == 3) { $level_3 = "<td align='left'><b>{$arrLangModule["Level 3"]}:</b></td>"; require_once 'libs/paloSantoNavigation.class.php'; $pMenu = new paloMenu($arrConf['elastix_dsn']['menu']); $arrMenu = $pMenu->cargar_menu(); $smarty = NULL; $pNav = new paloSantoNavigation($arrMenu, $smarty); $arrMenuLevel_3 = $pNav->getArrSubMenu($id_module_level_2); if ($arrMenuLevel_3 && count($arrMenuLevel_3) > 0) { $level_3 = "<td align='left'><b>{$arrLangModule["Level 3"]}:</b></td>"; $level_3 .= "<td>"; $level_3 .= "<select onchange='mostrar_menu()' name='module_level_3' id='module_level_3'>"; foreach ($arrMenuLevel_3 as $key2 => $valor2) { if ($key2 == $id_module_level_3) { $level_3 .= "<option value='{$key2}' selected>{$valor2['Name']}</option>"; } else { $level_3 .= "<option value='{$key2}'>{$valor2['Name']}</option>"; } } $level_3 .= "</select>"; } else { $level_3 .= "<td align='left'>" . $arrLangModule["This module don't have level 3"] . "</td>"; } $level_3 .= "</td>"; $respuesta->addAssign("level_3", "innerHTML", $level_3); } return $respuesta; }