From 7918b883aa7d549e48c8c17a5eb87ca407ddd611 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 29 Nov 2021 16:12:15 +0100 Subject: [PATCH] Set the last grouped comments to last events fired --- pandora_console/include/ajax/events.php | 23 +++++++------------ .../include/javascript/pandora_events.js | 7 ++++-- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 8533902238..c8813ab01c 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1225,26 +1225,19 @@ if ($dialogue_event_response) { } } -if ($add_comment) { - $aviability_comment = true; - $comment = get_parameter('comment'); +if ($add_comment === true) { + $comment = (string) get_parameter('comment'); + $eventId = (int) get_parameter('event_id'); + + // Safe comments for hacks. if (preg_match('/script/i', io_safe_output($comment))) { - $aviability_comment = false; $return = false; - } - - $event_id = get_parameter('event_id'); - - if ($aviability_comment !== false) { - $return = events_comment($event_id, $comment, 'Added comment', $meta, $history); - } - - if ($return) { - echo 'comment_ok'; } else { - echo 'comment_error'; + $return = events_comment($eventId, $comment, 'Added comment', $meta, $history); } + echo ($return === true) ? 'comment_ok' : 'comment_error'; + return; } diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index b5d684324c..19970e76dc 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -576,7 +576,6 @@ function event_comment(current_event) { return; } - var event_id = event.id_evento; var comment = $("#textarea_comment").val(); var meta = 0; if ($("#hidden-meta").val() != undefined) { @@ -596,7 +595,11 @@ function event_comment(current_event) { var params = []; params.push("page=include/ajax/events"); params.push("add_comment=1"); - params.push("event_id=" + event_id); + if (event.event_rep > 0) { + params.push("event_id=" + event.max_id_evento); + } else { + params.push("event_id=" + event.id_evento); + } params.push("comment=" + comment); params.push("meta=" + meta); params.push("history=" + history);