View Issue Details

IDProjectCategoryView StatusLast Update
0011615mantisbtplug-inspublic2017-04-01 00:13
Reportercas Assigned Todregad  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionno change required 
Product Version1.2.0 
Summary0011615: Select reporter while adding an issue
Description

We use Mantis on the Helpdesk so needed to have the option to allow our helpdesk to select the original reporter while for example on the phone.
We have anabeld this feature by 2 settings in config_inc.php:
$g_select_reporter = ON;
$g_select_reporter_threshold = UPDATER;

Next we needed changes in the following 2 scripts:
bug_report.php
bug_report_page.php

Additional Information

in bug_report:

$t_bug_data->project_id = gpc_get_int( 'project_id' );
// CN-2 Begin
// $t_bug_data->reporter_id = auth_get_current_user_id();
if (( ON==config_get( 'select_reporter')) and ( access_has_project_level( config_get( 'select_reporter_threshold' ) ) )) {
$t_bug_data->reporter_id = gpc_get_int( 'reporter_id', 0 );
}else{
$t_bug_data->reporter_id = auth_get_current_user_id();
}
// CN-2 End
$t_bug_data->summary = trim( $t_bug_data->summary );

And in bug_report_page (around line 245 or other position if you please):
// CN-2 Begin
if ( ON==config_get( 'select_reporter')) {
if ( access_has_project_level( config_get( 'select_reporter_threshold' ) ) ) {
?>
<tr <?php echo helper_alternate_class() ?>>
<!-- Reporter -->
<td class="category">
<?php echo lang_get( 'reporter' ) ?>
</td>
<td>
<select tabindex="5" name="reporter_id">
<?php print_reporter_option_list( auth_get_current_user_id(), $t_bug->project_id ) ?>
</select>
</td>
</tr>
<?php
} ?>
<?php
}
// CN-2 End

TagsNo tags attached.
Attached Files
CustomReporterPlugin.php (1,724 bytes)   
<?php

class CustomReporterPlugin extends MantisPlugin {

	function register() {
		$this->name = 'CustomReporterPlugin';    # Proper name of plugin
		$this->description = '';    # Short description of the plugin
		$this->page = '';           # Default plugin page
		
		$this->version = '1.0';     # Plugin version string
		$this->requires = array(    # Plugin dependencies, array of basename => version pairs
		    'MantisCore' => '1.2.0',  #   Should always depend on an appropriate version of MantisBT
		    );
		
		$this->author = 'carlos proensa';         # Author/team name
		$this->contact = '';        # Author/team e-mail address
		$this->url = '';            # Support webpage
	}

	function hooks() {
		return array(
		'EVENT_REPORT_BUG_FORM_TOP' => 'reportBugFormTop',
		'EVENT_REPORT_BUG' => 'reportBug'
		);
	}


	function reportBugFormTop ( $p_event, $p_project_id){
		
		#
		#/ allow to change reporter_id (if access level is higher than reporter)
		#
		$user_id= auth_get_current_user_id();
		$access_level= user_get_access_level( $user_id, $p_project_id );
		if ($access_level > REPORTER) {
			echo '<tr><td>';
			echo 'Reporter: ';
				echo '<select '.helper_get_tab_index().' name="user_id">';
				print_reporter_option_list( $user_id, $p_new_bug->project_id );
				echo '</select>';
			echo '&nbsp;<input type="checkbox" value="'.$user_id.'" name="user_monitor" />Monitor this bug';
		}
		echo '</td></tr>';
	}


	function reportBug($p_event, $p_bug_data, $p_bug_id) {
		// this custom input was created on bug_report page event
		$t_add_user= gpc_get_int('user_monitor',0);
		if ($t_add_user!=0){
			bug_monitor($p_bug_id, $t_add_user);
		}
	}
}
?>
CustomReporterPlugin.php (1,724 bytes)   
CustomReporter.zip (2,480 bytes)
CustomReporter101.zip (2,515 bytes)
allow-changing-the-reporter-upon-cloning.patch (4,462 bytes)   
From 3dfe846b0878e702a88844a084a02ffcc610a0e8 Mon Sep 17 00:00:00 2001
From: Vincent Sels <vincent_sels@hotmail.com>
Date: Thu, 12 Jan 2012 23:02:52 +0100
Subject: [PATCH] Added features to allow changing the reporter upon cloning a
 bug

---
 bug_report.php          |    2 +-
 bug_report_page.php     |   35 +++++++++++++++++++++++++++++++++--
 config_defaults_inc.php |   13 +++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/bug_report.php b/bug_report.php
index 32e86f2..586ab44 100644
--- a/bug_report.php
+++ b/bug_report.php
@@ -94,7 +94,7 @@
 
 	$t_bug_data->project_id			= $t_project_id;
 
-	$t_bug_data->reporter_id		= auth_get_current_user_id();
+	$t_bug_data->reporter_id		= gpc_get_int( 'reporter_id', auth_get_current_user_id() );
 
 	$t_bug_data->summary			= trim( $t_bug_data->summary );
 
diff --git a/bug_report_page.php b/bug_report_page.php
index 06b2e77..a0d7e1b 100644
--- a/bug_report_page.php
+++ b/bug_report_page.php
@@ -33,10 +33,12 @@
 	require_once( 'file_api.php' );
 	require_once( 'custom_field_api.php' );
 	require_once( 'last_visited_api.php' );
+	require_once( 'ajax_api.php' );
 	require_once( 'projax_api.php' );
 	require_once( 'collapse_api.php' );
 
-	$f_master_bug_id = gpc_get_int( 'm_id', 0 );
+	$f_master_bug_id 	= gpc_get_int( 'm_id', 0 );
+	$f_reporter_id		= auth_get_current_user_id();
 
 	# this page is invalid for the 'All Project' selection except if this is a clone
 	if ( ( ALL_PROJECTS == helper_get_current_project() ) && ( 0 == $f_master_bug_id ) ) {
@@ -93,6 +95,10 @@
 		$f_due_date				= $t_bug->due_date;
 
 		$t_project_id			= $t_bug->project_id;
+		
+		if ( config_get( 'keep_original_reporter_on_clone' ) == ON ) {
+			$f_reporter_id		= $t_bug->reporter_id;
+		}
 	} else {
 	    access_ensure_project_level( config_get( 'report_bug_threshold' ) );
 
@@ -153,7 +159,11 @@
 	$tpl_show_due_date = in_array( 'due_date', $t_fields ) && access_has_project_level( config_get( 'due_date_update_threshold' ), helper_get_current_project(), auth_get_current_user_id() );
 	$tpl_show_attachments = in_array( 'attachments', $t_fields ) && file_allow_bug_upload();
 	$tpl_show_view_state = in_array( 'view_state', $t_fields ) && access_has_project_level( config_get( 'set_view_status_threshold' ) );
-
+	
+	if ( $f_master_bug_id > 0 && config_get( 'show_reporter_on_clone' ) == ON ) {
+		$tpl_show_reporter = true;
+	}
+	
 	# don't index bug report page
 	html_robots_noindex();
 
@@ -165,6 +175,7 @@
 <div align="center">
 <form name="report_bug_form" method="post" <?php if ( $tpl_show_attachments ) { echo 'enctype="multipart/form-data"'; } ?> action="bug_report.php">
 <?php echo form_security_field( 'bug_report' ) ?>
+<input type="hidden" name="reporter_id" value="<?php echo $f_reporter_id ?>" />
 <table class="width90" cellspacing="1">
 	<tr>
 		<td class="form-title" colspan="2">
@@ -175,6 +186,26 @@
 	</tr>
 <?php
 	event_signal( 'EVENT_REPORT_BUG_FORM_TOP', array( $t_project_id ) );
+	
+	if ( $tpl_show_reporter ) {
+?>
+		<tr <?php echo helper_alternate_class() ?>>
+			<td class="category">
+				<?php echo lang_get( 'reporter' ) ?>
+			</td>
+			<td>
+			<?php 
+			if ( ON == config_get( 'use_javascript' ) ) {
+				echo ajax_click_to_edit( prepare_user_name( $f_reporter_id ), 'reporter_id', 'entrypoint=issue_reporter_combobox&issue_id=' . $t_bug->id );
+			} else {
+			?>
+				<select <?php echo helper_get_tab_index() ?> name="reporter_id">
+					<?php print_reporter_option_list( $f_reporter_id, $t_project_id ); ?>
+				</select>
+			<?php } ?>
+			</td>
+		</tr>
+<?php }
 
 	if ( $tpl_show_category ) {
 ?>
diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index 7087dab..13ba6b4 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -2722,6 +2722,19 @@
 	 * @global int $g_set_configuration_threshold
 	 */
 	$g_set_configuration_threshold = ADMINISTRATOR;
+	
+	/**
+	 * Upon cloning a bug, allows a user with sufficient privileges to change the reporter.
+	 * @global int $g_show_reporter_on_clone
+	 */
+	$g_show_reporter_on_clone = OFF;
+	
+	/**
+	 * Specify whether upon cloning a bug, the reporter should be kept the same as the original (ON)
+	 * or the reporter should become the person cloning the ticket (OFF).
+	 * @global int $g_keep_original_reporter_on_clone
+	 */
+	$g_keep_original_reporter_on_clone = OFF;
 
 	/************************************
 	 * MantisBT Look and Feel Variables *
-- 
1.7.6.msysgit.0

Relationships

has duplicate 0012412 closeddregad "Reporter" should be editable by access level 
has duplicate 0010449 closedvboctor Report issue for an other reporter 
has duplicate 0005212 closedatrol Add an issue on behalf of someone else ? 
has duplicate 0007450 closedatrol Filing bugs on behalf of another user 
related to 0007630 closeddregad Override reporter_id 

Activities

yw84ever

yw84ever

2010-03-05 15:22

reporter   ~0024659

I suppose this is not something the use of a new field, "original reporter", could solve?

Or the idea was to change the one reported as having entered the issue into mantisbt?

cas

cas

2010-03-05 15:51

reporter   ~0024660

You mean a customfield? No, the idea is that the original reporter is kept up to date through the email function.

TomR

TomR

2010-03-06 16:00

reporter   ~0024664

Cas,

I was looking for this. In about 75% of our issues I had to change Reporter. ( Taking calls at the HelpDesk )

Thanks a lot, and I hope it will be in the next release. ( I updated 1.1.8 in stead of 1.2.0, but als works ).

Thanks a lot!!

cproensa

cproensa

2010-11-08 09:38

developer   ~0027307

you can do this in a cleaner way with a plugin, as we did:

capture the EVENT_REPORT_BUG_FORM_TOP event
and this sample code to print a dropdown with the available reporters for the project:

if ($access_level > REPORTER) {
echo '<tr><td>';
echo 'Reporter: ';
echo '<select '.helper_get_tab_index().' name="user_id">';
print_reporter_option_list( $user_id, $p_new_bug->project_id );
echo '</select>';
echo '</td></tr>';

Actually any posted field with name="user_id" will provide the reporter numerical id for the new bug

cproensa

cproensa

2010-11-08 09:43

developer   ~0027308

moreso:

you can extend the report form with the EVENT_REPORT_BUG_FORM_TOP, adding any additional input

then, do your stuff on the event EVENT_REPORT_BUG once the bug is created to modify it.

or:
write a custom_function_override_issue_create_validate function on custom_functions_inc.php
to process the bug data before it is created.

cas

cas

2010-11-08 10:16

reporter   ~0027309

Even better, where can i find the plugin?

cproensa

cproensa

2010-11-08 10:35

developer   ~0027310

there you have a sketch, should work if not for any syntax miss.
attached "CustomReporterPlugin.php"

that sets a selection of reporters form that project and a check to include yourself in the monitor list

cas

cas

2010-11-08 11:00

reporter   ~0027312

It does work but looks awfull as such. Will see if I can improve it a bit to fit standard layout.

cproensa

cproensa

2010-11-08 11:09

developer   ~0027313

sure, a sketch, i told you ;)

cas

cas

2010-11-09 06:07

reporter   ~0027317

Attached the plugin which now looks ok aswell.
In addition the level to select a Reporter can be set in the config of the plugin.
Thanks to Carlos

dregad

dregad

2010-11-12 04:26

developer   ~0027341

Last edited: 2010-11-12 04:57

Hi Cas,

I tried your plugin, as I was looking for such functionality as well. Thanks for your work.

I think there is an issue with the threshold, which apparently checks only the global access level, and not the project specific (I tested with an account with global Developer access, Manager for the project and set the threshold to Manager; the selection list did not appear, but came up when I change the threshold down to Developer)

Also, if I may pick nits:

  • On the plugin config: it's spellt "threshold", not "treshold"
  • it does not look right as it's not picking up the background color like the rest of the bug report page (see attached screenshot).

Damien

cas

cas

2010-11-12 06:46

reporter   ~0027346

ouch, you are precise.
Please try version 1.01 which hopefully addressed all 3 issues,

dregad

dregad

2010-11-12 12:23

developer   ~0027350

You fixed the cosmetic changes, but not the functional problem with the access level.

I have found the root cause, you're testing current access level > threshold, instead of >=.

I also found a few inconsistencies in the code around the use of strings. If you don't mind, I'll provide later on a version 1.02 including my fix, as well as some changes to the code to generalize use of strings instead of hardcoded text, some cosmetic improvements and reformatting the code to follow the MantisBT guidelines.

dregad

dregad

2010-11-12 16:41

developer   ~0027351

Here it goes... Tell me what you think !

TomR

TomR

2010-11-12 18:28

reporter   ~0027352

Last edited: 2010-11-12 18:28

Looks fine: found a typo however in strings_english.txt:

$s_plugin_customceporter_config = "Configuration";

should be

$s_plugin_customreporter_config = "Configuration";

dregad

dregad

2010-11-13 12:24

developer   ~0027357

Hi Tom

Which version did you download & test ? I corrected this in the 1.02 I uploaded yesterday.

To Cas and other potential contributors - I created a repository to track the source code on github - git://github.com/dregad/CustomReporter.git

Damien

TomR

TomR

2010-11-13 15:02

reporter   ~0027358

Last edited: 2010-11-13 16:28

Hi Damien, I downloaded 1.02. And was comparing with 1.01.

Perhaps I was not looking to well into the code. I downloaded 1.02 again, and now the code is looking fine.

dregad

dregad

2010-11-13 15:33

developer   ~0027359

Great! Let me know if you have any more feedback or suggestions for improvement.

dregad

dregad

2011-06-20 08:29

developer   ~0029042

Released new version 1.03 including fix from vboctor (Thanks!)

cas

cas

2011-06-24 10:03

reporter   ~0029057

How come this shows as updated while nothing seems to bechanged?

atrol

atrol

2011-06-26 14:12

developer   ~0029059

cas, good catch.
The field "Last Update" is set by changes you are not allowed to see. For example if someone adds himself to monitor the issue but you don't have the right to see the monitoring list.($g_show_monitor_list_threshold)

dregad

dregad

2011-06-27 11:47

developer   ~0029061

I populated the wiki page for the plugin (Thanks Victor for creating the page for me)
http://www.mantisbt.org/wiki/doku.php/mantisbt:customreporter

dregad

dregad

2011-07-13 19:02

developer   ~0029165

I have moved the git repository to the new mantisbt-plugins organization on github

https://github.com/mantisbt-plugins/CustomReporter

vincent_sels

vincent_sels

2012-01-12 17:11

reporter   ~0030899

Last edited: 2012-01-13 07:04

Hm, should have checked here before writing a solution myself :)
Mine only works for cloning though. Check out the github branch: https://github.com/vincentsels/mantisbt/tree/feature-change-reporter-on-clone
Edit: thought about making it a plug-in but didn't think it was big enough for it. The plug-in is nicer of course.
Edit2: if anyone is interested though, I added my changes as a patch on v1.2.8: allow-changing-the-reporter-upon-cloning.patch

dregad

dregad

2017-03-24 21:03

developer   ~0056188

Since this plugin is supported at https://github.com/mantisbt-plugins/CustomReporter, there is really no point in keeping this issue open.