fix item name macros when using report templates

This commit is contained in:
alejandro-campos 2019-07-02 18:09:52 +02:00
parent c5be8e55ae
commit 51d7104de7
2 changed files with 44 additions and 9 deletions

View File

@ -1531,7 +1531,7 @@ function agents_get_alias($id_agent, $case='none')
return $cache[$case][$id_agent]; return $cache[$case][$id_agent];
} }
if ($config['dbconnection_cache'] == null && is_metaconsole()) { if (is_metaconsole()) {
$alias = (string) db_get_value('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent); $alias = (string) db_get_value('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent);
} else { } else {
$alias = (string) db_get_value('alias', 'tagente', 'id_agente', (int) $id_agent); $alias = (string) db_get_value('alias', 'tagente', 'id_agente', (int) $id_agent);

View File

@ -11488,17 +11488,32 @@ function reporting_label_macro($item, $label)
} }
if (preg_match('/_agentdescription_/', $label)) { if (preg_match('/_agentdescription_/', $label)) {
$agent_name = agents_get_description($item['id_agent']); if (!is_metaconsole()) {
$agent_name = agents_get_description($item['id_agent']);
} else {
$agent_name = $item['agent_description'];
}
$label = str_replace('_agentdescription_', $agent_name, $label); $label = str_replace('_agentdescription_', $agent_name, $label);
} }
if (preg_match('/_agentgroup_/', $label)) { if (preg_match('/_agentgroup_/', $label)) {
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); if (!is_metaconsole()) {
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true);
} else {
$agent_name = $item['agent_group'];
}
$label = str_replace('_agentgroup_', $agent_name, $label); $label = str_replace('_agentgroup_', $agent_name, $label);
} }
if (preg_match('/_address_/', $label)) { if (preg_match('/_address_/', $label)) {
$agent_name = agents_get_address($item['id_agent']); if (!is_metaconsole()) {
$agent_name = agents_get_address($item['id_agent']);
} else {
$agent_name = $item['agent_address'];
}
$label = str_replace('_address_', $agent_name, $label); $label = str_replace('_address_', $agent_name, $label);
} }
break; break;
@ -11537,7 +11552,11 @@ function reporting_label_macro($item, $label)
if (count($item['agents']) > 1) { if (count($item['agents']) > 1) {
$agent_name = ''; $agent_name = '';
} else { } else {
$agent_name = agents_get_description($item['id_agent']); if (!is_metaconsole()) {
$agent_name = agents_get_description($item['id_agent']);
} else {
$agent_name = $item['agent_description'];
}
} }
$label = str_replace('_agentdescription_', $agent_name, $label); $label = str_replace('_agentdescription_', $agent_name, $label);
@ -11547,7 +11566,11 @@ function reporting_label_macro($item, $label)
if (count($item['agents']) > 1) { if (count($item['agents']) > 1) {
$agent_name = ''; $agent_name = '';
} else { } else {
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); if (!is_metaconsole()) {
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true);
} else {
$agent_name = $item['agent_group'];
}
} }
$label = str_replace('_agentgroup_', $agent_name, $label); $label = str_replace('_agentgroup_', $agent_name, $label);
@ -11557,7 +11580,11 @@ function reporting_label_macro($item, $label)
if (count($item['agents']) > 1) { if (count($item['agents']) > 1) {
$agent_name = ''; $agent_name = '';
} else { } else {
$agent_name = agents_get_address($item['id_agent']); if (!is_metaconsole()) {
$agent_name = agents_get_address($item['id_agent']);
} else {
$agent_name = $item['agent_address'];
}
} }
$label = str_replace('_address_', $agent_name, $label); $label = str_replace('_address_', $agent_name, $label);
@ -11567,7 +11594,11 @@ function reporting_label_macro($item, $label)
if ($item['modules'] > 1) { if ($item['modules'] > 1) {
$module_name = $item['modules'].__(' modules'); $module_name = $item['modules'].__(' modules');
} else { } else {
$module_name = modules_get_agentmodule_name($item['id_agent_module']); if (!is_metaconsole()) {
$module_name = modules_get_agentmodule_name($item['id_agent_module']);
} else {
$module_name = $item['module_name'];
}
} }
$label = str_replace('_module_', $module_name, $label); $label = str_replace('_module_', $module_name, $label);
@ -11577,7 +11608,11 @@ function reporting_label_macro($item, $label)
if ($item['modules'] > 1) { if ($item['modules'] > 1) {
$module_description = ''; $module_description = '';
} else { } else {
$module_description = modules_get_agentmodule_descripcion($item['id_agent_module']); if (!is_metaconsole()) {
$module_description = modules_get_agentmodule_descripcion($item['id_agent_module']);
} else {
$module_description = $item['module_description'];
}
} }
$label = str_replace('_moduledescription_', $module_description, $label); $label = str_replace('_moduledescription_', $module_description, $label);