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('
', $comments); + case 'old': + $comm = explode('
', $comments); - // Split comments and put in table. - $col = 0; - $data = []; - - foreach ($comm as $c) { - switch ($col) { - case 0: - $row_text = preg_replace('/\s*--\s*/', '', $c); - $row_text = preg_replace('/\<\/b\>/', '', $row_text); - $row_text = preg_replace('/\[/', '

[', $row_text); - $row_text = preg_replace('/[\[|\]]/', '', $row_text); - break; - - case 1: - $row_text = preg_replace("/[\r\n|\r|\n]/", '
', io_safe_output(strip_tags($c))); - break; - - default: - // Ignore. - break; - } - - $data[$col] = $row_text; - - $col++; - - if ($col == 2) { - $col = 0; - $table_comments->data[] = $data; - $data = []; - } - } - - if (count($comm) == 1 && $comm[0] == '') { - $table_comments->style[0] = 'text-align:center;'; - $table_comments->colspan[0][0] = 2; + // Split comments and put in table. + $col = 0; $data = []; - $data[0] = __('There are no comments'); - $table_comments->data[] = $data; - } - break; - default: - // Ignore. - break; + foreach ($comm as $c) { + switch ($col) { + case 0: + $row_text = preg_replace('/\s*--\s*/', '', $c); + $row_text = preg_replace('/\<\/b\>/', '
', $row_text); + $row_text = preg_replace('/\[/', '

[', $row_text); + $row_text = preg_replace('/[\[|\]]/', '', $row_text); + break; + + case 1: + $row_text = preg_replace("/[\r\n|\r|\n]/", '
', io_safe_output(strip_tags($c))); + break; + + default: + // Ignore. + break; + } + + $data[$col] = $row_text; + + $col++; + + if ($col == 2) { + $col = 0; + $table_comments->data[] = $data; + $data = []; + } + } + break; + + default: + // Ignore. + break; + } } } diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index d9b4b992e5..6d9ab35492 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -118,22 +118,12 @@ sub help_screen{ help_screen_line('--get_planned_downtimes_items', ' [ ]', 'Get all items of planned downtimes'); help_screen_line('--set_planned_downtimes_deleted', ' ', 'Deleted a planned downtime'); help_screen_line('--get_module_id', ' ', 'Get the id of an module'); -<<<<<<< HEAD - help_screen_line('--get_agent_group', '', 'Get the group name of an agent'); - help_screen_line('--get_agent_group_id', '', 'Get the group ID of an agent'); - help_screen_line('--get_agent_modules', '', 'Get the modules of an agent'); - help_screen_line('--get_agents_id_name_by_alias', '', '[]', 'List id and alias of agents mathing given alias'); - help_screen_line('--get_agents', '[ ]', "Get \n\t list of agents with optative filter parameters"); - help_screen_line('--delete_conf_file', '', 'Delete a local conf of a given agent'); - help_screen_line('--clean_conf_file', '', "Clean a local conf of a given agent deleting all modules, \n\t policies, file collections and comments"); -======= help_screen_line('--get_agent_group', ' []', 'Get the group name of an agent'); help_screen_line('--get_agent_group_id', ' []', 'Get the group ID of an agent'); help_screen_line('--get_agent_modules', ' []', 'Get the modules of an agent'); help_screen_line('--get_agents', '[ ]', "Get \n\t list of agents with optative filter parameters"); help_screen_line('--delete_conf_file', ' []', 'Delete a local conf of a given agent'); help_screen_line('--clean_conf_file', ' []', "Clean a local conf of a given agent deleting all modules, \n\t policies, file collections and comments"); ->>>>>>> origin/develop help_screen_line('--get_bad_conf_files', '', 'Get the files bad configured (without essential tokens)'); help_screen_line('--locate_agent', ' []', 'Search a agent into of nodes of metaconsole. Only Enterprise.'); help_screen_line('--migration_agent_queue', ' []', 'Migrate agent only metaconsole'); @@ -4095,9 +4085,6 @@ sub cli_create_event() { $id_alert_agent_module = 0; } - if (defined($comment) && $comment ne '') { - $comment = '-- Added comment by '.$user_name. ' ['. localtime(time).'] --
'.$comment.'
'; - } print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n"; # Base64 encode custom data @@ -4148,9 +4135,6 @@ sub cli_create_event() { $id_alert_agent_module = 0; } - if (defined($comment) && $comment ne '') { - $comment = '-- Added comment by '.$user_name. ' ['. localtime(time).'] --
'.$comment.'
'; - } print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n"; # Base64 encode custom data