View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0012677 | mantisbt | administration | public | 2011-01-11 06:31 | 2020-10-27 14:56 |
Reporter | taken | Assigned To | atrol | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.4 | ||||
Target Version | 2.17.0 | Fixed in Version | 2.17.0 | ||
Summary | 0012677: Please change a search option to manage users | ||||
Description | Hello | ||||
Tags | No tags attached. | ||||
Attached Files | 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> | ||||
related to | 0012343 | new | Ability to manage and filter users based on realname instead of username | |
related to | 0015411 | closed | dregad | Huge memory consumption for print_user_option_list() |
related to | 0021785 | closed | dregad | Manage User Search fails if there are spaces around the username |
has duplicate | 0023280 | closed | atrol | 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 | closed | vboctor | Search in Manage User should also match real names |
related to | 0023486 | closed | atrol | features for mange users module |
related to | 0023915 | closed | atrol | Search for a part of (Real Name - Username - Email) |
related to | 0027117 | closed | atrol | SQL syntax error on manage_user_page |
related to | 0027387 | closed | dregad | Manage user page table footer is displayed even when empty |
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. |
|
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. 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 |
|
There is a hardcoded $p_per_page = 50; in file manage_user_page.php line 159 |
|
Yes but this increase a max user per page on letter A B C or D... Again mayby i wrong explain. |
|
There is a link "All" left from letter A |
|
In case you want them all on one page, do the following: |
|
You got right i don`t saw "ALL" |
|
As I wrote: This is nothing more than a quick workaround for you |
|
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. |
|
attached an updated script which has the function to search for the users realname by wildcard. Simply replace original (after backing up). |
|
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. |
|
Ah, should have mentioned that. This is off the 1.2.4 version. |
|
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. |
|
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. |
|
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 |
|
Cas
I did not notice this, and could not reproduce it in my tests. |
|
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. |
|
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? |
|
Daryn, sounds as the ultimate solution to me. |
|
@Daryn,those strange entries may appear if someone has "autocomplete" switched on. |
|
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). |
|
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). |
|
Unassigned after having been assigned for a long time without progress. |
|
Hi team, |
|
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:
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 |
|
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. |
|
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.
Autocomplete list is optional from my perspective. |
|
@samtuke, |
|
@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. |
|
@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. |
|
@ Damien, @Sam, |
|
PR https://github.com/mantisbt/mantisbt/pull/1378 I had a very short look at it. |
|
Added some comments to the PR. |
|
Thanks for the provided feedback, will adjust and provide a new PR. |
|
@cas No need for a new PR, just add commits to your feature branch, then push it to GitHub - the PR will update automatically. |
|
committed updates in order to fix bug and to follow standard Mantis. Possibly this can be released soonest. |
|
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 I am asking myself if it would be better to remove some parts of the current UI. 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 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 |
|
OK, have changed the functionality as follows:
|
|
It would be good to get some feedback from @dregad and @samtuke concerning the proposed UI change. As a side note, we will have to check if
|
|
Fixed the UI behavior when switching between result pages (although a search should not have so many results). Just out of curiosity, why would adding an index not be acceptable within the 2.x releases? |
|
@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 |
|
There are use cases with many results, e.g. I get about 130 rows when searching for
Testing with 1000 records is not enough, as there installations with lot more users.
There was a decision that database schema of 1.3.x and 2.x.x should be exactly the same. I created a new PR https://github.com/mantisbt/mantisbt/pull/1381
@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 |
|
@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). |
|
@cas, as a side note. @ Roland does not notify me (@atrol), but another user.
Done |
|
Enhanced PR https://github.com/mantisbt/mantisbt/pull/1381
|
|
Nice enhancements, 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 |
|
Enhanced PR https://github.com/mantisbt/mantisbt/pull/1381
|
|
MantisBT: master 9d59867c 2018-08-09 06:19 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 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 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 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 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 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 |