Added check of tags in report wizard
This commit is contained in:
parent
b4f3ce251b
commit
62ad6b9a35
|
@ -851,10 +851,15 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret
|
||||||
$filter = '1 = 1';
|
$filter = '1 = 1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$secondary_join = '';
|
||||||
|
if (!users_can_manage_group_all("ER")) {
|
||||||
|
$secondary_join = "LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent";
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf ("SELECT DISTINCT tevento.*
|
$sql = sprintf ("SELECT DISTINCT tevento.*
|
||||||
FROM tevento LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent
|
FROM tevento %s
|
||||||
WHERE %s %s
|
WHERE %s %s
|
||||||
ORDER BY utimestamp DESC LIMIT %d", $agent_condition, $filter, $limit);
|
ORDER BY utimestamp DESC LIMIT %d", $secondary_join, $agent_condition, $filter, $limit);
|
||||||
|
|
||||||
$result = db_get_all_rows_sql ($sql);
|
$result = db_get_all_rows_sql ($sql);
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,35 @@ function reporting_make_reporting_data($report = null, $id_report,
|
||||||
$metaconsole_on = is_metaconsole();
|
$metaconsole_on = is_metaconsole();
|
||||||
$index_content = 0;
|
$index_content = 0;
|
||||||
foreach ($contents as $content) {
|
foreach ($contents as $content) {
|
||||||
|
|
||||||
|
if (!empty($content["id_agent_module"]) && !empty($content["id_agent"])
|
||||||
|
&& tags_has_user_acl_tags($config['id_user'])) {
|
||||||
|
$where_tags = tags_get_acl_tags(
|
||||||
|
$config['id_user'],
|
||||||
|
$id_groups,
|
||||||
|
'AR',
|
||||||
|
'module_condition',
|
||||||
|
'AND',
|
||||||
|
'tagente_modulo',
|
||||||
|
false,
|
||||||
|
array(),
|
||||||
|
true);
|
||||||
|
|
||||||
|
$sql_tags_join = "INNER JOIN tagente ON tagente.id_agente = t1.id_agente
|
||||||
|
INNER JOIN ttag_module ON ttag_module.id_agente_modulo = t1.id_agente_modulo";
|
||||||
|
|
||||||
|
$sql = sprintf('SELECT count(*) FROM tagente_modulo t1
|
||||||
|
%s WHERE t1.delete_pending = 0 AND t1.id_agente_modulo = '. $content["id_agent_module"] .'
|
||||||
|
AND t1.id_agente = ' . $content['id_agent'] . ' %s',
|
||||||
|
$sql_tags_join, $where_tags);
|
||||||
|
|
||||||
|
$result_tags = db_get_value_sql($sql);
|
||||||
|
|
||||||
|
if (!$result_tags) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$server_name = $content['server_name'];
|
$server_name = $content['server_name'];
|
||||||
|
|
||||||
// General reports with 0 period means last value
|
// General reports with 0 period means last value
|
||||||
|
|
|
@ -336,6 +336,16 @@ if (is_ajax ()) {
|
||||||
$filter .= ' AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions;
|
$filter .= ' AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql_tags_join = "";
|
||||||
|
$where_tags = "";
|
||||||
|
if (tags_has_user_acl_tags($config['id_user'])) {
|
||||||
|
$where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR',
|
||||||
|
'module_condition', 'AND', 'tagente_modulo', false, array(), true);
|
||||||
|
|
||||||
|
$sql_tags_join = "INNER JOIN tagente ON tagente.id_agente = t1.id_agente
|
||||||
|
INNER JOIN ttag_module ON ttag_module.id_agente_modulo = t1.id_agente_modulo";
|
||||||
|
}
|
||||||
|
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$nameModules = array();
|
$nameModules = array();
|
||||||
|
@ -396,9 +406,10 @@ if (is_ajax ()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get agent's modules
|
//Get agent's modules
|
||||||
$sql = sprintf('SELECT t1.id_agente, t1.id_agente_modulo, t1.nombre
|
$sql = sprintf(
|
||||||
FROM tagente_modulo t1
|
'SELECT t1.id_agente, t1.id_agente_modulo, t1.nombre
|
||||||
WHERE %s
|
FROM tagente_modulo t1 %s
|
||||||
|
WHERE %s %s
|
||||||
AND t1.delete_pending = 0
|
AND t1.delete_pending = 0
|
||||||
AND t1.id_agente IN (%s)
|
AND t1.id_agente IN (%s)
|
||||||
AND (
|
AND (
|
||||||
|
@ -407,7 +418,7 @@ if (is_ajax ()) {
|
||||||
WHERE t2.delete_pending = 0
|
WHERE t2.delete_pending = 0
|
||||||
AND t1.nombre = t2.nombre
|
AND t1.nombre = t2.nombre
|
||||||
AND t2.id_agente IN (%s)) = (%d)',
|
AND t2.id_agente IN (%s)) = (%d)',
|
||||||
$filter, implode(',', $id_agents),
|
$sql_tags_join, $filter, $where_tags, implode(',', $id_agents),
|
||||||
implode(',', $id_agents), count($id_agents));
|
implode(',', $id_agents), count($id_agents));
|
||||||
|
|
||||||
$modules = db_get_all_rows_sql($sql);
|
$modules = db_get_all_rows_sql($sql);
|
||||||
|
@ -458,34 +469,27 @@ if (is_ajax ()) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if($idAgents[0] < 0){
|
if($idAgents[0] < 0){
|
||||||
if($selection_mode == 'common'){
|
if($selection_mode == 'common') {
|
||||||
$sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0';
|
$sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0';
|
||||||
$agent_total = db_get_value_sql($sql_agent_total);
|
$agent_total = db_get_value_sql($sql_agent_total);
|
||||||
$sql = "SELECT tam.nombre, tam.id_agente_modulo
|
$sql = sprintf ("SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1
|
||||||
FROM tagente_modulo tam
|
JOIN (SELECT COUNT(*) AS num_names, nombre FROM tagente_modulo
|
||||||
JOIN (
|
WHERE disabled=0 AND delete_pending=0 GROUP BY nombre) AS tj
|
||||||
SELECT COUNT(*) AS num_names, nombre
|
ON tj.num_names = $agent_total AND tj.nombre = t1.nombre %s %s",
|
||||||
FROM tagente_modulo
|
$sql_tags_join, (empty($where_tags)) ? "" : " WHERE 1=1 $where_tags");
|
||||||
WHERE disabled=0
|
} else {
|
||||||
AND delete_pending=0
|
$sql = sprintf('SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 %s %s',
|
||||||
GROUP BY nombre
|
$sql_tags_join, (empty($where_tags)) ? "" : " WHERE 1=1 $where_tags");
|
||||||
) AS tj
|
|
||||||
ON tj.num_names = $agent_total
|
|
||||||
AND tj.nombre = tam.nombre ";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$sql = 'SELECT nombre, id_agente_modulo
|
|
||||||
FROM tagente_modulo';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = 'SELECT DISTINCT nombre, t1.id_agente_modulo
|
$sql = sprintf (
|
||||||
FROM tagente_modulo t1, tagente_estado t2
|
'SELECT DISTINCT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1
|
||||||
WHERE t1.id_agente_modulo = t2.id_agente_modulo AND
|
INNER JOIN tagente_estado t2 ON t1.id_agente_modulo = t2.id_agente_modulo
|
||||||
' . $filter . '
|
%s WHERE %s AND t1.delete_pending = 0
|
||||||
AND t1.delete_pending = 0
|
AND t1.id_agente IN ('. implode(',', $idAgents) .')
|
||||||
AND t1.id_agente IN (' . implode(',', $idAgents) . ')
|
%s %s',
|
||||||
AND t2.datos NOT LIKE "%image%"';
|
$sql_tags_join, $filter, ' AND t2.datos NOT LIKE "%image%"', $where_tags);
|
||||||
|
|
||||||
if ($selection_mode == 'common') {
|
if ($selection_mode == 'common') {
|
||||||
$sql .= ' AND (
|
$sql .= ' AND (
|
||||||
|
|
Loading…
Reference in New Issue