Fixed "agents with templates" box in bulk alert actions add. Ticket#3087

This commit is contained in:
Arturo Gonzalez 2015-12-23 16:20:58 +01:00
parent 3f068fdefa
commit 54e0f25947
4 changed files with 19 additions and 9 deletions

View File

@ -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",

View File

@ -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 () {

View File

@ -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 {

View File

@ -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" : "_"