From 54e0f2594743ed49f1e16b2f303fc06b195a84cc Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 23 Dec 2015 16:20:58 +0100 Subject: [PATCH] Fixed "agents with templates" box in bulk alert actions add. Ticket#3087 --- pandora_console/godmode/groups/group_list.php | 7 +++++-- .../massive/massive_add_action_alerts.php | 1 + pandora_console/include/functions_agents.php | 19 ++++++++++++------- .../javascript/jquery.pandora.controls.js | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index caee73a739..866bdd3c39 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -72,6 +72,9 @@ if (is_ajax ()) { $privilege = (string) get_parameter ('privilege', ''); // Is is possible add keys prefix to avoid auto sorting in js object conversion $keys_prefix = (string) get_parameter ('keys_prefix', ''); + // This attr is for the operation "bulk alert accions add", it controls the query that take the agents + // from db + $add_alert_bulk_op = get_parameter ('add_alert_bulk_op', false); // Ids of agents to be include in the SQL clause as id_agent IN () $filter_agents_json = (string) get_parameter ('filter_agents_json', ''); $status_agents = (int)get_parameter('status_agents', AGENT_STATUS_ALL); @@ -113,10 +116,10 @@ if (is_ajax ()) { } if ( $id_group == 0 && $privilege != '') { + $groups = users_get_groups ($config["id_user"], $privilege, false); // if group ID doesn't matter and $privilege is specified (like 'AW'), // retruns all agents that current user has $privilege privilege for. - $agents = agents_get_group_agents( - array_keys (users_get_groups ($config["id_user"], $privilege, false)),$filter,"none",false,$recursion); + $agents = agents_get_group_agents(array_keys($groups), $filter, "none", false, $recursion, false, '|', $add_alert_bulk_op); } else { $agents = agents_get_group_agents($id_group, $filter, "none", diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 49592797bb..3900e80fec 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -220,6 +220,7 @@ $(document).ready (function () { $("#id_group").pandoraSelectGroupAgent ({ agentSelect: "select#id_agents", privilege: "AW", + add_alert_bulk_op: true, recursion: function() {return recursion}, filter_agents_json: filter_agents_json, callbackPost: function () { diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 25a85cdede..e7e6598d1c 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -805,8 +805,8 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge * @return array An array with all agents in the group or an empty array */ function agents_get_group_agents ($id_group = 0, $search = false, - $case = "lower", $noACL = false, $childGroups = false, $serialized = false, $separator = '|') { - + $case = "lower", $noACL = false, $childGroups = false, $serialized = false, $separator = '|', $add_alert_bulk_op = false) { + global $config; $filter = array(); @@ -901,7 +901,11 @@ function agents_get_group_agents ($id_group = 0, $search = false, } unset($search['status']); } - + + if (isset($search['id_agente'])) { + $filter['id_agente'] = $search['id_agente']; + } + if (is_metaconsole() && isset($search['id_server'])) { $filter['id_tmetaconsole_setup'] = $search['id_server']; @@ -912,10 +916,11 @@ function agents_get_group_agents ($id_group = 0, $search = false, unset ($search["id_server"]); } - - // Add the rest of the filter from the search array - foreach ($search as $key => $value) { - $filter[] = $value; + if (!$add_alert_bulk_op) { + // Add the rest of the filter from the search array + foreach ($search as $key => $value) { + $filter[] = $value; + } } } else { diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index 9ef224e4e7..ac14b5488e 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -44,6 +44,7 @@ "filter_agents_json" : config.filter_agents_json, "disabled" : config.disabled ? 1 : 0, "status_agents" : config.status_agents, + "add_alert_bulk_op" : config.add_alert_bulk_op, "privilege" : config.privilege, // Add a key prefix to avoid auto sorting in js object conversion "keys_prefix" : "_"