Merge branch 'ent-8942-token-para-cambiar-comportamiento-de-la-busqueda-de-grupos-en-filtro-de-eventos' into 'develop'
new filter search eventspandora_enterprise#8942 See merge request artica/pandorafms!5007
This commit is contained in:
commit
5d674b76b6
|
@ -38,4 +38,6 @@ ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAUL
|
|||
|
||||
ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`;
|
||||
|
||||
ALTER TABLE `tevent_filter` ADD COLUMN `search_secondary_groups` INT NOT NULL DEFAULT 0;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -89,6 +89,7 @@ if ($id) {
|
|||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = $filter['search_secondary_groups'];
|
||||
$custom_data = $filter['custom_data'];
|
||||
$custom_data_filter_type = $filter['custom_data_filter_type'];
|
||||
|
||||
|
@ -126,6 +127,7 @@ if ($id) {
|
|||
$tag_without_json = $tag_without_json_clean = json_encode([]);
|
||||
$tag_without_base64 = base64_encode($tag_without_json);
|
||||
$filter_only_alert = '';
|
||||
$search_secondary_groups = 0;
|
||||
}
|
||||
|
||||
if ($update || $create) {
|
||||
|
@ -167,6 +169,8 @@ if ($update || $create) {
|
|||
$tag_without_json = io_safe_input(base64_decode($tag_without_base64));
|
||||
|
||||
$filter_only_alert = get_parameter('filter_only_alert', '');
|
||||
$search_secondary_groups = get_parameter('search_secondary_groups', 0);
|
||||
|
||||
$custom_data = get_parameter('custom_data', '');
|
||||
$custom_data_filter_type = get_parameter('custom_data_filter_type', '');
|
||||
|
||||
|
@ -193,6 +197,7 @@ if ($update || $create) {
|
|||
'id_extra' => $id_extra,
|
||||
'user_comment' => $user_comment,
|
||||
'filter_only_alert' => $filter_only_alert,
|
||||
'search_secondary_groups' => $search_secondary_groups,
|
||||
'custom_data' => $custom_data,
|
||||
'custom_data_filter_type' => $custom_data_filter_type,
|
||||
];
|
||||
|
|
|
@ -356,6 +356,7 @@ if ($save_event_filter) {
|
|||
io_json_mb_encode([])
|
||||
);
|
||||
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
||||
$values['search_secondary_groups'] = get_parameter('search_secondary_groups');
|
||||
$values['id_group_filter'] = get_parameter('id_group_filter');
|
||||
$values['date_from'] = get_parameter('date_from');
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
|
@ -412,6 +413,7 @@ if ($update_event_filter) {
|
|||
io_json_mb_encode([])
|
||||
);
|
||||
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
||||
$values['search_secondary_groups'] = get_parameter('search_secondary_groups');
|
||||
$values['id_group_filter'] = get_parameter('id_group_filter');
|
||||
$values['date_from'] = get_parameter('date_from');
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
|
@ -457,31 +459,32 @@ if ($get_filter_values) {
|
|||
|
||||
if ($event_filter === false) {
|
||||
$event_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
'module_search' => '',
|
||||
'filter_only_alert' => '-1',
|
||||
'user_comment' => '',
|
||||
'id_extra' => '',
|
||||
'id_user_ack' => '',
|
||||
'date_from' => '',
|
||||
'time_from' => '',
|
||||
'date_to' => '',
|
||||
'time_to' => '',
|
||||
'severity' => '',
|
||||
'event_type' => '',
|
||||
'group_rep' => 0,
|
||||
'id_group' => 0,
|
||||
'id_group_filter' => 0,
|
||||
'group_name' => 'All',
|
||||
'text_agent' => '',
|
||||
'id_agent' => 0,
|
||||
'id_name' => 'None',
|
||||
'filter_id' => 0,
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
'module_search' => '',
|
||||
'filter_only_alert' => '-1',
|
||||
'search_secondary_groups' => 0,
|
||||
'user_comment' => '',
|
||||
'id_extra' => '',
|
||||
'id_user_ack' => '',
|
||||
'date_from' => '',
|
||||
'time_from' => '',
|
||||
'date_to' => '',
|
||||
'time_to' => '',
|
||||
'severity' => '',
|
||||
'event_type' => '',
|
||||
'group_rep' => 0,
|
||||
'id_group' => 0,
|
||||
'id_group_filter' => 0,
|
||||
'group_name' => 'All',
|
||||
'text_agent' => '',
|
||||
'id_agent' => 0,
|
||||
'id_name' => 'None',
|
||||
'filter_id' => 0,
|
||||
];
|
||||
} else {
|
||||
$event_filter['module_search'] = io_safe_output(
|
||||
|
@ -649,6 +652,8 @@ function load_form_filter() {
|
|||
$("#hidden-tag_without").val(val);
|
||||
if (i == 'filter_only_alert')
|
||||
$("#filter_only_alert").val(val);
|
||||
if (i == 'search_secondary_groups')
|
||||
$("#checkbox-search_secondary_groups").val(val);
|
||||
if (i == 'id_group_filter')
|
||||
$("#id_group_filter").val(val);
|
||||
if (i == 'source')
|
||||
|
@ -891,6 +896,7 @@ function save_new_filter() {
|
|||
"tag_with": Base64.decode($("#hidden-tag_with").val()),
|
||||
"tag_without": Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
|
||||
"id_group_filter": $("#id_group_filter").val(),
|
||||
"date_from": $("#text-date_from").val(),
|
||||
"time_from": $("#text-time_from").val(),
|
||||
|
@ -966,6 +972,7 @@ function save_update_filter() {
|
|||
"tag_with" : Base64.decode($("#hidden-tag_with").val()),
|
||||
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
|
||||
"id_group_filter": $("#id_group_filter").val(),
|
||||
"date_from": $("#text-date_from").val(),
|
||||
"time_from": $("#text-time_from").val(),
|
||||
|
@ -2467,6 +2474,7 @@ if ($get_events_fired) {
|
|||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'filter_only_alert' => -1,
|
||||
'search_secondary_groups' => 0,
|
||||
'source' => '',
|
||||
'id_extra' => '',
|
||||
'user_comment' => '',
|
||||
|
|
|
@ -626,6 +626,7 @@ function events_update_status($id_evento, $status, $filter=null)
|
|||
* 'tag_with'
|
||||
* 'tag_without'
|
||||
* 'filter_only_alert'
|
||||
* 'search_secondary_groups'
|
||||
* 'module_search'
|
||||
* 'group_rep'
|
||||
* 'server_id'
|
||||
|
@ -904,11 +905,18 @@ function events_get_all(
|
|||
$groups = [ $groups ];
|
||||
}
|
||||
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(',', $groups),
|
||||
join(',', $groups)
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(',', $groups),
|
||||
join(',', $groups)
|
||||
);
|
||||
} else {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo IN (%s)',
|
||||
join(',', $groups)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Skip system messages if user is not PM.
|
||||
|
@ -982,11 +990,18 @@ function events_get_all(
|
|||
$EW_groups = users_get_groups($config['id_user'], 'EW', true, true);
|
||||
|
||||
// Get groups where user have ER grants.
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
|
||||
join(', ', array_keys($ER_groups)),
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
|
||||
join(', ', array_keys($ER_groups)),
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
} else {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo IN ( %s )',
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare agent join sql filters.
|
||||
|
@ -1396,19 +1411,33 @@ function events_get_all(
|
|||
) {
|
||||
$tgrupo_join = 'INNER';
|
||||
if (is_array($groups) === true) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
|
||||
join(', ', $groups),
|
||||
join(', ', $groups)
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
|
||||
join(', ', $groups),
|
||||
join(', ', $groups)
|
||||
);
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))',
|
||||
join(', ', $groups)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group = %s)',
|
||||
$groups,
|
||||
$groups
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group = %s)',
|
||||
$groups,
|
||||
$groups
|
||||
);
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)',
|
||||
$groups
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$tgrupo_join_filters[] = ' te.id_grupo = tg.id_grupo';
|
||||
|
@ -1418,7 +1447,9 @@ function events_get_all(
|
|||
$event_lj = '';
|
||||
if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) {
|
||||
db_process_sql('SET group_concat_max_len = 9999999');
|
||||
$event_lj = events_get_secondary_groups_left_join($table);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$event_lj = events_get_secondary_groups_left_join($table);
|
||||
}
|
||||
}
|
||||
|
||||
$group_selects = '';
|
||||
|
|
|
@ -39,7 +39,7 @@ form.flex-row ul {
|
|||
margin: 0.5em 3em 0.5em 0;
|
||||
}
|
||||
|
||||
div.filter_input_little {
|
||||
form div.filter_input_little {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
@ -132,6 +132,14 @@ table.dataTable tbody td {
|
|||
flex: 1;
|
||||
}
|
||||
|
||||
form.flex-row div.filter_input.filter_input_switch {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
form.flex-row div.filter_input.filter_input_switch .p-slider {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
|
|
@ -169,6 +169,10 @@ $filter_only_alert = get_parameter(
|
|||
'filter[filter_only_alert]',
|
||||
($filter['filter_only_alert'] ?? '')
|
||||
);
|
||||
$search_secondary_groups = get_parameter(
|
||||
'filter[search_secondary_groups]',
|
||||
0
|
||||
);
|
||||
$id_group_filter = get_parameter(
|
||||
'filter[id_group_filter]',
|
||||
($filter['id_group_filter'] ?? '')
|
||||
|
@ -1051,6 +1055,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false
|
|||
$tag_without_base64 = base64_encode(json_encode($tag_without));
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = ($filter['search_secondary_groups'] ?? 0);
|
||||
$id_group_filter = $filter['id_group_filter'];
|
||||
$date_from = $filter['date_from'];
|
||||
$time_from = $filter['time_from'];
|
||||
|
@ -1669,6 +1674,24 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
|||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// Search secondary groups.
|
||||
$data = html_print_checkbox_switch(
|
||||
'search_secondary_groups',
|
||||
$search_secondary_groups,
|
||||
$search_secondary_groups,
|
||||
true,
|
||||
false,
|
||||
'search_in_secondary_groups(this);',
|
||||
true
|
||||
);
|
||||
|
||||
$in = '<div class="filter_input filter_input_switch"><label>'.__('Search in secondary groups').'</label>';
|
||||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// Trick view in table.
|
||||
$inputs[] = '<div style="min-width:32%;"></div>';
|
||||
|
||||
$buttons = [];
|
||||
|
||||
$buttons[] = [
|
||||
|
@ -2933,7 +2956,14 @@ $(document).ready( function() {
|
|||
|
||||
});
|
||||
|
||||
|
||||
function search_in_secondary_groups(element) {
|
||||
var value = $("#checkbox-"+element.name).val();
|
||||
if (value == 0) {
|
||||
$("#checkbox-"+element.name).val(1);
|
||||
} else {
|
||||
$("#checkbox-"+element.name).val(0);
|
||||
}
|
||||
}
|
||||
|
||||
function datetime_picker_callback() {
|
||||
$("#text-time_from, #text-time_to").timepicker({
|
||||
|
|
|
@ -1243,6 +1243,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
|
|||
`tag_with` TEXT,
|
||||
`tag_without` TEXT,
|
||||
`filter_only_alert` INT NOT NULL DEFAULT -1,
|
||||
`search_secondary_groups` INT NOT NULL DEFAULT 0,
|
||||
`date_from` date DEFAULT NULL,
|
||||
`date_to` date DEFAULT NULL,
|
||||
`source` TINYTEXT,
|
||||
|
|
|
@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
|
||||
('custom_report_front_header', ''),
|
||||
('custom_report_front_footer', ''),
|
||||
('MR', 55),
|
||||
('MR', 56),
|
||||
('identification_reminder', 1),
|
||||
('identification_reminder_timestamp', 0),
|
||||
('current_package', 763),
|
||||
('current_package', 764),
|
||||
('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.00097656250000":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'),
|
||||
('custom_docs_logo', 'default_docs.png'),
|
||||
('custom_support_logo', 'default_support.png'),
|
||||
|
|
Loading…
Reference in New Issue