Example #1
0
        } else {
            if ($t_reopen_issue && $t_existing_bug->status < $t_closed_status && $t_existing_bug->reporter_id === auth_get_current_user_id() && config_get('allow_reporter_reopen')) {
                $t_can_bypass_status_access_thresholds = true;
            }
        }
        if (!$t_can_bypass_status_access_thresholds) {
            trigger_error(ERROR_ACCESS_DENIED, ERROR);
        }
    }
    if ($t_reopen_issue) {
        # for everyone allowed to reopen an issue, set the reopen resolution
        $t_updated_bug->resolution = config_get('bug_reopen_resolution');
    }
}
# Validate any change to the handler of an issue.
$t_issue_is_sponsored = sponsorship_get_amount(sponsorship_get_all_ids($f_bug_id)) > 0;
if ($t_existing_bug->handler_id !== $t_updated_bug->handler_id) {
    access_ensure_bug_level(config_get('update_bug_assign_threshold'), $f_bug_id);
    if ($t_issue_is_sponsored && !access_has_bug_level(config_get('handle_sponsored_bugs_threshold'), $f_bug_id)) {
        trigger_error(ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR);
    }
    if ($t_updated_bug->handler_id !== NO_USER) {
        if (!access_has_bug_level(config_get('handle_bug_threshold'), $f_bug_id, $t_updated_bug->handler_id)) {
            trigger_error(ERROR_HANDLER_ACCESS_TOO_LOW, ERROR);
        }
        if ($t_issue_is_sponsored && !access_has_bug_level(config_get('assign_sponsored_bugs_threshold'), $f_bug_id)) {
            trigger_error(ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR);
        }
    }
}
# Check whether the category has been undefined when it's compulsory.
Example #2
0
/**
 * if sponsorship contains a non-zero id, then update the corresponding record.
 * if sponsorship contains a zero id, search for bug_id/user_id, if found, then update the entry
 * otherwise add a new entry
 * @param int $p_sponsorship
 * @return int
 */
function sponsorship_set($p_sponsorship)
{
    $t_min_sponsorship = config_get('minimum_sponsorship_amount');
    if ($p_sponsorship->amount < $t_min_sponsorship) {
        error_parameters($p_sponsorship->amount, $t_min_sponsorship);
        trigger_error(ERROR_SPONSORSHIP_AMOUNT_TOO_LOW, ERROR);
    }
    # if id == 0, check if the specified user is already sponsoring the bug, if so, overwrite
    if ($p_sponsorship->id == 0) {
        $t_sponsorship_id = sponsorship_get_id($p_sponsorship->bug_id, $p_sponsorship->user_id);
        if ($t_sponsorship_id !== false) {
            $p_sponsorship->id = $t_sponsorship_id;
        }
    }
    $t_sponsorship_table = db_get_table('sponsorship');
    $c_id = db_prepare_int($p_sponsorship->id);
    $c_bug_id = db_prepare_int($p_sponsorship->bug_id);
    $c_user_id = db_prepare_int($p_sponsorship->user_id);
    $c_amount = db_prepare_int($p_sponsorship->amount);
    $c_logo = $p_sponsorship->logo;
    $c_url = $p_sponsorship->url;
    $c_now = db_now();
    # if new sponsorship
    if ($c_id == 0) {
        # Insert
        $query = "INSERT INTO {$t_sponsorship_table}\n\t\t\t\t    ( bug_id, user_id, amount, logo, url, date_submitted, last_updated )\n\t\t\t\t  VALUES\n\t\t\t\t    (" . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
        db_query_bound($query, array($c_bug_id, $c_user_id, $c_amount, $c_logo, $c_url, $c_now, $c_now));
        $t_sponsorship_id = db_insert_id($t_sponsorship_table);
        history_log_event_special($c_bug_id, BUG_ADD_SPONSORSHIP, $c_user_id, $c_amount);
    } else {
        $t_old_amount = sponsorship_get_amount($c_id);
        $t_sponsorship_id = $c_id;
        if ($t_old_amount == $c_amount) {
            return $t_sponsorship_id;
        }
        # Update
        $query = "UPDATE {$t_sponsorship_table}\n\t\t\t\t\tSET\tbug_id = " . db_param() . ",\n\t\t\t\t\t\tuser_id = " . db_param() . ",\n\t\t\t\t\t\tamount = " . db_param() . ",\n\t\t\t\t\t\tlogo = " . db_param() . ",\n\t\t\t\t\t\turl = " . db_param() . ",\n\t\t\t\t\t\tlast_updated = " . db_param() . "\n\t\t\t\t\tWHERE\tid = " . db_param();
        sponsorship_clear_cache($c_id);
        db_query_bound($query, array($c_bug_id, $c_user_id, $c_amount, $c_logo, $c_url, $c_now, $c_id));
        history_log_event_special($c_bug_id, BUG_UPDATE_SPONSORSHIP, $c_user_id, $c_amount);
    }
    sponsorship_update_bug($c_bug_id);
    bug_monitor($c_bug_id, $c_user_id);
    if ($c_id == 0) {
        email_sponsorship_added($c_bug_id);
    } else {
        email_sponsorship_updated($c_bug_id);
    }
    return $t_sponsorship_id;
}
        if (bug_is_readonly($f_bug_id) || !access_has_bug_level(access_get_status_threshold($f_new_status, $t_bug->project_id), $f_bug_id, $t_current_user_id)) {
            access_denied();
        }
    }
}
$t_can_update_due_date = access_has_bug_level(config_get('due_date_update_threshold'), $f_bug_id);
if ($t_can_update_due_date) {
    require_js('jscalendar/calendar.js');
    require_js('jscalendar/lang/calendar-en.js');
    require_js('jscalendar/calendar-setup.js');
    require_css('calendar-blue.css');
}
# get new issue handler if set, otherwise default to original handler
$f_handler_id = gpc_get_int('handler_id', $t_bug->handler_id);
if (config_get('bug_assigned_status') == $f_new_status) {
    $t_bug_sponsored = config_get('enable_sponsorship') && sponsorship_get_amount(sponsorship_get_all_ids($f_bug_id)) > 0;
    if ($t_bug_sponsored && !access_has_bug_level(config_get('assign_sponsored_bugs_threshold'), $f_bug_id)) {
        trigger_error(ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR);
    }
    if ($f_handler_id != NO_USER) {
        if (!access_has_bug_level(config_get('handle_bug_threshold'), $f_bug_id, $f_handler_id)) {
            trigger_error(ERROR_HANDLER_ACCESS_TOO_LOW, ERROR);
        }
        if ($t_bug_sponsored && !access_has_bug_level(config_get('handle_sponsored_bugs_threshold'), $f_bug_id, $f_handler_id)) {
            trigger_error(ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR);
        }
    }
}
$t_status_label = str_replace(' ', '_', MantisEnum::getLabel(config_get('status_enum_string'), $f_new_status));
html_page_top(bug_format_summary($f_bug_id, SUMMARY_CAPTION));
print_recently_visited();
Example #4
0
/**
 * Build the bug raw data visible for specified user to be translated and sent by email to the user
 * (Filter the bug data according to user access level)
 * return array with bug data. See usage in email_format_bug_message(...)
 * @param int $p_user_id
 * @param int $p_bug_id
 * @param string $p_message_id
 * @return array
 */
function email_build_visible_bug_data($p_user_id, $p_bug_id, $p_message_id)
{
    $t_project_id = bug_get_field($p_bug_id, 'project_id');
    $t_user_access_level = user_get_access_level($p_user_id, $t_project_id);
    $t_user_bugnote_order = user_pref_get_pref($p_user_id, 'bugnote_order');
    $t_user_bugnote_limit = user_pref_get_pref($p_user_id, 'email_bugnote_limit');
    $row = bug_get_extended_row($p_bug_id);
    $t_bug_data = array();
    $t_bug_data['email_bug'] = $p_bug_id;
    if ($p_message_id !== 'email_notification_title_for_action_bug_deleted') {
        $t_bug_data['email_bug_view_url'] = string_get_bug_view_url_with_fqdn($p_bug_id);
    }
    if (access_compare_level($t_user_access_level, config_get('view_handler_threshold'))) {
        if (0 != $row['handler_id']) {
            $t_bug_data['email_handler'] = user_get_name($row['handler_id']);
        } else {
            $t_bug_data['email_handler'] = '';
        }
    }
    $t_bug_data['email_reporter'] = user_get_name($row['reporter_id']);
    $t_bug_data['email_project_id'] = $row['project_id'];
    $t_bug_data['email_project'] = project_get_field($row['project_id'], 'name');
    $t_category_name = category_full_name($row['category_id'], false);
    $t_bug_data['email_category'] = $t_category_name;
    $t_bug_data['email_date_submitted'] = $row['date_submitted'];
    $t_bug_data['email_last_modified'] = $row['last_updated'];
    $t_bug_data['email_status'] = $row['status'];
    $t_bug_data['email_severity'] = $row['severity'];
    $t_bug_data['email_priority'] = $row['priority'];
    $t_bug_data['email_reproducibility'] = $row['reproducibility'];
    $t_bug_data['email_resolution'] = $row['resolution'];
    $t_bug_data['email_fixed_in_version'] = $row['fixed_in_version'];
    if (!is_blank($row['target_version']) && access_compare_level($t_user_access_level, config_get('roadmap_view_threshold'))) {
        $t_bug_data['email_target_version'] = $row['target_version'];
    }
    $t_bug_data['email_summary'] = $row['summary'];
    $t_bug_data['email_description'] = $row['description'];
    $t_bug_data['email_additional_information'] = $row['additional_information'];
    $t_bug_data['email_steps_to_reproduce'] = $row['steps_to_reproduce'];
    $t_bug_data['set_category'] = '[' . $t_bug_data['email_project'] . '] ' . $t_category_name;
    $t_bug_data['custom_fields'] = custom_field_get_linked_fields($p_bug_id, $t_user_access_level);
    $t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes($p_bug_id, $t_user_bugnote_order, $t_user_bugnote_limit, $p_user_id);
    # put history data
    if (ON == config_get('history_default_visible') && access_compare_level($t_user_access_level, config_get('view_history_threshold'))) {
        $t_bug_data['history'] = history_get_raw_events_array($p_bug_id, $p_user_id);
    }
    # Sponsorship Information
    if (config_get('enable_sponsorship') == ON && access_has_bug_level(config_get('view_sponsorship_total_threshold'), $p_bug_id, $p_user_id)) {
        $t_sponsorship_ids = sponsorship_get_all_ids($p_bug_id);
        $t_bug_data['sponsorship_total'] = sponsorship_get_amount($t_sponsorship_ids);
        if (access_has_bug_level(config_get('view_sponsorship_details_threshold'), $p_bug_id, $p_user_id)) {
            $t_bug_data['sponsorships'] = array();
            foreach ($t_sponsorship_ids as $id) {
                $t_bug_data['sponsorships'][] = sponsorship_get($id);
            }
        }
    }
    $t_bug_data['relations'] = relationship_get_summary_text($p_bug_id);
    return $t_bug_data;
}
Example #5
0
/**
 * if sponsorship contains a non-zero id, then update the corresponding record.
 * if sponsorship contains a zero id, search for bug_id/user_id, if found, then update the entry
 * otherwise add a new entry
 * @param SponsorshipData $p_sponsorship The sponsorship data object to set.
 * @return integer
 */
function sponsorship_set(SponsorshipData $p_sponsorship)
{
    $t_min_sponsorship = config_get('minimum_sponsorship_amount');
    if ($p_sponsorship->amount < $t_min_sponsorship) {
        error_parameters($p_sponsorship->amount, $t_min_sponsorship);
        trigger_error(ERROR_SPONSORSHIP_AMOUNT_TOO_LOW, ERROR);
    }
    # if id == 0, check if the specified user is already sponsoring the bug, if so, overwrite
    if ($p_sponsorship->id == 0) {
        $t_sponsorship_id = sponsorship_get_id($p_sponsorship->bug_id, $p_sponsorship->user_id);
        if ($t_sponsorship_id !== false) {
            $p_sponsorship->id = $t_sponsorship_id;
        }
    }
    $c_id = (int) $p_sponsorship->id;
    $c_bug_id = (int) $p_sponsorship->bug_id;
    $c_user_id = (int) $p_sponsorship->user_id;
    $c_amount = (int) $p_sponsorship->amount;
    $c_logo = $p_sponsorship->logo;
    $c_url = $p_sponsorship->url;
    $c_now = db_now();
    # if new sponsorship
    if ($c_id == 0) {
        # Insert
        $t_query = 'INSERT INTO {sponsorship}
				    ( bug_id, user_id, amount, logo, url, date_submitted, last_updated )
				  VALUES
				    (' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
        db_query($t_query, array($c_bug_id, $c_user_id, $c_amount, $c_logo, $c_url, $c_now, $c_now));
        $t_sponsorship_id = db_insert_id(db_get_table('sponsorship'));
        history_log_event_special($c_bug_id, BUG_ADD_SPONSORSHIP, $c_user_id, $c_amount);
    } else {
        $t_old_amount = sponsorship_get_amount($c_id);
        $t_sponsorship_id = $c_id;
        if ($t_old_amount == $c_amount) {
            return $t_sponsorship_id;
        }
        # Update
        $t_query = 'UPDATE {sponsorship}
					SET	bug_id = ' . db_param() . ',
						user_id = ' . db_param() . ',
						amount = ' . db_param() . ',
						logo = ' . db_param() . ',
						url = ' . db_param() . ',
						last_updated = ' . db_param() . '
					WHERE	id = ' . db_param();
        sponsorship_clear_cache($c_id);
        db_query($t_query, array($c_bug_id, $c_user_id, $c_amount, $c_logo, $c_url, $c_now, $c_id));
        history_log_event_special($c_bug_id, BUG_UPDATE_SPONSORSHIP, $c_user_id, $c_amount);
    }
    sponsorship_update_bug($c_bug_id);
    bug_monitor($c_bug_id, $c_user_id);
    if ($c_id == 0) {
        email_sponsorship_added($c_bug_id);
    } else {
        email_sponsorship_updated($c_bug_id);
    }
    return $t_sponsorship_id;
}