# Add a bug note if there is one. if ($t_bug_note->note || helper_duration_to_minutes($t_bug_note->time_tracking) > 0) { bugnote_add($f_bug_id, $t_bug_note->note, $t_bug_note->time_tracking, $t_bug_note->view_state == VS_PRIVATE, 0, '', null, false); } # Add a duplicate relationship if requested. if ($t_updated_bug->duplicate_id !== 0) { relationship_add($f_bug_id, $t_updated_bug->duplicate_id, BUG_DUPLICATE); history_log_event_special($f_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $t_updated_bug->duplicate_id); history_log_event_special($t_updated_bug->duplicate_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $f_bug_id); if (user_exists($t_existing_bug->reporter_id)) { bug_monitor($f_bug_id, $t_existing_bug->reporter_id); } if (user_exists($t_existing_bug->handler_id)) { bug_monitor($f_bug_id, $t_existing_bug->handler_id); } bug_monitor_copy($f_bug_id, $t_updated_bug->duplicate_id); } event_signal('EVENT_UPDATE_BUG', array($t_existing_bug, $t_updated_bug)); # Allow a custom function to respond to the modifications made to the bug. Note # that custom functions are being deprecated in MantisBT. You should migrate to # the new plugin system instead. helper_call_custom_function('issue_update_notify', array($f_bug_id)); # Send a notification of changes via email. if ($t_resolve_issue) { email_resolved($f_bug_id); email_relationship_child_resolved($f_bug_id); } else { if ($t_close_issue) { email_close($f_bug_id); email_relationship_child_closed($f_bug_id); } else {
/** * resolve the given bug * @param int p_bug_id * @param int p_resolution resolution code * @param int p_status optional custom status (defaults to bug_resolved_status_threshold) * @param string p_fixed_in_version optional version string in which issue is fixed * @param int p_duplicate_id optional id of duplicate issue (defaults to null) * @param int p_handler_id optional id of issue handler * @param string p_bugnote_text optional bug note to add * @param bool p_bugnote_private optional true if bug note should be private (defaults to false) * @param string p_time_tracking optional time spent (defaults to '0:00') * @return bool (always true) * @access public */ function bug_resolve($p_bug_id, $p_resolution, $p_status = null, $p_fixed_in_version = '', $p_duplicate_id = null, $p_handler_id = null, $p_bugnote_text = '', $p_bugnote_private = false, $p_time_tracking = '0:00') { $c_resolution = (int) $p_resolution; if (null == $p_status) { $p_status = config_get('bug_resolved_status_threshold'); } $p_bugnote_text = trim($p_bugnote_text); # Add bugnote if supplied # Moved bugnote_add before bug_set_field calls in case time_tracking_no_note is off. # Error condition stopped execution but status had already been changed bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private, 0, '', NULL, FALSE); $t_duplicate = !is_blank($p_duplicate_id) && $p_duplicate_id != 0; if ($t_duplicate) { if ($p_bug_id == $p_duplicate_id) { trigger_error(ERROR_BUG_DUPLICATE_SELF, ERROR); # never returns } # the related bug exists... bug_ensure_exists($p_duplicate_id); # check if there is other relationship between the bugs... $t_id_relationship = relationship_same_type_exists($p_bug_id, $p_duplicate_id, BUG_DUPLICATE); if ($t_id_relationship > 0) { # Update the relationship relationship_update($t_id_relationship, $p_bug_id, $p_duplicate_id, BUG_DUPLICATE); # Add log line to the history (both bugs) history_log_event_special($p_bug_id, BUG_REPLACE_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id); history_log_event_special($p_duplicate_id, BUG_REPLACE_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id); } else { if ($t_id_relationship != -1) { # Add the new relationship relationship_add($p_bug_id, $p_duplicate_id, BUG_DUPLICATE); # Add log line to the history (both bugs) history_log_event_special($p_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id); history_log_event_special($p_duplicate_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id); } } # else relationship is -1 - same type exists, do nothing # Copy list of users monitoring the duplicate bug to the original bug bug_monitor_copy($p_bug_id, $p_duplicate_id); bug_set_field($p_bug_id, 'duplicate_id', (int) $p_duplicate_id); } bug_set_field($p_bug_id, 'status', $p_status); bug_set_field($p_bug_id, 'fixed_in_version', $p_fixed_in_version); bug_set_field($p_bug_id, 'resolution', $c_resolution); # only set handler if specified explicitly or if bug was not assigned to a handler if (null == $p_handler_id) { if (bug_get_field($p_bug_id, 'handler_id') == 0) { $p_handler_id = auth_get_current_user_id(); bug_set_field($p_bug_id, 'handler_id', $p_handler_id); } } else { bug_set_field($p_bug_id, 'handler_id', $p_handler_id); } email_resolved($p_bug_id); email_relationship_child_resolved($p_bug_id); if ($c_resolution >= config_get('bug_resolution_fixed_threshold') && $c_resolution < config_get('bug_resolution_not_fixed_threshold')) { twitter_issue_resolved($p_bug_id); } return true; }