From: Victor B. <vb...@us...> - 2004-07-13 12:16:21
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26944/core Modified Files: bug_api.php html_api.php print_api.php Log Message: Enh #3984: Support definining and enforcing custom workflow (thraxisp) Index: html_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -r1.109 -r1.110 --- html_api.php 11 Jul 2004 13:24:29 -0000 1.109 +++ html_api.php 13 Jul 2004 12:16:11 -0000 1.110 @@ -664,13 +664,21 @@ # -------------------- # Print Assign To: combo box of possible handlers function html_button_bug_assign_to( $p_bug_id ) { + # make sure status is allowed of assign would cause auto-set-status + $t_status = bug_get_field( $p_bug_id, 'status' ); # workflow implementation + + if ( ON == config_get( 'auto_set_status_to_assigned' ) && + !bug_check_workflow( $t_status, config_get( 'bug_assigned_status' ) ) ) { # workflow + return; + } + # make sure current user has access to modify bugs. if ( !access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) { return; } $t_reporter_id = bug_get_field( $p_bug_id, 'reporter_id' ); - $t_handler_id = bug_get_field( $p_bug_id, 'handler_id' ); + $t_handler_id = bug_get_field( $p_bug_id, 'handler_id' ); $t_current_user_id = auth_get_current_user_id(); $t_options = array(); @@ -740,8 +748,11 @@ # Print a button to resolve the given bug function html_button_bug_resolve( $p_bug_id ) { $t_status = bug_get_field( $p_bug_id, 'status' ); + $t_resolved_status = config_get( 'bug_resolved_status_threshold' ); - if ( ( $t_status < config_get( 'bug_resolved_status_threshold' ) ) && access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug_id ) ) { + if ( ( $t_status < $t_resolved_status ) && + access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug_id ) && + bug_check_workflow($t_status, $t_resolved_status ) ) { html_button( 'bug_resolve_page.php', lang_get( 'resolve_bug_button' ), array( 'bug_id' => $p_bug_id ) ); @@ -777,9 +788,14 @@ # -------------------- # Print a button to reopen the given bug function html_button_bug_reopen( $p_bug_id ) { - if ( access_has_bug_level( config_get( 'reopen_bug_threshold' ), $p_bug_id ) || - ( bug_get_field( $p_bug_id, 'reporter_id' ) == auth_get_current_user_id() && - ( ON == config_get( 'allow_reporter_reopen' ) ) ) ) { + $t_status = bug_get_field( $p_bug_id, 'status' ); + + if ( bug_check_workflow( $t_status, config_get( 'bug_reopen_status' ) ) && + ( access_has_bug_level( config_get( 'reopen_bug_threshold' ), $p_bug_id ) || + ( ( bug_get_field( $p_bug_id, 'reporter_id' ) == auth_get_current_user_id() ) && + ( ON == config_get( 'allow_reporter_reopen' ) ) + ) ) + ) { html_button( 'bug_reopen_page.php', lang_get( 'reopen_bug_button' ), array( 'bug_id' => $p_bug_id ) ); @@ -791,7 +807,9 @@ function html_button_bug_close( $p_bug_id ) { $t_status = bug_get_field( $p_bug_id, 'status' ); - if ( access_can_close_bug ( $p_bug_id ) && ( $t_status < CLOSED ) ) { + if ( access_can_close_bug ( $p_bug_id ) && + ( $t_status < CLOSED ) && + bug_check_workflow($t_status, CLOSED) ) { html_button( 'bug_close_page.php', lang_get( 'close_bug_button' ), array( 'bug_id' => $p_bug_id ) ); Index: bug_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/bug_api.php,v retrieving revision 1.68 retrieving revision 1.69 diff -u -d -r1.68 -r1.69 --- bug_api.php 11 Jul 2004 13:24:29 -0000 1.68 +++ bug_api.php 13 Jul 2004 12:16:10 -0000 1.69 @@ -260,7 +260,33 @@ return true; } + # -------------------- + # Validate workflow state to see if bug can be moved to requested state + function bug_check_workflow( $p_bug_status, $p_wanted_status ) { + $t_status_enum_workflow = config_get( 'status_enum_workflow' ); + + if ( count( $t_status_enum_workflow ) < 1) { + # workflow not defined, use default enum + return true; + } else { + # workflow defined - find allowed states + $t_allowed_states = $t_status_enum_workflow[$p_bug_status]; + $t_arr = explode_enum_string( $t_allowed_states ); + + $t_enum_count = count( $t_arr ); + for ( $i = 0; $i < $t_enum_count; $i++ ) { + # check if wanted status is allowed + $t_elem = explode_enum_arr( $t_arr[$i] ); + if ( $p_wanted_status == $t_elem[0] ) { + return true; + } + } # end for + } + + return false; + } + #=================================== # Creation / Deletion / Updating #=================================== Index: print_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/print_api.php,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- print_api.php 11 Jul 2004 07:09:52 -0000 1.90 +++ print_api.php 13 Jul 2004 12:16:11 -0000 1.91 @@ -565,19 +565,48 @@ # -------------------- # select the proper enum values based on the input parameter - # we use variable variables in order to achieve this - function print_enum_string_option_list( $p_enum_name, $p_val=0 ) { - $g_var = 'g_'.$p_enum_name.'_enum_string'; - global $$g_var; + # $p_enum_name - name of enumeration (eg: status) + # $p_val: current value + function print_enum_string_option_list( $p_enum_name, $p_val = 0 ) { + $t_config_var_name = $p_enum_name.'_enum_string'; + $t_config_var_value = config_get( $t_config_var_name ); - $t_arr = explode_enum_string( $$g_var ); - $enum_count = count( $t_arr ); - for ($i=0;$i<$enum_count;$i++) { + $t_arr = explode_enum_string( $t_config_var_value ); + $t_enum_count = count( $t_arr ); + for ( $i = 0; $i < $t_enum_count; $i++) { $t_elem = explode_enum_arr( $t_arr[$i] ); $t_elem2 = get_enum_element( $p_enum_name, $t_elem[0] ); - PRINT "<option value=\"$t_elem[0]\""; + echo "<option value=\"$t_elem[0]\""; check_selected( $p_val, $t_elem[0] ); - PRINT ">$t_elem2</option>"; + echo ">$t_elem2</option>"; + } # end for + } + # -------------------- + # Select the proper enum values for status based on workflow + # or the input parameter if workflows are not used + # $p_enum_name : name of enumeration (eg: status) + # $p_val : current value + function print_enum_string_option_list_workflow( $p_enum_name, $p_val = 0 ) { + $t_config_var_name = $p_enum_name . '_enum_string'; + $t_config_var_value = config_get( $t_config_var_name ); + $t_enum_workflow = config_get( $p_enum_name . '_enum_workflow' ); + + if ( count( $t_enum_workflow ) < 1 ) { + # workflow not defined, use default enum + $t_arr = explode_enum_string( $t_config_var_value ); + } else { + # workflow defined - find allowed states + $t_arr = explode_enum_string( $t_enum_workflow[$p_val] ); + } + + $t_enum_count = count( $t_arr ); + + for ( $i = 0; $i < $t_enum_count; $i++ ) { + $t_elem = explode_enum_arr( $t_arr[$i] ); + $t_elem2 = get_enum_element( $p_enum_name, $t_elem[0] ); + echo "<option value=\"$t_elem[0]\""; + check_selected( $t_elem[0], $p_val ); + echo ">$t_elem2</option>"; } # end for } # -------------------- @@ -1148,4 +1177,4 @@ $t_name = $g_file_type_icons[$ext]; PRINT '<img src="' . config_get( 'path' ) . 'images/'. $t_name . '" width="16" height="16" border="0" />'; } -?> \ No newline at end of file +?> |