diff --git a/pandora_console/extras/mr/39.sql b/pandora_console/extras/mr/39.sql new file mode 100644 index 0000000000..d37235e2ff --- /dev/null +++ b/pandora_console/extras/mr/39.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `tmensajes` ADD COLUMN `hidden_sent` TINYINT(1) UNSIGNED DEFAULT 0; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index b148f0f58d..d05785f4ed 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2314,6 +2314,7 @@ ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tmensajes` ADD COLUMN `hidden_sent` TINYINT(1) UNSIGNED DEFAULT 0; ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `tmensajes` DROP COLUMN `id_usuario_destino`, ADD UNIQUE INDEX `id_mensaje` (`id_mensaje`); diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index e0212a9478..08b0b10d48 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -311,7 +311,7 @@ function messages_get_message_sent(int $message_id) $sql = sprintf( "SELECT id_usuario_origen, subject, mensaje, timestamp FROM tmensajes - WHERE id_usuario_origen='%s' AND id_mensaje=%d", + WHERE id_usuario_origen='%s' AND id_mensaje=%d AND hidden_sent = 0", $config['id_user'], $message_id ); @@ -431,7 +431,7 @@ function messages_get_count_sent(string $user='') $sql = sprintf( "SELECT COUNT(*) - FROM tmensajes WHERE id_usuario_origen='%s'", + FROM tmensajes WHERE id_usuario_origen='%s' AND hidden_sent = 0", $user ); @@ -579,6 +579,17 @@ function messages_get_overview_sent( $order .= ' DESC'; } + $filter = [ + 'id_usuario_origen' => $config['id_user'], + 'hidden_sent' => 0, + 'order' => $order, + ]; + + return db_get_all_rows_filter( + 'tmensajes', + $filter + ); + return db_get_all_rows_field_filter( 'tmensajes', 'id_usuario_origen', @@ -661,3 +672,27 @@ function messages_get_url($message_id) // Return the message direction. return ui_get_full_url('index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id); } + + +/** + * Deletes sent message + * + * @param integer $message_id Message id to get URL. + * + * @return boolean true when deleted, false in case of error + */ +function messages_delete_message_sent($id_message) +{ + global $config; + + $ret = db_process_sql_update( + 'tmensajes', + ['hidden_sent' => 1], + [ + 'id_mensaje' => $id_message, + 'id_usuario_origen' => $config['id_user'], + ] + ); + + return $ret; +} diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index 0b9bca18ad..732dd9aeb1 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -158,7 +158,7 @@ if ($read_message) { ).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje']; - echo '
'; + echo ''; echo '
'; echo '
'; diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 23f9f09fa9..d529743adc 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -78,7 +78,13 @@ if ($mark_unread) { if ($delete_msg) { $id = (int) get_parameter('id'); - $result = messages_delete_message($id); + + if ($show_sent) { + $result = messages_delete_message_sent($id); + } else { + $result = messages_delete_message($id); + } + // Delete message function will actually check the credentials. ui_print_result_message( $result, @@ -91,7 +97,11 @@ if ($multiple_delete) { $ids = (array) get_parameter('delete_multiple_messages', []); foreach ($ids as $id) { - $result = messages_delete_message($id); + if ($show_sent) { + $result = messages_delete_message_sent($id); + } else { + $result = messages_delete_message($id); + } if ($result === false) { break; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 70fce90995..cb385f4245 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1291,6 +1291,7 @@ CREATE TABLE IF NOT EXISTS `tmensajes` ( `citicity` INT(10) UNSIGNED DEFAULT '0', `id_source` BIGINT(20) UNSIGNED NOT NULL, `subtype` VARCHAR(255) DEFAULT '', + `hidden_sent` TINYINT(1) UNSIGNED DEFAULT 0, PRIMARY KEY (`id_mensaje`), UNIQUE KEY `id_mensaje` (`id_mensaje`), KEY `tsource_fk` (`id_source`),