diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 4cee825ecc..1ecb6dd186 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -339,14 +339,16 @@ function messages_get_message_sent(int $message_id) /** * Counts private messages * - * @param string $user Target user. - * @param boolean $incl_read Whether or not to include read messages. + * @param string $user Target user. + * @param boolean $incl_read Whether or not to include read messages. + * @param boolean $ignore_source Ignore source. * * @return integer The number of messages this user has */ function messages_get_count( string $user='', - bool $incl_read=false + bool $incl_read=false, + bool $ignore_source=false ) { if (empty($user)) { global $config; @@ -361,10 +363,19 @@ function messages_get_count( $read = 'where t.read is null'; } + if ($ignore_source === true) { + $source_sql = ''; + } else { + $source_sql = 'INNER JOIN tnotification_source ns + ON tm.id_source = ns.id + AND ns.enabled = 1'; + } + $sql = sprintf( 'SELECT count(*) FROM ( SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + %s LEFT JOIN tnotification_user nu ON tm.id_mensaje=nu.id_mensaje AND nu.id_user="%s" @@ -377,6 +388,7 @@ function messages_get_count( AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0)) ) t %s', + $source_sql, $user, $user, $user, diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index b284bc3d13..8e6173ca24 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -106,34 +106,69 @@ if ($read_message) { $dst_name = $message['id_usuario_destino']; } - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox filters'; - $table->data = []; + // Parse message chain. + ?> - $table->data[0][0] = __('Sender'); - $table->data[0][1] = $user_name.' '.__('at').' '.ui_print_timestamp( - $message['timestamp'], - true, - ['prominent' => 'timestamp'] - ); +

Conversation with

+

Subject:

- $table->data[1][0] = __('Destination'); - $table->data[1][1] = $dst_name; + array_pop($decoded)[0], + 'date' => array_pop($decoded)[0], + ] + ); + } else { + array_push( + $conversation, + ['message' => $target_str] + ); + } + + $target_str = $decoded[1][0]; + } + + ui_require_css_file('message_edit'); + foreach ($conversation as $row) { + $date = $row['date']; + + if ($date === null) { + $date = date( + $config['date_format'], + $message['timestamp'] + ).' '.$user_name; + } + + $order = [ + "\r\n", + "\n", + "\r", + ]; + $replace = '
'; + $parsed_message = str_replace( + $order, + $replace, + io_safe_output($row['message']) + ); + + echo '
'; + echo '

'.$parsed_message.'

'; + echo ''.$date.''; + echo '
'; + } - $table->data[2][0] = __('Subject'); - $table->data[2][1] = html_print_input_text_extended( - 'subject', - $message['subject'], - 'text-subject', - '', - 50, - 70, - true, - false, - '', - 'readonly' - ); $order = [ "\r\n", @@ -143,16 +178,6 @@ if ($read_message) { $replace = '
'; $parsed_message = str_replace($order, $replace, $message['mensaje']); - $table->data[3][0] = __('Message'); - $table->data[3][1] = html_print_textarea( - 'message', - 15, - 255, - $message['mensaje'], - 'readonly', - true - ); - // Prevent RE: RE: RE:. if (strstr($message['subject'], 'RE:')) { $new_subj = $message['subject']; @@ -166,8 +191,8 @@ if ($read_message) { $message['timestamp'] ).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje']; + echo '
'; - html_print_table($table); echo '
'; echo '
'; @@ -179,7 +204,7 @@ if ($read_message) { echo "
"; html_print_submit_button( - __('Delete'), + __('Delete conversation'), 'delete_btn', false, 'form="delete_message" class="sub delete"' diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 4a6d48a397..9427159432 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -115,13 +115,13 @@ if ($show_sent) { $messages = messages_get_overview_sent('', 'DESC'); } else { // Messages received. - $num_messages = messages_get_count($config['id_user'], true); + $num_messages = messages_get_count($config['id_user'], true, true); if ($num_messages > 0 && !is_ajax()) { - $unread_messages = messages_get_count($config['id_user']); + $unread_messages = messages_get_count($config['id_user'], false, true); echo '

'.__('You have').' '.$unread_messages.' '.__('unread message(s)').'.

'; $messages = messages_get_overview(); } else { - $messages = messages_get_overview('status', 'ASC', false); + $messages = messages_get_overview('status', 'ASC'); } }