diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 6055e0fdad..8700bce7fb 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4275,7 +4275,7 @@ function events_page_comments($event) // If comments are not stored in json, the format is old. $comments_array = json_decode(io_safe_output($comments), true); - if (json_last_error() != JSON_ERROR_NONE) { + if (!empty($comments) && json_last_error() != JSON_ERROR_NONE) { $comments_array = [ [ 'comment' => 'Error retrieving comments', @@ -4383,9 +4383,26 @@ function events_page_comments($event) $childrens_ids ))) && $config['show_events_in_local'] == false || $config['event_replication'] == false ) { - $comments_form = '
'.html_print_textarea('comment', 3, 10, '', 'style="min-height: 15px; padding:0; width: 100%; disabled"', true); + $comments_form = '
'; + $comments_form .= html_print_textarea( + 'comment', + 3, + 10, + '', + 'style="min-height: 15px; padding:0; width: 100%; disabled"', + true + ); - $comments_form .= '
'.html_print_button(__('Add comment'), 'comment_button', false, 'event_comment();', 'class="sub next"', true).'

'; + $comments_form .= '
'; + $comments_form .= html_print_button( + __('Add comment'), + 'comment_button', + false, + 'event_comment();', + 'class="sub next"', + true + ); + $comments_form .= '

'; } else { $comments_form = ui_print_message( __('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.') diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 11ec207380..4798927536 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1,6 +1,7 @@ /*global jQuery,$,forced_title_callback,Base64, dt_events*/ // Show the modal window of an event +var current_event; function show_event_dialog(event, dialog_page, result) { var ajax_file = $("#hidden-ajax_file").val(); @@ -8,6 +9,8 @@ function show_event_dialog(event, dialog_page, result) { dialog_page = "general"; } + current_event = event; + try { event = JSON.parse(atob(event)); } catch (e) { @@ -56,8 +59,8 @@ function show_event_dialog(event, dialog_page, result) { opacity: 0.5, background: "black" }, - width: 850, - height: 750 + width: 710, + height: 600 }) .show(); @@ -515,19 +518,22 @@ function event_change_owner() { } // Save a comment into an event -function event_comment(e) { - var event_id = $("#hidden-id_event").val(); +function event_comment() { + var event; + try { + event = JSON.parse(atob(current_event)); + } catch (e) { + console.error(e); + return; + } + + var event_id = event.id_evento; var comment = $("#textarea_comment").val(); var meta = $("#hidden-meta").val(); var history = $("#hidden-history").val(); if (comment == "") { - show_event_dialog( - event_id, - $("#hidden-group_rep").val(), - "comments", - "comment_error" - ); + show_event_dialog(current_event, "comments", "comment_error"); return false; } @@ -552,13 +558,8 @@ function event_comment(e) { success: function(data) { $("#button-comment_button").removeAttr("disabled"); $("#response_loading").show(); - - show_event_dialog( - event_id, - $("#hidden-group_rep").val(), - "comments", - data - ); + dt_events.draw(false); + show_event_dialog(current_event, "comments", data); } }); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 68c6553f26..8fa3963d6a 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1616,6 +1616,11 @@ function process_datatables_item(item) { /* Event ID dash */ item.id_evento = "#"+item.id_evento; + /* Owner */ + if (item.owner_user == "0") { + item.owner_user = ''; + } + } /* Datatables auxiliary functions ends */