From 50cb7eb5bd81021ba5b22e3903dc9d814cb50fe7 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 27 May 2016 15:00:21 +0200 Subject: [PATCH] Now messages deleted is not deleted, only mark as deleted to that user --- .../update_manager.messages.php | 10 ++++---- .../include/functions_update_manager.php | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php index 47e4f7755d..2bd2ef5859 100644 --- a/pandora_console/godmode/update_manager/update_manager.messages.php +++ b/pandora_console/godmode/update_manager/update_manager.messages.php @@ -61,18 +61,20 @@ if ($delete_action !== false) { $selected = get_parameter ('select_multiple', false); foreach ($selected as $k => $message_id) { - db_process_sql_delete ('tupdate', array('svn_version' => $message_id)); + update_manger_set_deleted_message ($message_id); } } $offset = (int) get_parameter ('offset', 0); -$total_messages = update_manager_get_total_messages (); +$total_messages = update_manager_get_not_deleted_messages (); if ($total_messages){ // Get all messages - $sql = 'SELECT data, svn_version, filename, data_rollback, description FROM tupdate LIMIT ' . $offset . ',' . $config['block_size']; + $sql = 'SELECT data, svn_version, filename, data_rollback, db_field_value FROM tupdate '; + $sql .= 'WHERE description NOT LIKE \'%"' . $config['id_user'] . '":1%\' '; + $sql .= 'LIMIT ' . $offset . ',' . $config['block_size']; $um_messages = array (); $um_messages = db_get_all_rows_sql ($sql); @@ -127,7 +129,7 @@ if ($total_messages){ $data[1] = $message['filename']; - $data[2] = $message['description']; + $data[2] = $message['db_field_value']; //~ $delete_link = 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=messages&delete_single=1&message_id=' . $message['svn_version']; $data[3] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index 12a416dc57..51a6038a0a 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -567,4 +567,28 @@ function update_manager_get_unread_messages () { return $total - $read; } + +function update_manager_get_not_deleted_messages () { + global $config; + + $total = update_manager_get_total_messages (); + $sql = 'SELECT COUNT(*) FROM tupdate WHERE description LIKE \'%"' . $config['id_user'] . '":1%\''; + $read = (int) db_get_sql ($sql); + + return $total - $read; +} + +function update_manger_set_deleted_message ($message_id) { + global $config; + + $rollback = db_get_value('description', 'tupdate', 'svn_version', $message_id); + $users_read = json_decode ($rollback, true); + $users_read[$config['id_user']] = 1; + + $rollback = json_encode ($users_read); + db_process_sql_update('tupdate', array('description' => $rollback, ), array('svn_version' => $message_id)); + + //Mark as read too + update_manger_set_read_message ($message_id, 1); +} ?>