From f01902903c4e006765c9ad3541ee4fb7f1bbb115 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 13:38:29 +0100 Subject: [PATCH 1/3] #12789 fixed regex in event table --- .../include/javascript/datatablesFunction.js | 16 +++++++++- pandora_console/operation/events/events.php | 31 ++++++++++--------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/javascript/datatablesFunction.js b/pandora_console/include/javascript/datatablesFunction.js index b517830ce9..dae44dd6b1 100644 --- a/pandora_console/include/javascript/datatablesFunction.js +++ b/pandora_console/include/javascript/datatablesFunction.js @@ -1,3 +1,5 @@ +/* global $ */ + var dt = dt; var config = config; @@ -141,6 +143,8 @@ if (dt.no_move_elements_to_action === true) { noMoveElementsToAction = true; } +var showAlwaysPagination = false; + $(document).ready(function() { function checkPages() { if (dt_table.page.info().pages > 1) { @@ -253,7 +257,11 @@ $(document).ready(function() { $("div.pagination-child-div").hide(); $("div.dataTables_info").hide(); $(`#${dt.id}_wrapper`).hide(); - $(`.action_buttons_right_content .pagination-child-div`).hide(); + if (showAlwaysPagination) { + $(`.action_buttons_right_content .pagination-child-div`).show(); + } else { + $(`.action_buttons_right_content .pagination-child-div`).hide(); + } } else { $(`.datatable-msg-info-${dt.id}`).hide(); $(`table#${dt.id}`).show(); @@ -283,6 +291,12 @@ $(document).ready(function() { $(`#${dt.form_id}_loading`).remove(); } + if (json.showAlwaysPagination) { + showAlwaysPagination = true; + } else { + showAlwaysPagination = false; + } + if (json.error) { console.error(json.error); $(`#error-${dt.id}`).html(json.error); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index c9962483f5..1086b8f908 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1229,26 +1229,28 @@ if (is_ajax() === true) { } } - $no_return = false; + $regex_validation = false; if (empty($tmp) === false && $regex !== '') { - $regex_validation = false; foreach (json_decode(json_encode($tmp), true) as $key => $field) { + if ($key === 'b64') { + continue; + } + + $field = strip_tags($field); + if (preg_match('/'.$regex.'/', $field)) { $regex_validation = true; } } - if ($regex_validation === false) { - $no_return = true; + if ($regex_validation === true) { + $carry[] = $tmp; } + } else { + $carry[] = $tmp; } - if ($no_return === false) { - $carry[] = $tmp; - return $carry; - } else { - return; - } + return $carry; } ); } @@ -1256,10 +1258,11 @@ if (is_ajax() === true) { // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ - 'data' => ($data ?? []), - 'buffers' => $buffers, - 'recordsTotal' => $count, - 'recordsFiltered' => $count, + 'data' => ($data ?? []), + 'buffers' => $buffers, + 'recordsTotal' => $count, + 'recordsFiltered' => $count, + 'showAlwaysPagination' => (empty($regex) === false) ? true : false, ] ); } catch (Exception $e) { From 1738a06cf20ce34c2f298c16e508ea254951b4bb Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 13:42:09 +0100 Subject: [PATCH 2/3] #12789 added tip in regex search --- pandora_console/operation/events/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 1086b8f908..e99ac14fca 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2109,7 +2109,7 @@ $in .= $data.''; $inputs[] = $in; // REGEX search datatable. -$in = '
'; +$in = '
'; $in .= html_print_input_text('regex', $regex, '', '', 255, true); $in .= '
'; $inputs[] = $in; From 4971c29819b43d1c3279e071532955324c0c6eca Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 30 Jan 2024 09:25:17 +0100 Subject: [PATCH 3/3] #12789 fixed pagination in events --- pandora_console/operation/events/events.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index a1529ebcaf..76ec9d8e8e 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1255,15 +1255,17 @@ if (is_ajax() === true) { ); } - $data = array_values( - array_filter( - ($data ?? []), - function ($item) { - return (bool) (array) $item; - } - ) - ); - $count = count($data); + if ($regex !== '') { + $data = array_values( + array_filter( + ($data ?? []), + function ($item) { + return (bool) (array) $item; + } + ) + ); + } + // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [