diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index 2fbda5d75c..3d908c445b 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -35,7 +35,6 @@ $disable_alert = (bool) get_parameter('disable_alert'); $enable_alert = (bool) get_parameter('enable_alert'); $get_actions_module = (bool) get_parameter('get_actions_module'); $show_update_action_menu = (bool) get_parameter('show_update_action_menu'); -$get_agent_alerts_agent_view = (bool) get_parameter('get_agent_alerts_agent_view'); $resize_event_week = (bool) get_parameter('resize_event_week'); $get_agent_alerts_datatable = (bool) get_parameter('get_agent_alerts_datatable', 0); $alert_validate = (bool) get_parameter('alert_validate', false); @@ -91,270 +90,6 @@ if ($get_agent_alerts_simple) { } -if ($get_agent_alerts_agent_view) { - include_once $config['homedir'].'/include/functions_agents.php'; - include_once $config['homedir'].'/operation/agentes/alerts_status.functions.php'; - include_once $config['homedir'].'/include/functions_users.php'; - - $agent_a = check_acl($config['id_user'], 0, 'AR'); - $agent_w = check_acl($config['id_user'], 0, 'AW'); - $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); - - $free_search_alert = get_parameter('free_search_alert', ''); - $all_groups = json_decode(io_safe_output(get_parameter('all_groups'))); - $idAgent = (int) get_parameter('id_agent'); - $filter = get_parameter('filter', 'all_enabled'); - $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$idAgent; - - $sortField = get_parameter('sort_field'); - $sort = get_parameter('sort', 'none'); - $selected = true; - $selectModuleUp = false; - $selectModuleDown = false; - $selectTemplateUp = false; - $selectTemplateDown = false; - $selectLastFiredUp = false; - $selectLastFiredDown = false; - switch ($sortField) { - case 'module': - switch ($sort) { - case 'up': - $selectModuleUp = $selected; - $order = [ - 'field' => 'agent_module_name', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectModuleDown = $selected; - $order = [ - 'field' => 'agent_module_name', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'template': - switch ($sort) { - case 'up': - $selectTemplateUp = $selected; - $order = [ - 'field' => 'template_name', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectTemplateDown = $selected; - $order = [ - 'field' => 'template_name', - 'order' => 'DESC', - ]; - break; - } - break; - - case 'last_fired': - switch ($sort) { - case 'up': - $selectLastFiredUp = $selected; - $order = [ - 'field' => 'last_fired', - 'order' => 'ASC', - ]; - break; - - case 'down': - $selectLastFiredDown = $selected; - $order = [ - 'field' => 'last_fired', - 'order' => 'DESC', - ]; - break; - } - break; - - default: - $selectDisabledUp = ''; - $selectDisabledDown = ''; - $selectModuleUp = $selected; - $selectModuleDown = false; - $selectTemplateUp = false; - $selectTemplateDown = false; - $selectLastFiredUp = false; - $selectLastFiredDown = false; - $order = [ - 'field' => 'agent_module_name', - 'order' => 'ASC', - ]; - break; - } - - if ($free_search_alert != '') { - $whereAlertSimple = 'AND ('.'id_alert_template IN ( - SELECT id - FROM talert_templates - WHERE name LIKE "%'.$free_search_alert.'%") OR '.'id_alert_template IN ( - SELECT id - FROM talert_templates - WHERE id_alert_action IN ( - SELECT id - FROM talert_actions - WHERE name LIKE "%'.$free_search_alert.'%")) OR '.'talert_template_modules.id IN ( - SELECT id_alert_template_module - FROM talert_template_module_actions - WHERE id_alert_action IN ( - SELECT id - FROM talert_actions - WHERE name LIKE "%'.$free_search_alert.'%")) OR '.'id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE nombre LIKE "%'.$free_search_alert.'%") OR '.'id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE alias LIKE "%'.$free_search_alert.'%")'.')'; - } else { - $whereAlertSimple = ''; - } - - // Add checks for user ACL. - $groups = users_get_groups($config['id_user'], $access); - $id_groups = array_keys($groups); - - if (empty($id_groups)) { - $whereAlertSimple .= ' AND (1 = 0) '; - } else { - $whereAlertSimple .= sprintf( - ' AND id_agent_module IN ( - SELECT tam.id_agente_modulo - FROM tagente_modulo tam - WHERE tam.id_agente IN ( - SELECT - ta.id_agente - FROM - tagente ta - WHERE - ta.id_grupo IN (%s) - ) - OR tam.id_agente IN ( - SELECT - DISTINCT(tasg.id_agent) - FROM - tagent_secondary_group tasg - WHERE - tasg.id_group IN (%s) - ) - ) ', - implode(',', $id_groups), - implode(',', $id_groups) - ); - } - - $alerts = []; - - $filter_alert = []; - if ($filter_standby == 'standby_on') { - $filter_alert['disabled'] = $filter; - $filter_alert['standby'] = '1'; - } else if ($filter_standby == 'standby_off') { - $filter_alert['disabled'] = $filter; - $filter_alert['standby'] = '0'; - } else { - $filter_alert['disabled'] = $filter; - } - - $options_simple = ['order' => $order]; - - $alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, false, false, $strict_user, $tag_filter); - $countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, false, true, $strict_user, $tag_filter); - - // Urls to sort the table. - $url_up_module = $url.'&sort_field=module&sort=up'; - $url_down_module = $url.'&sort_field=module&sort=down'; - $url_up_template = $url.'&sort_field=template&sort=up'; - $url_down_template = $url.'&sort_field=template&sort=down'; - $url_up_lastfired = $url.'&sort_field=last_fired&sort=up'; - $url_down_lastfired = $url.'&sort_field=last_fired&sort=down'; - - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'info_table'; - $table->cellpadding = '0'; - $table->cellspacing = '0'; - $table->size = []; - $table->head = []; - $table->align = []; - - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->size[7] = '5%'; - if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) { - $table->head[8] = __('Validate'); - $table->align[8] = 'left'; - $table->size[8] = '5%'; - } - - $table->head[0] = "".__('P.').''; - $table->head[1] = "".__('S.').''; - - if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) { - $table->head[2] = "".__('F.').''; - } - - $table->head[3] = __('Module'); - $table->head[4] = __('Template'); - $table->head[5] = __('Action'); - $table->head[6] = __('Last fired'); - $table->head[7] = __('Status'); - - $table->align[7] = 'center'; - - $table->head[3] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown); - $table->head[4] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown); - $table->head[6] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown); - } else { - $table->size[6] = '5%'; - if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) { - $table->head[7] = __('Validate'); - $table->align[7] = 'left'; - $table->size[7] = '5%'; - } - - $table->head[0] = "".__('S.').''; - - if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) { - $table->head[1] = "".__('F.').''; - } - - $table->head[2] = __('Module'); - $table->head[3] = __('Template'); - $table->head[4] = __('Action'); - $table->head[5] = __('Last fired'); - $table->head[6] = __('Status'); - - $table->align[6] = 'center'; - - $table->head[2] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown); - $table->head[3] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown); - $table->head[5] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown); - } - - $table->data = []; - $rowPair = true; - $iterator = 0; - foreach ($alerts['alerts_simple'] as $alert) { - $row = ui_format_alert_row($alert, false, $url, 'font-size: 9pt;'); - $table->data[] = $row; - } - - if (empty($table->data) === false) { - html_print_table($table); - } else { - ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]); - } -} - if ($enable_alert) { if (! check_acl($config['id_user'], 0, 'LW')) { db_pandora_audit( diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 8915bd3dc9..ba6804b787 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1486,32 +1486,34 @@ function ui_format_alert_row( $actionText .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true); // Is possible manage actions if have LW permissions in the agent group of the alert module. - if (check_acl($config['id_user'], $id_group, 'LM')) { - $actionText .= ''.html_print_image( - 'images/delete.svg', - true, - [ - 'alt' => __('Delete action'), - 'title' => __('Delete action'), - 'class' => 'main_menu_icon invert_filter vertical_baseline', - ] - ).''; - } + if (is_metaconsole() === true) { + if (check_acl($config['id_user'], $id_group, 'LM')) { + $actionText .= ''.html_print_image( + 'images/delete.svg', + true, + [ + 'alt' => __('Delete action'), + 'title' => __('Delete action'), + 'class' => 'main_menu_icon invert_filter vertical_baseline', + ] + ).''; + } - if (check_acl($config['id_user'], $id_group, 'LW')) { - $actionText .= html_print_input_image( - 'update_action', - '/images/edit.svg', - 1, - 'padding:0px;', - true, - [ - 'title' => __('Update action'), - 'class' => 'main_menu_icon invert_filter', - 'onclick' => 'show_display_update_action(\''.$action['original_id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['original_id'].'\',\''.$alert['agent_name'].'\')', - ] - ); - $actionText .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); + if (check_acl($config['id_user'], $id_group, 'LW')) { + $actionText .= html_print_input_image( + 'update_action', + '/images/edit.svg', + 1, + 'padding:0px;', + true, + [ + 'title' => __('Update action'), + 'class' => 'main_menu_icon invert_filter', + 'onclick' => 'show_display_update_action(\''.$action['original_id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['original_id'].'\',\''.$alert['agent_name'].'\')', + ] + ); + $actionText .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); + } } $actionText .= '