From af80ec25aaacad97e8c37ecbc4449df124f453a1 Mon Sep 17 00:00:00 2001 From: hkosaka Date: Fri, 30 May 2014 11:01:22 +0000 Subject: [PATCH] 2014-05-30 Hirofumi Kosaka * include/javascript/jquery.pandora.controls.js, godmode/groups/group_list.php, godmode/massive/massive_add_alerts.php, godmode/massive/massive_add_action_alerts.php godmode/massive/massive_delete_action_alerts.php, godmode/massive/massive_delete_alerts.php, godmode/massive/massive_enable_disable_alerts.php, godmode/massive/massive_standby_alerts.php: fixed bug that all agents would be shown in the target for masssive operations, if the user has an AW privilege for any agent (group). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10048 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++++++++++ pandora_console/godmode/groups/group_list.php | 17 +++++++++++++---- .../massive/massive_add_action_alerts.php | 10 ++++++++-- .../godmode/massive/massive_add_alerts.php | 11 +++++++++-- .../massive/massive_delete_action_alerts.php | 8 +++++++- .../godmode/massive/massive_delete_alerts.php | 7 ++++++- .../massive/massive_enable_disable_alerts.php | 10 ++++++++-- .../godmode/massive/massive_standby_alerts.php | 13 +++++++++---- .../javascript/jquery.pandora.controls.js | 2 ++ 9 files changed, 75 insertions(+), 16 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 06825ce054..c47275b365 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2014-05-30 Hirofumi Kosaka + + * include/javascript/jquery.pandora.controls.js, + godmode/groups/group_list.php, + godmode/massive/massive_add_alerts.php, + godmode/massive/massive_add_action_alerts.php + godmode/massive/massive_delete_action_alerts.php, + godmode/massive/massive_delete_alerts.php, + godmode/massive/massive_enable_disable_alerts.php, + godmode/massive/massive_standby_alerts.php: Fixed bug that all + agents would be shown in the target for masssive operations, if + the user has an AW privilege for any agent (group). + 2014-05-30 Miguel de Dios * godmode/agentes/agent_manager.php, diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index a69d5aecc6..9e7763b038 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -67,6 +67,7 @@ if (is_ajax ()) { $disabled = (int) get_parameter ('disabled', 0); $search = (string) get_parameter ('search', ''); $recursion = (int) get_parameter ('recursion', 0); + $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', ''); // Ids of agents to be include in the SQL clause as id_agent IN () @@ -104,10 +105,18 @@ if (is_ajax ()) { $filter[$_sql_post] = '1'; } - - $agents = agents_get_group_agents($id_group, $filter, "none", - false, $recursion); - + + if ( $id_group == 0 && $privilege != '') { + // 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))); + } + else { + $agents = agents_get_group_agents($id_group, $filter, "none", + false, $recursion); + } + // Add keys prefix if ($keys_prefix !== "") { foreach($agents as $k => $v) { diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index a1e17dba09..4c3715a598 100644 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -109,6 +109,11 @@ if ($add) { } $groups = users_get_groups (); +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; // Avoid php warning if (empty($alert_templates)) { @@ -129,8 +134,8 @@ $table->size[3] = '35%'; $table->data = array (); $table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, - false, '', '', true); +$table->data[0][1] = html_print_select_groups(false, "AW", $return_all_group, + 'id_group', $id_group, false, '', '', true); $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false); @@ -197,6 +202,7 @@ $(document).ready (function () { $("#id_group").pandoraSelectGroupAgent ({ agentSelect: "select#id_agents", + privilege: "AW", recursion: function() {return recursion}, filter_agents_json: filter_agents_json, callbackPost: function () { diff --git a/pandora_console/godmode/massive/massive_add_alerts.php b/pandora_console/godmode/massive/massive_add_alerts.php index 407894a215..3eb0b23801 100644 --- a/pandora_console/godmode/massive/massive_add_alerts.php +++ b/pandora_console/godmode/massive/massive_add_alerts.php @@ -38,7 +38,8 @@ if (is_ajax ()) { // Is is possible add keys prefix to avoid auto sorting in js object conversion $keys_prefix = (string) get_parameter ('keys_prefix', ''); - $agents = agents_get_group_agents ($id_group, false, "", false, $recursion); + $agents = agents_get_group_agents ( array_keys (users_get_groups ($config["id_user"], "AW", false)), + false, "", false, $recursion); // Add keys prefix if ($keys_prefix !== "") { @@ -113,6 +114,11 @@ if ($add) { } $groups = users_get_groups (); +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; $table->id = 'add_table'; $table->width = '98%'; @@ -129,7 +135,7 @@ $table->size[3] = '40%'; $table->data = array (); $table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', 0, +$table->data[0][1] = html_print_select_groups(false, "AW", $return_all_group, 'id_group', 0, '', 'Select', -1, true, false, true, '', false, 'width:180px;'); $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false); @@ -140,6 +146,7 @@ $table->data[1][0] .= html_print_image('images/spinner.png', true); $table->data[1][0] .= ''; $agents_alerts = alerts_get_agents_with_alert_template ($id_alert_template, $id_group, false, array ('tagente.nombre', 'tagente.id_agente')); + $agents = agents_get_agents(); $table->data[1][1] = html_print_select (index_array ($agents, 'id_agente', 'nombre'), 'id_agents[]', '', '', '', '', true, true, true, '', false, 'width:180px;'); diff --git a/pandora_console/godmode/massive/massive_delete_action_alerts.php b/pandora_console/godmode/massive/massive_delete_action_alerts.php index 13d35a2889..bcc89976e1 100644 --- a/pandora_console/godmode/massive/massive_delete_action_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_action_alerts.php @@ -115,6 +115,11 @@ if ($delete) { } $groups = users_get_groups (); +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; $table->id = 'delete_table'; $table->width = '98%'; @@ -130,7 +135,7 @@ $table->size[3] = '35%'; $table->data = array (); $table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, +$table->data[0][1] = html_print_select_groups(false, "AW", $return_all_group, 'id_group', $id_group, false, '', '', true); $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false); @@ -201,6 +206,7 @@ $(document).ready (function () { $("#id_group").pandoraSelectGroupAgent ({ agentSelect: "select#id_agents", + privilege: "AW", recursion: function() {return recursion}, filter_agents_json: filter_agents_json, callbackPost: function () { diff --git a/pandora_console/godmode/massive/massive_delete_alerts.php b/pandora_console/godmode/massive/massive_delete_alerts.php index 59d31564f7..6b3f6098ae 100644 --- a/pandora_console/godmode/massive/massive_delete_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_alerts.php @@ -181,6 +181,11 @@ if ($delete) { } $groups = users_get_groups (); +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; $table->id = 'delete_table'; $table->width = '98%'; @@ -204,7 +209,7 @@ $table->data[0][2] = ''; $table->data[0][3] = ''; $table->data[1][0] = __('Group'); -$table->data[1][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, +$table->data[1][1] = html_print_select_groups(false, "AW", $return_all_group, 'id_group', $id_group, '', '', '', true, false, true, '', $id_alert_template == 0); $table->data[1][2] = __('Group recursion'); $table->data[1][3] = html_print_checkbox ("recursion", 1, false, true, false); diff --git a/pandora_console/godmode/massive/massive_enable_disable_alerts.php b/pandora_console/godmode/massive/massive_enable_disable_alerts.php index f1d2a0e976..fdd1af8392 100644 --- a/pandora_console/godmode/massive/massive_enable_disable_alerts.php +++ b/pandora_console/godmode/massive/massive_enable_disable_alerts.php @@ -109,6 +109,11 @@ switch ($action) { } $groups = users_get_groups (); +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; $table->id = 'delete_table'; $table->width = '98%'; @@ -128,7 +133,7 @@ $table->data[0][0] = '
data[0][1] = html_print_select_groups(false, "AW", $return_all_group, 'id_group', $id_group, '', '', '', true); $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false); @@ -136,7 +141,7 @@ $table->data[1][0] = __('Agents'); $table->data[1][0] .= ''; -$table->data[1][1] = html_print_select (agents_get_group_agents ($id_group, false, "none"), +$table->data[1][1] = html_print_select (agents_get_group_agents (array_keys (users_get_groups ($config["id_user"], "AW", false))), 'id_agents[]', 0, false, '', '', true, true); $table->data[2][0] = __('Alert template'); @@ -191,6 +196,7 @@ $(document).ready (function () { $("#id_group").pandoraSelectGroupAgent ({ agentSelect: "select#id_agents", + privilege: "AW", recursion: function() {return recursion}, callbackPost: function () { clear_alert_fields(); diff --git a/pandora_console/godmode/massive/massive_standby_alerts.php b/pandora_console/godmode/massive/massive_standby_alerts.php index 1c5e069e7e..af3b09afa4 100644 --- a/pandora_console/godmode/massive/massive_standby_alerts.php +++ b/pandora_console/godmode/massive/massive_standby_alerts.php @@ -109,6 +109,11 @@ switch($action) { } $groups = users_get_groups (); +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; $table->id = 'delete_table'; $table->width = '98%'; @@ -128,8 +133,8 @@ $templates = alerts_get_alert_templates (false, array ('id', 'name')); $table->data[0][0] = ''; $table->data[0][0] .= html_print_input_hidden('id_alert_template_not_standby', $id_alert_templates, true); $table->data[0][0] .= __('Group'); -$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, - '', '', '', true, false, true, ''); +$table->data[0][1] = html_print_select_groups(false, "AW", $return_all_group, + 'id_group', $id_group, '', '', '', true, false, true, ''); $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false); @@ -137,9 +142,8 @@ $table->data[1][0] = __('Agents'); $table->data[1][0] .= ''; -$table->data[1][1] = html_print_select (agents_get_group_agents ($id_group, false, "none"), +$table->data[1][1] = html_print_select (agents_get_group_agents (array_keys (users_get_groups ($config["id_user"], "AW", false))), 'id_agents[]', 0, false, '', '', true, true); - $table->data[2][0] = __('Alert template'); $table->data[2][0] .= '