diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 9563732c68..cb8ef39481 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -4559,116 +4559,98 @@ function events_page_comments($event, $ajax=false)
// Comments.
global $config;
- $comments = '';
-
- $comments = $event['user_comment'];
- if (isset($event['comments'])) {
- $comments = explode('
', $event['comments']);
- }
-
$table_comments = new stdClass;
$table_comments->width = '100%';
$table_comments->data = [];
$table_comments->head = [];
$table_comments->class = 'table_modal_alternate';
- $comments = str_replace(["\n", '
'], '
', $comments);
+ $comments = ($event['user_comment'] ?? '');
- if (is_array($comments)) {
- foreach ($comments as $comm) {
- if (empty($comm)) {
- continue;
- }
-
- $comments_array[] = json_decode(io_safe_output($comm), true);
- }
+ if (empty($comments)) {
+ $table_comments->style[0] = 'text-align:center;';
+ $table_comments->colspan[0][0] = 2;
+ $data = [];
+ $data[0] = __('There are no comments');
+ $table_comments->data[] = $data;
} else {
- // If comments are not stored in json, the format is old.
- $comments_array = json_decode(io_safe_output($comments), true);
- }
-
- foreach ($comments_array as $comm) {
- // Show the comments more recent first.
- if (is_array($comm)) {
- $comm = array_reverse($comm);
- }
-
- if (empty($comm)) {
- $comments_format = 'old';
- } else {
- $comments_format = 'new';
- }
-
- switch ($comments_format) {
- case 'new':
+ if (is_array($comments)) {
+ foreach ($comments as $comm) {
if (empty($comm)) {
- $table_comments->style[0] = 'text-align:center;';
- $table_comments->colspan[0][0] = 2;
- $data = [];
- $data[0] = __('There are no comments');
- $table_comments->data[] = $data;
+ continue;
}
- if (isset($comm) === true
- && is_array($comm) === true
- ) {
+ $comments_array[] = json_decode(io_safe_output($comm), true);
+ }
+ } else {
+ $comments = str_replace(["\n", '
'], '
', $comments);
+ // If comments are not stored in json, the format is old.
+ $comments_array[] = json_decode(io_safe_output($comments), true);
+ }
+
+ foreach ($comments_array as $comm) {
+ // Show the comments more recent first.
+ if (is_array($comm)) {
+ $comm = array_reverse($comm);
+ }
+
+ if (empty($comm)) {
+ $comments_format = 'old';
+ } else {
+ $comments_format = 'new';
+ }
+
+ switch ($comments_format) {
+ case 'new':
foreach ($comm as $c) {
$data[0] = ''.$c['action'].' by '.$c['id_user'].'';
$data[0] .= '
'.date($config['date_format'], $c['utimestamp']).'';
$data[1] = '
'.$c['comment'].'
'; $table_comments->data[] = $data; } - } - break; + break; - case 'old': - $comm = explode('