diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 666d23d244..7237cbbefb 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -100,76 +100,10 @@ if ($get_comments === true) {
return __('Failed to retrieve comments');
}
- $eventsGrouped = [];
- // Consider if the event is grouped.
- $whereGrouped = '1=1';
- if ($group_rep === EVENT_GROUP_REP_EVENTS && $event_rep > 1) {
- // Default grouped message filtering (evento and estado).
- $whereGrouped = sprintf(
- '`evento` = "%s"',
- $event['evento']
- );
-
- // If id_agente is reported, filter the messages by them as well.
- if ((int) $event['id_agente'] > 0) {
- $whereGrouped .= sprintf(
- ' AND `id_agente` = %d',
- (int) $event['id_agente']
- );
- }
-
- if ((int) $event['id_agentmodule'] > 0) {
- $whereGrouped .= sprintf(
- ' AND `id_agentmodule` = %d',
- (int) $event['id_agentmodule']
- );
- }
- } else if ($group_rep === EVENT_GROUP_REP_EXTRAIDS) {
- $whereGrouped = sprintf(
- '`id_extra` = "%s"',
- io_safe_output($event['id_extra'])
- );
- } else {
- $whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']);
- }
-
- try {
- if (is_metaconsole() === true
- && $event['server_id'] > 0
- ) {
- $node = new Node($event['server_id']);
- $node->connect();
- }
-
- $sql = sprintf(
- 'SELECT `user_comment`
- FROM tevento
- WHERE %s',
- $whereGrouped
- );
-
- // Get grouped comments.
- $eventsGrouped = db_get_all_rows_sql($sql);
- } catch (\Exception $e) {
- // Unexistent agent.
- if (is_metaconsole() === true
- && $event['server_id'] > 0
- ) {
- $node->disconnect();
- }
-
- $eventsGrouped = [];
- } finally {
- if (is_metaconsole() === true
- && $event['server_id'] > 0
- ) {
- $node->disconnect();
- }
- }
+ $eventsGrouped = event_get_comment($event, $group_rep, $event_rep);
// End of get_comments.
echo events_page_comments($event, true, $eventsGrouped);
-
return;
}
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index 77b2f9e3fa..5810df39dc 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -15744,6 +15744,8 @@ function api_get_cluster_items($cluster_id)
*/
function api_set_create_event_filter($name, $thrash1, $other, $thrash3)
{
+ global $config;
+
if ($name == '') {
returnError(
'The event filter could not be created. Event filter name cannot be left blank.'
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 3a6128e234..8498584e69 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -749,7 +749,7 @@ function events_get_all(
if (isset($from) === false) {
if (isset($filter['event_view_hr']) === true && ($filter['event_view_hr'] > 0)) {
$sql_filters[] = sprintf(
- ' AND utimestamp > UNIX_TIMESTAMP(now() - INTERVAL %d HOUR) ',
+ ' AND te.utimestamp > UNIX_TIMESTAMP(now() - INTERVAL %d HOUR) ',
$filter['event_view_hr']
);
}
@@ -1069,7 +1069,6 @@ function events_get_all(
$array_search = [
'te.id_evento',
'lower(te.evento)',
- 'lower(te.user_comment)',
'lower(te.id_extra)',
'lower(te.source)',
'lower('.$custom_data_search.')',
@@ -1106,7 +1105,6 @@ function events_get_all(
' AND (lower(ta.alias) not like lower("%%%s%%")
AND te.id_evento not like "%%%s%%"
AND lower(te.evento) not like lower("%%%s%%")
- AND lower(te.user_comment) not like lower("%%%s%%")
AND lower(te.id_extra) not like lower("%%%s%%")
AND lower(te.source) not like lower("%%%s%%") )',
array_fill(0, 6, $filter['search_exclude'])
@@ -1122,16 +1120,13 @@ function events_get_all(
}
// User comment.
+ $event_comment_join = '';
if (empty($filter['user_comment']) === false) {
- // For filter field.
+ $event_comment_join = 'INNER JOIN tevent_comment ON te.id_evento = tevent_comment.id_event';
$sql_filters[] = sprintf(
- ' AND lower(te.user_comment) like lower("%%%s%%") ',
- io_safe_input($filter['user_comment'])
- );
-
- // For show comments on event details.
- $sql_filters[] = sprintf(
- ' OR lower(te.user_comment) like lower("%%%s%%") ',
+ ' AND (lower(tevent_comment.comment) like lower("%%%s%%")
+ OR lower(tevent_comment.comment) like lower("%%%s%%"))',
+ io_safe_input($filter['user_comment']),
$filter['user_comment']
);
}
@@ -1455,7 +1450,7 @@ function events_get_all(
' LIMIT %d',
$config['max_number_of_events_per_node']
);
- } else if (isset($limit, $offset) === true && $limit > 0) {
+ } else if (isset($limit, $offset) === true && empty($limit) === false && $limit > 0) {
$pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset);
}
@@ -1552,36 +1547,20 @@ function events_get_all(
$group_selects = '';
if ($group_by != '') {
if ($count === false) {
- $idx = array_search('te.user_comment', $fields);
- if ($idx !== false) {
- unset($fields[$idx]);
- }
-
- db_process_sql('SET group_concat_max_len = 9999999');
-
$group_selects = sprintf(
',COUNT(id_evento) AS event_rep,
- %s
- MAX(utimestamp) as timestamp_last,
- MIN(utimestamp) as timestamp_first,
- MAX(id_evento) as max_id_evento',
- ($idx !== false) ? 'GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
") AS comments,' : ''
+ MAX(te.utimestamp) as timestamp_last,
+ MIN(te.utimestamp) as timestamp_first,
+ MAX(id_evento) as max_id_evento'
);
$group_selects_trans = sprintf(
',tmax_event.event_rep,
- %s
tmax_event.timestamp_last,
tmax_event.timestamp_first,
- tmax_event.max_id_evento',
- ($idx !== false) ? 'tmax_event.comments,' : ''
+ tmax_event.max_id_evento'
);
}
- } else {
- $idx = array_search('te.user_comment', $fields);
- if ($idx !== false) {
- $fields[$idx] = 'te.user_comment AS comments';
- }
}
if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
@@ -1596,11 +1575,12 @@ function events_get_all(
FROM %s
%s
%s
+ %s
%s JOIN %s ta
- ON ta.%s = te.id_agente
+ ON ta.%s = te.id_agente
%s
%s JOIN tgrupo tg
- ON %s
+ ON %s
WHERE 1=1
%s
%s
@@ -1611,6 +1591,7 @@ function events_get_all(
ON te.id_evento = tmax_event.max_id_evento
%s
%s
+ %s
%s JOIN %s ta
ON ta.%s = te.id_agente
%s
@@ -1625,6 +1606,7 @@ function events_get_all(
$tevento,
$event_lj,
$agentmodule_join,
+ $event_comment_join,
$tagente_join,
$tagente_table,
$tagente_field,
@@ -1638,6 +1620,7 @@ function events_get_all(
$having,
$event_lj,
$agentmodule_join,
+ $event_comment_join,
$tagente_join,
$tagente_table,
$tagente_field,
@@ -1654,6 +1637,7 @@ function events_get_all(
FROM %s
%s
%s
+ %s
%s JOIN %s ta
ON ta.%s = te.id_agente
%s
@@ -1671,6 +1655,7 @@ function events_get_all(
$tevento,
$event_lj,
$agentmodule_join,
+ $event_comment_join,
$tagente_join,
$tagente_table,
$tagente_field,
@@ -2238,91 +2223,18 @@ function events_comment(
$first_event = reset($id_event);
}
- $sql = sprintf(
- 'SELECT user_comment
- FROM tevento
- WHERE id_evento = %d',
- $first_event
+ // Update comment.
+ $ret = db_process_sql_insert(
+ 'tevent_comment',
+ [
+ 'id_event' => $first_event,
+ 'comment' => $comment,
+ 'action' => $action,
+ 'utimestamp' => time(),
+ 'id_user' => $config['id_user'],
+ ],
);
- $event_comments = db_get_all_rows_sql($sql);
- $event_comments_array = [];
-
- if ($event_comments[0]['user_comment'] == '') {
- $comments_format = 'new';
- } else {
- // If comments are not stored in json, the format is old.
- $event_comments[0]['user_comment'] = str_replace(
- [
- "\n",
- '
',
- ],
- '
',
- $event_comments[0]['user_comment']
- );
- $event_comments_array = json_decode($event_comments[0]['user_comment']);
-
- if (empty($event_comments_array) === true) {
- $comments_format = 'old';
- } else {
- $comments_format = 'new';
- }
- }
-
- switch ($comments_format) {
- case 'new':
- $comment_for_json['comment'] = io_safe_input($comment);
- $comment_for_json['action'] = $action;
- $comment_for_json['id_user'] = $config['id_user'];
- $comment_for_json['utimestamp'] = time();
- $comment_for_json['event_id'] = $first_event;
-
- $event_comments_array[] = $comment_for_json;
-
- $event_comments = io_json_mb_encode($event_comments_array);
-
- // Update comment.
- $ret = db_process_sql_update(
- 'tevento',
- ['user_comment' => $event_comments],
- ['id_evento' => implode(',', $id_event)]
- );
- break;
-
- case 'old':
- // Give old ugly format to comment.
- // Change this method for aux table or json.
- $comment = str_replace(["\r\n", "\r", "\n"], '
', $comment);
-
- if ($comment !== '') {
- $commentbox = '
';
- } else {
- $commentbox = '';
- }
-
- // Don't translate 'by' word because if multiple users with
- // different languages make comments in the same console
- // will be a mess.
- $comment = '-- '.$action.' by '.$config['id_user'].' ['.date($config['date_format']).'] --
'.$commentbox.'
';
-
- // Update comment.
- $sql_validation = sprintf(
- 'UPDATE %s
- SET user_comment = concat("%s", user_comment)
- WHERE id_evento in (%s)',
- 'tevento',
- $comment,
- implode(',', $id_event)
- );
-
- $ret = db_process_sql($sql_validation);
- break;
-
- default:
- // Ignore.
- break;
- }
-
if (($ret === false) || ($ret === 0)) {
return false;
}
@@ -5059,8 +4971,12 @@ function events_page_general($event)
}
$data[1] = $user_ack.' ( ';
+ // hd($config['date_format'], true);
+ // hd($event['ack_utimestamp_raw'], true);
+ // TODO: mirar en el manage y en la api que este ack de venir vacio lo herede del anterior que hubiera.
if ($event['ack_utimestamp_raw'] !== false
&& $event['ack_utimestamp_raw'] !== 'false'
+ && empty($event['ack_utimestamp_raw']) === false
) {
$data[1] .= date(
$config['date_format'],
@@ -5227,12 +5143,7 @@ function events_page_comments($event, $ajax=false, $groupedComments=[])
$table_comments->head = [];
$table_comments->class = 'table_modal_alternate';
- if (isset($event['user_comment']) === false) {
- $event['user_comment'] = '';
- }
-
- $comments = (empty($groupedComments) === true) ? $event['user_comment'] : $groupedComments;
-
+ $comments = $groupedComments;
if (empty($comments) === true) {
$table_comments->style[0] = 'text-align:left;';
$table_comments->colspan[0][0] = 2;
@@ -5241,49 +5152,7 @@ function events_page_comments($event, $ajax=false, $groupedComments=[])
$table_comments->data[] = $data;
} else {
if (is_array($comments) === true) {
- $comments_array = [];
- foreach ($comments as $comm) {
- if (empty($comm) === true) {
- continue;
- }
-
- // If exists user_comments, come from grouped events and must be handled like this.
- if (isset($comm['user_comment']) === true) {
- $comm = $comm['user_comment'];
- }
-
- $comm = str_replace(["\n", '
'], '
', $comm);
-
- $comments_array[] = io_safe_output(json_decode($comm, true));
- }
-
- // Plain comments. Can be improved.
- $sortedCommentsArray = [];
- foreach ($comments_array as $comm) {
- if (isset($comm) === true
- && empty($comm) === false
- ) {
- foreach ($comm as $subComm) {
- $sortedCommentsArray[] = $subComm;
- }
- }
- }
-
- // Sorting the comments by utimestamp (newer is first).
- usort(
- $sortedCommentsArray,
- function ($a, $b) {
- if ($a['utimestamp'] == $b['utimestamp']) {
- return 0;
- }
-
- return ($a['utimestamp'] > $b['utimestamp']) ? -1 : 1;
- }
- );
-
- // Clean the unsorted comments and return it to the original array.
- $comments_array = [];
- $comments_array[] = $sortedCommentsArray;
+ $comments_array = $comments;
} else {
$comments = str_replace(["\n", '
'], '
', $comments);
// If comments are not stored in json, the format is old.
@@ -5291,73 +5160,23 @@ function events_page_comments($event, $ajax=false, $groupedComments=[])
}
foreach ($comments_array as $comm) {
- $comments_format = (empty($comm) === true && is_array($comments) === false) ? 'old' : 'new';
+ $eventIdExplanation = (empty($groupedComments) === false) ? sprintf(' (#%d)', $comm['id_event']) : '';
+ $data[0] = sprintf(
+ '%s %s %s%s',
+ $comm['action'],
+ __('by'),
+ get_user_fullname(io_safe_input($comm['id_user'])).' ('.io_safe_input($comm['id_user']).')',
+ $eventIdExplanation
+ );
- switch ($comments_format) {
- case 'new':
- foreach ($comm as $c) {
- $eventIdExplanation = (empty($groupedComments) === false) ? sprintf(' (#%d)', $c['event_id']) : '';
+ $data[0] .= sprintf(
+ '
%s',
+ date($config['date_format'], $comm['utimestamp'])
+ );
- $data[0] = sprintf(
- '%s %s %s%s',
- $c['action'],
- __('by'),
- get_user_fullname(io_safe_input($c['id_user'])).' ('.io_safe_input($c['id_user']).')',
- $eventIdExplanation
- );
+ $data[1] = ''.stripslashes(str_replace(['\n', '\r'], '
', $comm['comment'])).'
';
- $data[0] .= sprintf(
- '
%s',
- date($config['date_format'], $c['utimestamp'])
- );
-
- $data[1] = ''.stripslashes(str_replace(['\n', '\r'], '
', $c['comment'])).'
';
-
- $table_comments->data[] = $data;
- }
- break;
-
- 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 = [];
- }
- }
- break;
-
- default:
- // Ignore.
- break;
- }
+ $table_comments->data[] = $data;
}
}
@@ -5540,7 +5359,7 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
break;
case 'comment':
- $sort_field_translated = 'user_comment';
+ $sort_field_translated = 'tevent_comment.comment';
break;
case 'extra_id':
@@ -6112,3 +5931,108 @@ function get_count_event_criticity(
return db_get_all_rows_sql($sql_meta);
}
+
+
+/**
+ * Comments for this events.
+ *
+ * @param array $event Info event.
+ * @param integer $mode Mode group by.
+ * @param integer $event_rep Events.
+ *
+ * @return array Comments.
+ */
+function event_get_comment($event, $mode, $event_rep)
+{
+ $eventsGrouped = [];
+ // Consider if the event is grouped.
+ $whereGrouped = '1=1';
+ if ($mode === EVENT_GROUP_REP_EVENTS && $event_rep > 1) {
+ // Default grouped message filtering (evento and estado).
+ $whereGrouped = sprintf(
+ '`tevento`.`evento` = "%s"',
+ $event['evento']
+ );
+
+ // If id_agente is reported, filter the messages by them as well.
+ if ((int) $event['id_agente'] > 0) {
+ $whereGrouped .= sprintf(
+ ' AND `tevento`.`id_agente` = %d',
+ (int) $event['id_agente']
+ );
+ }
+
+ if ((int) $event['id_agentmodule'] > 0) {
+ $whereGrouped .= sprintf(
+ ' AND `tevento`.`id_agentmodule` = %d',
+ (int) $event['id_agentmodule']
+ );
+ }
+ } else if ($mode === EVENT_GROUP_REP_EXTRAIDS) {
+ $whereGrouped = sprintf(
+ '`tevento`.`id_extra` = "%s"',
+ io_safe_output($event['id_extra'])
+ );
+ } else {
+ $whereGrouped = sprintf('`tevento`.`id_evento` = %d', $event['id_evento']);
+ }
+
+ try {
+ if (is_metaconsole() === true
+ && $event['server_id'] > 0
+ ) {
+ $node = new Node($event['server_id']);
+ $node->connect();
+ }
+
+ $sql = sprintf(
+ 'SELECT tevent_comment.*
+ FROM tevento
+ INNER JOIN tevent_comment
+ ON tevento.id_evento = tevent_comment.id_event
+ WHERE %s
+ ORDER BY tevent_comment.utimestamp DESC',
+ $whereGrouped
+ );
+
+ // Get grouped comments.
+ $eventsGrouped = db_get_all_rows_sql($sql);
+ } catch (\Exception $e) {
+ // Unexistent agent.
+ if (is_metaconsole() === true
+ && $event['server_id'] > 0
+ ) {
+ $node->disconnect();
+ }
+
+ $eventsGrouped = [];
+ } finally {
+ if (is_metaconsole() === true
+ && $event['server_id'] > 0
+ ) {
+ $node->disconnect();
+ }
+ }
+
+ return $eventsGrouped;
+}
+
+
+/**
+ * Last comment for this event.
+ *
+ * @param array $event Info event.
+ * @param integer $mode Mode group by.
+ * @param integer $event_rep Events.
+ *
+ * @return string Comment.
+ */
+function event_get_last_comment($event, $mode, $event_rep)
+{
+ $comments = event_get_comment($event, (int) $mode, $event_rep);
+ if (empty($comments) === false) {
+ return $comments[0];
+ }
+
+ return '';
+}
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index f50f2d56e4..b7018ac43d 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -7302,63 +7302,36 @@ function ui_print_breadcrums($tab_name)
*
* @return string HTML string with the last comment of the events.
*/
-function ui_print_comments($comments)
+function ui_print_comments($comment)
{
global $config;
- $comments = explode('
', $comments);
- $comments = str_replace(["\n", '
'], '
', $comments);
- if (is_array($comments)) {
- foreach ($comments as $comm) {
- if (empty($comm)) {
- continue;
- }
-
- $comments_array[] = io_safe_output(json_decode($comm, true));
- }
- }
-
- $order_utimestamp = array_reduce(
- $comments_array,
- function ($carry, $item) {
- foreach ($item as $k => $v) {
- $carry[$v['utimestamp']] = $v;
- }
-
- return $carry;
- }
- );
-
- $key_max_utimestamp = max(array_keys($order_utimestamp));
-
- $last_comment = $order_utimestamp[$key_max_utimestamp];
-
- if (empty($last_comment) === true) {
+ if (empty($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['action'] != 'Added comment') {
- $last_comment['comment'] = $last_comment['action'];
+ if ($comment['action'] != 'Added comment') {
+ $comment['comment'] = $comment['action'];
}
- $short_comment = substr($last_comment['comment'], 0, 20);
+ $short_comment = substr($comment['comment'], 0, 20);
if ($config['prominent_time'] == 'timestamp') {
- $comentario = ''.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$last_comment['comment'].'';
+ $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$comment['comment'].'';
if (strlen($comentario) > '200px') {
- $comentario = ''.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$short_comment.'...';
+ $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$short_comment.'...';
}
} else {
- $rest_time = (time() - $last_comment['utimestamp']);
+ $rest_time = (time() - $comment['utimestamp']);
$time_last = (($rest_time / 60) / 60);
- $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).' Hours ('.$last_comment['id_user'].'): '.$last_comment['comment'].'';
+ $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).' Hours ('.$comment['id_user'].'): '.$comment['comment'].'';
if (strlen($comentario) > '200px') {
- $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).' Hours ('.$last_comment['id_user'].'): '.$short_comment.'...';
+ $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).' Hours ('.$comment['id_user'].'): '.$short_comment.'...';
}
}
diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php
index adc9b3234e..ad9725825d 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php
@@ -528,7 +528,7 @@ class EventsListWidget extends Widget
$values['eventType'] = \get_parameter('eventType', 0);
$values['maxHours'] = \get_parameter('maxHours', 8);
- $values['limit'] = \get_parameter('limit', 20);
+ $values['limit'] = (int) \get_parameter('limit', 20);
$values['eventStatus'] = \get_parameter('eventStatus', -1);
$values['severity'] = \get_parameter_switch('severity', -1);
$values['groupId'] = \get_parameter_switch('groupId', []);
@@ -708,6 +708,10 @@ class EventsListWidget extends Widget
$hash = get_parameter('auth_hash', '');
$id_user = get_parameter('id_user', '');
+ if ($this->values['limit'] === 'null') {
+ $this->values['limit'] = $config['block_size'];
+ }
+
// Print datatable.
$output .= ui_print_datatable(
[
diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css
index 9ed5784026..d27ff6db4c 100755
--- a/pandora_console/mobile/include/style/main.css
+++ b/pandora_console/mobile/include/style/main.css
@@ -496,6 +496,10 @@ table.event_details td.cell_event_name {
font-size: 14px;
}
+table.event_details td.cell_event_comments {
+ height: auto;
+}
+
#validate_button {
margin: 10px auto;
padding: 0;
diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php
index 681de8445f..c03516f2d6 100644
--- a/pandora_console/mobile/operation/events.php
+++ b/pandora_console/mobile/operation/events.php
@@ -485,22 +485,16 @@ class Events
$event['tags'] = ''.__('N/A').'';
}
- $event_comments = db_get_value(
- 'user_comment',
- 'tevento',
- 'id_evento',
- $id_event
+ $event_comments_array = db_get_all_rows_sql(
+ sprintf(
+ 'SELECT * FROM tevent_comment where id_event = %d',
+ $id_event
+ )
);
- $event_comments_array = [];
- $event_comments_array = json_decode(
- $event_comments,
- true
- );
- // Support for new format only.
if (empty($event_comments_array) === true) {
$comment = ''.__('N/A').'';
} else {
- $comment = '';
+ $comment = '';
$event_comments_array = array_reverse(
$event_comments_array
);
@@ -521,6 +515,8 @@ class Events
);
$comment .= '
'.$c['comment'].'
';
}
+
+ $comment .= '
';
}
$event['comments'] = $comment;
diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php
index f7744056bd..103d65f85c 100755
--- a/pandora_console/operation/events/events.build_query.php
+++ b/pandora_console/operation/events/events.build_query.php
@@ -223,10 +223,6 @@ if ($id_extra != '') {
$sql_post .= " AND id_extra LIKE '%$id_extra%'";
}
-if ($user_comment != '') {
- $sql_post .= " AND user_comment LIKE '%$user_comment%'";
-}
-
if ($source != '') {
$sql_post .= " AND source LIKE '%$source%'";
}
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 696a85d40c..c1b930b2e3 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -330,7 +330,7 @@ if (is_ajax() === true) {
$groupRecursion = (bool) get_parameter('groupRecursion', false);
// Datatables offset, limit.
- $start = get_parameter('start', 0);
+ $start = (int) get_parameter('start', 0);
$length = get_parameter(
'length',
$config['block_size']
@@ -368,13 +368,6 @@ if (is_ajax() === true) {
'ta.direccion',
];
- if (strpos($config['event_fields'], 'user_comment') !== false
- || empty($user_comment) === false
- || empty($search) === false
- ) {
- $fields[] = 'te.user_comment';
- }
-
$order = get_datatable_order(true);
if (is_array($order) === true && $order['field'] === 'mini_severity') {
@@ -462,7 +455,7 @@ if (is_ajax() === true) {
$data = array_reduce(
$events,
- function ($carry, $item) use ($table_id, &$redirection_form_id) {
+ function ($carry, $item) use ($table_id, &$redirection_form_id, $filter) {
global $config;
$tmp = (object) $item;
@@ -504,10 +497,6 @@ if (is_ajax() === true) {
$tmp->module_name = io_safe_output($tmp->module_name);
}
- if (empty($tmp->comments) === false) {
- $tmp->comments = ui_print_comments($tmp->comments);
- }
-
// Show last event.
if (isset($tmp->max_id_evento) === true
&& $tmp->max_id_evento !== $tmp->id_evento
@@ -582,25 +571,13 @@ if (is_ajax() === true) {
$tmp->b64 = base64_encode(json_encode($tmp));
- // Show comments events.
- if (empty($tmp->comments) === false) {
- $tmp->user_comment = $tmp->comments;
- if ($tmp->comments !== 'undefined' && strlen($tmp->comments) > 80) {
- $tmp->user_comment .= ' ';
- $tmp->user_comment .= '