View Issue Details

IDProjectCategoryView StatusLast Update
0014559mantisbtadministrationpublic2014-12-22 08:23
ReporterLapinkiller Assigned Todregad  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.2.8 
Target Version1.2.13Fixed in Version1.2.13 
Summary0014559: Adding filter for "Configuration report"
Description

With lot of users and projects, the adminpage "Configuration report" is very very very long.

So i have just added filters on "user" and/or "project" and/or "config id"

Additional Information

new lang var :
//en
$s_none_filter = 'No filter';
//fr
$s_none_filter = 'Aucun filtre';

TagsNo tags attached.

Relationships

related to 0013680 closeddregad Configuration page takes a very long time to load 
related to 0013298 closeddregad commas and multi-dimensional arrays in adm_config_set 
related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 
related to 0015347 closeddregad Bad performance and memory issue with print_user_option_list 
related to 0012268 acknowledged In Config Report, hide or break out users custom column definations. 

Activities

Lapinkiller

Lapinkiller

2012-08-07 04:44

reporter  

Lapinkiller

Lapinkiller

2012-08-07 05:06

reporter   ~0032483

please delete adm_config_report.php-adding_filters.diff

Lapinkiller

Lapinkiller

2012-08-07 05:08

reporter  

adm_config_report.php-adding_filters-patch.diff (4,660 bytes)   
Index: adm_config_report.php
===================================================================
--- adm_config_report.php	(revision 286)
+++ adm_config_report.php	(revision 306)
@@ -87,15 +87,143 @@
 
 		echo '</pre>';
 	}
+	
+	$t_config_table = db_get_table( 'mantis_config_table' );
+	
+	//Listes des filtres
+	$t_user_table = db_get_table( 'mantis_user_table' );
+	$t_project_table = db_get_table( 'mantis_project_table' );
+		//Utilisateurs ayant réalisé des tâches sur l'administration
+		$query = "SELECT DISTINCT user_id, ut.realname as username, ut.username as idrh
+			  FROM $t_config_table as ct
+			  JOIN $t_user_table as ut
+			  	ON ut.id=ct.user_id
+			  ORDER BY username";
+		$t_result = db_query_bound($query);
+		$t_users_list = array();
+		$t_users_list[-1] = '<i>'.lang_get("none_filter").'</i>';
+		$t_users_list[ALL_USERS] = lang_get("all_users");
+		while ( $row = db_fetch_array( $t_result ) ) {
+			extract( $row, EXTR_PREFIX_ALL, 'v' );
+			$t_users_list[$v_user_id] = "$v_username ($v_idrh)";
+		}
+	
+		//Projets qui ont subi des modifications
+		$query = "SELECT DISTINCT project_id, pt.name as project_name
+			  FROM $t_config_table as ct
+			  JOIN $t_project_table as pt
+			  	ON pt.id=ct.project_id
+			  WHERE project_id!=0
+			  ORDER BY project_name";
+		$t_result = db_query_bound($query);
+		$t_projects_list = array();
+		$t_projects_list[-1] = '<i>'.lang_get("none_filter").'</i>';
+		$t_projects_list[ALL_PROJECTS] = lang_get("all_projects");
+		while ( $row = db_fetch_array( $t_result ) ) {
+			extract( $row, EXTR_PREFIX_ALL, 'v' );
+			$t_projects_list[$v_project_id] = $v_project_name;
+		}
+		
+		//Options de configuration
+		$query = "SELECT DISTINCT config_id
+			  FROM $t_config_table
+			  ORDER BY config_id";
+		$t_result = db_query_bound($query);
+		$t_configs_list = array();
+		$t_configs_list[-1] = '<i>'.lang_get("none_filter").'</i>';
+		while ( $row = db_fetch_array( $t_result ) ) {
+			extract( $row, EXTR_PREFIX_ALL, 'v' );
+			$t_configs_list[$v_config_id] = $v_config_id;
+		}
+	
+	function print_option_list_from_array($array,$filter_value){
+			
+			foreach ($array as $key => $value){
+				
+				if($filter_value == $key){
+				$selected = " selected='selected' "	;
+				}else{
+					$selected ="";
+				}
+				
+				echo "<option value='$key' $selected>$value</option>\n";
+			}
+			
+		}
+	
+	//----
+	
+	$t_filter_user_value 	= gpc_get_int('filter_user_id',-1);
+	$t_filter_project_value = gpc_get_int('filter_project_id',-1);
+	$t_filter_config_value 	= gpc_get_string('filter_config_id',-1);	
 
-	$t_config_table = db_get_table( 'mantis_config_table' );
-	$query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table ORDER BY user_id, project_id, config_id";
+	$where = '';
+	if($t_filter_user_value != -1){
+		$where .= " AND user_id=$t_filter_user_value ";
+	}
+	if($t_filter_project_value != -1){
+		$where .= " AND project_id=$t_filter_project_value ";
+	}
+	if($t_filter_config_value != -1){
+		$where .= " AND config_id='$t_filter_config_value' ";
+	}
+	if($where!=''){
+		$where = " WHERE 1=1 ".$where;
+	}
+	
+	$query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table $where ORDER BY user_id, project_id, config_id ";
 	$result = db_query_bound( $query );
 ?>
+
 <br />
 <div align="center">
+<form action="" name="form_filter">
 <table class="width100" cellspacing="1">
+	<!-- Title -->
+	<tr>
+		<td class="form-title" colspan="7">
+			<?php echo lang_get( 'filters' ) ?>
+		</td>
+	</tr>
+	
+	<tr class="row-category" style="width:30%;">
+		<td class="center">
+			<?php echo lang_get( 'username' );?> : <br />
+			<select name="filter_user_id" style="width:200px;">
+			<?php
+			print_option_list_from_array($t_users_list, $t_filter_user_value);
+			?>
+			</select>
+		</td>
+		<td class="center" style="width:30%;">
+			<?php echo lang_get( 'project_name' );?> : <br />
+			<select name="filter_project_id" style="width:200px;">
+			<?php
+			print_option_list_from_array($t_projects_list, $t_filter_project_value);
+			?>
+			</select>
+		</td>
+		<td class="center" style="width:40%;">
+			<?php echo lang_get( 'configuration_option' );?> : <br />
+			<select name="filter_config_id" style="width:200px;">
+			<?php
+			print_option_list_from_array($t_configs_list, $t_filter_config_value);
+			?>
+			</select>
+		</td>
+	</tr>
+	<tr>
+		<td colspan="3">
+			<input type="submit" value="<?php echo lang_get('filter_button');?>"/>
+		</td>
+	</tr>
+</table>
+</form>
 
+<br />
+
+<table class="width100" cellspacing="1">
+
 <!-- Title -->
 <tr>
 	<td class="form-title" colspan="7">
dregad

dregad

2012-08-07 05:21

developer   ~0032486

Many thanks for this patch !I have been meaning to implement something similar for quite some time myself.

I will review your code as time allows.

dregad

dregad

2012-08-15 06:21

developer   ~0032568

Pull request https://github.com/mantisbt/mantisbt/pull/58

Lapinkiller

Lapinkiller

2012-11-12 02:40

reporter   ~0034294

what about this pull request ?

dregad

dregad

2012-12-28 19:04

developer   ~0034637

I have reworked your patch and improved it somewhat. Please seee https://github.com/dregad/mantisbt/tree/manage-config - feedback would be appreciated.

atrol

atrol

2012-12-30 10:25

developer   ~0034645

I had a short look at it.
Nice work.

  1. Editing or deleting an option should not reset the filter
  2. Usernames should not be displayed in round brackets
  3. Heading "filters" should be "Filters"
dregad

dregad

2012-12-31 19:21

developer   ~0034647

Hi atrol,

Many thanks for your comments. I have pushed some changes to the branch, to cover for the 3 issues you raised:

  1. Filter persistency is now managed via a cookie instead of POST variables (similar to how it's done in other parts of MantisBT) - in fact a much more elegant solution not to mention better from an end-user perspective as it avoids that the browser requests for re-sending form data.

  2. The filter now respects the $g_show_realname setting, similar to the rest of the page (i.e. display either Realname or Username but not both)

  3. Fixed the corresponding language string

atrol

atrol

2013-01-01 06:53

developer   ~0034648

Last edited: 2013-01-01 06:53

View 2 revisions

Missing list of options after deleting an option

  1. Set filter to Username: [any], Project Name: [any], Configuration Option: one where only one entry exists
  2. Click "Apply filter"
  3. Delete the one entry
  4. Filter displayed: Username: [any], Project Name: [any], Configuration Option: [any]
  5. Confusing: No configuration entries are listed
  6. Click "Apply Filter"
  7. All entries are listed
dregad

dregad

2013-01-02 09:19

developer   ~0034662

Thanks atrol.

Latest commits to the branch [1] include

  • fix for the issue you reported in 0014559:0034648
  • new buttons to clear filter (i.e. view all configs) and reset it to default
  • preset the edit form fields to the current filter criteria

[1] https://github.com/dregad/mantisbt/tree/manage-config

atrol

atrol

2013-01-02 12:46

developer   ~0034671

Editing of complex values (for example view_issues_page_columns) is not longer possible.
All values are lost, you get only array ()

dregad

dregad

2013-01-02 17:46

developer   ~0034680

The changes in adm_config_set.php are still a work in progress and require additional testing; I only performed basic tests, and there are a lot of corner cases related to parsing the user's input especially with associative and multi-dimentional arrays.

I intentionally included these commits in the branch linked here, to benefit from additional testing - thanks for being a guinea pig ;)

If you find additional issues related to adm_config_set.php (i.e. what happens after you click the "Set Configuration Option" button, it would be best to report them in 0013298

If you want to restrict your testing to current 1.2.x behavior for adm_config_set, you can use the following branch [1] instead.

[1] https://github.com/dregad/mantisbt/tree/fix-14559

grangeway

grangeway

2013-04-05 17:56

reporter   ~0036074

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

Related Changesets

MantisBT: master-1.2.x f8a81a33

2012-08-13 15:16:48

Lapinkiller


Committer: Damien Regad Details Diff
fix 0014559 - Filter for adm_report_config.php

Signed-off-by: Damien Regad <damien.regad@merckgroup.com>
Affected Issues
0014559
mod - adm_config_report.php Diff File
mod - lang/strings_english.txt Diff File
mod - lang/strings_french.txt Diff File

MantisBT: master-1.2.x 259f95cd

2012-12-14 15:10:52

dregad

Details Diff
Issue 0014559: improve adm_report_config.php filter

The following changes were made

- revised UI to make it more similar to the issues filter
- make use of existing constants and language strings
- filter defaults to All Users / All Projects / All options which avoids
performance issues in installations having a large number of entries
in the config table (workaround for issue 0013680)
- filter form uses post instead of get method
- comply to coding guidelines
Affected Issues
0013680, 0014559
mod - adm_config_report.php Diff File
mod - lang/strings_english.txt Diff File
mod - lang/strings_french.txt Diff File

MantisBT: master-1.2.x 9f724904

2012-12-30 21:41:13

dregad

Details Diff
Fix 1st uppercase letter for 'Filters' language string

Affects issue 0014559
Affected Issues
0014559
mod - lang/strings_english.txt Diff File

MantisBT: master-1.2.x efdd6a75

2012-12-30 22:26:55

dregad

Details Diff
Respect $g_show_realname setting in config report's filter userlist

The filter's original implementation displayed "Realname (username)" in
the user selection list. We now only retrieve the user id from the db,
and call user_get_name() to get either the realname or the username as
appropriate instead.

Issue 0014559
Affected Issues
0014559
mod - adm_config_report.php Diff File

MantisBT: master-1.2.x 9dbfcd7d

2012-12-30 23:01:34

dregad

Details Diff
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 0014559
Affected Issues
0014559
mod - adm_config_report.php Diff File
mod - config_defaults_inc.php Diff File
mod - core/helper_api.php Diff File
mod - docbook/administration_guide/en/configuration.sgml Diff File

MantisBT: master-1.2.x b6f03b73

2013-01-01 23:22:17

dregad

Details Diff
Config report filter: added handling for invalid values in cookie

In some cases, the cookie could contain values which are no longer
applicable as filter criteria, e.g.
- a project id which has been deleted
- a user id for whom there are no config options
- a config id for which there are no config options

The code now correctly handles these, by making sure that either the
filter criteria is dynamically updated to a valid value (ALL_PROJECTS
for projects), or the filter's selection list effectively includes the
invalid value (user id, config id), so that the displayed filter
reflects the actual data listed in the Database Configuration table.

Fixes the bug reported by atrol in issue 0014559's bugnote 34648
Affected Issues
0014559
mod - adm_config_report.php Diff File

MantisBT: master-1.2.x d76a2106

2013-01-02 11:46:11

dregad

Details Diff
Config report filter: added buttons to clear and reset default filter

This provides the user with a single-click way to

- reset the filter to default settings
(i.e. ALL_USERS, ALL_PROJECTS, [any] config).
- clear the filter to display all configs
(i.e. [any] user, [any] project, [any] config)

Issue 0014559
Affected Issues
0014559
mod - adm_config_report.php Diff File
mod - lang/strings_english.txt Diff File

MantisBT: master 0c81929d

2013-01-18 15:53:13

dregad

Details Diff
Manage config page: added filtering

Porting the following 1.2.x commits
- f8a81a33880752364ea47bdd9a987bff986c81de
- 259f95cdb5a1561f9401b8c05f1aeddf8f016c81
- 3f75f68b08b0c52d5b3b488034f99214977a5dab
- 9f724904ec087cc1d07704cc387455f4c3c45068
- efdd6a7538ae2366b1dadb52e85fc5d95ae80c1c
- 9dbfcd7dd612137c8f75ba644d921c43f1d0a9f9
- beea901ca69692b989ec19461c6609571b5da5a2
- 65696fbffa0c1a197ce7441483abe78bd0b813e1
- b6f03b73e9134d1001e77445e109de733562cb8a
- 8b426cfc6c6ea7149beeafb352fa390dbf8c4624
- d76a21067e56aba847b650d17ad4e679392c7475
- c61dc631b4c37547a25e1306ed90aa09e9e1b837

Issue 0014559, 0015415
Affected Issues
0014559, 0015415
mod - adm_config_report.php Diff File
mod - config_defaults_inc.php Diff File
mod - core/helper_api.php Diff File
mod - core/obsolete.php Diff File
mod - css/default.css Diff File
mod - docbook/Admin_Guide/en-US/Configuration.xml Diff File
mod - lang/strings_english.txt Diff File
mod - manage_user_page.php Diff File

Issue History

Date Modified Username Field Change
2012-08-07 04:44 Lapinkiller New Issue
2012-08-07 04:44 Lapinkiller File Added: adm_config_report.php-adding_filters.png
2012-08-07 04:44 Lapinkiller File Added: adm_config_report.php-adding_filters.diff
2012-08-07 05:06 Lapinkiller Note Added: 0032483
2012-08-07 05:08 Lapinkiller File Added: adm_config_report.php-adding_filters-patch.diff
2012-08-07 05:20 dregad File Deleted: adm_config_report.php-adding_filters.diff
2012-08-07 05:21 dregad Note Added: 0032486
2012-08-07 05:21 dregad Status new => acknowledged
2012-08-08 15:10 atrol Relationship added related to 0013680
2012-08-15 06:21 dregad Note Added: 0032568
2012-11-12 02:40 Lapinkiller Note Added: 0034294
2012-12-26 08:47 dregad Assigned To => dregad
2012-12-26 08:47 dregad Status acknowledged => assigned
2012-12-28 19:04 dregad Note Added: 0034637
2012-12-28 19:04 dregad Status assigned => feedback
2012-12-30 10:25 atrol Note Added: 0034645
2012-12-31 19:21 dregad Note Added: 0034647
2013-01-01 06:53 atrol Note Added: 0034648
2013-01-01 06:53 atrol Note Edited: 0034648 View Revisions
2013-01-02 09:19 dregad Note Added: 0034662
2013-01-02 12:46 atrol Note Added: 0034671
2013-01-02 17:46 dregad Note Added: 0034680
2013-01-02 17:46 dregad Relationship added related to 0013298
2013-01-06 19:55 dregad Relationship added related to 0015347
2013-01-22 08:55 Lapinkiller Changeset attached => MantisBT master-1.2.x f8a81a33
2013-01-22 08:55 dregad Changeset attached => MantisBT master-1.2.x 259f95cd
2013-01-22 08:55 dregad Changeset attached => MantisBT master-1.2.x 9f724904
2013-01-22 08:55 dregad Changeset attached => MantisBT master-1.2.x efdd6a75
2013-01-22 08:55 dregad Changeset attached => MantisBT master-1.2.x 9dbfcd7d
2013-01-22 08:55 dregad Changeset attached => MantisBT master-1.2.x b6f03b73
2013-01-22 08:55 dregad Changeset attached => MantisBT master-1.2.x d76a2106
2013-01-22 08:55 Lapinkiller Assigned To dregad => Lapinkiller
2013-01-22 08:55 Lapinkiller Status feedback => resolved
2013-01-22 08:55 Lapinkiller Resolution open => fixed
2013-01-22 08:55 Lapinkiller Fixed in Version => 1.2.13
2013-01-22 09:47 dregad Target Version => 1.2.13
2013-01-22 09:47 dregad Status resolved => closed
2013-01-22 21:01 dregad Assigned To Lapinkiller => dregad
2013-03-08 11:05 dregad Changeset attached => MantisBT master 0c81929d
2013-03-13 06:17 jayavel Issue cloned: 0015624
2013-04-05 17:56 grangeway Status closed => acknowledged
2013-04-05 17:56 grangeway Note Added: 0036074
2013-04-05 19:43 grangeway Relationship added related to 0015721
2013-04-06 03:39 dregad Status acknowledged => resolved
2013-04-06 07:21 grangeway Status resolved => acknowledged
2013-04-06 09:22 dregad Tag Attached: 2.0.x check
2013-04-06 09:23 dregad Status acknowledged => closed
2013-08-04 16:24 dregad Relationship added related to 0012268
2013-08-14 08:36 MishaMart Issue cloned: 0016311
2014-09-23 18:05 grangeway Tag Detached: 2.0.x check