Index: bug_report.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/bug_report.php,v retrieving revision 1.33 diff -u -r1.33 bug_report.php --- bug_report.php 1 Aug 2004 22:24:58 -0000 1.33 +++ bug_report.php 4 Aug 2004 14:22:45 -0000 @@ -25,32 +25,33 @@ build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->product_version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + $t_bug_data->category = gpc_get_string( 'category', '' ); + $t_bug_data->reproducibility = gpc_get_int( 'reproducibility' ); + $t_bug_data->severity = gpc_get_int( 'severity' ); + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = gpc_get_string( 'summary' ); + $t_bug_data->description = gpc_get_string( 'description' ); + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_info = gpc_get_string( 'additional_info', '' ); $f_file = gpc_get_file( 'file', null ); $f_report_stay = gpc_get_bool( 'report_stay' ); - $f_project_id = gpc_get_int( 'project_id' ); + $t_bug_data->project_id = gpc_get_int( 'project_id' ); - $t_reporter_id = auth_get_current_user_id(); + $t_bug_data->reporter_id = auth_get_current_user_id(); $t_upload_method = config_get( 'file_upload_method' ); - $f_summary = trim( $f_summary ); + $t_bug_data->summary = trim( $f_summary ); # If a file was uploaded, and we need to store it on disk, let's make # sure that the file path for this project exists @@ -66,22 +67,24 @@ # if a profile was selected then let's use that information - if ( 0 != $f_profile_id ) { + if ( 0 != $t_bug_data->profile_id ) { $row = user_get_profile_row( $t_reporter_id, $f_profile_id ); - if ( is_blank( $f_platform ) ) { - $f_platform = $row['platform']; + if ( is_blank( $t_bug_data->platform ) ) { + $t_bug_data->platform = $row['platform']; } - if ( is_blank( $f_os ) ) { - $f_os = $row['os']; + if ( is_blank( $t_bug_data->os ) ) { + $t_bug_data->os = $row['os']; } - if ( is_blank( $f_os_build ) ) { - $f_os_build = $row['os_build']; + if ( is_blank( $t_bug_data->os_build ) ) { + $t_bug_data->os_build = $row['os_build']; } } + helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); + # Validate the custom fields before adding the bug. - $t_related_custom_field_ids = custom_field_get_linked_ids( $f_project_id ); + $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); foreach( $t_related_custom_field_ids as $t_id ) { $t_def = custom_field_get_definition( $t_id ); if ( $t_def['require_report'] && ( gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ) == '' ) ) { @@ -95,16 +98,7 @@ } # Create the bug - $t_bug_id = bug_create( $f_project_id, - $t_reporter_id, $f_handler_id, - $f_priority, - $f_severity, $f_reproducibility, - $f_category, - $f_os, $f_os_build, - $f_platform, $f_product_version, - $f_build, - $f_profile_id, $f_summary, $f_view_state, - $f_description, $f_steps_to_reproduce, $f_additional_info ); + $t_bug_id = bug_create( $t_bug_data ); # Handle the file upload @@ -130,6 +124,7 @@ } email_new_bug( $t_bug_id ); + helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) ); html_page_top1(); Index: bug_update.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/bug_update.php,v retrieving revision 1.66 diff -u -r1.66 bug_update.php --- bug_update.php 4 Aug 2004 01:38:06 -0000 1.66 +++ bug_update.php 4 Aug 2004 14:22:46 -0000 @@ -63,6 +63,8 @@ $t_bug_data->status = config_get( 'bug_assigned_status' ); } + helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bug_note_text ) ); + $t_custom_status_label = "update"; # default info to check if ( $t_bug_data->status == config_get( 'bug_resolved_status_threshold' ) ) { $t_custom_status_label = "resolved"; @@ -105,5 +107,7 @@ # Update the bug entry bug_update( $f_bug_id, $t_bug_data, true ); + helper_call_custom_function( 'issue_update_notify', array( $f_bug_id ) ); + print_successful_redirect_to_bug( $f_bug_id ); ?> Index: core/bug_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/bug_api.php,v retrieving revision 1.76 diff -u -r1.76 bug_api.php --- core/bug_api.php 1 Aug 2004 17:28:58 -0000 1.76 +++ core/bug_api.php 4 Aug 2004 14:22:46 -0000 @@ -294,36 +294,26 @@ # -------------------- # Create a new bug and return the bug id # - # @@@ pass in a bug object instead of all these params - function bug_create( $p_project_id, - $p_reporter_id, $p_handler_id, - $p_priority, - $p_severity, $p_reproducibility, - $p_category, - $p_os, $p_os_build, - $p_platform, $p_version, - $p_build, - $p_profile_id, $p_summary, $p_view_state, - $p_description, $p_steps_to_reproduce, $p_additional_info ) { - - $c_summary = db_prepare_string( $p_summary ); - $c_description = db_prepare_string( $p_description ); - $c_project_id = db_prepare_int( $p_project_id ); - $c_reporter_id = db_prepare_int( $p_reporter_id ); - $c_handler_id = db_prepare_int( $p_handler_id ); - $c_priority = db_prepare_int( $p_priority ); - $c_severity = db_prepare_int( $p_severity ); - $c_reproducibility = db_prepare_int( $p_reproducibility ); - $c_category = db_prepare_string( $p_category ); - $c_os = db_prepare_string( $p_os ); - $c_os_build = db_prepare_string( $p_os_build ); - $c_platform = db_prepare_string( $p_platform ); - $c_version = db_prepare_string( $p_version ); - $c_build = db_prepare_string( $p_build ); - $c_profile_id = db_prepare_int( $p_profile_id ); - $c_view_state = db_prepare_int( $p_view_state ); - $c_steps_to_reproduce = db_prepare_string( $p_steps_to_reproduce ); - $c_additional_info = db_prepare_string( $p_additional_info ); + function bug_create( $p_bug_data ) { + + $c_summary = db_prepare_string( $p_bug_data->summary ); + $c_description = db_prepare_string( $p_bug_data->description ); + $c_project_id = db_prepare_int( $p_bug_data->project_id ); + $c_reporter_id = db_prepare_int( $p_bug_data->reporter_id ); + $c_handler_id = db_prepare_int( $p_bug_data->handler_id ); + $c_priority = db_prepare_int( $p_bug_data->priority ); + $c_severity = db_prepare_int( $p_bug_data->severity ); + $c_reproducibility = db_prepare_int( $p_bug_data->reproducibility ); + $c_category = db_prepare_string( $p_bug_data->category ); + $c_os = db_prepare_string( $p_bug_data->os ); + $c_os_build = db_prepare_string( $p_bug_data->os_build ); + $c_platform = db_prepare_string( $p_bug_data->platform ); + $c_version = db_prepare_string( $p_bug_data->version ); + $c_build = db_prepare_string( $p_bug_data->build ); + $c_profile_id = db_prepare_int( $p_bug_data->profile_id ); + $c_view_state = db_prepare_int( $p_bug_data->view_state ); + $c_steps_to_reproduce = db_prepare_string( $p_bug_data->steps_to_reproduce ); + $c_additional_info = db_prepare_string( $p_bug_data->additional_info ); $c_sponsorship_total = 0; # Summary cannot be blank Index: core/constant_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/constant_inc.php,v retrieving revision 1.27 diff -u -r1.27 constant_inc.php --- core/constant_inc.php 1 Aug 2004 22:24:59 -0000 1.27 +++ core/constant_inc.php 4 Aug 2004 14:22:46 -0000 @@ -214,6 +214,7 @@ define( 'ERROR_BUG_DUPLICATE_SELF', 1101 ); define( 'ERROR_BUG_RESOLVED_ACTION_DENIED', 1102 ); // @@@ obsolete, remove after lang files are sync'd define( 'ERROR_BUG_READ_ONLY_ACTION_DENIED', 1103 ); + define( 'ERROR_BUG_VALIDATE_FAILURE', 1104 ); # ERROR_EMAIL_* define( 'ERROR_EMAIL_INVALID', 1200 ); Index: core/custom_function_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/custom_function_api.php,v retrieving revision 1.5 diff -u -r1.5 custom_function_api.php --- core/custom_function_api.php 30 Jul 2004 12:46:09 -0000 1.5 +++ core/custom_function_api.php 4 Aug 2004 14:22:46 -0000 @@ -45,4 +45,64 @@ } } } + + # -------------------- + # Hook to validate field settings before updating + # verify that the proper fields are set before proceeding to change the status + # returns true, and triggers error if there is something wrong + # p_issue_id is the issue number that can be used to get the existing state + # p_new_bug is an object (BugData) with the appropriate fields updated + function custom_function_default_issue_update_validate( $p_issue_id, $p_new_bug, $p_bug_note_text ) { + + return true; + } + + # -------------------- + # Hook to notify after a bug has been updated. + # returns true, and triggers error if there is something wrong + # p_issue_id is the issue number that can be used to get the existing state + function custom_function_default_issue_update_notify( $p_issue_id ) { + + return true; + } + + # -------------------- + # Hook to validate field settings before opening + # verify that the proper fields are set before proceeding to change the status + # returns true, and triggers error if there is something wrong + # p_new_bug is an object (BugData) with the appropriate fields updated + function custom_function_default_issue_create_validate( $p_new_bug ) { + + return true; + } + + # -------------------- + # Hook to notify after a bug has been opened. + # returns true, and triggers error if there is something wrong + # p_issue_id is the issue number that can be used to get the existing state + function custom_function_default_issue_create_notify( $p_issue_id ) { + + return true; + } + + # -------------------- + # Hook to validate field settings before deleting + # verify that the proper fields are set before proceeding to change the status + # returns true, and triggers error if there is something wrong + # p_issue_id is the issue number that can be used to get the existing state + function custom_function_default_issue_delete_validate( $p_issue_id ) { + + return true; + } + + # -------------------- + # Hook to notify after a bug has been deleted. + # returns true, and triggers error if there is something wrong + # p_issue_id is the issue number that can be used to get the existing state + function custom_function_default_issue_delete_notify( $p_issue_id ) { + + return true; + } + + ?> \ No newline at end of file Index: lang/strings_english.txt =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v retrieving revision 1.196 diff -u -r1.196 strings_english.txt --- lang/strings_english.txt 4 Aug 2004 01:38:07 -0000 1.196 +++ lang/strings_english.txt 4 Aug 2004 14:22:48 -0000 @@ -218,6 +218,7 @@ $MANTIS_ERROR[ERROR_SPONSORSHIP_SPONSOR_NO_EMAIL] = 'Sponsor has not provided an email address. Please update your profile.'; $MANTIS_ERROR[ERROR_CONFIG_OPT_INVALID] = 'Configuration option \'%s\' has invalid value \'%s\''; $MANTIS_ERROR[ERROR_BUG_READ_ONLY_ACTION_DENIED] = 'The action cannot be performed because issue \'%d\' is read-only'; +$MANTIS_ERROR[ERROR_BUG_VALIDATE_FAILURE] = 'Validation failed: \'%s\''; $MANTIS_ERROR[ERROR_RELATIONSHIP_ALREADY_EXISTS] = "There is already a relationship between these two issues."; $MANTIS_ERROR[ERROR_RELATIONSHIP_NOT_FOUND] = "Relationship not found."; $MANTIS_ERROR[ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW] = "Access denied: The issue %d requires higher access level.";