Browse files

Manage persistency of config report filter using a cookie

A new cookie 'manage_config_cookie' was added to store the user's filter
criteria.

Includes documentation update to admin guide.

Issue #14559
  • Loading branch information...
1 parent efdd6a7 commit 9dbfcd7dd612137c8f75ba644d921c43f1d0a9f9 @dregad dregad committed Dec 31, 2012
Showing with 44 additions and 5 deletions.
  1. +28 −3 adm_config_report.php
  2. +9 −2 config_defaults_inc.php
  3. +1 −0 core/helper_api.php
  4. +6 −0 docbook/administration_guide/en/configuration.sgml
View
31 adm_config_report.php
@@ -102,6 +102,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
}
# Get filter values
+ $t_filter_save = gpc_get_bool( 'save' );
$t_filter_user_value = gpc_get_int( 'filter_user_id', ALL_USERS );
$t_filter_project_value = gpc_get_int( 'filter_project_id', ALL_PROJECTS );
$t_filter_config_value = gpc_get_string( 'filter_config_id', META_FILTER_NONE );
@@ -113,6 +114,32 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
$t_edit_type = gpc_get_string( 'type', CONFIG_TYPE_DEFAULT );
$t_edit_value = gpc_get_string( 'value', '' );
+ # Manage filter's persistency through cookie
+ $t_cookie_name = config_get( 'manage_config_cookie' );
+ if( $t_filter_save ) {
+ # Save user's filter to the cookie
+ $t_cookie_string = implode(
+ ':',
+ array(
+ $t_filter_user_value,
+ $t_filter_project_value,
+ $t_filter_config_value,
+ )
+ );
+ gpc_set_cookie( $t_cookie_name, $t_cookie_string, true );
+ } else {
+ # Retrieve the filter from the cookie if it exists
+ $t_cookie_string = gpc_get_cookie( $t_cookie_name, null );
+ if( null !== $t_cookie_string ) {
+ $t_cookie_contents = explode( ':', $t_cookie_string );
+
+ $t_filter_user_value = $t_cookie_contents[0];
+ $t_filter_project_value = $t_cookie_contents[1];
+ $t_filter_config_value = $t_cookie_contents[2];
+ }
+
+ }
+
# Apply filters
$t_config_table = db_get_table( 'mantis_config_table' );
$t_project_table = db_get_table( 'mantis_project_table' );
@@ -189,6 +216,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<!-- FILTER FORM -->
<form id="filter_form" method="post">
<?php # CSRF protection not required here - form does not result in modifications ?>
+ <input type="hidden" name="save" value="1" />
<table class="width100" cellspacing="1">
<!-- Title -->
@@ -311,9 +339,6 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
'#config_set_form',
lang_get( 'edit_link' ),
array(
- 'filter_user_id' => $t_filter_user_value,
- 'filter_project_id' => $t_filter_project_value,
- 'filter_config_id' => $t_filter_config_value,
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
View
11 config_defaults_inc.php
@@ -2862,6 +2862,12 @@
$g_manage_cookie = '%cookie_prefix%_MANAGE_COOKIE';
/**
+ * Stores the filter criteria for the Manage Config Report page
+ * @global string $g_manage_config_cookie
+ */
+ $g_manage_config_cookie = '%cookie_prefix%_MANAGE_CONFIG_COOKIE';
+
+ /**
*
* @global string $g_logout_cookie
*/
@@ -3923,8 +3929,9 @@
'absolute_path_default_upload_folder', 'ldap_simulation_file_path', 'cookie_path',
'plugin_path', 'db_table_prefix', 'db_table_suffix', 'db_table', 'allow_permanent_cookie',
'cookie_time_length', 'cookie_domain', 'cookie_version', 'cookie_prefix',
- 'string_cookie', 'project_cookie', 'view_all_cookie', 'manage_cookie', 'logout_cookie',
- 'bug_list_cookie', 'db_username', 'db_password', 'db_schema', 'db_type', 'hostname',
+ 'string_cookie', 'project_cookie', 'view_all_cookie', 'manage_cookie',
+ 'manage_config_cookie', 'logout_cookie', 'bug_list_cookie',
+ 'db_username', 'db_password', 'db_schema', 'db_type', 'hostname',
'allow_signup', 'database_name', 'show_queries_count', 'show_queries_threshold',
'show_queries_list', 'admin_checks', 'version_suffix', 'global_settings', 'use_iis',
'default_language', 'language_choices_arr', 'language_auto_map', 'fallback_language',
View
1 core/helper_api.php
@@ -282,6 +282,7 @@ function helper_set_current_project( $p_project_id ) {
function helper_clear_pref_cookies() {
gpc_clear_cookie( config_get( 'project_cookie' ) );
gpc_clear_cookie( config_get( 'manage_cookie' ) );
+ gpc_clear_cookie( config_get( 'manage_config_cookie' ) );
}
/**
View
6 docbook/administration_guide/en/configuration.sgml
@@ -2580,6 +2580,12 @@
<para>$g_manage_cookie</para>
</listitem>
<listitem>
+ <para>$g_manage_config_cookie</para>
+ <para>Stores the filter criteria for the
+ Manage Config Report page
+ </para>
+ </listitem>
+ <listitem>
<para>$g_logout_cookie</para>
</listitem>
<listitem>

0 comments on commit 9dbfcd7

Please sign in to comment.