Skip to content

Commit

Permalink
Allow adding monitors when reporting an issue
Browse files Browse the repository at this point in the history
By adding `monitors` to the $g_bug_report_page_fields array, users
having $g_monitor_add_others_bug_threshold access level will be able
to select users to add to the issue's monitoring list.

Monitors will only be notified of the submission if both their e-mail
prefs and the flags allow it (`$g_notify_flags['new']['monitor'] = ON`).

Fixes #6128
  • Loading branch information
dregad committed May 19, 2019
1 parent e58c20f commit 8b565c0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
10 changes: 10 additions & 0 deletions bug_report.php
Expand Up @@ -155,6 +155,16 @@
$t_issue['handler'] = array( 'id' => $t_handler_id );
}

$t_monitors = gpc_get_int_array( 'monitors', array() );
if( $t_monitors ) {
# The API expects a list of arrays with 'id' as key
$t_list = array();
foreach( $t_monitors as $t_monitor_id ) {
$t_list[] = array( 'id' => $t_monitor_id );
}
$t_issue['monitors'] = $t_list;
}

$t_view_state = gpc_get_int( 'view_state', 0 );
if( $t_view_state != 0 ) {
$t_issue['view_state'] = array( 'id' => $t_view_state );
Expand Down
18 changes: 17 additions & 1 deletion bug_report_page.php
Expand Up @@ -203,7 +203,10 @@
$t_show_severity = in_array( 'severity', $t_fields );
$t_show_priority = in_array( 'priority', $t_fields );
$t_show_steps_to_reproduce = in_array( 'steps_to_reproduce', $t_fields );
$t_show_handler = in_array( 'handler', $t_fields ) && access_has_project_level( config_get( 'update_bug_assign_threshold' ) );
$t_show_handler = in_array( 'handler', $t_fields )
&& access_has_project_level( config_get( 'update_bug_assign_threshold' ) );
$t_show_monitors = in_array( 'monitors', $t_fields )
&& access_has_project_level( config_get( 'monitor_add_others_bug_threshold' ) );
$t_show_profiles = config_get( 'enable_profiles' );
$t_show_platform = $t_show_profiles && in_array( 'platform', $t_fields );
$t_show_os = $t_show_profiles && in_array( 'os', $t_fields );
Expand Down Expand Up @@ -484,6 +487,19 @@
</tr>
<?php } ?>

<?php if( $t_show_monitors ) { ?>
<tr>
<th class="category">
<label for="monitors"><?php echo lang_get( 'monitored_by' ) ?></label>
</th>
<td>
<select <?php echo helper_get_tab_index() ?> id="monitors" name="monitors[]" class="input-sm" multiple>
<?php print_user_option_list( NO_USER, $t_project_id, config_get( 'monitor_bug_threshold' ) ) ?>
</select>
</td>
</tr>
<?php } ?>

<?php if( $t_show_status ) { ?>
<tr>
<th class="category">
Expand Down
9 changes: 8 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -530,7 +530,6 @@
*/
$g_notify_flags['new'] = array(
'bugnotes' => OFF,
'monitor' => OFF
);

$g_notify_flags['monitor'] = array(
Expand Down Expand Up @@ -2385,6 +2384,7 @@
* - category_id
* - due_date
* - handler
* - monitors
* - os
* - os_version
* - platform
Expand All @@ -2404,6 +2404,13 @@
* report page. Visibility of custom fields is handled via the Manage =>
* Manage Custom Fields administrator page.
*
* Note that 'monitors' is not an actual field; adding it to the list will let
* authorized reporters select users to add to the issue's monitoring list.
* Monitors will only be notified of the submission if both their e-mail prefs
* and the flags allow it (i.e. `$g_notify_flags['new']['monitor'] = ON`).
* @see $g_monitor_add_others_bug_threshold
* @see $g_notify_flags
*
* This setting can be set on a per-project basis by using the
* Manage => Manage Configuration administrator page.
*
Expand Down
12 changes: 12 additions & 0 deletions docbook/Admin_Guide/en-US/config/fields.xml
Expand Up @@ -43,6 +43,7 @@
category_id,
due_date,
handler,
monitors,
os,
os_version,
platform,
Expand All @@ -65,6 +66,17 @@
page. Visibility of custom fields is handled via the
Manage =&gt; Manage Custom Fields administrator page.
</para>
<para>Note that <emphasis>monitors</emphasis> is not an actual
field; adding it to the list will let authorized reporters
(see <emphasis>monitor_add_others_bug_threshold</emphasis>
in <xref linkend="admin.config.misc" />)
select users to add to the issue's monitoring list.
Monitors will only be notified of the submission if both
their e-mail preferencess and the <emphasis>notify_flags</emphasis>
configuration (see <xref linkend="admin.config.email" />)
allows it, i.e.
<programlisting>$g_notify_flags['new']['monitor'] = ON;</programlisting>
</para>
<para>
This setting can be set on a per-project basis by
using the Manage =&gt; Manage Configuration
Expand Down

0 comments on commit 8b565c0

Please sign in to comment.