View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0012557 | mantisbt | bugtracker | public | 2010-11-23 16:22 | 2022-01-24 03:39 |
Reporter | dregad | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | new | Resolution | open | ||
Product Version | 1.2.9 | ||||
Summary | 0012557: Bug view page: add monitoring for user select from list | ||||
Description | It would be nice when adding users to the monitoring list of an issue, to be able to select them from a list instead of having to type the username blindly, particularly when Mantis is configured to display Realnames. | ||||
Tags | patch | ||||
Attached Files | 0001-Fix-#12557:-Select-user-from-list-when-making-them-monitor-an-issue.patch (6,454 bytes)
From f93c18bc90d1fda86ec66ce9c33f984a77a40fdc Mon Sep 17 00:00:00 2001 From: Damien Regad <damien.regad@merckserono.net> Date: Tue, 23 Nov 2010 22:27:30 +0100 Subject: [PATCH] Fix #12557: Select user from list when making them monitor an issue This is more user friendly than having to type the the username, particularly when Mantis is configured to display Realnames --- bug_monitor_add.php | 14 +++----- bug_monitor_list_view_inc.php | 78 ++++++++++++++++++++++++++++++++++------- lang/strings_english.txt | 2 +- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/bug_monitor_add.php b/bug_monitor_add.php index 6bcc027..ce55d4d 100644 --- a/bug_monitor_add.php +++ b/bug_monitor_add.php @@ -34,20 +34,16 @@ $f_bug_id = gpc_get_int( 'bug_id' ); $t_bug = bug_get( $f_bug_id, true ); $f_username = gpc_get_string( 'username', '' ); + $f_user_id = gpc_get_string( 'user_id', '' ); $t_logged_in_user_id = auth_get_current_user_id(); - if ( is_blank( $f_username ) ) { + if ( is_blank( $f_user_id ) ) { $t_user_id = $t_logged_in_user_id; } else { - $t_user_id = user_get_id_by_name( $f_username ); - if ( $t_user_id === false ) { - $t_user_id = user_get_id_by_realname( $f_username ); - - if ( $t_user_id === false ) { - error_parameters( $f_username ); - trigger_error( ERROR_USER_BY_NAME_NOT_FOUND, E_USER_ERROR ); - } + $t_user_id = $f_user_id; + if( 0 == $t_user_id ) { + trigger_error( ERROR_USER_BY_ID_NOT_FOUND, E_USER_ERROR ); } } diff --git a/bug_monitor_list_view_inc.php b/bug_monitor_list_view_inc.php index 9a539f5..e2d6c8f 100644 --- a/bug_monitor_list_view_inc.php +++ b/bug_monitor_list_view_inc.php @@ -37,12 +37,12 @@ if ( access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $f_bug_i $result = db_query_bound($query, Array( $c_bug_id ) ); $num_users = db_num_rows($result); - $t_users = array(); + $t_users_monitoring = array(); for ( $i = 0; $i < $num_users; $i++ ) { $row = db_fetch_array( $result ); - $t_users[$i] = $row['user_id']; + $t_users_monitoring[$i] = $row['user_id']; } - user_cache_array_rows( $t_users ); + user_cache_array_rows( $t_users_monitoring ); echo '<a name="monitors" id="monitors" /><br />'; @@ -69,23 +69,75 @@ if ( access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $f_bug_i $t_can_delete_others = access_has_bug_level( config_get( 'monitor_delete_others_bug_threshold' ), $f_bug_id ); for ( $i = 0; $i < $num_users; $i++ ) { echo ($i > 0) ? ', ' : ''; - echo print_user( $t_users[$i] ); + echo print_user( $t_users_monitoring[$i] ); if ( $t_can_delete_others ) { - echo ' [<a class="small" href="' . helper_mantis_url( 'bug_monitor_delete.php' ) . '?bug_id=' . $f_bug_id . '&user_id=' . $t_users[$i] . form_security_param( 'bug_monitor_delete' ) . '">' . lang_get( 'delete_link' ) . '</a>]'; + echo ' [<a class="small" href="' . helper_mantis_url( 'bug_monitor_delete.php' ) + . '?bug_id=' . $f_bug_id . '&user_id=' . $t_users_monitoring[$i] + . form_security_param( 'bug_monitor_delete' ) . '">' + . lang_get( 'delete_link' ) . '</a>]'; } } } if ( access_has_bug_level( config_get( 'monitor_add_others_bug_threshold' ), $f_bug_id ) ) { - echo '<br /><br />', lang_get( 'username' ); + + # Build list of users who can monitor the bug, excluding those already monitoring it + # @@@ Code is mostly based on print_user_option_list - maybe modify that slightly, to avoid code duplication + $t_users_can_monitor = project_get_all_user_rows( $g_project_override, config_get( 'monitor_bug_threshold' ) ); + + $t_display = array(); + $t_sort = array(); + $t_show_realname = ( ON == config_get( 'show_realname' ) ); + $t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) ); + + foreach( $t_users_can_monitor as $key => $t_user ) { + + # If user is already monitoring the issue, remove them from list + if( in_array( $t_user['id'], $t_users_monitoring ) ) { + unset( $t_users_can_monitor[$key] ); + continue; + } + + $t_user_name = string_attribute( $t_user['username'] ); + $t_sort_name = utf8_strtolower( $t_user_name ); + if( $t_show_realname && ( $t_user['realname'] <> '' ) ) { + $t_user_name = string_attribute( $t_user['realname'] ); + if( $t_sort_by_last_name ) { + $t_sort_name_bits = explode( ' ', utf8_strtolower( $t_user_name ), 2 ); + $t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0]; + } else { + $t_sort_name = utf8_strtolower( $t_user_name ); + } + } + $t_display[] = $t_user_name; + $t_sort[] = $t_sort_name; + } + + # Display form only if there are users who can monitor the bug + if( count( $t_users_can_monitor ) > 0 ) { + array_multisort( $t_sort, SORT_ASC, SORT_STRING, $t_users_can_monitor, $t_display ); + echo '<br /><br />'; +?> + <form method="get" action="bug_monitor_add.php"> + <?php echo form_security_field( 'bug_monitor_add' ) ?> + <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> + <select name="user_id"> + <option value="0"></option>"; +<?php + # Build selection list with all users who can monitor this bug + foreach( $t_users_can_monitor as $key => $t_user ) { + echo '<option value="' . $t_user['id'] . '" '; + echo '>' . string_attribute( $t_display[$key] ) . '</option>'; + } +?> + </select> + + <input type="submit" class="button" value="<?php echo lang_get( 'add_user_to_monitor' ) ?>" /> + </form> +<?php + } + } ?> - <form method="get" action="bug_monitor_add.php"> - <?php echo form_security_field( 'bug_monitor_add' ) ?> - <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> - <input type="text" name="username" /> - <input type="submit" class="button" value="<?php echo lang_get( 'add_user_to_monitor' ) ?>" /> - </form> - <?php } ?> </td> </tr> </table> diff --git a/lang/strings_english.txt b/lang/strings_english.txt index eb21912..da61f2e 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -1248,7 +1248,7 @@ $s_move_bug_button = 'Move'; $s_attached_files = 'Attached Files'; $s_publish = 'Publish'; $s_cached = 'Cached'; -$s_add_user_to_monitor = 'Add'; +$s_add_user_to_monitor = 'Start Monitoring'; # view_bug_inc.php -- 1.7.1 0001-Fix-12557-for-mantis-1.2.5.patch (6,026 bytes)
From e145e849c8dd86fc1e57acc4bc076ff780874690 Mon Sep 17 00:00:00 2001 From: Damien Regad <damien.regad@merckserono.net> Date: Tue, 23 Nov 2010 22:27:30 +0100 Subject: [PATCH] Fix #12557: Select user from list when making them monitor an issue This is more user friendly than having to type the the username, particularly when Mantis is configured to display Realnames --- bug_monitor_add.php | 14 +++----- bug_monitor_list_view_inc.php | 72 +++++++++++++++++++++++++++++++++++------ lang/strings_english.txt | 2 +- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/bug_monitor_add.php b/bug_monitor_add.php index 7aca38c..5ba7b13 100644 --- a/bug_monitor_add.php +++ b/bug_monitor_add.php @@ -34,20 +34,16 @@ $f_bug_id = gpc_get_int( 'bug_id' ); $t_bug = bug_get( $f_bug_id, true ); $f_username = gpc_get_string( 'username', '' ); + $f_user_id = gpc_get_string( 'user_id', '' ); $t_logged_in_user_id = auth_get_current_user_id(); - if ( is_blank( $f_username ) ) { + if ( is_blank( $f_user_id ) ) { $t_user_id = $t_logged_in_user_id; } else { - $t_user_id = user_get_id_by_name( $f_username ); - if ( $t_user_id === false ) { - $t_user_id = user_get_id_by_realname( $f_username ); - - if ( $t_user_id === false ) { - error_parameters( $f_username ); - trigger_error( ERROR_USER_BY_NAME_NOT_FOUND, E_USER_ERROR ); - } + $t_user_id = $f_user_id; + if( 0 == $t_user_id ) { + trigger_error( ERROR_USER_BY_ID_NOT_FOUND, E_USER_ERROR ); } } diff --git a/bug_monitor_list_view_inc.php b/bug_monitor_list_view_inc.php index 039847d..de90565 100644 --- a/bug_monitor_list_view_inc.php +++ b/bug_monitor_list_view_inc.php @@ -51,26 +51,78 @@ if ( access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $f_bug_i if ( 0 == $num_users ) { echo lang_get( 'no_users_monitoring_bug' ); } else { - $t_can_delete_others = access_has_bug_level( config_get( 'monitor_delete_others_bug_threshold' ), $f_bug_id ); + $t_can_delete_others = access_has_bug_level( config_get( 'monitor_delete_others_bug_threshold' ), $f_bug_id ); for ( $i = 0; $i < $num_users; $i++ ) { echo ($i > 0) ? ', ' : ''; echo print_user( $t_users[$i] ); if ( $t_can_delete_others ) { - echo ' [<a class="small" href="' . helper_mantis_url( 'bug_monitor_delete.php' ) . '?bug_id=' . $f_bug_id . '&user_id=' . $t_users[$i] . form_security_param( 'bug_monitor_delete' ) . '">' . lang_get( 'delete_link' ) . '</a>]'; + echo ' [<a class="small" href="' . helper_mantis_url( 'bug_monitor_delete.php' ) + . '?bug_id=' . $f_bug_id . '&user_id=' . $t_users[$i] + . form_security_param( 'bug_monitor_delete' ) . '">' + . lang_get( 'delete_link' ) . '</a>]'; } } } if ( access_has_bug_level( config_get( 'monitor_add_others_bug_threshold' ), $f_bug_id ) ) { - echo '<br /><br />', lang_get( 'username' ); + + # Build list of users who can monitor the bug, excluding those already monitoring it + # @@@ Code is mostly based on print_user_option_list - maybe modify that slightly, to avoid code duplication + $t_users_can_monitor = project_get_all_user_rows( $g_project_override, config_get( 'monitor_bug_threshold' ) ); + + $t_display = array(); + $t_sort = array(); + $t_show_realname = ( ON == config_get( 'show_realname' ) ); + $t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) ); + + foreach( $t_users_can_monitor as $key => $t_user ) { + + # If user is already monitoring the issue, remove them from list + if( in_array( $t_user['id'], $t_users ) ) { + unset( $t_users_can_monitor[$key] ); + continue; + } + + $t_user_name = string_attribute( $t_user['username'] ); + $t_sort_name = utf8_strtolower( $t_user_name ); + if( $t_show_realname && ( $t_user['realname'] <> '' ) ) { + $t_user_name = string_attribute( $t_user['realname'] ); + if( $t_sort_by_last_name ) { + $t_sort_name_bits = explode( ' ', utf8_strtolower( $t_user_name ), 2 ); + $t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0]; + } else { + $t_sort_name = utf8_strtolower( $t_user_name ); + } + } + $t_display[] = $t_user_name; + $t_sort[] = $t_sort_name; + } + + # Display form only if there are users who can monitor the bug + if( count( $t_users_can_monitor ) > 0 ) { + array_multisort( $t_sort, SORT_ASC, SORT_STRING, $t_users_can_monitor, $t_display ); + echo '<br /><br />'; +?> + <form method="get" action="bug_monitor_add.php"> + <?php echo form_security_field( 'bug_monitor_add' ) ?> + <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> + <select name="user_id"> + <option value="0"></option>"; +<?php + # Build selection list with all users who can monitor this bug + foreach( $t_users_can_monitor as $key => $t_user ) { + echo '<option value="' . $t_user['id'] . '" '; + echo '>' . string_attribute( $t_display[$key] ) . '</option>'; + } +?> + </select> + + <input type="submit" class="button" value="<?php echo lang_get( 'add_user_to_monitor' ) ?>" /> + </form> +<?php + } + } ?> - <form method="get" action="bug_monitor_add.php"> - <?php echo form_security_field( 'bug_monitor_add' ) ?> - <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> - <input type="text" name="username" /> - <input type="submit" class="button" value="<?php echo lang_get( 'add_user_to_monitor' ) ?>" /> - </form> - <?php } ?> </td> </tr> </table> diff --git a/lang/strings_english.txt b/lang/strings_english.txt index cff3989..e3069a4 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -1248,7 +1248,7 @@ $s_move_bug_button = 'Move'; $s_attached_files = 'Attached Files'; $s_publish = 'Publish'; $s_cached = 'Cached'; -$s_add_user_to_monitor = 'Add'; +$s_add_user_to_monitor = 'Start Monitoring'; # view_bug_inc.php -- 1.7.1 | ||||
related to | 0012677 | closed | atrol | Please change a search option to manage users |
related to | 0025815 | closed | dregad | Users can't add monitors if access < show_monitor_list_threshold and >= monitor_add_others_bug_threshold |
has duplicate | 0015891 | closed | dregad | user dropdown selection box to assign viewers? |
has duplicate | 0019490 | closed | atrol | How can we add easily monitoring user in a mantis |
has duplicate | 0025837 | closed | atrol | Filed add users who track incident like a list from all users |
related to | 0021099 | new | Support auto-complete when adding user to monitor list on an issue |
Attached is my first shot at implementing this. It works but I am not fully satisfied by the code as it duplicates a lot of the logic in print_user_option_list. I am also not sure about the wording for the button, and whether there should be an explanatory text in front of the selection list. Feedback welcome. |
|
Updated patch (applies on top of 1.2.5) attached |
|
Hi dregad, |
|
An alternate and maybe better way of implementing this feature could be to use the same code as proposed by daryn in 0012677:0028099 - it would at least avoid the code duplication from print_user_option_list (but only works in 1.3.x). |
|
Hi, I have no clue how to impelment a .patch file. Any tips? |
|
Do these patch files work for MantisBT 1.2.15? |
|
Hello, I just double-checked and can confirm that the patch does apply cleanly on latest 1.2.20dev (so it most likely does on 1.2.15 as well). When applying git-formatted patches, as mentioned in the error message you got, you need to use the -p option, like so: <pre> HTH |
|
Thanks dregad for the help. I have no experience with .patch and I don't want to accidentally break my mantis install so I'm a bit cautious! I ran the patch with the flags you suggested and got the error and output shown below. (I have rolled back the patch for the time being). From googling it suggests manually patching the file with the details from the .rej file but I was unable to find "$t_users = array();" in my original file. I also downloaded mantis 1.2.19 and checked the same file there and also could not find that string. -------RUNNING THE FIRST PATCH-------
-------bug_monitor_list_view_inc.php.rej FROM FIRST PATCH------- |
|
I don't have time to look into details atm, but I suspect you're attempting to apply the old patch (for Mantis <= 1.2.4). Try again with 0001-Fix-12557-for-mantis-1.2.5.patch |
|
That worked. Thanks dregad! ====== Summary for future readers: ======
====== How to patch (for noobs): ======
|
|
Glad you could sort things out, and thanks for posting your feedback. |
|
Hello, |
|
@cid (This works with MantisBT-1.3 ( use master-1.3.x branch) and MantisBT-2.0 (master branch) |
|
@libregeek; I have tried the plugin but it says it needs MantisBt Core2.0.0 and I am using 1.3.5 Thanks |
|
@elftron Try master-1.3.x branch instead of the branch. You can get it directly from https://github.com/ejyothi/MantisBT-AjaxUserMonitoring/tree/master-1.3.x |
|
@libregeek Thank you., Works perfectly and I now have a greater understanding of the Master Tree system |
|
Hello, since all my projects in Mantis are private I'd like to see only users who belong to the current project, tried this plugin but everyone sees every user to add in the box. Any idea? |
|
@dregad |
|
related to and the cause for Realnameproblems since 2.12.0 which are solved by this https://mantisbt.org/bugs/view.php?id=24139#c59850 |
|
https://github.com/mantisbt/mantisbt/pull/1351#issuecomment-391495880 @atrol - great Job! |
|
Hi: Is there any patch for version 9.3.3 ? drop list of users for monitoring a issue. Thanks in advance |
|
Update to latest version. |
|
Hi again: Thanks a lot |
|
It depends on your rights You can send an reminder there is a drop down |
|
A Combo to select users will be nice as written above |
|
Mantis 2.21.0 Error: Please, can you check? |
|
I am not using this functionality anymore - with a large number of users it becomes counterproductive to have a selection list vs typing the users' names in the field. Anyway, here's an updated version of the patch. Note that this is against current dev-master (commit afb40dca79e54ff9c453d8bbe1b747c972e38f6f). NOTE: I did not test with older versions, and in fact it may not apply cleanly on 2.21.0 and older, because of changes introduced in 0025815. 0001-fix-12557-for-mantis-2.22.0-dev.patch (6,301 bytes)
From 020d09ac3a93a75c698dee1e90cc4f9222e984b1 Mon Sep 17 00:00:00 2001 From: Damien Regad <dregad@mantisbt.org> Date: Wed, 5 Jun 2019 15:09:30 +0200 Subject: [PATCH 1/2] Add monitors to a bug by selecting users from list This is more user friendly than having to type the the username, particularly when Mantis is configured to display Realnames Fixes #12557 --- bug_monitor_add.php | 30 +++++----------- bug_monitor_list_view_inc.php | 66 ++++++++++++++++++++++++++++++----- lang/strings_english.txt | 2 +- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/bug_monitor_add.php b/bug_monitor_add.php index b5c18ff5d..f6d252f27 100644 --- a/bug_monitor_add.php +++ b/bug_monitor_add.php @@ -15,7 +15,7 @@ # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. /** - * This file turns monitoring on or off for a bug for the current user + * This file adds the current or specified user(s) to a bug's monitoring list * * @package MantisBT * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org @@ -23,44 +23,32 @@ * @link http://www.mantisbt.org * * @uses core.php - * @uses access_api.php * @uses form_api.php * @uses gpc_api.php - * @uses helper_api.php * @uses print_api.php - * @uses utility_api.php */ require_once( 'core.php' ); -require_api( 'error_api.php' ); require_api( 'form_api.php' ); require_api( 'gpc_api.php' ); -require_api( 'helper_api.php' ); require_api( 'print_api.php' ); -require_api( 'utility_api.php' ); form_security_validate( 'bug_monitor_add' ); $f_bug_id = gpc_get_int( 'bug_id' ); -$f_usernames = trim( gpc_get_string( 'username', '' ) ); - -$t_payload = array(); - -if( !is_blank( $f_usernames ) ) { - $t_usernames = preg_split( '/[,|]/', $f_usernames, -1, PREG_SPLIT_NO_EMPTY ); - $t_users = array(); - foreach( $t_usernames as $t_username ) { - $t_users[] = array( 'name_or_realname' => trim( $t_username ) ); - } - - $t_payload['users'] = $t_users; -} +$f_user_ids = gpc_get_int_array( 'user_id', array() ); $t_data = array( 'query' => array( 'issue_id' => $f_bug_id ), - 'payload' => $t_payload, ); +if( $f_user_ids ) { + foreach( $f_user_ids as $t_user_id ) { + $t_users[] = array( 'id' => $t_user_id ); + } + $t_data['payload'] = array( 'users' => $t_users ); +} + $t_command = new MonitorAddCommand( $t_data ); $t_command->execute(); diff --git a/bug_monitor_list_view_inc.php b/bug_monitor_list_view_inc.php index 6cafd9275..d8cc8e342 100644 --- a/bug_monitor_list_view_inc.php +++ b/bug_monitor_list_view_inc.php @@ -119,17 +119,65 @@ if( $t_can_see_monitors || $t_can_add_others ) { </div> <?php if( $t_can_add_others ) { + # Build list of users who can monitor the bug, excluding those already monitoring it + # @@@ Code is mostly based on print_user_option_list - maybe modify that slightly, to avoid code duplication + $t_users_can_monitor = project_get_all_user_rows( $g_project_override, config_get( 'monitor_bug_threshold' ) ); + + $t_display = array(); + $t_sort = array(); + $t_show_realname = ( ON == config_get( 'show_realname' ) ); + $t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) ); + + foreach( $t_users_can_monitor as $key => $t_user ) { + + # If user is already monitoring the issue, remove them from list + if( in_array( $t_user['id'], $t_users ) ) { + unset( $t_users_can_monitor[$key] ); + continue; + } + + $t_user_name = string_attribute( $t_user['username'] ); + $t_sort_name = mb_strtolower( $t_user_name ); + if( $t_show_realname && ( $t_user['realname'] <> '' ) ) { + $t_user_name = string_attribute( $t_user['realname'] ); + if( $t_sort_by_last_name ) { + $t_sort_name_bits = explode( ' ', mb_strtolower( $t_user_name ), 2 ); + $t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0]; + } else { + $t_sort_name = mb_strtolower( $t_user_name ); + } + } + $t_display[] = $t_user_name; + $t_sort[] = $t_sort_name; + } + + # Display form only if there are users who can monitor the bug + if( count( $t_users_can_monitor ) > 0 ) { + array_multisort( $t_sort, SORT_ASC, SORT_STRING, $t_users_can_monitor, $t_display ); +?> + <div class="space-10"></div> + <form method="get" action="bug_monitor_add.php"> + <?php echo form_security_field( 'bug_monitor_add' ) ?> + <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> + <select name="user_id[]" class="input-sm" multiple> + <option value="0"><?php echo '[' . lang_get( 'myself' ) . ']'; ?></option>"; +<?php + # Build selection list with all users who can monitor this bug + foreach( $t_users_can_monitor as $key => $t_user ) { + echo '<option value="' . $t_user['id'] . '" '; + echo '>' . string_attribute( $t_display[$key] ) . '</option>'; + } ?> + </select> - <div class="space-10"></div> - <form method="get" action="bug_monitor_add.php" class="form-inline noprint"> - <?php echo form_security_field( 'bug_monitor_add' ) ?> - <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> - <label for="bug_monitor_list_username"><?php echo lang_get( 'username' ) ?></label> - <input type="text" class="input-sm" id="bug_monitor_list_username" name="username" /> - <input type="submit" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'add_user_to_monitor' ) ?>" /> - </form> -<?php } ?> + <button class="btn btn-primary btn-sm btn-white btn-round"> + <?php echo lang_get( 'add_user_to_monitor' ) ?> + </button> + </form> +<?php + } + } +?> </td> </tr> </table> diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 87cfeca49..e98b320bc 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -1280,7 +1280,7 @@ $s_close_bug_button = 'Close'; $s_move_bug_button = 'Move'; $s_attached_files = 'Attached Files'; $s_publish = 'Publish'; -$s_add_user_to_monitor = 'Add'; +$s_add_user_to_monitor = 'Start Monitoring'; # view_bug_page.php $s_bug_view_title = 'View Issue Details'; -- 2.17.0 |
|
sudo patch --dry-run -p1 <0001-fix-12557-for-mantis-2.22.0-dev.patch |
|
Yeah well as I said before
QED. I'm not going to adapt the patch for compatibility with earlier versions. Feel free to do so yourself if you need it. |
|
Thanks so much for your patch. I think it should be integrated in the next version. The feature is really cool and expected. |
|
Hello, Why the resolution of this issue is not resolved ? The version actually in developpement is the 2.24.1 so > 2.21. Currently we prepare a big upgrade (1.2.10 to the last stable version) so It will be nice to me to know if this feature is ready or not ? Thank a lot for your answer. and have a good Week. |
|
It is not planned at all, I think you misinterpreted what I wrote.
Because it is not resolved... and unlikely to be in the near future too.
It will not be integrated into MantisBT core in its current form, for the reasons explained in earlier notes
Anyway for convenience, please find attached an updated patch for 2.24.0 0001-fix-12557-for-mantis-2.24.0-dev.patch (6,395 bytes)
From 696c7e223968f7c0298ef5819996188a680a1dd4 Mon Sep 17 00:00:00 2001 From: Damien Regad <dregad@mantisbt.org> Date: Wed, 5 Jun 2019 15:09:30 +0200 Subject: [PATCH] Add monitors to a bug by selecting users from list This is more user friendly than having to type the the username, particularly when Mantis is configured to display Realnames Fixes #12557 --- bug_monitor_add.php | 30 +++++----------- bug_monitor_list_view_inc.php | 66 ++++++++++++++++++++++++++++++----- lang/strings_english.txt | 2 +- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/bug_monitor_add.php b/bug_monitor_add.php index b5c18ff5d..f6d252f27 100644 --- a/bug_monitor_add.php +++ b/bug_monitor_add.php @@ -15,7 +15,7 @@ # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. /** - * This file turns monitoring on or off for a bug for the current user + * This file adds the current or specified user(s) to a bug's monitoring list * * @package MantisBT * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org @@ -23,44 +23,32 @@ * @link http://www.mantisbt.org * * @uses core.php - * @uses access_api.php * @uses form_api.php * @uses gpc_api.php - * @uses helper_api.php * @uses print_api.php - * @uses utility_api.php */ require_once( 'core.php' ); -require_api( 'error_api.php' ); require_api( 'form_api.php' ); require_api( 'gpc_api.php' ); -require_api( 'helper_api.php' ); require_api( 'print_api.php' ); -require_api( 'utility_api.php' ); form_security_validate( 'bug_monitor_add' ); $f_bug_id = gpc_get_int( 'bug_id' ); -$f_usernames = trim( gpc_get_string( 'username', '' ) ); - -$t_payload = array(); - -if( !is_blank( $f_usernames ) ) { - $t_usernames = preg_split( '/[,|]/', $f_usernames, -1, PREG_SPLIT_NO_EMPTY ); - $t_users = array(); - foreach( $t_usernames as $t_username ) { - $t_users[] = array( 'name_or_realname' => trim( $t_username ) ); - } - - $t_payload['users'] = $t_users; -} +$f_user_ids = gpc_get_int_array( 'user_id', array() ); $t_data = array( 'query' => array( 'issue_id' => $f_bug_id ), - 'payload' => $t_payload, ); +if( $f_user_ids ) { + foreach( $f_user_ids as $t_user_id ) { + $t_users[] = array( 'id' => $t_user_id ); + } + $t_data['payload'] = array( 'users' => $t_users ); +} + $t_command = new MonitorAddCommand( $t_data ); $t_command->execute(); diff --git a/bug_monitor_list_view_inc.php b/bug_monitor_list_view_inc.php index 8b41e48ec..ebbcedb09 100644 --- a/bug_monitor_list_view_inc.php +++ b/bug_monitor_list_view_inc.php @@ -119,17 +119,65 @@ if( $t_can_see_monitors || $t_can_add_others ) { </div> <?php if( $t_can_add_others ) { + # Build list of users who can monitor the bug, excluding those already monitoring it + # @@@ Code is mostly based on print_user_option_list - maybe modify that slightly, to avoid code duplication + $t_users_can_monitor = project_get_all_user_rows( $g_project_override, config_get( 'monitor_bug_threshold' ) ); + + $t_display = array(); + $t_sort = array(); + $t_show_realname = ( ON == config_get( 'show_realname' ) ); + $t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) ); + + foreach( $t_users_can_monitor as $key => $t_user ) { + + # If user is already monitoring the issue, remove them from list + if( in_array( $t_user['id'], $t_users ) ) { + unset( $t_users_can_monitor[$key] ); + continue; + } + + $t_user_name = string_attribute( $t_user['username'] ); + $t_sort_name = mb_strtolower( $t_user_name ); + if( $t_show_realname && ( $t_user['realname'] <> '' ) ) { + $t_user_name = string_attribute( $t_user['realname'] ); + if( $t_sort_by_last_name ) { + $t_sort_name_bits = explode( ' ', mb_strtolower( $t_user_name ), 2 ); + $t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0]; + } else { + $t_sort_name = mb_strtolower( $t_user_name ); + } + } + $t_display[] = $t_user_name; + $t_sort[] = $t_sort_name; + } + + # Display form only if there are users who can monitor the bug + if( count( $t_users_can_monitor ) > 0 ) { + array_multisort( $t_sort, SORT_ASC, SORT_STRING, $t_users_can_monitor, $t_display ); +?> + <div class="space-10"></div> + <form method="get" action="bug_monitor_add.php"> + <?php echo form_security_field( 'bug_monitor_add' ) ?> + <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> + <select name="user_id[]" class="input-sm" multiple> + <option value="0"><?php echo '[' . lang_get( 'myself' ) . ']'; ?></option>"; +<?php + # Build selection list with all users who can monitor this bug + foreach( $t_users_can_monitor as $key => $t_user ) { + echo '<option value="' . $t_user['id'] . '" '; + echo '>' . string_attribute( $t_display[$key] ) . '</option>'; + } ?> + </select> - <div class="space-10"></div> - <form method="get" action="bug_monitor_add.php" class="form-inline noprint"> - <?php echo form_security_field( 'bug_monitor_add' ) ?> - <input type="hidden" name="bug_id" value="<?php echo (integer)$f_bug_id; ?>" /> - <label for="bug_monitor_list_username"><?php echo lang_get( 'username' ) ?></label> - <input type="text" class="input-sm" id="bug_monitor_list_username" name="username" /> - <input type="submit" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'add_user_to_monitor' ) ?>" /> - </form> -<?php } ?> + <button class="btn btn-primary btn-sm btn-white btn-round"> + <?php echo lang_get( 'add_user_to_monitor' ) ?> + </button> + </form> +<?php + } + } +?> </td> </tr> </table> diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 11d04b9bc..a2f9bdc1c 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -1284,7 +1284,7 @@ $s_close_bug_button = 'Close'; $s_move_bug_button = 'Move'; $s_attached_files = 'Attached Files'; $s_publish = 'Publish'; -$s_add_user_to_monitor = 'Add'; +$s_add_user_to_monitor = 'Start Monitoring'; $s_browser_does_not_support_audio = 'Your browser does not support audio tag.'; $s_browser_does_not_support_video = 'Your browser does not support video tag.'; -- 2.17.1 |
|
@dregad - there is a similar list in "send a reminder" function, which is easy and smooth to use. |
|
Hello @Dregad, thank a lot for your quick response. It is clearly. For my opinion the most useful feature it should be the automatic completion by first name or by last name. @ Mahindra : I Don't know what it is a "send a reminder" function, it is perhaps a useful solution too. |
|
@cathbis The function depends on your rights and is not visible here (maybe in your mantis) |
|
@mahindra I know about the reminder feature, thanks. I'm not sure I get your point though - this is essentially the same UI as the one used in my patch, and suffers from the same problem and limitation I outlined in 0012557:0063868 (point 2). It is not an issue there, because the list of recipients for reminders is usually quite short as it's limited to developers by default, but if you take for example an instance like mantisbt.org where we have nearly 40'000 users with 99.9% of them being reporters, selection lists are simply not an option - just retrieving the data and having the browser render it can take several minutes. The proper solution for this issue, as mentioned by @cathbis, is to use a text field with automatic completion. |
|
@dregad thank you - I think you are right. |
|
Patch 2.24 doesn't work for me. I have mantis 2.24.2 installed. I tried to patch using svn patch method. I can see all 3 files updated. Restarted everything, but It doesn't work. "Add" is replaced by "Start Monitoring", But when I type a name nothing comes up and when I press enter with any valid or invalid entry, it adds me as monitor. |
|
This is because one of the patched files, So while the patch I uploaded in 0012557:0063868 applies, it is effectively useless. I am not going to update or maintain this anymore; if you're interested in this functionality, you're welcome to adapt it to work with MantisBT >= 2.23.0. |
|
@dregad did you know how to add the user list in 2.25 version ? thanks. |
|
@Phill as mentioned in 0012557:0065068
Thanks for your understanding. |
|