New filter actions. Ticket #3893.

(cherry picked from commit ec073eb8b4)
This commit is contained in:
Daniel Maya 2016-06-28 14:55:13 +02:00
parent 69796812c4
commit ee35e98fed
3 changed files with 25 additions and 9 deletions

View File

@ -1612,6 +1612,10 @@ function get_group_alerts($id_group, $filter = '', $options = false,
if ($tag) {
$filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))';
}
if($action_filter){
$filter .= ' AND (talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions where id_alert_action = '.$action_filter.'))';
}
if (is_array ($options)) {
$filter .= db_format_array_where_clause_sql ($options);
}

View File

@ -88,10 +88,10 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
$tags = tags_get_user_tags();
if (empty($tags)) {
$table->data[0][4] .= html_print_input_text('tags', __('No tags'), '', 20, 40, true,true);
$table->data[0][5] .= html_print_input_text('tags', __('No tags'), '', 20, 40, true,true);
}
else {
$table->data[0][4] .= html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
$table->data[0][5] .= html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
}
$table->data[1][0] = __('Free text for search') .
@ -99,9 +99,19 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
__("Filter by agent name, module name, template name or action name"),
true);
$table->data[1][1] = html_print_input_text('free_search', $free_search, '', 20, 40, true);
$table->data[1][2] = __('Standby');
$table->data[1][3] = html_print_select ($alert_standby, "filter_standby", $filter_standby, '', '', '', true);
$table->data[1][4] = __('Action');
$alert_action = alerts_get_alert_actions_filter();
if(empty($alert_action)){
$table->data[1][5] .= html_print_input_text('action', __('No actions'), '', 20, 40, true,true);
}else{
$table->data[1][5] = html_print_select ($alert_action, "action_filter", $action_filter, '', __('All'), '', true);
}
$table->data[1][5] = html_print_select ($alert_action, "action_filter", $action_filter, '', __('All'), '', true);
if (defined('METACONSOLE')) {
$table->data[0][7] = html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true);
$table->rowspan[0][7] = 2;

View File

@ -52,6 +52,8 @@ if ($tag_filter) {
}
}
$action_filter = get_parameter("action_filter", 0);
$sec2 = get_parameter_get ('sec2');
$sec2 = safe_url_extraclean ($sec2);
@ -67,7 +69,7 @@ $pure = get_parameter('pure', 0);
$url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr .
'&filter=' . $filter . '&filter_standby=' . $filter_standby .
'&ag_group=' . $id_group .'&tag_filter=' .$tag_filter;
'&ag_group=' . $id_group .'&tag_filter=' .$tag_filter .'&action_filter=' .$action_filter;
if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) {
forceExecution($id_group);
@ -356,10 +358,10 @@ else {
else {
$id_groups = array_keys(
users_get_groups($config["id_user"], 'AR', false));
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter,$action_filter);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
}
}
@ -386,7 +388,7 @@ if ($print_agent) {
else {
ui_toggle(
printFormFilterAlert($id_group, $filter, $free_search,
$url, $filter_standby, $tag_filter, true, $strict_user),
$url, $filter_standby, $tag_filter, $action_filter, true, $strict_user),
__('Alert control filter'), __('Toggle filter(s)'));
}
}