[Secondary groups] Fixed agent/modules view
This commit is contained in:
parent
b597c936e8
commit
399c9c2d58
|
@ -128,43 +128,20 @@ function mainModuleGroups() {
|
|||
require_once($config['homedir'] . "/include/functions_users.php");
|
||||
|
||||
//The big query
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado
|
||||
FROM tagente_estado
|
||||
WHERE id_agente IN
|
||||
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE)
|
||||
AND id_agente_modulo IN
|
||||
(SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE)
|
||||
GROUP BY estado";
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = "SELECT COUNT(id_agente) AS count,
|
||||
case utimestamp when 0 then 5 else estado end as estado
|
||||
FROM tagente_estado
|
||||
WHERE id_agente IN
|
||||
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0)
|
||||
AND id_agente_modulo IN
|
||||
(SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_module_group = %d AND disabled = 0 AND delete_pending = 0)
|
||||
GROUP BY estado, utimestamp";
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = "SELECT COUNT(id_agente) AS count, (case when utimestamp = 0 then 5 else estado end) AS estado
|
||||
FROM tagente_estado
|
||||
WHERE id_agente IN
|
||||
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND (disabled IS NOT NULL AND disabled <> 0))
|
||||
AND id_agente_modulo IN
|
||||
(SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_module_group = %d AND (disabled IS NOT NULL AND disabled <> 0) AND (delete_pending IS NOT NULL AND delete_pending <> 0))
|
||||
GROUP BY (case when utimestamp = 0 then 5 else estado end)";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado
|
||||
FROM tagente_estado
|
||||
WHERE id_agente IN
|
||||
(SELECT id_agente
|
||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE (ta.id_grupo = %d OR tasg.id_group = %d) AND disabled IS FALSE
|
||||
)
|
||||
AND id_agente_modulo IN
|
||||
(SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE)
|
||||
GROUP BY estado";
|
||||
|
||||
ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, '');
|
||||
|
||||
ui_print_info_message ( array('no_close'=>true, 'message'=>
|
||||
|
@ -207,7 +184,7 @@ function mainModuleGroups() {
|
|||
|
||||
foreach ($modelGroups as $idModelGroup => $modelGroup) {
|
||||
$fired = false;
|
||||
$query = sprintf($sql, $idAgentGroup, $idModelGroup);
|
||||
$query = sprintf($sql, $idAgentGroup, $idAgentGroup, $idModelGroup);
|
||||
|
||||
$rowsDB = db_get_all_rows_sql ($query);
|
||||
|
||||
|
|
|
@ -258,10 +258,7 @@ if(!$new_agent){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$groups = users_get_groups ($config["id_user"], "AR",false);
|
||||
$agents = agents_get_group_agents (array_keys ($groups));
|
||||
|
||||
|
||||
$modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
|
||||
WHERE id_agente = " . $id_parent);
|
||||
|
|
|
@ -842,11 +842,18 @@ function agents_get_group_agents (
|
|||
users_get_groups(false, "AR", true, false, (array)$id_group));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Search for primary and secondary groups
|
||||
if (!empty($id_group)) {
|
||||
$filter['id_grupo'] = $id_group;
|
||||
$filter[] = '(' . db_format_array_where_clause_sql(
|
||||
array(
|
||||
'id_group' => $id_group,
|
||||
'id_grupo' => $id_group
|
||||
),
|
||||
'OR'
|
||||
) . ')';
|
||||
}
|
||||
|
||||
|
||||
if ($search === true) {
|
||||
//No added search. Show both disabled and non-disabled
|
||||
}
|
||||
|
@ -959,8 +966,8 @@ function agents_get_group_agents (
|
|||
$filter['order'] = 'alias';
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$table_name = 'tmetaconsole_agent';
|
||||
|
||||
$table_name = 'tmetaconsole_agent LEFT JOIN tmetaconsole_agent_secondary_group ON ta.id_agente = tasg.id_agent';
|
||||
|
||||
$fields = array(
|
||||
'id_tagente AS id_agente',
|
||||
'alias',
|
||||
|
@ -968,16 +975,16 @@ function agents_get_group_agents (
|
|||
);
|
||||
}
|
||||
else {
|
||||
$table_name = 'tagente';
|
||||
|
||||
$table_name = 'tagente LEFT JOIN tagent_secondary_group ON id_agente=id_agent';
|
||||
|
||||
$fields = array(
|
||||
'id_agente',
|
||||
'alias'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$result = db_get_all_rows_filter($table_name, $filter, $fields);
|
||||
|
||||
|
||||
if ($result === false)
|
||||
return array (); //Return an empty array
|
||||
|
||||
|
@ -985,7 +992,6 @@ function agents_get_group_agents (
|
|||
foreach ($result as $row) {
|
||||
if (!isset($row["id_agente"]) || !isset($row["alias"]))
|
||||
continue;
|
||||
|
||||
if ($serialized && isset($row["id_server"])) {
|
||||
$key = $row["id_server"] . $separator . $row["id_agente"];
|
||||
} elseif ($force_serialized) {
|
||||
|
|
Loading…
Reference in New Issue