2016-12-11 04:57 EST

View Issue Details Jump to Notes ] Wiki ]
IDProjectCategoryView StatusLast Update
0012677mantisbtadministrationpublic2015-03-06 04:06
Assigned To 
Product Version1.2.4 
Target VersionFixed in Version 
Summary0012677: Please change a search option to manage users
I use your software 5 years and You do verry good work.
I got now 1000+ users and my db got 1200MB and working fine... but i got big problem with users.
Some of my users don`t remember own login... and sometimes i need change for someone and don`t know exacly a login...
This is possible to change a search in mantisbt?
When i click search i need give exacly username but can`t use *something*
For example someone name is someone and lastname something, when i try do search *someone* or *something* he say no user exist... this is possible to change this?
Someone i need change preferences many users and don`t remember what login he got i know only lastname and i know someone got login XYZ-lastname - where XYZ is City.
Please help if possible will be good if You add this to new version because when db o users id verry big this is a hard to manage users and find 1 users from 10000 other.
TagsNo tags attached.
Attached Files
  • zip file icon manage_user_page.zip (3,649 bytes) 2011-01-25 07:46
  • patch file icon user-autocomplete.patch (3,256 bytes) 2011-01-27 00:31 -
    diff --git a/core/user_api.php b/core/user_api.php
    index 883f2f2..2e1ef90 100644
    --- a/core/user_api.php
    +++ b/core/user_api.php
    @@ -131,6 +131,19 @@ function user_cache_array_rows( $p_user_id_array ) {
    +function user_cache_all() {
    +	global $g_cache_user;
    +	$t_user_table = db_get_table( 'user' );
    +	$t_query = "SELECT * FROM $t_user_table";
    +	$t_result = db_query_bound( $t_query );
    +	while( $t_row = db_fetch_array( $t_result ) ) {
    +		$g_cache_user[(int) $t_row['id']] = $t_row;
    +	}
    +	return $g_cache_user;
     # --------------------
     # Cache an object as a bug.
     function user_cache_database_result( $p_user_database_result ) {
    @@ -730,6 +743,12 @@ function user_get_row( $p_user_id ) {
     # --------------------
    +# return all users
    +function user_get_all() {
    +	return user_cache_all();
    +# --------------------
     # return the specified user field for the user id
     function user_get_field( $p_user_id, $p_field_name ) {
     	if( NO_USER == $p_user_id ) {
    diff --git a/core/xmlhttprequest_api.php b/core/xmlhttprequest_api.php
    index 7c9e243..307a31a 100644
    --- a/core/xmlhttprequest_api.php
    +++ b/core/xmlhttprequest_api.php
    @@ -57,6 +57,22 @@ function xmlhttprequest_filter_by_prefix( $p_set, $p_prefix ) {
    + * Filter a set of strings by finding strings that match a case-insensitive substring.
    + * @param array $p_set An array of strings to search through.
    + * @param string $p_substr The substring to filter by.
    + * @return array An array of strings which match the supplied substring.
    + */
    +function xmlhttprequest_filter_match( $p_set, $p_substr ) {
    +	$t_matches = array();
    +	foreach ( $p_set as $p_item ) {
    +		if( utf8_strpos( utf8_strtolower( $p_item ), utf8_strtolower( $p_substr ) ) !== false ) {
    +			$t_matches[] = $p_item;
    +		}
    +	}
    +	return $t_matches;
      * Echos a serialized list of platforms starting with the prefix specified in the $_POST
      * @return null
      * @access public
    @@ -97,3 +113,21 @@ function xmlhttprequest_os_build_get_with_prefix() {
     	echo json_encode( $t_matching_entries );
    + * Echos a serialized list of Users starting with the prefix specified in the $_POST
    + * @return null
    + * @access public
    + */
    +function xmlhttprequest_username_get_with_prefix() {
    +	$f_username = gpc_get_string( 'username' );
    +	$t_users = user_cache_all();
    +	foreach( $t_users AS $t_user ) {
    +		$t_unique_entries[] = $t_user['username'];
    +	}
    +	$t_matching_entries = xmlhttprequest_filter_match( $t_unique_entries, $f_username );
    +	echo json_encode( $t_matching_entries );
    diff --git a/manage_user_page.php b/manage_user_page.php
    index 3231f7b..484031b 100644
    --- a/manage_user_page.php
    +++ b/manage_user_page.php
    @@ -380,7 +380,7 @@ for ($i=0;$i<$user_count;$i++) {
     				<span class="field-container">
     					<span class="label"><label for="username"><?php echo lang_get( 'username' ) ?></label></span>
    -					<span class="input"><input id="username" type="text" name="username" value="" /></span>
    +					<span class="input"><input id="username" type="text" name="username" value="" class="autocomplete" /></span>
     				<span class="submit-button"><input type="submit" class="button" value="<?php echo lang_get( 'manage_user' ) ?>" /></span>
    patch file icon user-autocomplete.patch (3,256 bytes) 2011-01-27 00:31 +
  • png file icon ScreenShot017.png (3,427 bytes) 2011-01-27 10:30 -
    png file icon ScreenShot017.png (3,427 bytes) 2011-01-27 10:30 +

related to 0012343new Ability to manage and filter users based on realname instead of username 
related to 0015411closeddregad Huge memory consumption for print_user_option_list() 
related to 0012557new Bug view page: add monitoring for user select from list 
related to 0019470closedvboctor Search in Manage User should also match real names 



cas (reporter)

I use the search function from the browser (CTRL+f) in those cases. This works ok since there is no pagination on the userpage. Having said that disadvanatge is slow loading of that page with 1000+ users.
Improvement is easy in this area be it low priority.


taken (reporter)

Yes, You got right, you can use CTRL+F on 1.1.8 version but after upgrade to version 1.2.X there is no all users in 1 page there is many many page.
There is page A B C D E F and on every letter u got page 1 2 3 4 so u can`t use CTRL+F

On version 1.1.8 i got all users in 1 page and i use CTRL+F with no problem, but now i can`t use at 1.2.4



atrol (developer)

There is a hardcoded $p_per_page = 50; in file manage_user_page.php line 159
As a workaround, change the value to whatever you want


taken (reporter)

Yes but this increase a max user per page on letter A B C or D...
Don`t give all ppl on 1 page

Again mayby i wrong explain.
I got many ppl with login: XYZ-lastname sometimes if someone got this same lastname i give XYZ-lastname2 or XYZ-firstnamelastname and other combination.
Where XYZ is name of City where someone live.
If i don`t know from what City he is i can`t find this user...
I kniow he got lastname: atrol and don`t know from what city he is = this is verrry hard to find what username he got.
Because there is not possible to enter *atrol* to search.


atrol (developer)

There is a link "All" left from letter A


cas (reporter)

In case you want them all on one page, do the following:
Follow Atrol's instruction to change the max number in manage_user_page.php
Set the number high, like 5000.
Now you will have enough for the coming years and can keep on using the CTRL+f function of the browser. keep the selection on "All" on you can search on any (part of a ) string. No nee for the *..........


taken (reporter)

You got right i don`t saw "ALL"
Hmmm but not better do good search engine than change this option to see 5000 ppl in 1 page?
Mayby better do good search with allow use *string* ?


atrol (developer)

As I wrote: This is nothing more than a quick workaround for you
Lowering priority and severity


dregad (developer)

Another simple workaround, assuming you have the access: use a quick SQL query on your DB back-end. That's what I do sometimes.

That being said, I have the same problem as you, and I have been thinking about implementing some "quick search" or filter functionality on the user management page, but do not have time ATM to work on that.


cas (reporter)

attached an updated script which has the function to search for the users realname by wildcard. Simply replace original (after backing up).
On the bottom of the page you will a search field which will work upon more than 2 characters. Otherwise it will simply use the alphabet filter as on top of the page


dregad (developer)


As mentioned before, I have been meaning to implement this for quite some time, so thanks for that !

However, I have some other customizations on this page which I don't want to overwrite. Can you tell me which version of Mantis you used as a basis, this way I can make a diff and apply only changes, keeping my own stuff.

Then I can upload here a git patch, which will help the Mantis dev team, to more easily integrate the changes in a future release.


cas (reporter)

Ah, should have mentioned that. This is off the 1.2.4 version.
My changes are clearly marked.


daryn (reporter)

I've attached a patch against master for an autocomplete on the username field at the bottom of the manage user page. Let me know if this meets the requirement and I'll push it to master.


cas (reporter)

Last edited: 2011-01-27 03:55

View 2 revisions

That certainly is an improvement. The list does show entries that you made in other forms (not available in the user table) so that is a bit confusing but it does help.
The adjustments made by me do a %wildcard% search on the realname field which is slightly different since it searches within the whole string and on a different field. Personally my solution could even replace the username search at the bottom. No doubt that functionality could be improved.
Anyway thanks for the follow up.



dregad (developer)

Hi Daryn,

I tested your proposed patch and found no problems or bugs with it. From my POV it is certainly a useful feature worth having, although it does not go quite as far as I'd like.

Particularly it continues to only allow to search based on Username, whereas I need to have this functionality available for Realname (due to Username being a non-meaningful series of letter+numbers in my company). See also related issue 0012343 - if you could please add the relationship.

What Cas proposes is more along the lines of what I am looking for, i.e. an ability to *Filter* multiple records (as opposed to search for a single user), based on the realname. It would be even better to allow the administrator to pick the field they want to filter on.

In my opinion, the perfect solution would be something like Excel AutoFilter, or maybe a simplified version of the filtering for issues.

Having good tools for the user administration is nice when, like in my Mantis, there are hundreds or even thousands of users, and their access to multiple projects needs to be managed individually (e.g. reporter on Proj1 and Proj2, developer on Proj3, etc).



dregad (developer)


> The list does show entries that you made in other forms (not available in the user table)

I did not notice this, and could not reproduce it in my tests.


cas (reporter)

attached a small image of what i find in the list. The first 2 (there were some email-addresses also)certainly are not in the DB, the last 5 are typical db entries.
I agree that this patch is beneficial so please move to core. Same time look into the wildcard search on realname. We have around 700 entries which make such facility very usefull (certainly since the pagination, which was also appreciated)


daryn (reporter)

cas, I'm not sure why you're getting those. The filter is only searching the user table.

I'm going to work this so you get an autocomplete that searches both the username and realname displaying results as "Realname (username)". If the user selects an item from the list the value submitted is the username.

I think for the backend we should first check for an exact username match. If that doesn't exist then wildcard match both the username and realname and display the results.

Does this sound right to you guys?


cas (reporter)

Daryn, sounds as the ultimate solution to me.
Look forward to testing the patch.


cas (reporter)

@Daryn,those strange entries may appear if someone has "autocomplete" switched on.


dregad (developer)


What you propose is an option that I think would work, and for sure make my life easier.

An alternative would be to have 2 text fields, one for username, and one for realname (but maybe that would needlessly clutter the interface and complicate the code ?).

As mentioned before (0012677:0028103) for me the ultimate solution would be to have *filtering* capability, not just a search (although they are not mutually exclusive).


dregad (developer)

Maybe this user autocomplete logic could be used throughout MantisBT to replace the current user selection lists.

It would avoid the performance and memory issues caused by loading a large number of records (see 0015411). For example on my dev box, populating the list takes about 12 seconds and memory consumption peaks around 180M (for 21'000 users in the DB).


atrol (developer)

Unassigned after having been assigned for a long time without progress.

-Issue History
Date Modified Username Field Change
2011-01-11 06:31 taken New Issue
2011-01-11 07:42 cas Note Added: 0027892
2011-01-11 07:48 taken Note Added: 0027893
2011-01-11 08:44 atrol Note Added: 0027896
2011-01-11 08:57 taken Note Added: 0027897
2011-01-11 09:13 atrol Note Added: 0027898
2011-01-11 10:39 cas Note Added: 0027899
2011-01-11 10:53 taken Note Added: 0027900
2011-01-11 11:04 atrol Note Added: 0027902
2011-01-11 11:05 atrol Priority urgent => normal
2011-01-11 11:05 atrol Severity major => feature
2011-01-12 05:45 dregad Note Added: 0027910
2011-01-25 07:45 cas Note Added: 0028075
2011-01-25 07:46 cas File Added: manage_user_page.zip
2011-01-26 09:51 dregad Note Added: 0028089
2011-01-26 10:36 cas Note Added: 0028090
2011-01-27 00:27 daryn File Added: user-autocomplete.patch
2011-01-27 00:31 daryn File Deleted: user-autocomplete.patch
2011-01-27 00:31 daryn File Added: user-autocomplete.patch
2011-01-27 00:35 daryn Note Added: 0028099
2011-01-27 00:35 daryn Assigned To => daryn
2011-01-27 00:35 daryn Status new => feedback
2011-01-27 02:54 cas Note Added: 0028100
2011-01-27 03:55 cas Note Edited: 0028100 View Revisions
2011-01-27 08:26 dregad Note Added: 0028103
2011-01-27 08:30 dregad Note Added: 0028104
2011-01-27 10:30 cas File Added: ScreenShot017.png
2011-01-27 10:35 cas Note Added: 0028105
2011-01-27 12:02 daryn Note Added: 0028108
2011-01-27 13:15 cas Note Added: 0028109
2011-01-31 04:52 cas Note Added: 0028115
2011-03-02 10:47 dregad Note Added: 0028348
2011-09-09 10:53 dregad Relationship added related to 0012557
2011-09-09 10:54 dregad Relationship added related to 0012343
2013-01-24 03:34 dregad Note Added: 0034885
2013-01-24 03:35 dregad Relationship added related to 0015411
2014-02-01 06:11 atrol Note Added: 0039267
2014-02-01 06:11 atrol Assigned To daryn =>
2014-02-01 06:11 atrol Status feedback => acknowledged
2015-03-06 04:06 dregad Relationship added related to 0019470
+Issue History