Index: bug_actiongroup.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_actiongroup.php,v
retrieving revision 1.49
diff -u -r1.49 bug_actiongroup.php
--- bug_actiongroup.php	16 Dec 2006 20:12:55 -0000	1.49
+++ bug_actiongroup.php	7 Feb 2007 05:15:20 -0000
@@ -62,7 +62,10 @@
 			if ( access_can_close_bug( $t_bug_id ) &&
 					( $t_status < CLOSED ) &&
 					bug_check_workflow($t_status, CLOSED) ) {
+
+				# @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) );
 				bug_close( $t_bug_id );
+				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
 				if ( ! access_can_close_bug( $t_bug_id ) ) {
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
@@ -82,8 +85,10 @@
 
 		case 'MOVE':
 			if ( access_has_bug_level( config_get( 'move_bug_threshold' ), $t_bug_id ) ) {
+				# @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 				$f_project_id = gpc_get_int( 'project_id' );
 				bug_set_field( $t_bug_id, 'project_id', $f_project_id );
+				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
@@ -112,7 +117,9 @@
 			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 )	) {
+				# @@@ 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 );
+				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' );
@@ -129,7 +136,9 @@
 						bug_check_workflow($t_status, $t_resolved_status ) ) {
 				$f_resolution = gpc_get_int( 'resolution' );
 				$f_fixed_in_version = gpc_get_string( 'fixed_in_version', '' );
+				# @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 				bug_resolve( $t_bug_id, $f_resolution, $f_fixed_in_version );
+				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
 				if ( ( $t_status < $t_resolved_status ) &&
 						bug_check_workflow($t_status, $t_resolved_status ) ) {
@@ -143,7 +152,9 @@
 		case 'UP_PRIOR':
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				$f_priority = gpc_get_int( 'priority' );
+				# @@@ 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, 'priority', $f_priority );
+				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
@@ -154,7 +165,9 @@
 			$t_project = bug_get_field( $t_bug_id, '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 ) ) {
+					# @@@ 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 );
+					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 				}
@@ -168,7 +181,9 @@
 			$t_project = bug_get_field( $t_bug_id, 'project_id' );
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				if ( category_exists( $t_project, $f_category ) ) {
+					# @@@ 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, 'category', $f_category );
+					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_category' );
 				}
@@ -183,7 +198,9 @@
 			
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				if ( version_exists( $t_project_id, $f_version ) ) {
+					# @@@ 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, 'fixed_in_version', $f_fixed_in_version );
+					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_failed' );
 				}
@@ -196,7 +213,9 @@
 
 			if ( access_has_bug_level( config_get( 'roadmap_view_threshold' ), $t_bug_id ) ) {
 				if ( version_exists( $t_project_id, $f_version ) ) {
+					# @@@ 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, 'target_version', $f_fixed_in_version );
+					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
 					$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_failed' );
 				}
@@ -206,7 +225,9 @@
 		case 'VIEW_STATUS':
 			if ( access_has_bug_level( config_get( 'change_view_status_threshold' ), $t_bug_id ) ) {
 				$f_view_status = gpc_get_int( 'view_status' );
+				# @@@ 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, 'view_state', $f_view_status );
+				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
@@ -216,7 +237,9 @@
 			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
+				# @@@ 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, 'sticky', intval( !$f_sticky ) );
+				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
 				$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 			}
@@ -227,9 +250,11 @@
 				trigger_error( ERROR_GENERIC, ERROR );
 			}
 
+			# @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 			$t_form_var = "custom_field_$f_custom_field_id";
 			$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:
Index: bug_delete.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_delete.php,v
retrieving revision 1.40
diff -u -r1.40 bug_delete.php
--- bug_delete.php	25 Jul 2005 16:34:10 -0000	1.40
+++ bug_delete.php	7 Feb 2007 05:01:05 -0000
@@ -35,11 +35,7 @@
 
 	$t_bug = bug_get( $f_bug_id, true );
 
-	helper_call_custom_function( 'issue_delete_validate', array( $f_bug_id ) );
-
 	bug_delete( $f_bug_id );
 
-	helper_call_custom_function( 'issue_delete_notify', array( $f_bug_id ) );
-
 	print_successful_redirect( 'view_all_bug_page.php' );
 ?>
Index: core/bug_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/bug_api.php,v
retrieving revision 1.103
diff -u -r1.103 bug_api.php
--- core/bug_api.php	12 Dec 2006 18:26:29 -0000	1.103
+++ core/bug_api.php	7 Feb 2007 05:00:47 -0000
@@ -662,11 +662,19 @@
 		$t_bug_table		= config_get( 'mantis_bug_table' );
 		$t_bug_text_table	= config_get( 'mantis_bug_text_table' );
 
+		# call pre-deletion custom function
+		helper_call_custom_function( 'issue_delete_validate', array( $p_bug_id ) );
+
 		# log deletion of bug
 		history_log_event_special( $p_bug_id, BUG_DELETED, bug_format_id( $p_bug_id ) );
 
 		email_bug_deleted( $p_bug_id );
 
+		# call post-deletion custom function.  We call this here to allow the custom function to access the details of the bug before 
+		# they are deleted from the database given it's id.  The other option would be to move this to the end of the function and
+		# provide it with bug data rather than an id, but this will break backward compatibility.
+		helper_call_custom_function( 'issue_delete_notify', array( $f_bug_id ) );
+
 		# Unmonitor bug for all users
 		bug_unmonitor( $p_bug_id, null );
 
