not show edition buttons of alert detail pandora_enterprise#12035
This commit is contained in:
parent
bab81b08e2
commit
16f1d80919
|
@ -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] = "<span title='".__('Policy')."'>".__('P.').'</span>';
|
||||
$table->head[1] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
|
||||
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] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
|
||||
$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] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[1] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
|
||||
$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(
|
||||
|
|
|
@ -1486,6 +1486,7 @@ 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 (is_metaconsole() === true) {
|
||||
if (check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$actionText .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&delete_action=1&id_alert='.$alert['id'].'&id_agent='.$agente['alias'].'&id_action='.$action['original_id'].'" onClick="if (!confirm(\' '.__('Are you sure you want to delete alert action?').'\')) return false;">'.html_print_image(
|
||||
'images/delete.svg',
|
||||
|
@ -1513,6 +1514,7 @@ function ui_format_alert_row(
|
|||
);
|
||||
$actionText .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$actionText .= '<div id="update_action-div-'.$alert['id'].'" class="invisible">';
|
||||
$actionText .= '</div>';
|
||||
|
|
|
@ -349,12 +349,6 @@ if (is_metaconsole() === true) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$alert_action = empty(alerts_get_alert_actions_filter()) === false
|
||||
? alerts_get_alert_actions_filter()
|
||||
: ['' => __('No actions')];
|
||||
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
|
|
Loading…
Reference in New Issue