From 3117e6f20527996ccab936814bf81c66243b0776 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 3 Dec 2012 10:05:20 +0000 Subject: [PATCH] 2012-12-03 Ramon Novoa * include/functions_agents.php, include/functions_treeview.php: Improved error detection and small fixes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7216 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++ pandora_console/include/functions_agents.php | 2 + .../include/functions_treeview.php | 41 +++++++++++-------- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7d9bd5a599..f9c57c0cce 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2012-12-03 Ramon Novoa + + * include/functions_agents.php, + include/functions_treeview.php: Improved error detection and small fixes. + 2012-12-03 Hirofumi Kosaka * include/functions_html.php: Use "autocomplete=off" in all diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2c36666cae..19cf3c12e7 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -401,6 +401,8 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o elseif (! is_array ($filter['id_grupo'])) { $all_groups = false; //If group is specified but not allowed, return false +echo "GROUP: " . $filter['id_grupo'] . ":"; +print_r ($groups); if (! in_array ($filter['id_grupo'], $groups)) { return false; } diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 6e160f6a0e..eb87dbddeb 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -261,8 +261,12 @@ function treeview_printTree($type) { echo "
  • "; // Convert the id to hexadecimal, since it will be used as a div id - $hex_id = unpack ('H*', $item['_id_']); - $hex_id = $hex_id[1]; + if (defined ('METACONSOLE')) { + $id = unpack ('H*', $item['_id_']); + $id = $hex_id[1]; + } else { + $id = $item['_id_']; + } echo ""; echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('. @@ -769,14 +773,6 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel //Extract all rows of data for each type switch ($type) { case 'group': - - if (defined ('METACONSOLE')) { - $id = groups_get_id (pack ('H*', $id)); - if ($id == '') { - return false; - } - } - $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'id_grupo' => $id, @@ -787,6 +783,14 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel 'AR', false, true); + + if (defined ('METACONSOLE')) { + $id = groups_get_id (pack ('H*', $id)); + if ($id == '') { + return false; + } + } + break; case 'os': @@ -884,19 +888,24 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel ', $name); break; case 'tag': - $id = tags_get_id (pack ('H*', $id)); - if ($id === false) { - return false; - } - $sql = "SELECT tagente.* FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = " . $id; + + $id = tags_get_id (pack ('H*', $id)); + if ($id === false) { + return false; + } + break; } - + + if ($sql === false || $sql == '') { + return false; + } + $sql .= ' AND tagente.disabled = 0'. $search_sql; return $sql; }