'', 'label' => __('Alert actions'), ], ] ); } if ($copy_action) { $id = get_parameter('id'); $al_action = alerts_get_alert_action($id); if ($al_action !== false) { // If user who doesn't have permission to modify group all tries to copy an action with group=ALL. if ($can_edit_all == false && $al_action['id_group'] == 0) { $al_action['id_group'] = users_get_first_group(false, 'LM', false); } else { $own_info = get_user_info($config['id_user']); if ($can_edit_all == true || check_acl($config['id_user'], 0, 'PM')) { $own_groups = array_keys( users_get_groups($config['id_user'], 'LM') ); } else { $own_groups = array_keys( users_get_groups($config['id_user'], 'LM', false) ); } $is_in_group = in_array($al_action['id_group'], $own_groups); // Then action group have to be in his own groups. if (!$is_in_group) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access Alert Management' ); include 'general/noaccess.php'; exit; } } } $result = alerts_clone_alert_action($id, $al_action['id_group']); $auditMessage = ((bool) $result === true) ? sprintf('Duplicate alert action %s clone to %s', $id, $result) : sprintf('Fail try to duplicate alert action %s', $id); db_pandora_audit( AUDIT_LOG_ALERT_MANAGEMENT, $auditMessage ); ui_print_result_message( $result, __('Successfully copied'), __('Could not be copied') ); } if ($update_action || $create_action) { alerts_ui_update_or_create_actions($update_action); } if ($delete_action) { $id = get_parameter('id'); $al_action = alerts_get_alert_action($id); if (!check_acl_restricted_all($config['id_user'], $al_action['id_group'], 'LM')) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access Alert Management' ); include 'general/noaccess.php'; exit; } if ($al_action !== false) { // If user tries to delete an action with group=ALL. if ($al_action['id_group'] == 0) { // Then must have "PM" access privileges. if (! check_acl($config['id_user'], 0, 'PM')) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access Alert Management' ); include 'general/noaccess.php'; exit; } // If user tries to delete an action of others groups. } else { $own_info = get_user_info($config['id_user']); if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { $own_groups = array_keys( users_get_groups($config['id_user'], 'LM') ); } else { $own_groups = array_keys( users_get_groups($config['id_user'], 'LM', false) ); } $is_in_group = in_array($al_action['id_group'], $own_groups); // Then action group have to be in his own groups. if (!$is_in_group) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access Alert Management' ); include 'general/noaccess.php'; exit; } } } $result = alerts_delete_alert_action($id); $auditMessage = ((bool) $result === true) ? sprintf('Delete alert action #%s', $id) : sprintf('Fail try to delete alert action #%s', $id); db_pandora_audit( AUDIT_LOG_ALERT_MANAGEMENT, $auditMessage ); ui_print_result_message( $result, __('Successfully deleted'), __('Could not be deleted') ); } $is_management_allowed = is_management_allowed(); if ($is_management_allowed === false) { if (is_metaconsole() === false) { $url = ''.__('metaconsole').''; } else { $url = __('any node'); } ui_print_warning_message( __( 'This node is configured with centralized mode. All alert actions information is read only. Go to %s to manage it.', $url ) ); } $search_string = (string) get_parameter('search_string', ''); $group = (int) get_parameter('group', 0); $group_search = (int) get_parameter('group_search', 0); $id_command_search = (int) get_parameter('id_command_search', 0); $url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&search_string='.$search_string.'&group_search='.$group_search.'&id_command_search='.$id_command_search; // Filter table. $table_filter = new stdClass(); $table_filter->width = '100%'; $table_filter->class = 'databox filters no_border filter-table-adv'; $table_filter->style = []; $table_filter->style[0] = 'width: 33%'; $table_filter->style[1] = 'width: 33%'; $table_filter->style[2] = 'width: 33%'; $table_filter->data = []; $table_filter->colspan = []; $table_filter->colspan[1][0] = 3; $table_filter->data[0][0] = html_print_label_input_block( __('Search'), html_print_input_text( 'search_string', $search_string, '', 25, 255, true ) ); $return_all_group = false; if (users_can_manage_group_all('LM') === true) { $return_all_group = true; } $table_filter->data[0][1] = html_print_label_input_block( __('Group'), html_print_select_groups( $config['id_user'], 'LM', $return_all_group, 'group_search', $group_search, '', '', 0, true ) ); $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][2] = html_print_label_input_block( __('Command'), html_print_select( index_array($commands, 'id', 'name'), 'id_command_search', $id_command_search, '', __('None'), 0, true, false, true, '', false, 'width:100%' ) ); $table_filter->data[1][0] = '