diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 65adff285a..a5d2e48f5f 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -387,8 +387,6 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal $filter = ['group_rep' => EVENT_GROUP_REP_ALL]; } - hd($filter['group_rep'], true); - switch ($filter['group_rep']) { case EVENT_GROUP_REP_ALL: case EVENT_GROUP_REP_AGENTS: @@ -1543,8 +1541,8 @@ function events_get_all( } } - if (($filter['group_rep'] === EVENT_GROUP_REP_EVENTS - || $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false + if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS + || (int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false ) { $sql = sprintf( 'SELECT %s @@ -1576,7 +1574,9 @@ function events_get_all( %s %s %s JOIN tgrupo tg - ON %s', + ON %s + %s + %s', join(',', $fields), $group_selects_trans, $tevento, @@ -1605,7 +1605,8 @@ function events_get_all( join(' ', $agent_join_filters), $tgrupo_join, join(' ', $tgrupo_join_filters), - join(' ', $sql_filters) + join(' ', $sql_filters), + $order_by ); } else { $sql = sprintf( diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 632069a397..a55d338407 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6510,7 +6510,7 @@ function ui_print_breadcrums($tab_name) /** * Show last comment * - * @param array $comments array with comments + * @param string $comments String with comments. * * @return string HTML string with the last comment of the events. */ @@ -6534,31 +6534,45 @@ function ui_print_comments($comments) foreach ($comments_array as $comm) { // Show the comments more recent first. if (is_array($comm)) { - $last_comment[] = array_reverse($comm); + $order_utimestamp = array_reduce( + $comm, + function ($carry, $item) { + $carry[$item['utimestamp']] = $item; + return $carry; + } + ); + + $key_max_utimestamp = max(array_keys($order_utimestamp)); + + $last_comment = $order_utimestamp[$key_max_utimestamp]; } } + if (empty($last_comment) === true) { + return ''; + } + // Only show the last comment. If commment its too long,the comment will short with ... // If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes. // Else show comments hours ago - if ($last_comment[0][0]['action'] != 'Added comment') { - $last_comment[0][0]['comment'] = $last_comment[0][0]['action']; + if ($last_comment['action'] != 'Added comment') { + $last_comment['comment'] = $last_comment['action']; } - $short_comment = substr($last_comment[0][0]['comment'], 0, 20); + $short_comment = substr($last_comment['comment'], 0, 20); if ($config['prominent_time'] == 'timestamp') { - $comentario = ''.date($config['date_format'], $last_comment[0][0]['utimestamp']).' ('.$last_comment[0][0]['id_user'].'): '.$last_comment[0][0]['comment'].''; + $comentario = ''.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$last_comment['comment'].''; if (strlen($comentario) > '200px') { - $comentario = ''.date($config['date_format'], $last_comment[0][0]['utimestamp']).' ('.$last_comment[0][0]['id_user'].'): '.$short_comment.'...'; + $comentario = ''.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$short_comment.'...'; } } else { - $rest_time = (time() - $last_comment[0][0]['utimestamp']); + $rest_time = (time() - $last_comment['utimestamp']); $time_last = (($rest_time / 60) / 60); - $comentario = ''.number_format($time_last, 0).'  Hours  ('.$last_comment[0][0]['id_user'].'): '.$last_comment[0][0]['comment'].''; + $comentario = ''.number_format($time_last, 0).'  Hours  ('.$last_comment['id_user'].'): '.$last_comment['comment'].''; if (strlen($comentario) > '200px') { - $comentario = ''.number_format($time_last, 0).'  Hours  ('.$last_comment[0][0]['id_user'].'): '.$short_comment.'...'; + $comentario = ''.number_format($time_last, 0).'  Hours  ('.$last_comment['id_user'].'): '.$short_comment.'...'; } }