View Issue Details

IDProjectCategoryView StatusLast Update
0011726mantisbtadministrationpublic2014-09-23 18:05
Reporterandy_mbt Assigned Todregad  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version1.2.0 
Target Version1.2.11Fixed in Version1.2.11 
Summary0011726: Add a "Hide Disabled" filter option to the Manage Users page.
Description

Pretty self-explanatory, add a filter (similar to the "Hide Inactive" filter) that would hide all Disabled user accounts from the user list in Manage Users.

TagsNo tags attached.
Attached Files
show-disabled-checkbox.diff (8,392 bytes)   
diff -Naur issues-1.2.9/core/print_api.php issues/core/print_api.php
--- issues-1.2.9/core/print_api.php	2012-05-04 13:58:01.970330248 +0100
+++ issues/core/print_api.php	2012-05-04 14:43:52.904124744 +0100
@@ -1229,7 +1229,7 @@
 	}
 }
 
-function print_manage_user_sort_link( $p_page, $p_string, $p_field, $p_dir, $p_sort_by, $p_hide = 0, $p_filter = ALL ) {
+function print_manage_user_sort_link( $p_page, $p_string, $p_field, $p_dir, $p_sort_by, $p_hide = 0, $p_filter = ALL, $p_showdisabled = 0 ) {
 	if( $p_sort_by == $p_field ) {
 
 		# If this is the selected field flip the order
@@ -1244,7 +1244,7 @@
 	}
 
 	$t_field = rawurlencode( $p_field );
-	print_link( "$p_page?sort=$t_field&dir=$t_dir&save=1&hide=$p_hide&filter=$p_filter", $p_string );
+	print_link( "$p_page?sort=$t_field&dir=$t_dir&save=1&hide=$p_hide&filter=$p_filter&showdisabled=$p_showdisabled", $p_string );
 }
 
 function print_manage_project_sort_link( $p_page, $p_string, $p_field, $p_dir, $p_sort_by ) {
diff -Naur issues-1.2.9/lang/strings_english.txt issues/lang/strings_english.txt
--- issues-1.2.9/lang/strings_english.txt	2012-05-04 13:58:03.857043424 +0100
+++ issues/lang/strings_english.txt	2012-05-04 14:29:38.211057840 +0100
@@ -765,6 +765,7 @@
 $s_never_logged_in_title = 'Never Logged In';
 $s_prune_accounts = 'Prune Accounts';
 $s_hide_inactive = 'Hide Inactive';
+$s_show_disabled = 'Show Disabled';
 $s_manage_accounts_title = 'Manage Accounts';
 $s_p = 'p';
 $s_date_created = 'Date Created';
diff -Naur issues-1.2.9/manage_user_page.php issues/manage_user_page.php
--- issues-1.2.9/manage_user_page.php	2012-05-04 13:58:03.343121552 +0100
+++ issues/manage_user_page.php	2012-05-04 14:45:36.839324192 +0100
@@ -34,6 +34,7 @@
 	$f_sort	= gpc_get_string( 'sort', 'username' );
 	$f_dir	= gpc_get_string( 'dir', 'ASC' );
 	$f_hide = gpc_get_bool( 'hide' );
+	$f_showdisabled = gpc_get_bool( 'showdisabled' );
 	$f_save = gpc_get_bool( 'save' );
 	$f_filter = utf8_strtoupper( gpc_get_string( 'filter', config_get( 'default_manage_user_prefix' ) ) );
 	$f_page_number		= gpc_get_int( 'page_number', 1 );
@@ -63,9 +64,16 @@
 	}
 	$t_hide_filter = '&hide=' . $c_hide;
 
+	if ($f_showdisabled == 0) { # a 0 will turn it off
+		$c_showdisabled = 0;
+	} else {            # anything else (including 'on') will turn it on
+		$c_showdisabled = 1;
+	}
+	$t_showdisabled_filter = '&showdisabled=' . $c_showdisabled;
+
 	# set cookie values for hide, sort by, and dir
 	if ( $f_save ) {
-		$t_manage_string = $c_hide.':'.$c_sort.':'.$c_dir;
+		$t_manage_string = $c_hide.':'.$c_sort.':'.$c_dir.':'.$c_showdisabled;
 		gpc_set_cookie( $t_cookie_name, $t_manage_string, true );
 	} else if ( !is_blank( gpc_get_cookie( $t_cookie_name, '' ) ) ) {
 		$t_manage_arr = explode( ':', gpc_get_cookie( $t_cookie_name ) );
@@ -82,6 +90,11 @@
 		} else {
 			$f_dir = 'DESC';
 		}
+		if ( isset( $t_manage_arr[3] ) ) {
+			$f_showdisabled = $t_manage_arr[3];
+		} else {
+			$f_showdisabled = $c_showdisabled;
+		}
 	}
 
 	html_page_top( lang_get( 'manage_users_link' ) );
@@ -132,7 +145,7 @@
 			$c_filter = $f_filter;
 			echo "<strong>$t_caption</strong>";
 		} else {
-			print_link( "manage_user_page.php?sort=$c_sort&dir=$c_dir&save=1$t_hide_filter&filter=$t_prefix", $t_caption );
+			print_link( "manage_user_page.php?sort=$c_sort&dir=$c_dir&save=1$t_hide_filter&filter=$t_prefix&showdisabled=$c_showdisabled", $t_caption );
 		}
 
 		if ( $t_prefix === 'UNUSED' ) {
@@ -164,17 +177,22 @@
 
 	# Get the user data in $c_sort order
 	$result = '';
+
+	$t_showdisabled_cond = ( 1 == $c_showdisabled ? '' : ' AND enabled = 1' );
+
 	if ( 0 == $c_hide ) {
 		$query = "SELECT count(*) as usercnt
 				FROM $t_user_table
-				WHERE $t_where";
+				WHERE $t_where
+				$t_showdisabled_cond";
 		$result = db_query_bound($query, $t_where_params);
 		$row = db_fetch_array( $result );
 		$total_user_count = $row['usercnt'];
 	} else {
 		$query = "SELECT count(*) as usercnt
 				FROM $t_user_table
-				WHERE $t_where AND " . db_helper_compare_days("" . db_now() . "","last_visit","< $days_old");
+				WHERE $t_where AND " . db_helper_compare_days("" . db_now() . "","last_visit","< $days_old")
+				. $t_showdisabled_cond;
 		$result = db_query_bound($query, $t_where_params);
 		$row = db_fetch_array( $result );
 		$total_user_count = $row['usercnt'];
@@ -200,6 +218,7 @@
 		$query = "SELECT *
 				FROM $t_user_table
 				WHERE $t_where
+				$t_showdisabled_cond
 				ORDER BY $c_sort $c_dir";
 		$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset);
 	} else {
@@ -207,6 +226,7 @@
 		$query = "SELECT *
 				FROM $t_user_table
 				WHERE $t_where AND " . db_helper_compare_days( "" . db_now() . "", "last_visit", "< $days_old" ) . "
+				$t_showdisabled_cond
 				ORDER BY $c_sort $c_dir";
 		$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset );
 	}
@@ -229,6 +249,7 @@
 		<input type="hidden" name="save" value="1" />
 		<input type="hidden" name="filter" value="<?php echo $c_filter ?>" />
 		<input type="checkbox" name="hide" value="1" <?php check_checked( $c_hide, 1 ); ?> /> <?php echo lang_get( 'hide_inactive' ) ?>
+		<input type="checkbox" name="showdisabled" value="1" <?php check_checked( $c_showdisabled, 1 ); ?> /> <?php echo lang_get( 'show_disabled' ) ?>
 		<input type="submit" class="button" value="<?php echo lang_get( 'filter_button' ) ?>" />
 		</form>
 	</td>
@@ -236,49 +257,49 @@
 <tr class="row-category">
 	<td>
 		<?php
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'username' ), 'username', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'username' ), 'username', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'username' );
 		?>
 	</td>
 	<td>
 		<?php
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'realname' ), 'realname', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'realname' ), 'realname', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'realname' );
 		?>
 	</td>
 	<td>
 		<?php
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'email' ), 'email', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'email' ), 'email', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'email' );
 		?>
 	</td>
 	<td>
 		<?php 
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'access_level' ), 'access_level', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'access_level' ), 'access_level', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'access_level' );
 		?>
 	</td>
 	<td>
 		<?php
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'enabled' ), 'enabled', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'enabled' ), 'enabled', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'enabled' );
 		?>
 	</td>
 	<td>
 		<?php 
-			print_manage_user_sort_link(  'manage_user_page.php', $t_lock_image, 'protected', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', $t_lock_image, 'protected', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'protected' );
 		?>
 	</td>
 	<td>
 		<?php 
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'date_created' ), 'date_created', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'date_created' ), 'date_created', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'date_created' );
 		?>
 	</td>
 	<td>
 		<?php 
-			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'last_visit' ), 'last_visit', $c_dir, $c_sort, $c_hide, $c_filter );
+			print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'last_visit' ), 'last_visit', $c_dir, $c_sort, $c_hide, $c_filter, $c_showdisabled );
 			print_sort_icon( $c_dir, $c_sort, 'last_visit' );
 		?>
 	</td>
show-disabled-checkbox.diff (8,392 bytes)   

Relationships

duplicate of 0005498 closedatrol Add a "Hide Disabled" Filter to the Admin Interface 
related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 

Activities

jreese

jreese

2010-03-29 18:34

reporter   ~0024929

Targetting for next feature release

davidnewcomb

davidnewcomb

2012-05-04 09:11

reporter   ~0031760

Last edited: 2012-05-04 09:19

How about flipping it around? I don't know about anyone else but I never need to see the Disabled users! How about it defaults to not showing disabled users and you have a checkbox to include them.

davidnewcomb

davidnewcomb

2012-05-04 10:06

reporter   ~0031761

The quickest way to get your features in is to do it yourself ;)
I've uploaded a patch that can be applied to 1.2.9 to add this feature.

I know this feature is targeted for 1.3 but please can you apply this patch to the 1.2 branch as 1.3 is nowhere near being released yet.

dregad

dregad

2012-05-04 12:26

developer   ~0031762

David,

First of all, many thanks for your contribution.

I'll have a look in detail as time allows. I believe this kind of change should be no problem to include on 1.2.x, considering you gave us the code for it ;-)

Would you like to be listed as author on the commit in the repository (your e-mail address would appear there as well), or alternatively credited in the commit message ?

Note: in the future, if that is possible for you, please make our lives easier by providing your patches as Github pull requests.

grangeway

grangeway

2013-04-05 17:57

reporter   ~0036268

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

Related Changesets

MantisBT: master 93eb5401

2012-05-05 23:16

dregad


Details Diff
Add filter in Manage Users page to show/hide disabled users

This is a port of the following 1.2.x commits:

- a21374af650c06a27bf9a930edbcbef9b41989ac,

Original patch written by David Newcomb.

Fixed issue with new filter not specified on the multi-page navigation
links. Also made minor cosmetic changes: whitespace, coding guidelines.

- 129a8e5e93fda7537884bea371b794bb44c13c0c

Simplify code by using a for loop to print the column headers instead of
manually building the table cells one by one. Note that this actually
changes the label of the 'Protected' column from the padlock icon to a
text description.

Rename 'hide' variable to 'hide_inactive'. With the addition of the new
filter option 'show_disabled', using just 'hide' was potentially
confusing.

- e28fa43081f8365fafbc0c2331938032a3fe89a4

The filter in managed_user_page.php is not persistent

The filter values stored in the cookie whenever the criteria change,
were restored to the form variables instead of the sanitized ($c_)
variables, and were therefore not taken into account when building the
page.

Fixes 0011726, 0014216
Affected Issues
0011726, 0014216
mod - core/print_api.php Diff File
mod - lang/strings_english.txt Diff File
mod - manage_user_page.php Diff File

MantisBT: master-1.2.x a21374af

2012-05-05 23:16

dregad


Details Diff
Add filter in Manage Users page to show/hide disabled users

Original patch written by David Newcomb.

Fixed issue with new filter not specified on the multi-page navigation
links. Also made minor cosmetic changes: whitespace, coding guidelines.

Fixes 0011726
Affected Issues
0011726
mod - core/print_api.php Diff File
mod - lang/strings_english.txt Diff File
mod - manage_user_page.php Diff File