Ejemplo n.º 1
0
/**
 * 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;
}
Ejemplo n.º 2
0
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 {
        if ($t_reopen_issue) {
            email_reopen($f_bug_id);
        } else {
            if ($t_existing_bug->handler_id === NO_USER && $t_updated_bug->handler_id !== NO_USER) {
                email_assign($f_bug_id);
            } else {
                if ($t_existing_bug->status !== $t_updated_bug->status) {
                    $t_new_status_label = MantisEnum::getLabel(config_get('status_enum_string'), $t_updated_bug->status);
                    $t_new_status_label = str_replace(' ', '_', $t_new_status_label);
                    email_generic($f_bug_id, $t_new_status_label, 'email_notification_title_for_status_bug_' . $t_new_status_label);
                } else {
                    email_generic($f_bug_id, 'updated', 'email_notification_title_for_action_bug_updated');
                }
            }
        }
    }
}
# Twitter notification of bug update.
if ($t_resolve_issue && $t_updated_bug->resolution >= config_get('bug_resolution_fixed_threshold') && $t_updated_bug->resolution < config_get('bug_resolution_not_fixed_threshold')) {
    twitter_issue_resolved($f_bug_id);
}
form_security_purge('bug_update');
print_successful_redirect_to_bug($f_bug_id);
Ejemplo n.º 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;
}