View Issue Details

IDProjectCategoryView StatusLast Update
0012677mantisbtadministrationpublic2020-10-27 14:56
Reportertaken Assigned Toatrol  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.4 
Target Version2.17.0Fixed in Version2.17.0 
Summary0012677: Please change a search option to manage users
Description

Hello
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 dont remember own login... and sometimes i need change for someone and dont know exacly a login...
This is possible to change a search in mantisbt?
When i click search i need give exacly username but cant 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 dont 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.
Thanks

TagsNo tags attached.
Attached Files
manage_user_page.zip (3,649 bytes)
user-autocomplete.patch (3,256 bytes)   
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 ) {
 	return;
 }
 
+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++) {
 			<fieldset>
 				<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>
 				<span class="submit-button"><input type="submit" class="button" value="<?php echo lang_get( 'manage_user' ) ?>" /></span>
 			</fieldset>
user-autocomplete.patch (3,256 bytes)   
ScreenShot017.png (3,427 bytes)   
ScreenShot017.png (3,427 bytes)   

Relationships

related to 0012343 new Ability to manage and filter users based on realname instead of username 
related to 0015411 closeddregad Huge memory consumption for print_user_option_list() 
related to 0021785 closeddregad Manage User Search fails if there are spaces around the username 
has duplicate 0023280 closedatrol Searching for a user in manage_user_page.php is misleading 
related to 0012557 new Bug view page: add monitoring for user select from list 
related to 0019470 closedvboctor Search in Manage User should also match real names 
related to 0023486 closedatrol features for mange users module 
related to 0023915 closedatrol Search for a part of (Real Name - Username - Email) 
related to 0027117 closedatrol SQL syntax error on manage_user_page 
related to 0027387 closeddregad Manage user page table footer is displayed even when empty 

Activities

cas

cas

2011-01-11 07:42

reporter   ~0027892

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

taken

2011-01-11 07:48

reporter   ~0027893

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

Thanks

atrol

atrol

2011-01-11 08:44

developer   ~0027896

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

taken

2011-01-11 08:57

reporter   ~0027897

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 dont know from what City he is i cant 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.
Thanks

atrol

atrol

2011-01-11 09:13

developer   ~0027898

There is a link "All" left from letter A

cas

cas

2011-01-11 10:39

reporter   ~0027899

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

taken

2011-01-11 10:53

reporter   ~0027900

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 ?
Thanks

atrol

atrol

2011-01-11 11:04

developer   ~0027902

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

dregad

dregad

2011-01-12 05:45

developer   ~0027910

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

cas

2011-01-25 07:45

reporter   ~0028075

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

dregad

2011-01-26 09:51

developer   ~0028089

Cas,

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

cas

2011-01-26 10:36

reporter   ~0028090

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

daryn

daryn

2011-01-27 00:35

reporter   ~0028099

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

cas

2011-01-27 02:54

reporter   ~0028100

Last edited: 2011-01-27 03:55

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

dregad

2011-01-27 08:26

developer   ~0028103

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).

Damien

dregad

dregad

2011-01-27 08:30

developer   ~0028104

Cas

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

cas

2011-01-27 10:35

reporter   ~0028105

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

daryn

2011-01-27 12:02

reporter   ~0028108

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

cas

2011-01-27 13:15

reporter   ~0028109

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

cas

cas

2011-01-31 04:52

reporter   ~0028115

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

dregad

dregad

2011-03-02 10:47

developer   ~0028348

Daryn,

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

dregad

2013-01-24 03:34

developer   ~0034885

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

atrol

2014-02-01 06:11

developer   ~0039267

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

jeromedl

jeromedl

2018-06-12 12:15

reporter   ~0060071

Hi team,
what is the best way to propose a patch?

atrol

atrol

2018-06-12 12:23

developer   ~0060072

what is the best way to propose a patch?

Submitting a patch is always a good idea, as it increases the chances of improvement eventually making it into MantisBT core. All contributions are welcome and greatly appreciated.

Patch submissions can be made in several ways. In the order of preference:

  1. Send us a Pull Request on our Github repository [1]
  2. Attach a GIT patch to the issue
  3. Attach a Unified Diff, clearly specifying the patch's base release

Kindly avoid to upload entire modified PHP files.

Please make sure that your submissions adhere to our Coding Guidelines [2], if they don't your patch might be rejected.

[1] https://github.com/mantisbt/mantisbt
[2] http://www.mantisbt.org/wiki/doku.php/mantisbt:coding_guidelines

samtuke

samtuke

2018-07-07 10:05

reporter   ~0060225

This is still a problem; it appears that there is still no built-in way to search for partial usernames or users with similar usernames.

samtuke

samtuke

2018-08-07 09:56

reporter   ~0060366

Offering a bounty to encourage progress on this issue: $150 to implement the following (payable via PayPal) . To others desiring the functionality, please add your bounty pledges also to increase the total.

  1. Partial username search (e.g. samt will match samtuke)
  2. Exact match syntax (e.g. "A B C" including quotes matches the phrase "A B C")
  3. Negative keyword syntax (e.g. samt -uke matches samt and samteke but not samtuke)

Autocomplete list is optional from my perspective.

cas

cas

2018-08-09 05:42

reporter   ~0060392

@samtuke,
I can make easily the fix for you. In my book options 1 & 2 both can be resolved with the wildcard option.
Option 3 would require some more work.
However it would be a (documented) change to the standard mantis php script.
Which version are you currently using?

dregad

dregad

2018-08-09 09:38

developer   ~0060400

Last edited: 2018-08-09 09:48

@cas much better would be to submit this as pull request so we can review and hopefully integrate in a future release.

As for point 3, this is very similar to the logic for text search in filter API, have a look at filter_get_bug_rows_query_clauses(), around line 2375 so it might be an idea to somehow reuse this code.

samtuke

samtuke

2018-08-09 10:01

reporter   ~0060402

@cas The wildcard option would work. We are using 2.6.0 (https://mantis.phplist.org). As @dregad says however it would be much better to include the change in a standard release than merely as a patch.

cas

cas

2018-08-09 10:30

reporter   ~0060403

Last edited: 2018-08-09 10:36

@ Damien,
had a first go at it, created a pull request (1378) for this, please have a look.

@Sam,
Proposed an update to the mantis team based on 2.16.0. Hopefully it will be included in a future release.
Till then I can easily make it work in 2.6.0 if required.
Have it already available.

atrol

atrol

2018-08-09 11:00

developer   ~0060404

PR https://github.com/mantisbt/mantisbt/pull/1378

I had a very short look at it.
@cas as a first step, please ensure that your submissions adhere to our Coding Guidelines

atrol

atrol

2018-08-09 17:52

developer   ~0060405

Added some comments to the PR.

cas

cas

2018-08-10 04:42

reporter   ~0060407

Thanks for the provided feedback, will adjust and provide a new PR.

dregad

dregad

2018-08-10 04:51

developer   ~0060408

@cas No need for a new PR, just add commits to your feature branch, then push it to GitHub - the PR will update automatically.

cas

cas

2018-08-10 08:48

reporter   ~0060409

Last edited: 2018-08-10 10:24

committed updates in order to fix bug and to follow standard Mantis. Possibly this can be released soonest.

atrol

atrol

2018-08-13 07:44

developer   ~0060412

The current state of the PR provides a nice new functionality but the UI is not intuitive and bit confusing.

Have a look at attached screen shot for how it would look like after merging the PR
There are quite a lot of input fields, buttons and check boxes.

I am asking myself if it would be better to remove some parts of the current UI.
E.g. remove Search label, the input field and the Manage User button, but extent the new Search functionality
to search also by user name and e-mail address.

The current search / manage user functionality offers the ability to enter a complete user name or a complete e-mail address and to go to the manage_user_edit_page.php with one click.
If there is more than one user using the same e-mail adress, the result is random.

At the moment I see just a small disadvantage if the old functionality is replaced by an extended new search functionality : There is one more click needed to go to the manage_user_edit_page.php

ManageUserPR-Cas.PNG (48,752 bytes)   
ManageUserPR-Cas.PNG (48,752 bytes)   
cas

cas

2018-08-13 08:50

reporter   ~0060413

OK, have changed the functionality as follows:

  1. Just one search box
  2. No direct link to manage_user_edit_page.php anymore (removed the direct search form)
  3. Fields username/realname/email are searched for the string provided
  4. In case exclusion symbol(-) used, also all 3 fields are checked
    Commits made in github
atrol

atrol

2018-08-13 09:17

developer   ~0060414

It would be good to get some feedback from @dregad and @samtuke concerning the proposed UI change.
Do we loose / miss some functionality after having removed the old search / manage UI ?

As a side note, we will have to check if

  • performance is acceptable as there is no index on column realname
  • if adding an index increases performance (can't be done in 2.x as database schema changes are needed for it)
cas

cas

2018-08-13 09:55

reporter   ~0060416

Fixed the UI behavior when switching between result pages (although a search should not have so many results).
Tested this on my user table which holds over a 1000 records and here performance impact was neglectable.

Just out of curiosity, why would adding an index not be acceptable within the 2.x releases?

samtuke

samtuke

2018-08-13 13:24

reporter   ~0060420

@cas The changes you describe sound like they meet our requirements very well, thanks! I cannot easily test the code from GitHub so I'm judging by the previous screenshot and descriptions of your updates.

Regarding indexes and performance, for reference: our installation has 2,800 user accounts

atrol

atrol

2018-08-13 18:02

developer   ~0060421

Last edited: 2018-08-13 18:03

although a search should not have so many results

There are use cases with many results, e.g. I get about 130 rows when searching for Peter on our bug tracker.

Tested this on my user table which holds over a 1000 records and here performance impact was neglectable.

Testing with 1000 records is not enough, as there installations with lot more users.
For example there are about 37000 users in our bugtracker.
I tested with a copy of the data and performance was quite good, so there is no need for an index.

Just out of curiosity, why would adding an index not be acceptable within the 2.x releases?

There was a decision that database schema of 1.3.x and 2.x.x should be exactly the same.
Database schema changes are just allowed when starting next major release.
Of course, it would have been worth a discussion to break this rule if the index would habe been needed.

I created a new PR https://github.com/mantisbt/mantisbt/pull/1381

  • rebased based on latest master
  • squashed commits while keeping commits of cas and dregad
  • minor code style corrections
  • removed unrelated changes (config_defaults_inc.php)
  • replaced User Name label by placeholder Username, Real Name or E-mail

@cas, let me know if you want to close your PR or if you want to include my changes to your PR.

After applying my latest changes, the UI will look like the following screenshot

NewSearch.png (10,540 bytes)   
NewSearch.png (10,540 bytes)   
cas

cas

2018-08-14 02:33

reporter   ~0060422

Last edited: 2018-08-14 08:05

@Roland, thanks for the update. Like the placeholder option, looks much better. Pleasse close my PR.

@samtuke , I have the source from 2.6.0, could prepare manage_user_page.php for you so you just need to copy it into your installation (after renaming the existing version).

atrol

atrol

2018-08-14 02:46

developer   ~0060425

@cas, as a side note. @ Roland does not notify me (@atrol), but another user.
And also @ Sam does not notify @samtuke.

Please close my PR.

Done

atrol

atrol

2018-08-14 17:23

developer   ~0060432

Enhanced PR https://github.com/mantisbt/mantisbt/pull/1381

  • offer unlimited number of search terms
  • offer quoting of search terms
  • display entered search string in input field after search
cas

cas

2018-08-15 09:25

reporter   ~0060434

Nice enhancements, perhaps input box should be extended a bit to hold more search terms.

atrol

atrol

2018-08-16 06:06

developer   ~0060441

perhaps input box should be extended a bit to hold more search terms.

Extended a bit, but primarily because of the placeholder text that will typically be longer in other languages than English
e.g. in German it will be Benutzername, Bürgerlicher Name oder E-Mail

atrol

atrol

2018-08-22 17:39

developer   ~0060477

Enhanced PR https://github.com/mantisbt/mantisbt/pull/1381

  • code cleanup
  • harmonize button size
  • move search field to top
  • combine clickable username filter with new search term

Related Changesets

MantisBT: master 9d59867c

2018-08-09 06:19

cas

Committer: atrol


Details Diff
Add realname case-insensitive wildcard search on manage_user_page.php

Provide the option to exclude a pattern.
Searchterm "jan" would lead to wildcard "%jan%"
Searchterm "jan -dek" would lead to include "%jan%" and to exclude "%dek%"

Issue 0012677
Affected Issues
0012677
mod - manage_user_page.php Diff File

MantisBT: master e6951da2

2018-08-13 00:03

dregad

Committer: atrol


Details Diff
Whitespace / coding guidelines

Issue 0012677
Affected Issues
0012677
mod - manage_user_page.php Diff File

MantisBT: master 98c45505

2018-08-13 03:43

cas

Committer: atrol


Details Diff
Extend search in manage_user_page.php

Search also for username and e-mail

Issue 0012677
Affected Issues
0012677
mod - config_defaults_inc.php Diff File
mod - manage_user_page.php Diff File

MantisBT: master 5b2e3b65

2018-08-13 12:17

atrol


Details Diff
Enhance user search UI on page manage_user_page.php

- Replace label by placeholder
- White space fixes
- Remove unrelated changes from PR

Fixes 0012677
Affected Issues
0012677
mod - config_defaults_inc.php Diff File
mod - lang/strings_english.txt Diff File
mod - manage_user_page.php Diff File

MantisBT: master ba4ff4ea

2018-08-14 11:22

atrol


Details Diff
Enhance user search functionality

- offer unlimited number of search terms
- offer quoting of search terms
- display entered search string in input field

Issue 0012677
Affected Issues
0012677
mod - manage_user_page.php Diff File

MantisBT: master 247b2ef3

2020-10-11 00:12

dregad

Committer: atrol


Details Diff
Display footer only when page navigation is needed

- In manage user page, the navigation controls are only displayed in the
section footer when there is more than one page. Issue 0012677 moved
the search form to the header, resulting in an empty footer div when
there are 50 users or less.
- In manage tags page, the navigation controls are only displayed in the
section footer when there is more than one page, resulting in an empty
footer div when there are 20 tags or less.

The footer div in the above pages is now hidden when there is only one
page worth of data.

Fixes 0027387
Affected Issues
0012677, 0027387
mod - manage_tags_page.php Diff File
mod - manage_user_page.php Diff File