a, A:link, a:visited, a:active {color: #0000aa; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px} A:hover {color: #ff0000; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px} "; $jsPage[] = "scriptApl/tree.js"; $jsPage[] = "scriptApl/tree_tpl_func.js"; $grupos = GetGrupo($dbcon, $codGp, 1); $funcs = GetFunc($dbcon, $codGp, 1); $smarty->assign("grupos", $grupos); $smarty->assign("funcs", $funcs); $smarty->assign("lstGrupo", $codGp); $smarty->assign("nameGrupo", $nomeGp); GetTemplate($smarty, 'seguranca/perfilGrupos.tpl'); function GetGrupoDef($dbcon, &$codGp, &$nomeGp, $idUser) { $flagSystem = (IsAdmin() && IsLocalServer()) ? '1=1' : " gp_system = '0' "; $query = "select gp_id, gp_nome from pbx_grupo g where $flagSystem and gp_status = 1 {REST} order by gp_nome limit 1"; //restricao se o usuario nao for admin $query = strtoupper(GetLogin()) == "ADMIN" ? str_replace("{REST}", "", $query) : str_replace("{REST}", " and exists(select '' from pbx_grupo_usuario where gp_id = g.gp_id and user_id = $idUser)", $query); $result = pg_query($dbcon, $query); $row = pg_fetch_array($result); $codGp = $row["gp_id"]; $nomeGp = $row["gp_nome"]; } function GetGrupo($dbcon, $codGp, $size = 1) { $flagSystem = (IsAdmin() && IsLocalServer()) ? '1=1' : " gp_system = '0' "; $idUser = GetIdUser(); //$query = "select gp_id, gp_nome from pbx_grupo g where $flagSystem and gp_status = 1 {REST} order by 2"; $query = "select gp_id, case when(gp_system = 1)then (gp_nome || '#') else case when(user_id = 0)then gp_nome else (gp_nome || '**') end end gp_nome, case when(user_id = 0)then 0 else 1 end as ord from pbx_grupo g where $flagSystem and gp_status = 1 {REST} order by 3,2"; //restricao se o usuario nao for admin $query = strtoupper(GetLogin()) == "ADMIN" ? str_replace("{REST}", "", $query) : str_replace("{REST}", " and exists(select '' from pbx_grupo_usuario where gp_id = g.gp_id and user_id = $idUser)", $query); $result = @pg_query($dbcon, $query); $sel = ""; $cont = 0; $lista = "" : "\n\n"; return $lista; } function GetFunc($dbcon, $idGrupo, $notMenu = 0) { //$dadosMenu = Menu($dbcon, QueryPerfilHead($idGrupo), QueryPerfilItens($idGrupo)); $_SESSION["SStreRoot"] = GetLogin(); $_SESSION["SStreView"] = 1; $_SESSION["SSperfilAcao"] = "add"; $idUser = GetIdUser(); //$dadosMenu = Menu($dbcon, QueryMenuHead($idUser), QueryMenuItens($idUser, true)); $dadosMenu = MontaMenu(0, $idUser, 2, $notMenu, "add"); $dadosMenu = str_replace("MENU_ITEMS", "TREE_ITEMS", $dadosMenu); $GLOBALS["jsBlok"][] = $dadosMenu; /* $menu = "
\n"; $menu .= "\n"; $menu .= "
\n"; */ $menu = "
\n"; $menu .= "\n"; $menu .= "
\n"; return $menu; } function GetGrupoFunc($dbcon, $idGrupo) { return $lista; } function QueryPerfilHead($idGrupo) { $idUser = GetIdUser(); $query = "select b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai from pbx_funcoes b where coalesce(b.fun_id_pai, 0) = 0 "; // and b.fun_id not in(select b.fun_id from pbx_grupo_funcoes a, pbx_funcoes b where b.fun_id = a.fun_id and a.gp_id = '$idGrupo') "; if (!IsAdmin()) $query .= " and b.fun_id in(select gf.fun_id from pbx_grupo_funcoes gf, pbx_grupo_usuario gu where gf.gp_id = gu.gp_id and gu.user_id = '$idUser' order by 1) "; $query .= "Union select b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai from pbx_funcoes b where coalesce(b.fun_id_pai, 0) = 0 and fun_public = 1"; $query .= " order by 1 "; return $query; } function QueryPerfilItens($idGrupo) { $idUser = GetIdUser(); $query = "select b.fun_id, b.fun_nome, b.fun_menu, b.fun_menu_text, b.fun_menu_url, b.fun_menu_img, b.fun_id_pai from pbx_funcoes b where coalesce(b.fun_id_pai, 0) > 0 "; // and b.fun_id not in(select b.fun_id from pbx_grupo_funcoes a, pbx_funcoes b where b.fun_id = a.fun_id and a.gp_id = '$idGrupo') "; if (!IsAdmin()) $query .= " and b.fun_id in(select gf.fun_id from pbx_grupo_funcoes gf, pbx_grupo_usuario gu where gf.gp_id = gu.gp_id and gu.user_id = '$idUser' order by 1) "; $query .= " order by b.fun_id "; return $query; } ?>