示例#1
0
$t_bug = bug_get($f_bug_id, true);
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;
}
if (config_get('enable_sponsorship') == OFF) {
    trigger_error(ERROR_SPONSORSHIP_NOT_ENABLED, ERROR);
}
access_ensure_bug_level(config_get('sponsor_threshold'), $f_bug_id);
helper_ensure_confirmed(sprintf(lang_get('confirm_sponsorship'), $f_bug_id, sponsorship_format_amount($f_amount)), lang_get('sponsor_issue'));
if ($f_amount == 0) {
    # if amount == 0, delete sponsorship by current user (if any)
    $t_sponsorship_id = sponsorship_get_id($f_bug_id);
    if ($t_sponsorship_id !== false) {
        sponsorship_delete($t_sponsorship_id);
    }
} else {
    # add sponsorship
    $t_user = auth_get_current_user_id();
    if (is_blank(user_get_email($t_user))) {
        trigger_error(ERROR_SPONSORSHIP_SPONSOR_NO_EMAIL, ERROR);
    } else {
        $sponsorship = new SponsorshipData();
        $sponsorship->bug_id = $f_bug_id;
        $sponsorship->user_id = $t_user;
        $sponsorship->amount = $f_amount;
        sponsorship_set($sponsorship);
    }
}
form_security_purge('bug_set_sponsorship');
示例#2
0
/**
 * delete a sponsorship given its id
 * id can be an array of ids or just an id.
 * @param int $p_sponsorship_id
 * @return null
 */
function sponsorship_delete($p_sponsorship_id)
{
    # handle the case of array of ids
    if (is_array($p_sponsorship_id)) {
        foreach ($p_sponsorship_id as $id) {
            sponsorship_delete($id);
        }
        return;
    }
    $c_sponsorship_id = db_prepare_int($p_sponsorship_id);
    $t_sponsorship = sponsorship_get($c_sponsorship_id);
    $t_sponsorship_table = db_get_table('sponsorship');
    # Delete the bug entry
    $query = "DELETE FROM {$t_sponsorship_table}\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($c_sponsorship_id));
    sponsorship_clear_cache($p_sponsorship_id);
    history_log_event_special($t_sponsorship->bug_id, BUG_DELETE_SPONSORSHIP, $t_sponsorship->user_id, $t_sponsorship->amount);
    sponsorship_update_bug($t_sponsorship->bug_id);
    email_sponsorship_deleted($t_sponsorship->bug_id);
}
示例#3
0
/**
 * delete a sponsorship given its id
 * id can be an array of ids or just an id.
 * @param integer $p_sponsorship_id The sponsorship identifier to delete.
 * @return void
 */
function sponsorship_delete($p_sponsorship_id)
{
    # handle the case of array of ids
    if (is_array($p_sponsorship_id)) {
        foreach ($p_sponsorship_id as $t_id) {
            sponsorship_delete($t_id);
        }
        return;
    }
    $t_sponsorship = sponsorship_get($p_sponsorship_id);
    # Delete the bug entry
    $t_query = 'DELETE FROM {sponsorship} WHERE id=' . db_param();
    db_query($t_query, array((int) $p_sponsorship_id));
    sponsorship_clear_cache($p_sponsorship_id);
    history_log_event_special($t_sponsorship->bug_id, BUG_DELETE_SPONSORSHIP, $t_sponsorship->user_id, $t_sponsorship->amount);
    sponsorship_update_bug($t_sponsorship->bug_id);
    email_sponsorship_deleted($t_sponsorship->bug_id);
}
示例#4
0
/**
 * allows bug deletion :
 * delete the bug, bugtext, bugnote, and bugtexts selected
 * @param array p_bug_id integer representing bug id
 * @return bool (always true)
 * @access public
 */
function bug_delete($p_bug_id)
{
    $c_bug_id = (int) $p_bug_id;
    $t_bug_table = db_get_table('bug');
    $t_bug_text_table = db_get_table('bug_text');
    # call pre-deletion custom function
    helper_call_custom_function('issue_delete_validate', array($p_bug_id));
    # log deletion of bug
    history_log_event_special($p_bug_id, BUG_DELETED, bug_format_id($p_bug_id));
    email_bug_deleted($p_bug_id);
    # call post-deletion custom function.  We call this here to allow the custom function to access the details of the bug before
    # they are deleted from the database given it's id.  The other option would be to move this to the end of the function and
    # provide it with bug data rather than an id, but this will break backward compatibility.
    helper_call_custom_function('issue_delete_notify', array($p_bug_id));
    # Unmonitor bug for all users
    bug_unmonitor($p_bug_id, null);
    # Delete custom fields
    custom_field_delete_all_values($p_bug_id);
    # Delete bugnotes
    bugnote_delete_all($p_bug_id);
    # Delete all sponsorships
    sponsorship_delete(sponsorship_get_all_ids($p_bug_id));
    # MASC RELATIONSHIP
    # we delete relationships even if the feature is currently off.
    relationship_delete_all($p_bug_id);
    # MASC RELATIONSHIP
    # Delete files
    file_delete_attachments($p_bug_id);
    # Detach tags
    tag_bug_detach_all($p_bug_id, false);
    # Delete the bug history
    history_delete($p_bug_id);
    # Delete bug info revisions
    bug_revision_delete($p_bug_id);
    # Delete the bugnote text
    $t_bug_text_id = bug_get_field($p_bug_id, 'bug_text_id');
    $query = "DELETE FROM {$t_bug_text_table}\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($t_bug_text_id));
    # Delete the bug entry
    $query = "DELETE FROM {$t_bug_table}\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($c_bug_id));
    bug_clear_cache($p_bug_id);
    bug_text_clear_cache($p_bug_id);
    # db_query errors on failure so:
    return true;
}
示例#5
0
function bug_delete($p_bug_id)
{
    $c_bug_id = db_prepare_int($p_bug_id);
    $t_bug_table = config_get('mantis_bug_table');
    $t_bug_text_table = config_get('mantis_bug_text_table');
    # log deletion of bug
    history_log_event_special($p_bug_id, BUG_DELETED, bug_format_id($p_bug_id));
    email_bug_deleted($p_bug_id);
    # Unmonitor bug for all users
    bug_unmonitor($p_bug_id, null);
    # Delete custom fields
    custom_field_delete_all_values($p_bug_id);
    # Delete bugnotes
    bugnote_delete_all($p_bug_id);
    # Delete all sponsorships
    sponsorship_delete(sponsorship_get_all_ids($p_bug_id));
    # MASC RELATIONSHIP
    # we delete relationships even if the feature is currently off.
    relationship_delete_all($p_bug_id);
    # MASC RELATIONSHIP
    # Delete files
    file_delete_attachments($p_bug_id);
    # Delete the bug history
    history_delete($p_bug_id);
    # Delete the bugnote text
    $t_bug_text_id = bug_get_field($p_bug_id, 'bug_text_id');
    $query = "DELETE FROM {$t_bug_text_table}\n\t\t\t\t  WHERE id='{$t_bug_text_id}'";
    db_query($query);
    # Delete the bug entry
    $query = "DELETE FROM {$t_bug_table}\n\t\t\t\t  WHERE id='{$c_bug_id}'";
    db_query($query);
    bug_clear_cache($p_bug_id);
    bug_text_clear_cache($p_bug_id);
    # db_query() errors on failure so:
    return true;
}