Messages view

This commit is contained in:
Jose Gonzalez 2023-03-07 22:05:06 +01:00
parent 4af67db415
commit 5017878701
2 changed files with 141 additions and 94 deletions

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -52,7 +52,7 @@ $buttons['message_list'] = [
true, true,
[ [
'title' => __('Received messages'), 'title' => __('Received messages'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
).'</a>', ).'</a>',
]; ];
@ -64,7 +64,7 @@ $buttons['sent_messages'] = [
true, true,
[ [
'title' => __('Sent messages'), 'title' => __('Sent messages'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
).'</a>', ).'</a>',
]; ];
@ -76,7 +76,7 @@ $buttons['create_message'] = [
true, true,
[ [
'title' => __('Create message'), 'title' => __('Create message'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
).'</a>', ).'</a>',
]; ];
@ -218,11 +218,8 @@ if ($read_message) {
true true
); );
html_print_div( html_print_action_buttons(
[ $outputButtons
'class' => 'action-buttons',
'content' => $outputButtons,
],
); );
return; return;
@ -264,18 +261,6 @@ if ($send_mes === true) {
// User info. // User info.
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data = [];
$table->data[0][0] = __('Sender');
$table->data[0][1] = (empty($own_info['fullname']) === false) ? $own_info['fullname'] : $config['id_user'];
$table->data[1][0] = __('Destination');
$is_admin = (bool) db_get_value( $is_admin = (bool) db_get_value(
'is_admin', 'is_admin',
'tusuario', 'tusuario',
@ -305,15 +290,29 @@ foreach ($users_full as $user_id => $user_info) {
$users[$user_info['id_user']] = (empty($user_info['fullname']) === true) ? $user_info['id_user'] : $user_info['fullname']; $users[$user_info['id_user']] = (empty($user_info['fullname']) === true) ? $user_info['id_user'] : $user_info['fullname'];
} }
$table = new stdClass();
$table->id = 'send_message_table';
$table->width = '100%';
$table->class = 'databox max_floating_element_size filter-table-adv';
$table->style = [];
$table->style[0] = 'width: 30%';
$table->style[1] = 'width: 70%';
$table->data = [];
$table->data[0][] = html_print_label_input_block(
__('Sender'),
'<span class="result_info_text">'.((empty($own_info['fullname']) === false) ? $own_info['fullname'] : $config['id_user']).'</span>'
);
// Check if the user to reply is in the list, if not add reply user. // Check if the user to reply is in the list, if not add reply user.
if ($reply === true) { if ($reply === true) {
$table->data[1][1] = (array_key_exists($dst_user, $users) === true) ? $users[$dst_user] : $dst_user; $destinationInputs = (array_key_exists($dst_user, $users) === true) ? $users[$dst_user] : $dst_user;
$table->data[1][1] .= html_print_input_hidden( $destinationInputs .= html_print_input_hidden(
'dst_user', 'dst_user',
$dst_user, $dst_user,
true true
); );
$table->data[1][1] .= html_print_input_hidden( $destinationInputs .= html_print_input_hidden(
'replied', 'replied',
'1', '1',
true true
@ -324,21 +323,27 @@ if ($reply === true) {
$groups = users_get_groups($config['id_user'], 'AR'); $groups = users_get_groups($config['id_user'], 'AR');
// Get a list of all groups. // Get a list of all groups.
$table->data[1][1] = html_print_select( $destinationInputs = html_print_div(
$users,
'dst_user',
$dst_user,
'changeStatusOtherSelect(\'dst_user\', \'dst_group\')',
__('Select user'),
false,
true,
false,
''
);
$table->data[1][1] .= '&nbsp;&nbsp;'.__('OR').'&nbsp;&nbsp;';
$table->data[1][1] .= html_print_div(
[ [
'class' => 'w250px inline', 'class' => 'select_users mrgn_right_5px',
'content' => html_print_select(
$users,
'dst_user',
$dst_user,
'changeStatusOtherSelect(\'dst_user\', \'dst_group\')',
__('Select user'),
false,
true,
false,
''
),
],
true
);
$destinationInputs .= __('OR');
$destinationInputs .= html_print_div(
[
'class' => 'mrgn_lft_5px',
'content' => html_print_select_groups( 'content' => html_print_select_groups(
$config['id_user'], $config['id_user'],
'AR', 'AR',
@ -355,24 +360,41 @@ if ($reply === true) {
); );
} }
$table->data[2][0] = __('Subject'); $table->data[0][] = html_print_label_input_block(
$table->data[2][1] = html_print_input_text( __('Destination'),
'subject', html_print_div(
$subject, [
'', 'class' => 'flex-content-left',
50, 'content' => $destinationInputs,
70, ],
true true
)
); );
$table->data[3][0] = __('Message'); $table->colspan[1][] = 2;
$table->data[3][1] = html_print_textarea( $table->data[1][] = html_print_label_input_block(
'message', __('Subject'),
15, html_print_input_text(
255, 'subject',
$message, $subject,
'', '',
true 50,
70,
true
)
);
$table->colspan[2][] = 2;
$table->data[2][] = html_print_label_input_block(
__('Message'),
html_print_textarea(
'message',
15,
50,
$message,
'',
true
)
); );
$jsOutput = ''; $jsOutput = '';
@ -396,17 +418,14 @@ echo '<form method="post" action="index.php?sec=message_list&amp;sec2=operation/
// Print the main table. // Print the main table.
html_print_table($table); html_print_table($table);
// Print the action buttons section. // Print the action buttons section.
html_print_div( html_print_action_buttons(
[ html_print_submit_button(
'class' => 'action-buttons', __('Send message'),
'content' => html_print_submit_button( 'send_mes',
__('Send message'), false,
'send_mes', [ 'icon' => 'wand' ],
false, true
[ 'icon' => 'wand' ], )
true
),
]
); );
echo '</form>'; echo '</form>';

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -206,26 +206,37 @@ if (empty($messages) === true) {
$data[0] = ''; $data[0] = '';
if ($message['read'] == 1) { if ($message['read'] == 1) {
if ($show_sent === true) { if ($show_sent === true) {
$data[0] .= '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_edit&read_message=1&amp;show_sent=1&amp;id_message='.$message_id.'">'; $pathRead = 'index.php?sec=message_list&amp;sec2=operation/messages/message_edit&read_message=1&amp;show_sent=1&amp;id_message='.$message_id;
$data[0] .= html_print_image('images/email_inbox.png', true, ['border' => 0, 'title' => __('Click to read'), 'class' => 'invert_filter']); $titleRead = __('Click to read');
$data[0] .= '</a>';
} else { } else {
$data[0] .= '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_list&amp;mark_unread=1&amp;id_message='.$message_id.'">'; $pathRead = 'index.php?sec=message_list&amp;sec2=operation/messages/message_list&amp;mark_unread=1&amp;id_message='.$message_id;
$data[0] .= html_print_image('images/email_inbox.png', true, ['border' => 0, 'title' => __('Mark as unread'), 'class' => 'invert_filter']); $titleRead = __('Mark as unread');
$data[0] .= '</a>';
} }
} else { } else {
if ($show_sent === true) { if ($show_sent === true) {
$data[0] .= '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&amp;show_sent=1&amp;id_message='.$message_id.'">'; $pathRead = 'index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&amp;show_sent=1&amp;id_message='.$message_id;
$data[0] .= html_print_image('images/email_inbox.png', true, ['border' => 0, 'title' => __('Message unread - click to read'), 'class' => 'invert_filter']); $titleRead = __('Message unread - click to read');
$data[0] .= '</a>';
} else { } else {
$data[0] .= '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&amp;id_message='.$message_id.'">'; $pathRead = 'index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&amp;id_message='.$message_id;
$data[0] .= html_print_image('images/email_inbox.png', true, ['border' => 0, 'title' => __('Message unread - click to read'), 'class' => 'invert_filter']); $titleRead = __('Message unread - click to read');
$data[0] .= '</a>';
} }
} }
$data[0] = html_print_anchor(
[
'href' => $pathRead,
'content' => html_print_image(
'images/email_inbox.png',
true,
[
'title' => $titleRead,
'class' => 'main_menu_icon invert_filter',
],
),
],
true
);
if ($show_sent === true) { if ($show_sent === true) {
$dest_user = get_user_fullname($message['dest']); $dest_user = get_user_fullname($message['dest']);
if (!$dest_user) { if (!$dest_user) {
@ -243,18 +254,24 @@ if (empty($messages) === true) {
} }
if ($show_sent === true) { if ($show_sent === true) {
$data[2] = '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&show_sent=1&amp;id_message='.$message_id.'">'; $pathSubject = 'index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&show_sent=1&amp;id_message='.$message_id;
} else { } else {
$data[2] = '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&amp;id_message='.$message_id.'">'; $pathSubject = 'index.php?sec=message_list&amp;sec2=operation/messages/message_edit&amp;read_message=1&amp;id_message='.$message_id;
} }
if ($message['subject'] == '') { $contentSubject = (empty($message['subject']) === true) ? __('No Subject') : $message['subject'];
$data[2] .= __('No Subject');
} else { if ((int) $message['read'] !== 1) {
$data[2] .= $message['subject']; $contentSubject = '<strong>'.$contentSubject.'</strong>';
} }
$data[2] .= '</a>'; $data[2] .= html_print_anchor(
[
'href' => $pathSubject,
'content' => $contentSubject,
],
true
);
$data[3] = ui_print_timestamp( $data[3] = ui_print_timestamp(
$message['timestamp'], $message['timestamp'],
@ -264,13 +281,27 @@ if (empty($messages) === true) {
$table->cellclass[][4] = 'table_action_buttons'; $table->cellclass[][4] = 'table_action_buttons';
if ($show_sent === true) { if ($show_sent === true) {
$data[4] = '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'" $pathDelete = 'index.php?sec=message_list&amp;sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id;
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>';
} else { } else {
$data[4] = '<a href="index.php?sec=message_list&amp;sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'" $pathDelete = 'index.php?sec=message_list&amp;sec2=operation/messages/message_list&delete_message=1&id='.$message_id;
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>';
} }
$data[4] = html_print_anchor(
[
'href' => $pathDelete,
'content' => html_print_image(
'images/delete.svg',
true,
[
'title' => __('Delete'),
'class' => 'main_menu_icon invert_filter',
]
),
'onClick' => 'javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;',
],
true
);
array_push($table->data, $data); array_push($table->data, $data);
} }
} }
@ -312,11 +343,8 @@ if (empty($messages) === false) {
echo '<form id="create_message_form" method="post" class="float-right" action="index.php?sec=message_list&sec2=operation/messages/message_edit"></form>'; echo '<form id="create_message_form" method="post" class="float-right" action="index.php?sec=message_list&sec2=operation/messages/message_edit"></form>';
html_print_div( html_print_action_buttons(
[ $outputButton
'class' => 'action-buttons',
'content' => $outputButton,
]
); );
?> ?>