View Issue Details

IDProjectCategoryView StatusLast Update
0013233mantisbtfeaturepublic2014-11-07 17:02
Reportervincent_sels Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.1.8 
Summary0013233: Allow status change upon moving tickets to another project
Description

When you move a ticket to another project using the 'Move' button, it would be nice to directly be able to change the status and the user it is assigned to.

Personally, when I move a ticket to another project, I want the status to be changed to 'new', and the ticket to not be assigned to anyone any more. It is not always certain that the user the ticket was assigned to will have sufficient privileges to view it in the new project - so a filter on users based on the selected project would be even better.

Tagspatch
Attached Files
2011-09-22_225054.png (3,870 bytes)   
2011-09-22_225054.png (3,870 bytes)   
0013233.diff (9,136 bytes)   
--- C:/Documents and Settings/vsel/mantisbt-1.2.8/bug_actiongroup_page.php	Tue Sep 06 10:23:10 2011
+++ C:/Documents and Settings/vsel/mantisbt-edited/bug_actiongroup_page.php	Thu Sep 22 23:36:42 2011
@@ -123,6 +123,10 @@
 			$t_question_title 		= lang_get( 'move_bugs_conf_msg' );
 			$t_button_title 		= lang_get( 'move_group_bugs_button' );
 			$t_form					= 'project_id';
+			$t_question_title2		= lang_get( 'assign_bugs_conf_msg' );
+			$t_form2				= 'assign';
+			$t_question_title3		= lang_get( 'status_bugs_conf_msg' );
+			$t_form3				= 'status';
 			break;
 
 		case 'COPY' :
@@ -296,6 +300,39 @@
 		</tr>
 	<?php
 				}
+				break;
+			case 'MOVE':
+	?>
+		<tr class="row-2">
+			<td class="category">
+				<?php echo $t_question_title2 ?>
+			</td>
+			<td>
+				<select name="<?php echo $t_form2 ?>">
+					<option value="0"></option>
+					<?php print_assign_to_option_list( '', ALL_PROJECTS );?>
+				</select>
+			</td>
+		</tr>
+	<?php
+				break;
+		}
+	}
+	if ( isset( $t_question_title3 ) ) {
+		switch ( $f_action ) {
+			case 'MOVE':
+	?>
+		<tr class="row-2">
+			<td class="category">
+				<?php echo $t_question_title3 ?>
+			</td>
+			<td>
+				<select name="<?php echo $t_form3 ?>">
+					<?php print_enum_string_option_list( 'status', config_get( 'bug_move_status' ) );?>
+				</select>
+			</td>
+		</tr>
+	<?php
 				break;
 		}
 	}
--- C:/Documents and Settings/vsel/mantisbt-1.2.8/bug_actiongroup.php	Tue Sep 06 10:23:10 2011
+++ C:/Documents and Settings/vsel/mantisbt-edited/bug_actiongroup.php	Thu Sep 22 22:50:02 2011
@@ -68,9 +68,7 @@
 
 		$t_status = $t_bug->status;
 
-		switch ( $f_action ) {
-
-		case 'CLOSE':
+		if ( $f_action == 'CLOSE' ) {
 			$t_closed = config_get( 'bug_closed_status_threshold' );
 			if ( access_can_close_bug( $t_bug_id ) &&
 					( $t_status < $t_closed ) &&
@@ -86,18 +84,18 @@
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 				}
 			}
-			break;
+		}
 
-		case 'DELETE':
+		if ( $f_action == 'DELETE' ) {
 			if ( access_has_bug_level( config_get( 'delete_bug_threshold' ), $t_bug_id ) ) {
 				event_signal( 'EVENT_BUG_DELETED', array( $t_bug_id ) );
 				bug_delete( $t_bug_id );
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'MOVE':
+		if ( $f_action == 'MOVE' ) {
 			$f_project_id = gpc_get_int( 'project_id' );
 			if ( access_has_bug_level( config_get( 'move_bug_threshold' ), $t_bug_id ) &&
 			     access_has_project_level( config_get( 'report_bug_threshold' ), $f_project_id ) ) {
@@ -107,9 +105,9 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'COPY':
+		if ( $f_action == 'COPY' ) {
 			$f_project_id = gpc_get_int( 'project_id' );
 
 			if ( access_has_project_level( config_get( 'report_bug_threshold' ), $f_project_id ) ) {
@@ -117,10 +115,14 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'ASSIGN':
+		if ( $f_action == 'ASSIGN' || $f_action == 'MOVE' ) {
 			$f_assign = gpc_get_int( 'assign' );
+			
+			if ( $f_assign == NO_USER ) {
+				bug_assign( $t_bug_id, $f_assign, $f_bug_notetext, $f_bug_noteprivate );
+			} else {
 			if ( ON == config_get( 'auto_set_status_to_assigned' ) ) {
 				$t_assign_status = config_get( 'bug_assigned_status' );
 			} else {
@@ -128,7 +130,11 @@
 			}
 			# check that new handler has rights to handle the issue, and
 			#  that current user has rights to assign the issue
-			$t_threshold = access_get_status_threshold( $t_assign_status, bug_get_field( $t_bug_id, 'project_id' ) );
+				$t_target_project = bug_get_field( $t_bug_id, 'project_id' );
+				if ( $f_action == 'MOVE' ) {
+					$t_target_project = gpc_get_int( 'project_id' );
+				}
+				$t_threshold = access_get_status_threshold( $t_assign_status, $t_target_project );
 			if ( access_has_bug_level( $t_threshold , $t_bug_id, $f_assign ) &&
 				 access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $t_bug_id ) &&
 					bug_check_workflow($t_status, $t_assign_status )	) {
@@ -142,9 +148,10 @@
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 				}
 			}
-			break;
+			}
+		}
 
-		case 'RESOLVE':
+		if ( $f_action == 'RESOLVE' ) {
 			$t_resolved_status = config_get( 'bug_resolved_status_threshold' );
 			if ( access_has_bug_level( access_get_status_threshold( $t_resolved_status, bug_get_field( $t_bug_id, 'project_id' ) ), $t_bug_id ) &&
 				 		( $t_status < $t_resolved_status ) &&
@@ -162,9 +169,9 @@
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 				}
 			}
-			break;
+		}
 
-		case 'UP_PRIOR':
+		if ( $f_action == 'UP_PRIOR' ) {
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				$f_priority = gpc_get_int( 'priority' );
 				/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
@@ -173,11 +180,14 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'UP_STATUS':
+		if ( $f_action == 'UP_STATUS' || $f_action == 'MOVE' ) {
 			$f_status = gpc_get_int( 'status' );
 			$t_project = bug_get_field( $t_bug_id, 'project_id' );
+			if ( $f_action == 'MOVE' ) {
+				$t_project = gpc_get_int( 'project_id' );
+			}
 			if ( access_has_bug_level( access_get_status_threshold( $f_status, $t_project ), $t_bug_id ) ) {
 				if ( TRUE == bug_check_workflow($t_status, $f_status ) ) {
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
@@ -195,9 +205,9 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'UP_CATEGORY':
+		if ( $f_action == 'UP_CATEGORY' ) {
 			$f_category_id = gpc_get_int( 'category' );
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				if ( category_exists( $f_category_id ) ) {
@@ -210,9 +220,9 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'UP_FIXED_IN_VERSION':
+		if ( $f_action == 'UP_FIXED_IN_VERSION' ) {
 			$f_fixed_in_version = gpc_get_string( 'fixed_in_version' );
 			$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
 			$t_success = false;
@@ -229,9 +239,9 @@
 			if ( !$t_success ) {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'UP_TARGET_VERSION':
+		if ( $f_action == 'UP_TARGET_VERSION' ) {
 			$f_target_version = gpc_get_string( 'target_version' );
 			$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
 			$t_success = false;
@@ -248,9 +258,9 @@
 			if ( !$t_success ) {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'VIEW_STATUS':
+		if ( $f_action == 'VIEW_STATUS' ) {
 			if ( access_has_bug_level( config_get( 'change_view_status_threshold' ), $t_bug_id ) ) {
 				$f_view_status = gpc_get_int( 'view_status' );
 				/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
@@ -259,9 +269,9 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'SET_STICKY':
+		if ( $f_action == 'SET_STICKY' ) {
 			if ( access_has_bug_level( config_get( 'set_bug_sticky_threshold' ), $t_bug_id ) ) {
 				$f_sticky = bug_get_field( $t_bug_id, 'sticky' );
 				// The new value is the inverted old value
@@ -271,9 +281,9 @@
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
-			break;
+		}
 
-		case 'CUSTOM':
+		if ( $f_action == 'CUSTOM' ) {
 			if ( 0 === $f_custom_field_id ) {
 				trigger_error( ERROR_GENERIC, ERROR );
 			}
@@ -283,10 +293,6 @@
 			$t_custom_field_value = gpc_get_custom_field( $t_form_var, $t_custom_field_def['type'], null );
 			custom_field_set_value( $f_custom_field_id, $t_bug_id, $t_custom_field_value );
 			helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
-			break;
-
-		default:
-			trigger_error( ERROR_GENERIC, ERROR );
 		}
 
 		// Bug Action Event
--- C:/Documents and Settings/vsel/mantisbt-1.2.8/config_defaults_inc.php	Tue Sep 06 10:23:10 2011
+++ C:/Documents and Settings/vsel/mantisbt-edited/config_defaults_inc.php	Mon Sep 26 21:41:15 2011
@@ -1760,6 +1760,12 @@
 	$g_bug_submit_status = NEW_;
 
 	/**
+	 * Status to assign to the bug when moved between projects.
+	 * @global int $g_bug_moved_status
+	 */
+	$g_bug_move_status = '%bug_submit_status%';
+
+	/**
 	 * Status to assign to the bug when assigned.
 	 * @global int $g_bug_assigned_status
 	 */
0013233.diff (9,136 bytes)   

Relationships

related to 0012667 closedvboctor Moving issues between projects doesn't update the category 
related to 0010325 confirmed Move should have the option of changing categories 

Activities

vincent_sels

vincent_sels

2011-09-15 17:42

reporter   ~0029737

Last edited: 2011-09-15 17:43

This feature is related to the following tickets:
0012667 - Moving issues between projects doesn't update the category (solved in v1.2.5)
0010325 - Move should have the option of changing categories (assigned)

vincent_sels

vincent_sels

2011-09-22 17:08

reporter   ~0029845

Last edited: 2011-09-22 17:17

I achieved this (see attached screenshot) by making the following changes:

Added a new config: $g_bug_move_status = '%bug_submit_status%';


File: bug_actiongroup_page


case 'MOVE' :
$t_question_title = lang_get( 'move_bugs_conf_msg' );
$t_button_title = lang_get( 'move_group_bugs_button' );
$t_form = 'project_id';
$t_question_title2 = lang_get( 'assign_bugs_conf_msg' );
$t_form2 = 'assign';
$t_question_title3 = lang_get( 'status_bugs_conf_msg' );
$t_form3 = 'status';
break;

...

<?php
if ( isset( $t_question_title2 ) ) {
switch ( $f_action ) {
case 'RESOLVE':
$t_show_product_version = ( ON == config_get( 'show_product_version' ) )
|| ( ( AUTO == config_get( 'show_product_version' ) )
&& ( count( version_get_all_rows( $t_project_id ) ) > 0 ) );
if ( $t_show_product_version ) {
?>
<tr class="row-2">
<td class="category">
<?php echo $t_question_title2 ?>
</td>
<td>
<select name="<?php echo $t_form2 ?>">
<?php print_version_option_list( '', null, VERSION_ALL );?>
</select>
</td>
</tr>
<?php
}
break;
case 'MOVE':
?>
<tr class="row-2">
<td class="category">
<?php echo $t_question_title2 ?>
</td>
<td>
<select name="<?php echo $t_form2 ?>">
<option value="0"></option>
<?php print_assign_to_option_list( '', ALL_PROJECTS );?>
</select>
</td>
</tr>
<?php
break;
}
}
if ( isset( $t_question_title3 ) ) {
switch ( $f_action ) {
case 'MOVE':
?>
<tr class="row-2">
<td class="category">
<?php echo $t_question_title3 ?>
</td>
<td>
<select name="<?php echo $t_form3 ?>">
<?php print_enum_string_option_list( 'status', config_get( 'bug_move_status' ) );?>
</select>
</td>
</tr>
<?php
break;

}
}
?>


File: bug_actiongroup


Instead of a switch statement checking for the value of $f_action, change this into seperate if ( $f_action == xxx ) statements. This way, you can execute the same logic for multiple actions:

if ( $f_action == 'ASSIGN' || $f_action == 'MOVE' ) {
$f_assign = gpc_get_int( 'assign' );

if ( $f_assign == NO_USER ) {
bug_assign( $t_bug_id, $f_assign, $f_bug_notetext, $f_bug_noteprivate );
} else
{
if ( ON == config_get( 'auto_set_status_to_assigned' ) ) {
$t_assign_status = config_get( 'bug_assigned_status' );
} else {
$t_assign_status = $t_status;
}

check that new handler has rights to handle the issue, and

    #  that current user has rights to assign the issue

$t_target_project = bug_get_field( $t_bug_id, 'project_id' );
if ( $f_action == 'MOVE' ) {
$t_target_project = gpc_get_int( 'project_id' );
}

$t_threshold = access_get_status_threshold( $t_assign_status, $t_target_project );
if ( access_has_bug_level( $t_threshold , $t_bug_id, $f_assign ) &&
access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $t_bug_id ) &&
bug_check_workflow($t_status, $t_assign_status ) ) {
/* @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); /
bug_assign( $t_bug_id, $f_assign, $f_bug_notetext, $f_bug_noteprivate );
helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
if ( bug_check_workflow($t_status, $t_assign_status ) ) {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
}
}
}
}

...

if ( $f_action == 'UP_STATUS' || $f_action == 'MOVE' ) {
$f_status = gpc_get_int( 'status' );
$t_project = bug_get_field( $t_bug_id, 'project_id' );
if ( $f_action == 'MOVE' ) {
$t_project = gpc_get_int( 'project_id' );
}

if ( access_has_bug_level( access_get_status_threshold( $f_status, $t_project ), $t_bug_id ) ) {
if ( TRUE == bug_check_workflow($t_status, $f_status ) ) {
/* @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); /
bug_set_field( $t_bug_id, 'status', $f_status );

        # Add bugnote if supplied
        if ( !is_blank( $f_bug_notetext ) ) {
            bugnote_add( $t_bug_id, $f_bug_notetext, null, $f_bug_noteprivate );
        }

        helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
    } else {
        $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
    }
} else {
    $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}

}


I would like to change this logic so it's more generic: instead of using
"$t_question_title2", "$t_question_title3" etc, use an array instead and add the corresponding input fields that way.

Would be great to see this added... has to be tested of course. All access checks should still be in place (eg if you try to assign the moved project to a handler who has no rights on the project it is moved to).

vincent_sels

vincent_sels

2011-09-26 15:50

reporter   ~0029869

I added the changes as a unified diff patch (0013233.diff). Please remove the other two files.

andy778

andy778

2012-03-03 11:34

reporter   ~0031371

Also when moving a case from one project to another it will not send out any mail.