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 * Handling of Bug Status change 19 * @package MantisBT 20 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 21 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 22 * @link http://www.mantisbt.org 23 * 24 * @uses core.php 25 * @uses access_api.php 26 * @uses authentication_api.php 27 * @uses bug_api.php 28 * @uses config_api.php 29 * @uses constant_inc.php 30 * @uses custom_field_api.php 31 * @uses date_api.php 32 * @uses event_api.php 33 * @uses form_api.php 34 * @uses gpc_api.php 35 * @uses helper_api.php 36 * @uses html_api.php 37 * @uses lang_api.php 38 * @uses print_api.php 39 * @uses relationship_api.php 40 * @uses sponsorship_api.php 41 * @uses version_api.php 42 */ 43 44require_once( 'core.php' ); 45require_api( 'access_api.php' ); 46require_api( 'authentication_api.php' ); 47require_api( 'bug_api.php' ); 48require_api( 'config_api.php' ); 49require_api( 'constant_inc.php' ); 50require_api( 'custom_field_api.php' ); 51require_api( 'date_api.php' ); 52require_api( 'event_api.php' ); 53require_api( 'form_api.php' ); 54require_api( 'gpc_api.php' ); 55require_api( 'helper_api.php' ); 56require_api( 'html_api.php' ); 57require_api( 'lang_api.php' ); 58require_api( 'print_api.php' ); 59require_api( 'relationship_api.php' ); 60require_api( 'sponsorship_api.php' ); 61require_api( 'version_api.php' ); 62 63$f_bug_id = gpc_get_int( 'id' ); 64$t_bug = bug_get( $f_bug_id ); 65 66$t_file = __FILE__; 67$t_mantis_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; 68$t_show_page_header = false; 69$t_force_readonly = true; 70 71if( $t_bug->project_id != helper_get_current_project() ) { 72 # in case the current project is not the same project of the bug we are viewing... 73 # ... override the current project. This to avoid problems with categories and handlers lists etc. 74 $g_project_override = $t_bug->project_id; 75} 76 77$f_new_status = gpc_get_int( 'new_status' ); 78$f_change_type = gpc_get_string( 'change_type', BUG_UPDATE_TYPE_CHANGE_STATUS ); 79 80$t_reopen = config_get( 'bug_reopen_status', null, null, $t_bug->project_id ); 81$t_resolved = config_get( 'bug_resolved_status_threshold', null, null, $t_bug->project_id ); 82$t_closed = config_get( 'bug_closed_status_threshold', null, null, $t_bug->project_id ); 83$t_resolution_fixed = config_get( 'bug_resolution_fixed_threshold', null, null, $t_bug->project_id ); 84$t_current_user_id = auth_get_current_user_id(); 85 86# Ensure user has proper access level before proceeding 87if( $f_new_status == $t_reopen && $f_change_type == BUG_UPDATE_TYPE_REOPEN ) { 88 access_ensure_can_reopen_bug( $t_bug, $t_current_user_id ); 89} else if( $f_new_status == $t_closed ) { 90 access_ensure_can_close_bug( $t_bug, $t_current_user_id ); 91} else if( bug_is_readonly( $f_bug_id ) 92 || !access_has_bug_level( access_get_status_threshold( $f_new_status, $t_bug->project_id ), $f_bug_id, $t_current_user_id ) ) { 93 access_denied(); 94} 95 96$t_can_update_due_date = access_has_bug_level( config_get( 'due_date_update_threshold' ), $f_bug_id ); 97 98# get new issue handler if set, otherwise default to original handler 99$f_handler_id = gpc_get_int( 'handler_id', $t_bug->handler_id ); 100 101if( config_get( 'bug_assigned_status' ) == $f_new_status ) { 102 $t_bug_sponsored = config_get( 'enable_sponsorship' ) 103 && sponsorship_get_amount( sponsorship_get_all_ids( $f_bug_id ) ) > 0; 104 if( $t_bug_sponsored && !access_has_bug_level( config_get( 'assign_sponsored_bugs_threshold' ), $f_bug_id ) ) { 105 trigger_error( ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR ); 106 } 107 108 if( $f_handler_id != NO_USER ) { 109 # The new handler is checked at project level 110 if( !access_has_project_level( config_get( 'handle_bug_threshold' ), $t_bug->project_id, $f_handler_id ) ) { 111 trigger_error( ERROR_HANDLER_ACCESS_TOO_LOW, ERROR ); 112 } 113 if( $t_bug_sponsored && !access_has_project_level( config_get( 'handle_sponsored_bugs_threshold' ), $t_bug->project_id, $f_handler_id ) ) { 114 trigger_error( ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR ); 115 } 116 } 117} 118 119$t_status_label = str_replace( ' ', '_', MantisEnum::getLabel( config_get( 'status_enum_string' ), $f_new_status ) ); 120 121layout_page_header( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) ); 122 123layout_page_begin(); 124?> 125 126<div class="col-md-12 col-xs-12"> 127 128 <div id="bug-change-status-div" class="form-container"> 129 <form id="bug-change-status-form" name="bug_change_status_form" method="post" action="bug_update.php"> 130 131 <fieldset> 132 133 <?php echo form_security_field( 'bug_update' ) ?> 134 <div class="widget-box widget-color-blue2"> 135 <div class="widget-header widget-header-small"> 136 <h4 class="widget-title lighter"> 137 <?php echo lang_get( $t_status_label . '_bug_title' ) ?> 138 </h4> 139 </div> 140 141 <div class="widget-body"> 142 <div class="widget-main no-padding"> 143 144 <div class="table-responsive"> 145 <table class="table table-bordered table-condensed table-striped"> 146 <thead> 147 <input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" /> 148 <input type="hidden" name="status" value="<?php echo $f_new_status ?>" /> 149 <input type="hidden" name="last_updated" value="<?php echo $t_bug->last_updated ?>" /> 150 <?php 151 if( $f_new_status >= $t_resolved ) { 152 if( relationship_can_resolve_bug( $f_bug_id ) == false ) { 153 if( OFF == config_get( 'allow_parent_of_unresolved_to_close' ) ) { 154 trigger_error( ERROR_BUG_RESOLVE_DEPENDANTS_BLOCKING, ERROR ); 155 } 156 echo '<tr><td colspan="2">' . lang_get( 'relationship_warning_blocking_bugs_not_resolved_2' ) . '</td></tr>'; 157 } 158 } 159 ?> 160 </thead> 161 <tbody> 162<?php 163 $t_current_resolution = $t_bug->resolution; 164 $t_bug_resolution_is_fixed = $t_current_resolution >= $t_resolution_fixed; 165 166 if( $f_new_status >= $t_resolved && ( $f_new_status < $t_closed || !$t_bug_resolution_is_fixed ) ) { 167?> 168<!-- Resolution --> 169 <tr> 170 <th class="category"> 171 <?php echo lang_get( 'resolution' ) ?> 172 </th> 173 <td> 174 <select name="resolution" class="input-sm"> 175 <?php 176 $t_resolution = $t_bug_resolution_is_fixed ? $t_current_resolution : $t_resolution_fixed; 177 178 $t_relationships = relationship_get_all_src( $f_bug_id ); 179 foreach( $t_relationships as $t_relationship ) { 180 if( $t_relationship->type == BUG_DUPLICATE ) { 181 $t_resolution = config_get( 'bug_duplicate_resolution' ); 182 break; 183 } 184 } 185 186 print_enum_string_option_list( 'resolution', $t_resolution ); 187 ?> 188 </select> 189 </td> 190 </tr> 191<?php 192 if( $t_resolution != config_get( 'bug_duplicate_resolution' ) ) { 193?> 194<!-- Duplicate ID --> 195 <tr> 196 <th class="category"> 197 <?php echo lang_get( 'duplicate_id' ) ?> 198 </th> 199 <td> 200 <input type="text" class="input-sm" name="duplicate_id" maxlength="10" /> 201 </td> 202 </tr> 203 204<?php 205 } 206 } 207 208 if( access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $f_bug_id ) ) { 209 $t_suggested_handler_id = $t_bug->handler_id; 210 211 if( $t_suggested_handler_id == NO_USER && access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id ) ) { 212 $t_suggested_handler_id = $t_current_user_id; 213 } 214 215?> 216<!-- Assigned To --> 217 <tr> 218 <th class="category"> 219 <?php echo lang_get( 'assigned_to' ) ?> 220 </th> 221 <td> 222 <select name="handler_id" class="input-sm"> 223 <option value="0"></option> 224 <?php print_assign_to_option_list( $t_suggested_handler_id, $t_bug->project_id ) ?> 225 </select> 226 </td> 227 </tr> 228<?php } ?> 229 230<?php 231 if( $t_can_update_due_date ) { 232 $t_date_to_display = ''; 233 234 if( !date_is_null( $t_bug->due_date ) ) { 235 $t_date_to_display = date( config_get( 'normal_date_format' ), $t_bug->due_date ); 236 } 237?> 238 <!-- Due date --> 239 <tr> 240 <th class="category"> 241 <?php echo lang_get( 'due_date' ) ?> 242 </th> 243 <td> 244 <input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" maxlength="16" 245 data-picker-locale="<?php lang_get_current_datetime_locale() ?>" 246 data-picker-format="<?php echo config_get( 'datetime_picker_format' ) ?>" 247 <?php helper_get_tab_index() ?> value="<?php echo $t_date_to_display ?>" /> 248 <?php print_icon( 'fa-calendar', 'fa-xlg datetimepicker' ); ?> 249 </td> 250 </tr> 251 252<?php 253 } 254?> 255 256 <!-- Custom Fields --> 257<?php 258 /** 259 * @todo thraxisp - I undid part of the change for #5068 for #5527 260 * We really need to say what fields are shown in which statusses. For now, 261 * this page will show required custom fields in update mode, or 262 * display or required fields on resolve or close 263 */ 264 $t_custom_status_label = 'update'; # Don't show custom fields by default 265 if( ( $f_new_status >= $t_resolved ) && ( $f_new_status < $t_closed ) ) { 266 $t_custom_status_label = 'resolved'; 267 } 268 if( $t_closed == $f_new_status ) { 269 $t_custom_status_label = 'closed'; 270 } 271 272 $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug->project_id ); 273 274 foreach( $t_related_custom_field_ids as $t_id ) { 275 $t_def = custom_field_get_definition( $t_id ); 276 $t_display = $t_def['display_' . $t_custom_status_label]; 277 $t_require = $t_def['require_' . $t_custom_status_label]; 278 279 if( ( 'update' == $t_custom_status_label ) && ( !$t_require ) ) { 280 continue; 281 } 282 if( in_array( $t_custom_status_label, array( 'resolved', 'closed' ) ) && !( $t_display || $t_require ) ) { 283 continue; 284 } 285 $t_has_write_access = custom_field_has_write_access( $t_id, $f_bug_id ); 286?> 287 <tr> 288 <th class="category"> 289 <?php if( $t_require && $t_has_write_access ) {?><span class="required">*</span><?php } ?> 290 <?php echo lang_get_defaulted( $t_def['name'] ) ?> 291 </th> 292 <td> 293<?php 294 if( $t_has_write_access ) { 295 print_custom_field_input( $t_def, $f_bug_id, $t_require ); 296 } elseif( custom_field_has_read_access( $t_id, $f_bug_id ) ) { 297 print_custom_field_value( $t_def, $t_id, $f_bug_id ); 298 } 299?> 300 </td> 301 </tr> 302 303<?php 304 } # foreach( $t_related_custom_field_ids as $t_id ) 305 306 if( ( $f_new_status >= $t_resolved ) ) { 307 if( version_should_show_product_version( $t_bug->project_id ) 308 && !bug_is_readonly( $f_bug_id ) 309 && access_has_bug_level( config_get( 'update_bug_threshold' ), $f_bug_id ) 310 ) { 311?> 312 <!-- Fixed in Version --> 313 <tr> 314 <th class="category"> 315 <?php echo lang_get( 'fixed_in_version' ) ?> 316 </th> 317 <td> 318 <select name="fixed_in_version" class="input-sm"> 319 <?php print_version_option_list( $t_bug->fixed_in_version, $t_bug->project_id, VERSION_ALL ) ?> 320 </select> 321 </td> 322 </tr> 323<?php 324 } 325 } 326 327 event_signal( 'EVENT_UPDATE_BUG_STATUS_FORM', array( $f_bug_id, $f_new_status ) ); 328 329 if( $f_change_type == BUG_UPDATE_TYPE_REOPEN ) { 330?> 331 <!-- Bug was re-opened --> 332<?php 333 printf( ' <input type="hidden" name="resolution" value="%s" />' . "\n", config_get( 'bug_reopen_resolution' ) ); 334 } 335?> 336<?php 337 $t_default_bugnote_view_status = config_get( 'default_bugnote_view_status' ); 338 $t_bugnote_private = $t_default_bugnote_view_status == VS_PRIVATE; 339 $t_bugnote_class = $t_bugnote_private ? 'form-control bugnote-private' : 'form-control'; 340 341 if( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?> 342 <tr> 343 <th class="category"> 344 <?php echo lang_get( 'view_status' ) ?> 345 </th> 346 <td> 347<?php 348 if( access_has_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id ) ) { 349?> 350 <input type="checkbox" id="bugnote_add_view_status" class="ace" name="private" 351 <?php check_checked( $t_default_bugnote_view_status, VS_PRIVATE ); ?> /> 352 <label class="lbl padding-6" for="bugnote_add_view_status"><?php echo lang_get( 'private' ) ?></label> 353<?php 354 } else { 355 echo get_enum_element( 'view_state', $t_default_bugnote_view_status ); 356 } 357?> 358 </td> 359 </tr> 360<?php } ?> 361 <!-- Bugnote --> 362 <tr id="bug-change-status-note"> 363 <th class="category"> 364 <?php echo lang_get( 'add_bugnote_title' ) ?> 365 </th> 366 <td> 367 <textarea name="bugnote_text" id="bugnote_text" class="<?php echo $t_bugnote_class ?>" cols="80" rows="7"></textarea> 368 </td> 369 </tr> 370<?php 371 if( config_get( 'time_tracking_enabled' ) 372 && access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) 373 && access_has_bug_level( config_get( 'time_tracking_edit_threshold' ), $f_bug_id ) 374 ) { 375 ?> 376 <tr> 377 <th class="category"> 378 <?php echo lang_get( 'time_tracking' ) ?> 379 </th> 380 <td> 381 <input type="text" name="time_tracking" class="input-sm" size="5" placeholder="hh:mm" /> 382 </td> 383 </tr> 384 385<?php 386 } 387 388 event_signal( 'EVENT_BUGNOTE_ADD_FORM', array( $f_bug_id ) ); 389?> 390 391</tbody> 392</table> 393<input type="hidden" name="action_type" value="<?php echo string_attribute( $f_change_type ); ?>" /> 394 395</div> 396</div> 397<div class="widget-toolbox padding-8 clearfix"> 398 <span class="required pull-right"> * <?php echo lang_get( 'required' ) ?></span> 399 <input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( $t_status_label . '_bug_button' ) ?>" /> 400</div> 401</div> 402</div> 403</div> 404</form> 405<div class="space-10"></div> 406</div> 407<?php 408define( 'BUG_VIEW_INC_ALLOW', true ); 409include( dirname( __FILE__ ) . '/bug_view_inc.php' ); 410