+----------------------------------------------------------------------+ $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; $arrMenuFiltered[$idMenu] = $arrMenuItem;
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(); }
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; }