mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Fixed the generation filter by tag the networkmap.
This commit is contained in:
parent
5c0620e426
commit
bff44de236
@ -257,6 +257,8 @@ class Networkmap extends Map {
|
|||||||
$return['dont_show_subgroups'] = false;
|
$return['dont_show_subgroups'] = false;
|
||||||
$return['old_mode'] = false;
|
$return['old_mode'] = false;
|
||||||
$return['filter'] = $this->filter['text'];
|
$return['filter'] = $this->filter['text'];
|
||||||
|
$return['id_tag'] = $this->filter['id_tag'];
|
||||||
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
@ -292,7 +294,8 @@ class Networkmap extends Map {
|
|||||||
$parameters['dont_show_subgroups'],
|
$parameters['dont_show_subgroups'],
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
$parameters['old_mode']);
|
$parameters['old_mode'],
|
||||||
|
$parameters['id_tag']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
|
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
|
||||||
$relative = false, $text_filter = '', $l2_network_or_mixed = false,
|
$relative = false, $text_filter = '', $l2_network_or_mixed = false,
|
||||||
$ip_mask = null, $dont_show_subgroups = false, $strict_user = false,
|
$ip_mask = null, $dont_show_subgroups = false, $strict_user = false,
|
||||||
$size_canvas = null, $old_mode = false) {
|
$size_canvas = null, $old_mode = false, $id_tag = 0) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -351,6 +351,15 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
|
|||||||
//return false;
|
//return false;
|
||||||
$agents = array();
|
$agents = array();
|
||||||
|
|
||||||
|
// Filter by tags
|
||||||
|
if (!empty($id_tag)) {
|
||||||
|
foreach ($agents as $index => $agent) {
|
||||||
|
if (!tags_agent_has_tag($agent['id_agente'], $id_tag)) {
|
||||||
|
unset($agents[$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Open Graph
|
// Open Graph
|
||||||
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom,
|
||||||
$ranksep, $font_size, $size_canvas);
|
$ranksep, $font_size, $size_canvas);
|
||||||
|
@ -534,6 +534,23 @@ function tags_get_tags ($ids) {
|
|||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tags_agent_has_tag($id_agent, $id_tag) {
|
||||||
|
$exists = db_get_value_sql("
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM ttag_module
|
||||||
|
WHERE id_agente_modulo IN (
|
||||||
|
SELECT id_agente_modulo
|
||||||
|
FROM tagente_modulo
|
||||||
|
WHERE id_agente = " . $id_agent . ")
|
||||||
|
AND id_tag = " . $id_tag);
|
||||||
|
|
||||||
|
if (empty($exists)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (bool)$exists;
|
||||||
|
}
|
||||||
|
|
||||||
function tags_get_agents($id_tag, $id_policy_module = 0) {
|
function tags_get_agents($id_tag, $id_policy_module = 0) {
|
||||||
|
|
||||||
$agents = db_get_all_rows_sql("
|
$agents = db_get_all_rows_sql("
|
||||||
@ -2461,13 +2478,16 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
|||||||
*
|
*
|
||||||
* @return mixed Returns count of agents with this tag or false if they aren't.
|
* @return mixed Returns count of agents with this tag or false if they aren't.
|
||||||
*/
|
*/
|
||||||
function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true, $return_all_fields = false) {
|
function tags_get_all_user_agents ($id_tag = false, $id_user = false,
|
||||||
|
$groups_and_tags = array(), $filter = false, $fields = false,
|
||||||
|
$meta = true, $strict_user = true, $return_all_fields = false) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (empty($id_tag)) {
|
if (empty($id_tag)) {
|
||||||
$tag_filter = '';
|
$tag_filter = '';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) ";
|
$tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) ";
|
||||||
}
|
}
|
||||||
if (empty($id_user)) {
|
if (empty($id_user)) {
|
||||||
@ -2481,13 +2501,14 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
|
|||||||
}
|
}
|
||||||
|
|
||||||
$select_fields = implode(',',$fields);
|
$select_fields = implode(',',$fields);
|
||||||
|
|
||||||
$groups_clause = "";
|
$groups_clause = "";
|
||||||
if ($strict_user) {
|
if ($strict_user) {
|
||||||
if (!empty($groups_and_tags)) {
|
if (!empty($groups_and_tags)) {
|
||||||
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
|
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$groups_clause = " AND tagente.id_grupo IN (".implode(',', array_keys($groups_and_tags)).")";
|
$groups_clause = " AND tagente.id_grupo IN (".implode(',', array_keys($groups_and_tags)).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2498,7 +2519,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
|
|||||||
$groups_str = $filter['id_group'];
|
$groups_str = $filter['id_group'];
|
||||||
$groups_clause .= " AND tagente.id_grupo IN ($groups_str)";
|
$groups_clause .= " AND tagente.id_grupo IN ($groups_str)";
|
||||||
}
|
}
|
||||||
|
|
||||||
$status_sql = '';
|
$status_sql = '';
|
||||||
if (isset($filter['status'])) {
|
if (isset($filter['status'])) {
|
||||||
switch ($filter['status']) {
|
switch ($filter['status']) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user