| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # MantisBT - A PHP based bugtracking system 3 4 # MantisBT is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published by 6 # the Free Software Foundation, either version 2 of the License, or 7 # (at your option) any later version. 8 # 9 # MantisBT is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Workflow API 19 * 20 * @package CoreAPI 21 * @subpackage WorkflowAPI 22 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 23 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 24 * @link http://www.mantisbt.org 25 * 26 * @uses config_api.php 27 */ 28 29 require_api( 'config_api.php' ); 30 31 /** 32 * Determine if there is a transition possible between two workflow states. The 33 * direction of the transition is factored into this check. 34 * @param int $p_from_status_id Source status ID 35 * @param int $p_to_status_id Destination status ID 36 * @return bool Whether a transition exists in the specified direction 37 */ 38 function workflow_transition_edge_exists( $p_from_status_id, $p_to_status_id ) { 39 if ( $p_from_status_id == $p_to_status_id ) { 40 return false; 41 } 42 43 $t_project_workflow = workflow_parse( config_get( 'status_enum_workflow' ) ); 44 45 return isset( $t_project_workflow['exit'][$p_from_status_id][$p_to_status_id] ); 46 } 47 48 /** 49 * Parse a workflow into a graph-like array of workflow transitions. 50 * @param array The workflow enumeration to parse. 51 * @return array The parsed workflow graph. 52 */ 53 function workflow_parse( $p_enum_workflow ) { 54 $t_status_arr = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) ); 55 if ( count( $p_enum_workflow ) == 0 ) { 56 # workflow is not set, default it to all transitions 57 foreach ( $t_status_arr as $t_status => $t_label ) { 58 $t_temp_workflow = array(); 59 foreach ( $t_status_arr as $t_next => $t_next_label ) { 60 if ( $t_status != $t_next ) { 61 $t_temp_workflow[] = $t_next . ':' . $t_next_label; 62 } 63 } 64 $p_enum_workflow[$t_status] = implode( ',', $t_temp_workflow ); 65 } 66 } 67 68 $t_entry = array(); 69 $t_exit = array(); 70 71 # prepopulate new bug state (bugs go from nothing to here) 72 $t_submit_status_array = config_get( 'bug_submit_status' ); 73 $t_new_label = MantisEnum::getLabel( lang_get( 'status_enum_string' ), config_get( 'bug_submit_status' ) ); 74 if ( is_array( $t_submit_status_array ) ) { 75 # @@@ (thraxisp) this is not implemented in bug_api.php 76 foreach ($t_submit_status_array as $t_access => $t_status ) { 77 $t_entry[$t_status][0] = $t_new_label; 78 $t_exit[0][$t_status] = $t_new_label; 79 } 80 } else { 81 $t_status = $t_submit_status_array; 82 $t_entry[$t_status][0] = $t_new_label; 83 $t_exit[0][$t_status] = $t_new_label; 84 } 85 86 # add user defined arcs and implicit reopen arcs 87 $t_reopen = config_get( 'bug_reopen_status' ); 88 $t_reopen_label = MantisEnum::getLabel( lang_get( 'resolution_enum_string' ), config_get( 'bug_reopen_resolution' ) ); 89 $t_resolved_status = config_get( 'bug_resolved_status_threshold' ); 90 $t_default = array(); 91 foreach ( $t_status_arr as $t_status => $t_status_label ) { 92 if ( isset( $p_enum_workflow[$t_status] ) ) { 93 $t_next_arr = MantisEnum::getAssocArrayIndexedByValues( $p_enum_workflow[$t_status] ); 94 foreach ( $t_next_arr as $t_next => $t_next_label) { 95 if ( !isset( $t_default[$t_status] ) ) { 96 $t_default[$t_status] = $t_next; 97 } 98 $t_exit[$t_status][$t_next] = ''; 99 $t_entry[$t_next][$t_status] = ''; 100 } 101 } else { 102 $t_exit[$t_status] = array(); 103 } 104 if ( $t_status >= $t_resolved_status ) { 105 $t_exit[$t_status][$t_reopen] = $t_reopen_label; 106 $t_entry[$t_reopen][$t_status] = $t_reopen_label; 107 } 108 if ( !isset( $t_entry[$t_status] ) ) { 109 $t_entry[$t_status] = array(); 110 } 111 } 112 return array( 'entry' => $t_entry, 'exit' => $t_exit, 'default' => $t_default ); 113 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |