diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php new file mode 100644 index 0000000000..aef074e5ae --- /dev/null +++ b/pandora_console/godmode/update_manager/update_manager.messages.php @@ -0,0 +1,231 @@ + $message_id) { + + update_manger_set_read_message ($message_id, 0); + } +} + +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)); + } + +} + +// Get all messages +$sql = 'SELECT data, svn_version, filename, data_rollback, description FROM tupdate'; +$um_messages = array (); +$um_messages = db_get_all_rows_sql ($sql); + +echo '
'; + +html_print_input_hidden ('tab', 'messages'); +echo '
'; +html_print_submit_button (__('Delete'), 'delete_button', false, + 'class="sub upd"'); +echo '
'; + +echo '
'; +html_print_submit_button (__('Mark as not read'), 'not_read_button', false, + 'class="sub upd"'); +echo '
'; + +$table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox data'; + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->head = array (); + $table->data = array (); + $table->align = array (); + $table->size = array (); + $table->id = 'um_messages_table'; + + $table->align[0] = "left"; + $table->align[1] = "left"; + $table->align[2] = "left"; + $table->align[3] = "left"; + $table->align[4] = "left"; + + $table->size[0] = "20px"; + $table->size[1] = "100px"; + $table->size[3] = "80px"; + $table->size[4] = "60px"; + + $table->head[0] = __('Message Id'); + $table->head[1] = __('Expiration date'); + $table->head[2] = __('Subject'); + $table->head[3] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); + + $i = 0; + foreach ($um_messages as $message) { + $data[0] = $message['svn_version']; + + $data[1] = $message['filename']; + + $data[2] = $message['description']; + + //~ $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); + + + // Change row class if message is read or not by this user + if (update_manger_get_read_message ($message['svn_version'], $message['data_rollback'])) { + $table->rowclass[count($table->data)] = "um_read_message"; + + } else { + $table->rowclass[count($table->data)] = "um_not_read_message"; + + } + array_push ($table->data, $data); + + // Insert an empty row too. Here the message will be displayed + $empty[0] = ""; + $table->colspan[count($table->data)][0] = 4; + $table->cellclass[count($table->data)][0] = "um_message_" . $i; + $table->cellstyle[count($table->data)][0] = "display: none;"; + array_push ($table->data, $empty); + + $i++; + } +html_print_table($table); + +echo '
'; +html_print_submit_button (__('Delete'), 'delete_button', false, + 'class="sub upd"'); +echo '
'; + +echo '
'; +html_print_submit_button (__('Mark as not read'), 'not_read_button', false, + 'class="sub upd"'); +echo '
'; +echo '
'; +?> + + diff --git a/pandora_console/godmode/update_manager/update_manager.php b/pandora_console/godmode/update_manager/update_manager.php index 4659550a4e..27590bc011 100644 --- a/pandora_console/godmode/update_manager/update_manager.php +++ b/pandora_console/godmode/update_manager/update_manager.php @@ -40,7 +40,11 @@ $buttons = array( 'online' => array( 'active' => ($tab == 'online') ? true : false, 'text' => '' . - html_print_image("images/op_gis.png", true, array ("title" => __('Online update manager'))) .'') + html_print_image("images/op_gis.png", true, array ("title" => __('Online update manager'))) .''), + 'messages' => array( + 'active' => ($tab == 'messages') ? true : false, + 'text' => '' . + html_print_image("images/hourglass.png", true, array ("title" => __('Update manager messages'))) .'') ); switch ($tab) { @@ -53,6 +57,9 @@ switch ($tab) { case 'online': $title = __('Update manager » Online'); break; + case 'messages': + $title = __('Update manager » Messages'); + break; } ui_print_page_header($title, @@ -65,6 +72,9 @@ switch ($tab) { case 'offline': require($config['homedir'] . "/godmode/update_manager/update_manager.offline.php"); break; + case 'messages': + require($config['homedir'] . "/godmode/update_manager/update_manager.messages.php"); + break; case 'online': default: require($config['homedir'] . "/godmode/update_manager/update_manager.online.php"); diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index b4ec1c2ae7..02a4b07d13 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -523,4 +523,31 @@ function update_manager_get_current_package() { return $current_update; } + +// Set the read or not read status message of current user +function update_manger_set_read_message ($message_id, $status) { + global $config; + + $rollback = db_get_value('data_rollback', 'tupdate', 'svn_version', $message_id); + $users_read = json_decode ($rollback, true); + $users_read[$config['id_user']] = $status; + + $rollback = json_encode ($users_read); + db_process_sql_update('tupdate', array('data_rollback' => $rollback), array('svn_version' => $message_id)); +} + +// Get the read or not read status message +function update_manger_get_read_message ($message_id, $rollback = false) { + global $config; + + if ($rollback === false) { + $rollback = db_get_value('data_rollback', 'tupdate', 'svn_version', $message_id); + } + $users_read = json_decode ($rollback, true); + + if (isset ($users_read[$config['id_user']]) && ($users_read[$config['id_user']] == 1)) { + return true; + } + return false; +} ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 0a5506346d..03c3c1d023 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -3098,6 +3098,14 @@ table#policy_modules td * { margin-left: 3%; } +.um_not_read_message{ + font-weight: 900; +} +.um_read_message{ + font-weight: 500; + color: #bbbbbb; +} + /* The items with the class 'spinner' will rotate */ /* Not supported on IE9 and below */ .spinner {