diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql
index 8161c4c2b6..2e87a795dc 100644
--- a/pandora_console/extras/mr/66.sql
+++ b/pandora_console/extras/mr/66.sql
@@ -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);
diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php
index e230055f1e..113c156df3 100644
--- a/pandora_console/godmode/events/event_edit_filter.php
+++ b/pandora_console/godmode/events/event_edit_filter.php
@@ -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
+ )
)
);
diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php
index 533bfe1190..c4f1860e6f 100644
--- a/pandora_console/godmode/events/event_filter.php
+++ b/pandora_console/godmode/events/event_filter.php
@@ -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();
diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 7ccf17938b..f9bf50b7ae 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -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] = ''.__('Filter name').''.$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) {
?>