Merge branch 'ent-10065-post-filtros-de-eventos-privados' into 'develop'
Draft: Ent 10065 post filtros de eventos privados See merge request artica/pandorafms!6318
This commit is contained in:
commit
6ecd8ca899
|
@ -1,5 +1,6 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE tevent_filter ADD private_filter_user text NULL;
|
||||
ALTER TABLE `ttrap` ADD COLUMN `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0;
|
||||
|
||||
UPDATE ttrap SET utimestamp=UNIX_TIMESTAMP(timestamp);
|
||||
|
|
|
@ -61,6 +61,9 @@ if ($id) {
|
|||
$filter = events_get_event_filter($id);
|
||||
$id_group_filter = $filter['id_group_filter'];
|
||||
$id_group = $filter['id_group'];
|
||||
// Get owner user private filter.
|
||||
$private_filter = ($filter['private_filter_user'] === null || $filter['private_filter_user'] === '') ? 0 : 1;
|
||||
$private_filter_user = $filter['private_filter_user'];
|
||||
$id_name = $filter['id_name'];
|
||||
$event_type = $filter['event_type'];
|
||||
$severity = explode(',', $filter['severity']);
|
||||
|
@ -113,6 +116,7 @@ if ($id) {
|
|||
$server_id = ($filter['server_id'] ?? '');
|
||||
} else {
|
||||
$id_group = '';
|
||||
$private_filter = 0;
|
||||
$id_group_filter = '';
|
||||
$id_name = '';
|
||||
$event_type = '';
|
||||
|
@ -167,8 +171,8 @@ if ($update || $create) {
|
|||
$id_user_ack = get_parameter('id_user_ack', '');
|
||||
$owner_user = get_parameter('owner_user', '');
|
||||
$group_rep = get_parameter('group_rep', '');
|
||||
$date_from = get_parameter('date_from', '');
|
||||
$date_to = get_parameter('date_to', '');
|
||||
$date_from = get_parameter('date_from', '0000-00-00');
|
||||
$date_to = get_parameter('date_to', '0000-00-00');
|
||||
$source = get_parameter('source');
|
||||
$id_extra = get_parameter('id_extra');
|
||||
$user_comment = get_parameter('user_comment');
|
||||
|
@ -192,6 +196,16 @@ if ($update || $create) {
|
|||
$server_id = implode(',', $servers_array);
|
||||
}
|
||||
|
||||
// Get private filter from user.
|
||||
$private_filter = get_parameter_switch('private_filter_event', 0);
|
||||
if ((int) $private_filter === 1 && $create) {
|
||||
$private_filter_user = $_SESSION['id_usuario'];
|
||||
} else if ((int) $private_filter === 1 && $update) {
|
||||
$private_filter_user = ($private_filter_user === $_SESSION['id_usuario']) ? $private_filter_user : $_SESSION['id_usuario'];
|
||||
} else if ((int) $private_filter === 0) {
|
||||
$private_filter_user = null;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_name' => $id_name,
|
||||
'id_group_filter' => $id_group_filter,
|
||||
|
@ -222,6 +236,7 @@ if ($update || $create) {
|
|||
'custom_data' => $custom_data,
|
||||
'custom_data_filter_type' => $custom_data_filter_type,
|
||||
'server_id' => $server_id,
|
||||
'private_filter_user' => $private_filter_user,
|
||||
];
|
||||
|
||||
$severity = explode(',', $severity);
|
||||
|
@ -293,6 +308,17 @@ $table->data[0][0] = html_print_label_input_block(
|
|||
false,
|
||||
'',
|
||||
'w100p'
|
||||
).html_print_label_input_block(
|
||||
__('Private'),
|
||||
html_print_checkbox_switch(
|
||||
'private_filter_event',
|
||||
$private_filter,
|
||||
$private_filter,
|
||||
true,
|
||||
false,
|
||||
'checked_slide_events(this);',
|
||||
true
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -133,6 +133,18 @@ $filters = db_get_all_rows_sql($sql);
|
|||
|
||||
if ($filters === false) {
|
||||
$filters = [];
|
||||
} else {
|
||||
foreach ($filters as $key => $filter) {
|
||||
$permission = users_is_admin($config['id_user']);
|
||||
// Validate permission and private filter user.
|
||||
if ($permission || $filter['private_filter_user'] === $config['id_user']) {
|
||||
if ($filter['private_filter_user'] !== null) {
|
||||
$filters[$key]['id_name'] = $filter['id_name'].' (P)';
|
||||
}
|
||||
} else if ($filter['private_filter_user'] !== null) {
|
||||
unset($filters[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
|
|
|
@ -92,6 +92,9 @@ $get_id_source_event = get_parameter('get_id_source_event');
|
|||
$node_id = (int) get_parameter('node_id', 0);
|
||||
$settings_modal = get_parameter('settings', 0);
|
||||
$parameters_modal = get_parameter('parameters', 0);
|
||||
// User private filter.
|
||||
$current_filter = get_parameter('current_filter', 0);
|
||||
$private_filter_event = get_parameter('private_filter_event', 0);
|
||||
|
||||
if ($get_comments === true) {
|
||||
global $config;
|
||||
|
@ -337,6 +340,14 @@ if ($save_event_filter) {
|
|||
$values['custom_data'] = get_parameter('custom_data');
|
||||
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
|
||||
|
||||
// Get private filter from user.
|
||||
$private_filter = get_parameter_switch('private_filter_user', 0);
|
||||
if ((int) $private_filter === 1) {
|
||||
$values['private_filter_user'] = $config['id_user'];
|
||||
} else {
|
||||
$values['private_filter_user'] = null;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$values['server_id'] = implode(',', get_parameter('server_id'));
|
||||
}
|
||||
|
@ -397,6 +408,17 @@ if ($update_event_filter) {
|
|||
$values['custom_data'] = get_parameter('custom_data');
|
||||
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
|
||||
|
||||
// Get private filter from user.
|
||||
$private_filter = get_parameter('private_filter_user', 0);
|
||||
$user_private_filter = events_get_event_filter($id);
|
||||
if ((int) $private_filter === 1 && $user_private_filter['private_filter_user'] === null) {
|
||||
$values['private_filter_user'] = $config['id_user'];
|
||||
} else if ($private_filter === $user_private_filter['private_filter_user'] && $user_private_filter['private_filter_user'] !== $config['id_user']) {
|
||||
$values['private_filter_user'] = $user_private_filter['private_filter_user'];
|
||||
} else {
|
||||
$values['private_filter_user'] = null;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$values['server_id'] = implode(',', get_parameter('server_id'));
|
||||
}
|
||||
|
@ -712,8 +734,8 @@ if ($save_filter_modal) {
|
|||
$table = new StdClass;
|
||||
$table->id = 'save_filter_form';
|
||||
$table->width = '100%';
|
||||
$table->cellspacing = 4;
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 5;
|
||||
$table->cellpadding = 5;
|
||||
$table->class = 'databox';
|
||||
if (is_metaconsole() === true) {
|
||||
$table->class = 'databox filters';
|
||||
|
@ -732,7 +754,7 @@ if ($save_filter_modal) {
|
|||
'filter_mode',
|
||||
'new',
|
||||
__('New filter'),
|
||||
true,
|
||||
((int) $current_filter === 0) ? true : false,
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -740,7 +762,7 @@ if ($save_filter_modal) {
|
|||
'filter_mode',
|
||||
'update',
|
||||
__('Update filter'),
|
||||
false,
|
||||
((int) $current_filter > 0) ? true : false,
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -755,6 +777,7 @@ if ($save_filter_modal) {
|
|||
$table->rowclass[2] = 'flex';
|
||||
$table->rowclass[3] = 'flex';
|
||||
$table->rowclass[4] = 'flex';
|
||||
$table->rowclass[5] = 'flex';
|
||||
$data[0] = '<b>'.__('Filter name').'</b>'.$jump;
|
||||
$data[0] .= html_print_input_text('id_name', '', '', 15, 255, true);
|
||||
if (is_metaconsole()) {
|
||||
|
@ -801,9 +824,9 @@ if ($save_filter_modal) {
|
|||
$data[0] .= html_print_select(
|
||||
$_filters_update,
|
||||
'overwrite_filter',
|
||||
$current_filter,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
__('None'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
|
@ -814,6 +837,31 @@ if ($save_filter_modal) {
|
|||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
$data = [];
|
||||
$table->rowid[4] = 'update_filter_row2';
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
// Update user private filter.
|
||||
$data = [];
|
||||
$table->rowid[6] = 'private_filter_event_row1';
|
||||
$data[0] = html_print_label_input_block(
|
||||
__('Private'),
|
||||
html_print_checkbox_switch(
|
||||
'private_filter_event',
|
||||
$private_filter_event,
|
||||
$private_filter_event,
|
||||
true,
|
||||
false,
|
||||
'checked_slide_events(this);',
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
html_print_div(
|
||||
|
@ -858,10 +906,19 @@ if ($save_filter_modal) {
|
|||
?>
|
||||
<script type="text/javascript">
|
||||
function show_save_filter() {
|
||||
$('#save_filter_row1').show();
|
||||
$('#save_filter_row2').show();
|
||||
$('#update_filter_row1').hide();
|
||||
$('#button-update_filter').hide();
|
||||
|
||||
if ($('#hidden-id_filter_event').val() == 0) {
|
||||
$('#save_filter_row1').show();
|
||||
$('#save_filter_row2').show();
|
||||
$('#update_filter_row1').hide();
|
||||
$('#button-update_filter').hide();
|
||||
} else {
|
||||
$('#save_filter_row1').hide();
|
||||
$('#save_filter_row2').hide();
|
||||
$('#button-save_filter').hide();
|
||||
$('#update_filter_row1').show();
|
||||
$('#button-update_filter').show();
|
||||
}
|
||||
// Filter save mode selector
|
||||
$("[name='filter_mode']").click(function() {
|
||||
if ($(this).val() == 'new') {
|
||||
|
@ -936,7 +993,8 @@ function save_new_filter() {
|
|||
"id_source_event": $("#text-id_source_event").val(),
|
||||
"server_id": $("#server_id").val(),
|
||||
"custom_data": $("#text-custom_data").val(),
|
||||
"custom_data_filter_type": $("#custom_data_filter_type").val()
|
||||
"custom_data_filter_type": $("#custom_data_filter_type").val(),
|
||||
"private_filter_user": $("#checkbox-private_filter_event").val()
|
||||
},
|
||||
function (data) {
|
||||
$("#info_box").hide();
|
||||
|
@ -1015,7 +1073,8 @@ function save_update_filter() {
|
|||
"id_source_event": $("#text-id_source_event").val(),
|
||||
"server_id": $("#server_id").val(),
|
||||
"custom_data": $("#text-custom_data").val(),
|
||||
"custom_data_filter_type": $("#custom_data_filter_type").val()
|
||||
"custom_data_filter_type": $("#custom_data_filter_type").val(),
|
||||
"private_filter_user": $("#checkbox-private_filter_event").val()
|
||||
|
||||
},
|
||||
function (data) {
|
||||
|
|
|
@ -2760,7 +2760,6 @@ function agents_delete_agent($id_agents, $disableACL=false)
|
|||
enterprise_include_once('include/functions_agents.php');
|
||||
enterprise_hook('agent_delete_from_cache', [$id_agent]);
|
||||
|
||||
|
||||
// Delete agent from fav menu.
|
||||
db_process_sql_delete(
|
||||
'tfavmenu_user',
|
||||
|
|
|
@ -3357,7 +3357,7 @@ function events_get_event_filter_select($manage=true)
|
|||
}
|
||||
|
||||
$sql = '
|
||||
SELECT id_filter, id_name
|
||||
SELECT id_filter, id_name, private_filter_user
|
||||
FROM tevent_filter
|
||||
WHERE id_group_filter IN (0, '.implode(',', array_keys($user_groups)).')';
|
||||
|
||||
|
@ -3368,7 +3368,20 @@ function events_get_event_filter_select($manage=true)
|
|||
} else {
|
||||
$result = [];
|
||||
foreach ($event_filters as $event_filter) {
|
||||
$result[$event_filter['id_filter']] = $event_filter['id_name'];
|
||||
$permission = users_is_admin($config['id_user']);
|
||||
if ($permission || $event_filter['private_filter_user'] === $config['id_user']) {
|
||||
if ($event_filter['private_filter_user'] !== null) {
|
||||
$filter_name = $event_filter['id_name'].' (P)';
|
||||
} else {
|
||||
$filter_name = $event_filter['id_name'];
|
||||
}
|
||||
|
||||
$result[$event_filter['id_filter']] = $filter_name;
|
||||
}
|
||||
|
||||
if ($event_filter['private_filter_user'] === null) {
|
||||
$result[$event_filter['id_filter']] = $event_filter['id_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5089,7 +5089,7 @@ div#dialog_messages table th:last-child {
|
|||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 5px;
|
||||
left: 0;
|
||||
left: 5px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
|
|
|
@ -201,6 +201,10 @@ $search_recursive_groups = get_parameter(
|
|||
'filter[search_recursive_groups]',
|
||||
($filter['search_recursive_groups'] ?? '')
|
||||
);
|
||||
$search_recursive_groups = get_parameter(
|
||||
'filter[private_filter_event]',
|
||||
($filter['private_filter_event'] ?? '')
|
||||
);
|
||||
$id_group_filter = get_parameter(
|
||||
'filter[id_group_filter]',
|
||||
($filter['id_group'] ?? '')
|
||||
|
@ -1334,6 +1338,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false
|
|||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = ($filter['search_secondary_groups'] ?? 0);
|
||||
$private_filter_event = ($filter['private_filter_user'] ?? 0);
|
||||
$search_recursive_groups = ($filter['search_recursive_groups'] ?? 0);
|
||||
$id_group_filter = $filter['id_group_filter'];
|
||||
$date_from = $filter['date_from'];
|
||||
|
@ -1886,6 +1891,9 @@ if (enterprise_hook(
|
|||
* Load filter form.
|
||||
*/
|
||||
|
||||
// User private filter process.
|
||||
$inputs[] = html_print_input_hidden('id_filter_event', $load_filter_id, true);
|
||||
|
||||
// Group.
|
||||
if ($id_group === null) {
|
||||
$id_group = 0;
|
||||
|
@ -1919,7 +1927,7 @@ $data = html_print_checkbox_switch(
|
|||
|
||||
$in_group = '<div class="display-initial">';
|
||||
$in_group .= $data;
|
||||
$in_group .= '<label class="vert-align-bottom pdd_r_20px">';
|
||||
$in_group .= '<label class="vert-align-bottom pdd_r_15px">';
|
||||
$in_group .= __('Group recursion');
|
||||
$in_group .= ui_print_help_tip(
|
||||
__('WARNING: This could cause a performace impact.'),
|
||||
|
@ -2070,6 +2078,8 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
|||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// User private filter.
|
||||
$inputs[] = html_print_input_hidden('private_filter_event', $private_filter_event, true);
|
||||
// Trick view in table.
|
||||
$inputs[] = '<div class="w100p pdd_t_15px"></div>';
|
||||
|
||||
|
@ -3363,7 +3373,8 @@ $(document).ready( function() {
|
|||
data: {
|
||||
page: 'include/ajax/events',
|
||||
save_filter_modal: 1,
|
||||
current_filter: $('#latest_filter_id').val()
|
||||
current_filter: $('#hidden-id_filter_event').val(),
|
||||
private_filter_event: $('#hidden-private_filter_event').val()
|
||||
},
|
||||
success: function (data){
|
||||
$('#save-modal-filter')
|
||||
|
|
|
@ -1301,6 +1301,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
|
|||
`custom_data` VARCHAR(500) DEFAULT '',
|
||||
`custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0,
|
||||
`owner_user` TEXT,
|
||||
`private_filter_user` TEXT,
|
||||
PRIMARY KEY (`id_filter`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
|
|
Loading…
Reference in New Issue