/**
 * 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;
}
Example #2
0
 if ($t_bug->project_id != helper_get_current_project()) {
     # in case the current project is not the same project of the bug we are viewing...
     # ... override the current project. This to avoid problems with categories and handlers lists etc.
     $g_project_override = $t_bug->project_id;
 }
 # check if there is other relationship between the bugs...
 $t_old_id_relationship = relationship_same_type_exists($f_src_bug_id, $f_dest_bug_id, $f_rel_type);
 if ($t_old_id_relationship == -1) {
     # the relationship type is exactly the same of the new one. No sense to proceed
     trigger_error(ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR);
 } else {
     if ($t_old_id_relationship > 0) {
         # there is already a relationship between them -> we have to update it and not to add a new one
         helper_ensure_confirmed(lang_get('replace_relationship_sure_msg'), lang_get('replace_relationship_button'));
         # Update the relationship
         relationship_update($t_old_id_relationship, $f_src_bug_id, $f_dest_bug_id, $f_rel_type);
         # Add log line to the history (both bugs)
         history_log_event_special($f_src_bug_id, BUG_REPLACE_RELATIONSHIP, $f_rel_type, $f_dest_bug_id);
         history_log_event_special($f_dest_bug_id, BUG_REPLACE_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $f_src_bug_id);
     } else {
         # Add the new relationship
         relationship_add($f_src_bug_id, $f_dest_bug_id, $f_rel_type);
         # Add log line to the history (both bugs)
         history_log_event_special($f_src_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_dest_bug_id);
         history_log_event_special($f_dest_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $f_src_bug_id);
     }
 }
 # update bug last updated (just for the src bug)
 bug_update_date($f_src_bug_id);
 # send email notification to the users addressed by both the bugs
 email_relationship_added($f_src_bug_id, $f_dest_bug_id, $f_rel_type);
Example #3
0
function bug_resolve($p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bugnote_text = '', $p_duplicate_id = null, $p_handler_id = null, $p_bugnote_private = false, $p_time_tracking = '0:00')
{
    $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);
        if (ON == config_get('enable_relationship')) {
            # 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 == -1) {
                # the relationship type is already set. Nothing to do
            } else {
                if ($t_id_relationship > 0) {
                    # there is already a relationship between them -> we have to update it and not to add a new one
                    helper_ensure_confirmed(lang_get('replace_relationship_sure_msg'), lang_get('replace_relationship_button'));
                    # 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 {
                    # 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);
                }
            }
        }
        bug_set_field($p_bug_id, 'duplicate_id', (int) $p_duplicate_id);
    }
    $c_resolution = db_prepare_int($p_resolution);
    bug_set_field($p_bug_id, 'status', config_get('bug_resolved_status_threshold'));
    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);
    if ($c_resolution == FIXED) {
        twitter_issue_resolved($p_bug_id);
    }
    # MASC RELATIONSHIP
    if (ON == config_get('enable_relationship')) {
        email_relationship_child_resolved($p_bug_id);
    }
    # MASC RELATIONSHIP
    return true;
}