From 765d7938f90307a324de6bb865c0832ba9f17f8b Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 23 Oct 2020 12:20:20 +0200 Subject: [PATCH] Handled comments for validated comments --- pandora_console/include/ajax/events.php | 4 ++- pandora_console/include/functions_events.php | 36 +++++++++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 230b55a476..d6a760413b 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -114,7 +114,9 @@ if ($get_comments) { sprintf( ' HAVING max_id_evento = %d', $event['id_evento'] - ) + ), + // True for show comments of validated events. + true ); if ($events !== false) { $event = $events[0]; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 7a337fbdab..8efeff3f2e 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -673,15 +673,16 @@ function events_update_status($id_evento, $status, $filter=null, $history=false) /** * Retrieve all events filtered. * - * @param array $fields Fields to retrieve. - * @param array $filter Filters to be applied. - * @param integer $offset Offset (pagination). - * @param integer $limit Limit (pagination). - * @param string $order Sort order. - * @param string $sort_field Sort field. - * @param boolean $history Apply on historical table. - * @param boolean $return_sql Return SQL (true) or execute it (false). - * @param string $having Having filter. + * @param array $fields Fields to retrieve. + * @param array $filter Filters to be applied. + * @param integer $offset Offset (pagination). + * @param integer $limit Limit (pagination). + * @param string $order Sort order. + * @param string $sort_field Sort field. + * @param boolean $history Apply on historical table. + * @param boolean $return_sql Return SQL (true) or execute it (false). + * @param string $having Having filter. + * @param boolean $validatedEvents If true, evaluate validated events. * * @return array Events. * @throws Exception On error. @@ -695,7 +696,8 @@ function events_get_all( $sort_field=null, $history=false, $return_sql=false, - $having='' + $having='', + $validatedEvents=false ) { global $config; @@ -926,10 +928,20 @@ function events_get_all( break; case EVENT_NO_VALIDATED: + // Show comments in validated events. + $validatedState = ''; + if ($validatedEvents === true) { + $validatedState = sprintf( + 'OR estado = %d', + EVENT_VALIDATE + ); + } + $sql_filters[] = sprintf( - ' AND (estado = %d OR estado = %d)', + ' AND (estado = %d OR estado = %d %s)', EVENT_NEW, - EVENT_PROCESS + EVENT_PROCESS, + $validatedState ); break; }