From fe8e7b7d0c33f047742235147208168830793439 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 31 Aug 2020 12:48:00 +0200 Subject: [PATCH] Add new filter search actions --- .../godmode/alerts/alert_actions.php | 180 +++++++++++++----- 1 file changed, 132 insertions(+), 48 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index f4502c1413..70f4c46713 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -1,17 +1,32 @@ class = 'databox filters'; $table_filter->style = []; $table_filter->style[0] = 'font-weight: bold'; $table_filter->style[2] = 'font-weight: bold'; +$table_filter->style[4] = 'font-weight: bold'; $table_filter->data = []; $table_filter->data[0][0] = __('Search'); @@ -200,16 +237,54 @@ $table_filter->data[0][1] = html_print_input_text( true ); $table_filter->data[0][2] = __('Group'); -$table_filter->data[0][3] = html_print_select_groups($config['id_user'], 'LM', true, 'group', $group, '', '', 0, true); -$table_filter->data[0][4] = '
'; -$table_filter->data[0][4] .= html_print_submit_button( +$table_filter->data[0][3] = html_print_select_groups( + $config['id_user'], + 'LM', + true, + 'group_search', + $group_search, + '', + '', + 0, + true +); +$table_filter->data[0][4] = __('Command'); +$commands_sql = db_get_all_rows_filter( + 'talert_commands', + ['id_group' => array_keys(users_get_groups(false, 'LW'))], + [ + 'id', + 'name', + ], + 'AND', + false, + true +); + +$commands = db_get_all_rows_sql($commands_sql); +$table_filter->data[0][5] = html_print_select( + index_array($commands, 'id', 'name'), + 'id_command_search', + $id_command_search, + '', + __('None'), + 0, + true, + false, + true, + '', + false, + 'width:150px' +); +$table_filter->data[0][6] = '
'; +$table_filter->data[0][6] .= html_print_submit_button( __('Search'), '', false, 'class="sub search"', true ); -$table_filter->data[0][4] .= '
'; +$table_filter->data[0][5] .= '
'; $show_table_filter = '
'; @@ -228,41 +303,49 @@ $table->class = 'info_table'; $table->data = []; $table->head = []; $table->head[0] = __('Name'); -$table->head[1] = __('Group'); +$table->head[1] = __('Command'); +$table->head[2] = __('Group'); if (is_central_policies_on_node() === false) { - $table->head[2] = __('Copy'); - $table->head[3] = __('Delete'); + $table->head[3] = __('Copy'); + $table->head[4] = __('Delete'); } $table->style = []; $table->style[0] = 'font-weight: bold'; $table->size = []; -$table->size[1] = '200px'; -$table->size[2] = '40px'; $table->size[3] = '40px'; +$table->size[4] = '40px'; $table->align = []; $table->align[1] = 'left'; $table->align[2] = 'left'; $table->align[3] = 'left'; +$table->align[4] = 'left'; $filter = []; if (!is_user_admin($config['id_user']) && $group === 0) { - $filter['talert_actions.id_group'] = array_keys(users_get_groups(false, 'LM')); + $filter['talert_actions.id_group'] = array_keys( + users_get_groups(false, 'LM') + ); } -if ($group !== 0) { - $filter['talert_actions.id_group'] = $group; +if ($group_search !== 0) { + $filter['talert_actions.id_group'] = $group_search; } if ($search_string !== '') { $filter['talert_actions.name'] = '%'.$search_string.'%'; } +if ($id_command_search !== 0) { + $filter['talert_commands.id'] = $id_command_search; +} + $actions = db_get_all_rows_filter( 'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id', $filter, - 'talert_actions.* , talert_commands.id_group AS command_group' + 'talert_actions.* , talert_commands.id_group AS command_group, talert_commands.name AS command_name' ); + if ($actions === false) { $actions = []; } @@ -288,9 +371,10 @@ foreach ($actions as $action) { $data = []; $data[0] = ''.$action['name'].''; - $data[1] = ui_print_group_icon($action['id_group'], true).' '; + $data[1] = $action['command_name']; + $data[2] = ui_print_group_icon($action['id_group'], true).' '; if (!alerts_validate_command_to_action($action['id_group'], $action['command_group'])) { - $data[1] .= html_print_image( + $data[2] .= html_print_image( 'images/error.png', true, // FIXME: Translation. @@ -304,16 +388,16 @@ foreach ($actions as $action) { && check_acl($config['id_user'], $action['id_group'], 'LM') ) { $table->cellclass[] = [ - 2 => 'action_buttons', 3 => 'action_buttons', + 4 => 'action_buttons', ]; $id_action = $action['id']; $text_confirm = __('Are you sure?'); - $data[2] = ''.html_print_image('images/copy.png', true).''; - $data[3] = ''.html_print_image('images/cross.png', true).''; } @@ -346,7 +430,7 @@ function copy_action(id_action, text_confirm) { if (!confirm(text_confirm)) { return false; } else { - jQuery.post ("ajax.php", + jQuery.post ("ajax.php", { "page" : "godmode/alerts/alert_actions", "copy_action" : 1,