| [ 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 * Bug Group Action API 19 * 20 * @package CoreAPI 21 * @subpackage BugGroupActionAPI 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 bug_api.php 27 * @uses config_api.php 28 * @uses constant_inc.php 29 * @uses helper_api.php 30 * @uses html_api.php 31 * @uses lang_api.php 32 * @uses string_api.php 33 */ 34 35 require_api( 'bug_api.php' ); 36 require_api( 'config_api.php' ); 37 require_api( 'constant_inc.php' ); 38 require_api( 'helper_api.php' ); 39 require_api( 'html_api.php' ); 40 require_api( 'lang_api.php' ); 41 require_api( 'string_api.php' ); 42 43 require_css( 'status_config.php' ); 44 45 46 /** 47 * Print the top part for the bug action group page. 48 */ 49 function bug_group_action_print_top() { 50 html_page_top(); 51 } 52 53 /** 54 * Print the bottom part for the bug action group page. 55 */ 56 function bug_group_action_print_bottom() { 57 html_page_bottom(); 58 } 59 60 /** 61 * Print the list of selected issues and the legend for the status colors. 62 * 63 * @param $p_bug_ids_array An array of issue ids. 64 */ 65 function bug_group_action_print_bug_list( $p_bug_ids_array ) { 66 $t_legend_position = config_get( 'status_legend_position' ); 67 68 if( STATUS_LEGEND_POSITION_TOP == $t_legend_position ) { 69 html_status_legend(); 70 echo '<br />'; 71 } 72 73 echo '<div>'; 74 echo '<table class="width75" cellspacing="1">'; 75 echo '<tr class="row-1">'; 76 echo '<th class="category" colspan="2">'; 77 echo lang_get( 'actiongroup_bugs' ); 78 echo '</th>'; 79 echo '</tr>'; 80 81 $t_i = 1; 82 83 foreach( $p_bug_ids_array as $t_bug_id ) { 84 $t_class = sprintf( "row-%d", ( $t_i++ % 2 ) + 1 ); 85 86 # choose color based on status 87 $status_label = html_get_status_css_class( bug_get_field( $t_bug_id, 'status' ) ); 88 89 echo sprintf( "<tr class=\"%s\"> <td>%s</td> <td>%s</td> </tr>\n", $status_label, string_get_bug_view_link( $t_bug_id ), string_attribute( bug_get_field( $t_bug_id, 'summary' ) ) ); 90 } 91 92 echo '</table>'; 93 echo '</div>'; 94 95 if( STATUS_LEGEND_POSITION_BOTTOM == $t_legend_position ) { 96 echo '<br />'; 97 html_status_legend(); 98 } 99 } 100 101 /** 102 * Print the array of issue ids via hidden fields in the form to be passed on to 103 * the bug action group action page. 104 * 105 * @param $p_bug_ids_array An array of issue ids. 106 */ 107 function bug_group_action_print_hidden_fields( $p_bug_ids_array ) { 108 foreach( $p_bug_ids_array as $t_bug_id ) { 109 echo '<input type="hidden" name="bug_arr[]" value="' . $t_bug_id . '" />' . "\n"; 110 } 111 } 112 113 /** 114 * Prints the list of fields in the custom action form. These are the user inputs 115 * and the submit button. This ends up calling action_<action>_print_fields() 116 * from bug_actiongroup_<action>_inc.php 117 * 118 * @param $p_action The custom action name without the "EXT_" prefix. 119 */ 120 function bug_group_action_print_action_fields( $p_action ) { 121 $t_include_definition = strtoupper( 'bug_actiongroup_' . $p_action . '_inc_allow' ); 122 if( !defined( $t_include_definition ) ) { 123 define( $t_include_definition, true ); 124 } 125 require_once( config_get_global( 'absolute_path' ) . 'bug_actiongroup_' . $p_action . '_inc.php' ); 126 $t_function_name = 'action_' . $p_action . '_print_fields'; 127 $t_function_name(); 128 } 129 130 /** 131 * Prints some title text for the custom action page. This ends up calling 132 * action_<action>_print_title() from bug_actiongroup_<action>_inc.php 133 * 134 * @param $p_action The custom action name without the "EXT_" prefix. 135 */ 136 function bug_group_action_print_title( $p_action ) { 137 $t_include_definition = strtoupper( 'bug_actiongroup_' . $p_action . '_inc_allow' ); 138 if( !defined( $t_include_definition ) ) { 139 define( $t_include_definition, true ); 140 } 141 require_once( config_get_global( 'absolute_path' ) . 'bug_actiongroup_' . $p_action . '_inc.php' ); 142 $t_function_name = 'action_' . $p_action . '_print_title'; 143 $t_function_name(); 144 } 145 146 /** 147 * Validates the combination of an action and a bug. This ends up calling 148 * action_<action>_validate() from bug_actiongroup_<action>_inc.php 149 * 150 * @param $p_action The custom action name without the "EXT_" prefix. 151 * @param $p_bug_id The id of the bug to validate the action on. 152 * 153 * @returns true|array true if action can be applied or array of ( bug_id => reason for failure to validate ) 154 */ 155 function bug_group_action_validate( $p_action, $p_bug_id ) { 156 $t_include_definition = strtoupper( 'bug_actiongroup_' . $p_action . '_inc_allow' ); 157 if( !defined( $t_include_definition ) ) { 158 define( $t_include_definition, true ); 159 } 160 require_once( config_get_global( 'absolute_path' ) . 'bug_actiongroup_' . $p_action . '_inc.php' ); 161 $t_function_name = 'action_' . $p_action . '_validate'; 162 return $t_function_name( $p_bug_id ); 163 } 164 165 166 /** 167 * Executes an action on a bug. This ends up calling 168 * action_<action>_process() from bug_actiongroup_<action>_inc.php 169 * 170 * @param $p_action The custom action name without the "EXT_" prefix. 171 * @param $p_bug_id The id of the bug to validate the action on. 172 * @returns true|array Action can be applied., ( bug_id => reason for failure to process ) 173 */ 174 function bug_group_action_process( $p_action, $p_bug_id ) { 175 $t_include_definition = strtoupper( 'bug_actiongroup_' . $p_action . '_inc_allow' ); 176 if( !defined( $t_include_definition ) ) { 177 define( $t_include_definition, true ); 178 } 179 require_once( config_get_global( 'absolute_path' ) . 'bug_actiongroup_' . $p_action . '_inc.php' ); 180 $t_function_name = 'action_' . $p_action . '_process'; 181 return $t_function_name( $p_bug_id ); 182 } 183 184 /** 185 * Get a list of bug group actions available to the current user for one or 186 * more projects. 187 * @param array $p_projects An array containing one or more project IDs 188 * @return null 189 */ 190 function bug_group_action_get_commands( $p_project_ids = null ) { 191 if ( $p_project_ids === null || count( $p_project_ids ) == 0 ) { 192 $p_project_ids = array( ALL_PROJECTS ); 193 } 194 195 $t_commands = array(); 196 foreach( $p_project_ids as $t_project_id ) { 197 198 if( !isset( $t_commands['MOVE'] ) && 199 access_has_project_level( config_get( 'move_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 200 $t_commands['MOVE'] = lang_get( 'actiongroup_menu_move' ); 201 } 202 203 if( !isset( $t_commands['COPY'] ) && 204 access_has_any_project( config_get( 'report_bug_threshold', null, null, $t_project_id ) ) ) { 205 $t_commands['COPY'] = lang_get( 'actiongroup_menu_copy' ); 206 } 207 208 if( !isset( $t_commands['ASSIGN'] ) && 209 access_has_project_level( config_get( 'update_bug_assign_threshold', null, null, $t_project_id ), $t_project_id ) ) { 210 if( ON == config_get( 'auto_set_status_to_assigned', null, null, $t_project_id ) && 211 access_has_project_level( access_get_status_threshold( config_get( 'bug_assigned_status', null, null, $t_project_id ), $t_project_id ), $t_project_id ) ) { 212 $t_commands['ASSIGN'] = lang_get( 'actiongroup_menu_assign' ); 213 } else { 214 $t_commands['ASSIGN'] = lang_get( 'actiongroup_menu_assign' ); 215 } 216 } 217 218 if( !isset( $t_commands['CLOSE'] ) && 219 access_has_project_level( config_get( 'update_bug_status_threshold', null, null, $t_project_id ), $t_project_id ) && 220 ( access_has_project_level( access_get_status_threshold( config_get( 'bug_closed_status_threshold', null, null, $t_project_id ), $t_project_id ), $t_project_id ) || 221 access_has_project_level( config_get( 'allow_reporter_close', null, null, $t_project_id ), $t_project_id ) ) ) { 222 $t_commands['CLOSE'] = lang_get( 'actiongroup_menu_close' ); 223 } 224 225 if( !isset( $t_commands['DELETE'] ) && 226 access_has_project_level( config_get( 'delete_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 227 $t_commands['DELETE'] = lang_get( 'actiongroup_menu_delete' ); 228 } 229 230 if( !isset( $t_commands['RESOLVE'] ) && 231 access_has_project_level( config_get( 'update_bug_status_threshold', null, null, $t_project_id ), $t_project_id ) && 232 access_has_project_level( access_get_status_threshold( config_get( 'bug_resolved_status_threshold', null, null, $t_project_id ), $t_project_id ), $t_project_id ) ) { 233 $t_commands['RESOLVE'] = lang_get( 'actiongroup_menu_resolve' ); 234 } 235 236 if( !isset( $t_commands['SET_STICKY'] ) && 237 access_has_project_level( config_get( 'set_bug_sticky_threshold', null, null, $t_project_id ), $t_project_id ) ) { 238 $t_commands['SET_STICKY'] = lang_get( 'actiongroup_menu_set_sticky' ); 239 } 240 241 if( !isset( $t_commands['UP_PRIOR'] ) && 242 access_has_project_level( config_get( 'update_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 243 $t_commands['UP_PRIOR'] = lang_get( 'actiongroup_menu_update_priority' ); 244 } 245 246 if( !isset( $t_commands['EXT_UPDATE_SEVERITY'] ) && 247 access_has_project_level( config_get( 'update_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 248 $t_commands['EXT_UPDATE_SEVERITY'] = lang_get( 'actiongroup_menu_update_severity' ); 249 } 250 251 if( !isset( $t_commands['UP_STATUS'] ) && 252 access_has_project_level( config_get( 'update_bug_status_threshold', null, null, $t_project_id ), $t_project_id ) ) { 253 $t_commands['UP_STATUS'] = lang_get( 'actiongroup_menu_update_status' ); 254 } 255 256 if( !isset( $t_commands['UP_CATEGORY'] ) && 257 access_has_project_level( config_get( 'update_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 258 $t_commands['UP_CATEGORY'] = lang_get( 'actiongroup_menu_update_category' ); 259 } 260 261 if( !isset( $t_commands['VIEW_STATUS'] ) && 262 access_has_project_level( config_get( 'change_view_status_threshold', null, null, $t_project_id ), $t_project_id ) ) { 263 $t_commands['VIEW_STATUS'] = lang_get( 'actiongroup_menu_update_view_status' ); 264 } 265 266 if( !isset( $t_commands['EXT_UPDATE_PRODUCT_BUILD'] ) && 267 config_get( 'enable_product_build', null, null, $t_project_id ) == ON && 268 access_has_project_level( config_get( 'update_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 269 $t_commands['EXT_UPDATE_PRODUCT_BUILD'] = lang_get( 'actiongroup_menu_update_product_build' ); 270 } 271 272 if( !isset( $t_commands['EXT_ADD_NOTE'] ) && 273 access_has_project_level( config_get( 'add_bugnote_threshold', null, null, $t_project_id ), $t_project_id ) ) { 274 $t_commands['EXT_ADD_NOTE'] = lang_get( 'actiongroup_menu_add_note' ); 275 } 276 277 if( !isset( $t_commands['EXT_ATTACH_TAGS'] ) && 278 access_has_project_level( config_get( 'tag_attach_threshold', null, null, $t_project_id ), $t_project_id ) ) { 279 $t_commands['EXT_ATTACH_TAGS'] = lang_get( 'actiongroup_menu_attach_tags' ); 280 } 281 282 if( !isset( $t_commands['UP_FIXED_IN_VERSION'] ) && 283 version_should_show_product_version( $t_project_id ) && 284 access_has_project_level( config_get( 'update_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) { 285 $t_commands['UP_FIXED_IN_VERSION'] = lang_get( 'actiongroup_menu_update_fixed_in_version' ); 286 } 287 288 if( !isset( $t_commands['UP_TARGET_VERSION'] ) && 289 version_should_show_product_version( $t_project_id ) && 290 access_has_project_level( config_get( 'roadmap_update_threshold', null, null, $t_project_id ), $t_project_id ) ) { 291 $t_commands['UP_TARGET_VERSION'] = lang_get( 'actiongroup_menu_update_target_version' ); 292 } 293 294 $t_custom_field_ids = custom_field_get_linked_ids( $t_project_id ); 295 foreach( $t_custom_field_ids as $t_custom_field_id ) { 296 if( !custom_field_has_write_access_to_project( $t_custom_field_id, $t_project_id ) ) { 297 continue; 298 } 299 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id ); 300 $t_command_id = 'custom_field_' . $t_custom_field_id; 301 $t_command_caption = sprintf( lang_get( 'actiongroup_menu_update_field' ), lang_get_defaulted( $t_custom_field_def['name'] ) ); 302 $t_commands[$t_command_id] = string_display( $t_command_caption ); 303 } 304 } 305 306 $t_custom_group_actions = config_get( 'custom_group_actions' ); 307 308 foreach( $t_custom_group_actions as $t_custom_group_action ) { 309 # use label if provided to get the localized text, otherwise fallback to action name. 310 if( isset( $t_custom_group_action['label'] ) ) { 311 $t_commands[$t_custom_group_action['action']] = lang_get_defaulted( $t_custom_group_action['label'] ); 312 } else { 313 $t_commands[$t_custom_group_action['action']] = lang_get_defaulted( $t_custom_group_action['action'] ); 314 } 315 } 316 317 return $t_commands; 318 }
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 |