Ent 5809 message delete not working
This commit is contained in:
parent
382dca14c9
commit
efb69c18bc
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `hidden_sent` TINYINT(1) UNSIGNED DEFAULT 0;
|
||||
|
||||
COMMIT;
|
|
@ -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`);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ if ($read_message) {
|
|||
).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje'];
|
||||
|
||||
|
||||
echo '<form id="delete_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'">';
|
||||
echo '<form id="delete_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent='.$show_sent.'&delete_message=1&id='.$message_id.'">';
|
||||
echo '</form>';
|
||||
|
||||
echo '<form id="reply_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1&reply=1">';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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`),
|
||||
|
|
Loading…
Reference in New Issue