Fixed an error that occurred under certain circunstances when retrieving the group data

This commit is contained in:
Alejandro Gallardo Escobar 2015-08-05 13:38:58 +02:00
parent cd6d142cf4
commit e8ce41e77c

View File

@ -2346,7 +2346,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
* Agent cache for metaconsole. * Agent cache for metaconsole.
* Retrieve the statistic data from the cache table. * Retrieve the statistic data from the cache table.
*/ */
if (!$user_strict && defined('METACONSOLE') && !empty($list_groups)) { if (!$user_strict && is_metaconsole() && !empty($list_groups)) {
$cache_table = 'tmetaconsole_agent'; $cache_table = 'tmetaconsole_agent';
$sql_stats = "SELECT id_grupo, COUNT(id_agente) AS agents_total, $sql_stats = "SELECT id_grupo, COUNT(id_agente) AS agents_total,
@ -2476,7 +2476,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
foreach ($list_groups as $key => $item) { foreach ($list_groups as $key => $item) {
$id = $item['id_grupo']; $id = $item['id_grupo'];
if (!$user_strict && defined('METACONSOLE')) { // Agent cache if (!$user_strict && is_metaconsole()) { // Agent cache
$group_stat = array(); $group_stat = array();
if (isset($stats_by_group[$id])) if (isset($stats_by_group[$id]))
$group_stat = $stats_by_group[$id]; $group_stat = $stats_by_group[$id];
@ -2924,21 +2924,9 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
if (! is_metaconsole()) { // If using metaconsole, the strict users will use the agent table of every node
$result_list = group_get_data ($id_user, $user_strict, $acltags, if (is_metaconsole() && $user_strict) {
$returnAllGroup, $mode); $servers = metaconsole_get_servers();
return $result_list;
}
else {
$servers = db_get_all_rows_sql ("
SELECT *
FROM tmetaconsole_setup
WHERE disabled = 0");
if ($servers === false) {
$servers = array();
}
$result_list = array (); $result_list = array ();
foreach ($servers as $server) { foreach ($servers as $server) {
@ -2987,6 +2975,13 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
} }
return $result_list;
}
// If using metaconsole, the not strict users will use the metaconsole's agent cache table
else {
$result_list = group_get_data ($id_user, $user_strict, $acltags,
$returnAllGroup, $mode);
return $result_list; return $result_list;
} }
} }