function renderIssues($status)
    {
        $content = array();
        $t_bug_table = db_get_table('mantis_bug_table');
        $t_user_id = auth_get_current_user_id();
        $specific_where = helper_project_specific_where($this->project_id, $t_user_id);
        if ($this->severity) {
            $severityCond = '= ' . $this->severity;
        } else {
            $severityCond = '> -1';
        }
        if ($this->version) {
            $versionCon = '= ' . $this->version;
        } else {
            $versionCon = '> -1';
        }
        $query = "SELECT *\n\t\t\tFROM {$t_bug_table}\n\t\t\tWHERE {$specific_where}\n\t\t\tAND status = {$status}\n\t\t\tAND severity {$severityCond}\n                        AND version {$versionCon}\n\t\t\tORDER BY last_updated DESC\n\t\t\tLIMIT 20";
        $result = db_query_bound($query);
        $category_count = db_num_rows($result);
        for ($i = 0; $i < $category_count; $i++) {
            $row = db_fetch_array($result);
            $content[] = '<div class="portlet ui-helper-clearfix" id="' . $row['id'] . '"> 
			<div class="portlet-header">' . icon_get_status_icon($row['priority']) . ' ' . string_get_bug_view_link($row['id']) . ': ' . $row['summary'] . '</div>
			<div class="portlet-content">' . ($row['handler_id'] ? '<strong>Assigned:</strong> ' . user_get_name($row['handler_id']) . BR : '') . '</div></div>';
        }
        if ($row) {
            //pre_var_dump(array_keys($row));
        }
        return $content;
    }
Example #2
0
function profile_get_all_for_project($p_project_id)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_bug_table = config_get('mantis_bug_table');
    $t_user_profile_table = config_get('mantis_user_profile_table');
    # using up.* causes an SQL error on MS SQL since up.description is of type text
    $query = "SELECT DISTINCT(up.id), up.user_id, up.platform, up.os, up.os_build\n\t\t\t\t  FROM {$t_user_profile_table} up, {$t_bug_table} b\n\t\t\t\t  WHERE {$t_project_where}\n\t\t\t\t  AND up.id = b.profile_id";
    $result = db_query($query);
    $t_rows = array();
    $t_row_count = db_num_rows($result);
    for ($i = 0; $i < $t_row_count; $i++) {
        array_push($t_rows, db_fetch_array($result));
    }
    return $t_rows;
}
Example #3
0
echo lang_get('my_sponsorship');
?>
	</td>
	<td class="right">
		<?php 
print_account_menu('account_sponsor_page.php');
?>
	</td>
</tr>
</table>
<?php 
# get issues user has sponsored
$t_user = auth_get_current_user_id();
$t_resolved = config_get('bug_resolved_status_threshold');
$t_payment = config_get('payment_enable', 0);
$t_project_clause = helper_project_specific_where($t_project);
$t_query = 'SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status
	FROM {bug} b, {sponsorship} s
	WHERE s.user_id=' . db_param() . ' AND s.bug_id = b.id ' . ($t_show_all ? '' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID . ')') . '
	AND ' . $t_project_clause . '
	ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC';
$t_result = db_query($t_query, $t_show_all ? array($t_user) : array($t_user, $t_resolved));
$t_sponsors = array();
while ($t_row = db_fetch_array($t_result)) {
    $t_sponsors[] = $t_row;
}
$t_sponsor_count = count($t_sponsors);
if ($t_sponsor_count === 0) {
    echo '<p>' . lang_get('no_own_sponsored') . '</p>';
} else {
    ?>
Example #4
0
function news_get_count($p_project_id, $p_sitewide = true)
{
    $c_project_id = db_prepare_int($p_project_id);
    $t_news_table = db_get_table('mantis_news_table');
    $t_project_where = helper_project_specific_where($p_project_id);
    $query = "SELECT COUNT(*)\n\t\t\t\t  FROM {$t_news_table}\n\t\t\t\t  WHERE {$t_project_where}";
    if ($p_sitewide) {
        $query .= ' OR project_id=' . ALL_PROJECTS;
    }
    $result = db_query_bound($query);
    return db_result($result, 0, 0);
}
Example #5
0
function user_get_reported_open_bug_count($p_user_id, $p_project_id = ALL_PROJECTS)
{
    $c_user_id = db_prepare_int($p_user_id);
    $c_project_id = db_prepare_int($p_project_id);
    $t_bug_table = config_get('mantis_bug_table');
    $t_where_prj = helper_project_specific_where($p_project_id, $p_user_id) . " AND";
    $t_resolved = config_get('bug_resolved_status_threshold');
    $query = "SELECT COUNT(*)\n\t\t\t\t  FROM {$t_bug_table}\n\t\t\t\t  WHERE {$t_where_prj}\n\t\t\t\t\t\t  status<'{$t_resolved}' AND\n\t\t\t\t\t\t  reporter_id='{$c_user_id}'";
    $result = db_query($query);
    return db_result($result);
}
Example #6
0
/**
 * Print reporter effectiveness report
 *
 * @param string $p_severity_enum_string   Severity enumeration string.
 * @param string $p_resolution_enum_string Resolution enumeration string.
 * @return void
 */
function summary_print_reporter_effectiveness($p_severity_enum_string, $p_resolution_enum_string)
{
    $t_reporter_summary_limit = config_get('reporter_summary_limit');
    $t_project_id = helper_get_current_project();
    $t_severity_multipliers = config_get('severity_multipliers');
    $t_resolution_multipliers = config_get('resolution_multipliers');
    # Get the severity values to use
    $c_sev_s = MantisEnum::getValues($p_severity_enum_string);
    $t_enum_sev_count = count($c_sev_s);
    # Get the resolution values to use
    $c_res_s = MantisEnum::getValues($p_resolution_enum_string);
    # Checking if it's a per project statistic or all projects
    $t_specific_where = helper_project_specific_where($t_project_id);
    if (' 1<>1' == $t_specific_where) {
        return;
    }
    # Get all of the bugs and split them up into an array
    $t_query = 'SELECT COUNT(id) as bugcount, reporter_id, resolution, severity
				FROM {bug}
				WHERE ' . $t_specific_where . '
				GROUP BY reporter_id, resolution, severity';
    $t_result = db_query($t_query);
    $t_reporter_ressev_arr = array();
    $t_reporter_bugcount_arr = array();
    $t_arr = db_fetch_array($t_result);
    while ($t_arr) {
        if (!isset($t_reporter_ressev_arr[$t_arr['reporter_id']])) {
            $t_reporter_ressev_arr[$t_arr['reporter_id']] = array();
            $t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
        }
        if (!isset($t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']])) {
            $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']] = array();
            $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] = 0;
        }
        if (!isset($t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']])) {
            $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] = 0;
        }
        $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] += $t_arr['bugcount'];
        $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] += $t_arr['bugcount'];
        $t_reporter_bugcount_arr[$t_arr['reporter_id']] += $t_arr['bugcount'];
        $t_arr = db_fetch_array($t_result);
    }
    # Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
    arsort($t_reporter_bugcount_arr);
    $t_row_count = 0;
    # We now have a multi dimensional array of users, resolutions and severities, with the
    # value of each resolution and severity for each user
    foreach ($t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs) {
        # Limit the number of reporters listed
        if ($t_row_count > $t_reporter_summary_limit) {
            break;
        }
        # Only print reporters who have reported at least one bug. This helps
        # prevent divide by zeroes, showing reporters not on this project, and showing
        # users that aren't actually reporters...
        if ($t_total_user_bugs > 0) {
            $t_arr2 = $t_reporter_ressev_arr[$t_reporter_id];
            echo '<tr>';
            $t_row_count++;
            echo '<td>';
            echo string_display_line(user_get_name($t_reporter_id));
            echo '</td>';
            $t_total_severity = 0;
            $t_total_errors = 0;
            for ($j = 0; $j < $t_enum_sev_count; $j++) {
                if (!isset($t_arr2[$c_sev_s[$j]])) {
                    continue;
                }
                $t_sev_bug_count = $t_arr2[$c_sev_s[$j]]['total'];
                $t_sev_mult = 1;
                if ($t_severity_multipliers[$c_sev_s[$j]]) {
                    $t_sev_mult = $t_severity_multipliers[$c_sev_s[$j]];
                }
                if ($t_sev_bug_count > 0) {
                    $t_total_severity += $t_sev_bug_count * $t_sev_mult;
                }
                foreach ($t_resolution_multipliers as $t_res => $t_res_mult) {
                    if (isset($t_arr2[$c_sev_s[$j]][$t_res])) {
                        $t_total_errors += $t_sev_mult * $t_res_mult;
                    }
                }
            }
            echo '<td class="right">' . $t_total_severity . '</td>';
            echo '<td class="right">' . $t_total_errors . '</td>';
            printf('<td class="right">%d</td>', $t_total_severity - $t_total_errors);
            echo '</tr>';
        }
    }
}
Example #7
0
/**
 * return the number of open reported bugs by a user in a project
 *
 * @param int $p_user_id User ID
 * @param int $p_project_id Project ID
 * @return int
 */
function user_get_reported_open_bug_count($p_user_id, $p_project_id = ALL_PROJECTS)
{
    $t_bug_table = db_get_table('bug');
    $t_where_prj = helper_project_specific_where($p_project_id, $p_user_id) . ' AND';
    $t_resolved = config_get('bug_resolved_status_threshold');
    $query = "SELECT COUNT(*)\n\t\t\t\t  FROM {$t_bug_table}\n\t\t\t\t  WHERE {$t_where_prj}\n\t\t\t\t\t\t  status<'{$t_resolved}' AND\n\t\t\t\t\t\t  reporter_id=" . db_param();
    $result = db_query_bound($query, array($p_user_id));
    return db_result($result);
}
Example #8
0
/**
 * Return all versions for the specified project, including subprojects
 * @param int $p_project_id
 * @param int $p_released
 * @param bool $p_obsolete
 * @return array
 */
function version_get_all_rows_with_subs($p_project_id, $p_released = null, $p_obsolete = false)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_param_count = 0;
    $t_query_params = array();
    if ($p_released === null) {
        $t_released_where = '';
    } else {
        $c_released = db_prepare_int($p_released);
        $t_released_where = "AND ( released = " . db_param($t_param_count++) . " )";
        $t_query_params[] = $c_released;
    }
    if ($p_obsolete === null) {
        $t_obsolete_where = '';
    } else {
        $c_obsolete = db_prepare_bool($p_obsolete);
        $t_obsolete_where = "AND ( obsolete = " . db_param($t_param_count++) . " )";
        $t_query_params[] = $c_obsolete;
    }
    $t_project_version_table = db_get_table('project_version');
    $query = "SELECT *\n\t\t\t\t  FROM {$t_project_version_table}\n\t\t\t\t  WHERE {$t_project_where} {$t_released_where} {$t_obsolete_where}\n\t\t\t\t  ORDER BY date_order DESC";
    $result = db_query_bound($query, $t_query_params);
    $count = db_num_rows($result);
    $rows = array();
    for ($i = 0; $i < $count; $i++) {
        $row = db_fetch_array($result);
        $rows[] = $row;
    }
    return $rows;
}
Example #9
0
function summary_print_reporter_effectiveness($p_severity_enum_string, $p_resolution_enum_string)
{
    $t_mantis_bug_table = config_get('mantis_bug_table');
    $t_mantis_user_table = config_get('mantis_user_table');
    $t_reporter_summary_limit = config_get('reporter_summary_limit');
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    # These are our overall "values" for severities and non-bug results
    $t_severity_multiplier[FEATURE] = 1;
    $t_severity_multiplier[TRIVIAL] = 2;
    $t_severity_multiplier[TEXT] = 3;
    $t_severity_multiplier[TWEAK] = 2;
    $t_severity_multiplier[MINOR] = 5;
    $t_severity_multiplier[MAJOR] = 8;
    $t_severity_multiplier[CRASH] = 8;
    $t_severity_multiplier[BLOCK] = 10;
    $t_severity_multiplier['average'] = 5;
    $t_notbug_multiplier[UNABLE_TO_DUPLICATE] = 2;
    $t_notbug_multiplier[DUPLICATE] = 3;
    $t_notbug_multiplier[NOT_A_BUG] = 5;
    $t_sev_arr = explode_enum_string($p_severity_enum_string);
    $enum_sev_count = count($t_sev_arr);
    $c_sev_s = array();
    for ($i = 0; $i < $enum_sev_count; $i++) {
        $t_sev_s = explode_enum_arr($t_sev_arr[$i]);
        $c_sev_s[$i] = db_prepare_string($t_sev_s[0]);
    }
    $t_res_arr = explode_enum_string($p_resolution_enum_string);
    $enum_res_count = count($t_res_arr);
    $c_res_s = array();
    for ($i = 0; $i < $enum_res_count; $i++) {
        $t_res_s = explode_enum_arr($t_res_arr[$i]);
        $c_res_s[$i] = db_prepare_string($t_res_s[0]);
    }
    # Checking if it's a per project statistic or all projects
    $specific_where = helper_project_specific_where($t_project_id);
    if (' 1<>1' == $specific_where) {
        return;
    }
    # Get all of the bugs and split them up into an array
    $query = "SELECT COUNT(id) as count, reporter_id, resolution, severity\n\t\t\t\tFROM {$t_mantis_bug_table}\n\t\t\t\tWHERE {$specific_where}\n\t\t\t\tGROUP BY reporter_id, resolution, severity";
    $result = db_query($query);
    $t_reporter_ressev_arr = array();
    $t_reporter_bugcount_arr = array();
    $t_arr = db_fetch_array($result);
    while ($t_arr) {
        if (!isset($t_reporter_ressev_arr[$t_arr['reporter_id']])) {
            $t_reporter_ressev_arr[$t_arr['reporter_id']] = array();
            $t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
        }
        if (!isset($t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']])) {
            $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']] = array();
            $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] = 0;
        }
        if (!isset($t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']])) {
            $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] = 0;
        }
        $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] += $t_arr['count'];
        $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] += $t_arr['count'];
        $t_reporter_bugcount_arr[$t_arr['reporter_id']] += $t_arr['count'];
        $t_arr = db_fetch_array($result);
    }
    # Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
    arsort($t_reporter_bugcount_arr);
    $t_row_count = 0;
    # We now have a multi dimensional array of users, resolutions and severities, with the
    # value of each resolution and severity for each user
    foreach ($t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs) {
        # Limit the number of reporters listed
        if ($t_row_count > $t_reporter_summary_limit) {
            break;
        }
        # Only print reporters who have reported at least one bug. This helps
        # prevent divide by zeroes, showing reporters not on this project, and showing
        # users that aren't actually reporters...
        if ($t_total_user_bugs > 0) {
            $t_arr2 = $t_reporter_ressev_arr[$t_reporter_id];
            print '<tr ' . helper_alternate_class($t_row_count) . '>';
            $t_row_count++;
            print '<td>';
            print user_get_name($t_reporter_id);
            print '</td>';
            $t_total_severity = 0;
            $t_total_errors = 0;
            for ($j = 0; $j < $enum_sev_count; $j++) {
                if (!isset($t_arr2[$c_sev_s[$j]])) {
                    continue;
                }
                $sev_bug_count = $t_arr2[$c_sev_s[$j]]['total'];
                $t_sev_mult = $t_severity_multiplier['average'];
                if ($t_severity_multiplier[$c_sev_s[$j]]) {
                    $t_sev_mult = $t_severity_multiplier[$c_sev_s[$j]];
                }
                if ($sev_bug_count > 0) {
                    $t_total_severity += $sev_bug_count * $t_sev_mult;
                }
                # Calculate the "error value" of bugs reported
                $t_notbug_res_arr = array(UNABLE_TO_DUPLICATE, DUPLICATE, NOT_A_BUG);
                foreach ($t_notbug_res_arr as $t_notbug_res) {
                    if (isset($t_arr2[$c_sev_s[$j]][$t_notbug_res])) {
                        $t_notbug_mult = 1;
                        if ($t_notbug_multiplier[$t_notbug_res]) {
                            $t_notbug_mult = $t_notbug_multiplier[$t_notbug_res];
                        }
                        $t_total_errors += $t_sev_mult * $t_notbug_mult;
                    }
                }
            }
            print '<td>';
            print $t_total_severity;
            print '</td>';
            print '<td>';
            print $t_total_errors;
            print '</td>';
            print '<td>';
            print $t_total_severity - $t_total_errors;
            print '</td>';
            print '</tr>';
        }
    }
}
Example #10
0
function mci_category_get_all_rows($p_project_id, $p_user_id)
{
    $t_project_category_table = config_get('mantis_project_category_table');
    $c_project_id = db_prepare_int($p_project_id);
    $t_project_where = helper_project_specific_where($c_project_id, $p_user_id);
    $query = "SELECT category FROM {$t_project_category_table}\n\t\t\t\tWHERE {$t_project_where}\n\t\t\t\tORDER BY category ASC";
    $result = db_query($query);
    $count = db_num_rows($result);
    $cat_arr = array();
    for ($i = 0; $i < $count; $i++) {
        $row = db_fetch_array($result);
        $cat_arr[] = string_attribute($row['category']);
    }
    sort($cat_arr);
    return $cat_arr;
}
Example #11
0
/**
 * get the status percentages
 * @return array key is the status value, value is the percentage of bugs for the status
 */
function get_percentage_by_status() {
	$t_project_id = helper_get_current_project();
	$t_user_id = auth_get_current_user_id();

	# checking if it's a per project statistic or all projects
	$t_specific_where = helper_project_specific_where( $t_project_id, $t_user_id );

	$t_query = 'SELECT status, COUNT(*) AS num
				FROM {bug}
				WHERE ' . $t_specific_where;
	if( !access_has_project_level( config_get( 'private_bug_threshold' ) ) ) {
		$t_query .= ' AND view_state < ' . VS_PRIVATE;
	}
	$t_query .= ' GROUP BY status';
	$t_result = db_query( $t_query );

	$t_status_count_array = array();

	while( $t_row = db_fetch_array( $t_result ) ) {
		$t_status_count_array[$t_row['status']] = $t_row['num'];
	}
	$t_bug_count = array_sum( $t_status_count_array );
	foreach( $t_status_count_array as $t_status=>$t_value ) {
		$t_status_count_array[$t_status] = round( ( $t_value / $t_bug_count ) * 100 );
	}

	return $t_status_count_array;
}
Example #12
0
/**
 * Return an array containing all profiles used in a given project
 * @param integer $p_project_id A valid project identifier.
 * @return array
 */
function profile_get_all_for_project($p_project_id)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_query = 'SELECT DISTINCT(up.id), up.user_id, up.platform, up.os, up.os_build
				  FROM {user_profile} up, {bug} b
				  WHERE ' . $t_project_where . '
				  AND up.id = b.profile_id
				  ORDER BY up.platform, up.os, up.os_build';
    $t_result = db_query($t_query);
    $t_rows = array();
    while ($t_row = db_fetch_array($t_result)) {
        array_push($t_rows, $t_row);
    }
    return $t_rows;
}
Example #13
0
/**
 * Return an array containing all profiles used in a given project
 * @param int $p_project_id
 * @return array
 */
function profile_get_all_for_project($p_project_id)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_bug_table = db_get_table('bug');
    $t_user_profile_table = db_get_table('user_profile');
    # using up.* causes an SQL error on MS SQL since up.description is of type text
    $query = "SELECT DISTINCT(up.id), up.user_id, up.platform, up.os, up.os_build\n\t\t\t\t  FROM {$t_user_profile_table} up, {$t_bug_table} b\n\t\t\t\t  WHERE {$t_project_where}\n\t\t\t\t  AND up.id = b.profile_id\n\t\t\t\t  ORDER BY platform, os, os_build";
    $t_result = db_query_bound($query);
    $t_rows = array();
    while ($t_row = db_fetch_array($t_result)) {
        array_push($t_rows, $t_row);
    }
    return $t_rows;
}
Example #14
0
/**
 * Create cumulative graph by date
 * @return array
 */
function create_cumulative_bydate()
{
    $t_clo_val = config_get('bug_closed_status_threshold');
    $t_res_val = config_get('bug_resolved_status_threshold');
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    $t_specific_where = helper_project_specific_where($t_project_id, $t_user_id);
    # Get all the submitted dates
    $t_query = 'SELECT date_submitted FROM {bug} WHERE ' . $t_specific_where . ' ORDER BY date_submitted';
    $t_result = db_query($t_query);
    while ($t_row = db_fetch_array($t_result)) {
        # rationalise the timestamp to a day to reduce the amount of data
        $t_date = $t_row['date_submitted'];
        $t_date = (int) ($t_date / SECONDS_PER_DAY);
        if (isset($t_calc_metrics[$t_date])) {
            $t_calc_metrics[$t_date][0]++;
        } else {
            $t_calc_metrics[$t_date] = array(1, 0, 0);
        }
    }
    # ## Get all the dates where a transition from not resolved to resolved may have happened
    #    also, get the last updated date for the bug as this may be all the information we have
    $t_query = 'SELECT {bug}.id, last_updated, date_modified, new_value, old_value
			FROM {bug} LEFT JOIN {bug_history}
			ON {bug}.id = {bug_history}.bug_id
			WHERE ' . $t_specific_where . '
						AND {bug}.status >= ' . db_param() . '
						AND ( ( {bug_history}.new_value >= ' . db_param() . '
								AND {bug_history}.field_name = \'status\' )
						OR {bug_history}.id is NULL )
			ORDER BY {bug}.id, date_modified ASC';
    $t_result = db_query($t_query, array($t_res_val, (string) $t_res_val));
    $t_bug_count = db_num_rows($t_result);
    $t_last_id = 0;
    $t_last_date = 0;
    while ($t_row = db_fetch_array($t_result)) {
        $t_id = $t_row['id'];
        # if h_last_updated is NULL, there were no appropriate history records
        #  (i.e. pre 0.18 data), use last_updated from bug table instead
        if (null == $t_row['date_modified']) {
            $t_date = $t_row['last_updated'];
        } else {
            if ($t_res_val > $t_row['old_value']) {
                $t_date = $t_row['date_modified'];
            }
        }
        if ($t_id != $t_last_id) {
            if (0 != $t_last_id) {
                # rationalise the timestamp to a day to reduce the amount of data
                $t_date_index = (int) ($t_last_date / SECONDS_PER_DAY);
                if (isset($t_calc_metrics[$t_date_index])) {
                    $t_calc_metrics[$t_date_index][1]++;
                } else {
                    $t_calc_metrics[$t_date_index] = array(0, 1, 0);
                }
            }
            $t_last_id = $t_id;
        }
        $t_last_date = $t_date;
    }
    ksort($t_calc_metrics);
    $t_last_opened = 0;
    $t_last_resolved = 0;
    foreach ($t_calc_metrics as $i => $t_values) {
        $t_date = $i * SECONDS_PER_DAY;
        $t_metrics[0][$t_date] = $t_last_opened = $t_calc_metrics[$i][0] + $t_last_opened;
        $t_metrics[1][$t_date] = $t_last_resolved = $t_calc_metrics[$i][1] + $t_last_resolved;
        $t_metrics[2][$t_date] = $t_metrics[0][$t_date] - $t_metrics[1][$t_date];
    }
    return $t_metrics;
}
Example #15
0
/**
 * get news count (selected project plus site wide posts)
 *
 * @param integer $p_project_id A project identifier.
 * @param boolean $p_global     Whether this is site wide news i.e. ALL_PROJECTS.
 * @return int news count
 */
function news_get_count($p_project_id, $p_global = true)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_query = 'SELECT COUNT(*) FROM {news} WHERE ' . $t_project_where;
    if ($p_global) {
        $t_query .= ' OR project_id=' . ALL_PROJECTS;
    }
    $t_result = db_query($t_query);
    return db_result($t_result, 0);
}
Example #16
0
require_api('constant_inc.php');
require_api('database_api.php');
require_api('gpc_api.php');
require_api('helper_api.php');
require_api('html_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('summary_api.php');
require_api('user_api.php');
$f_project_id = gpc_get_int('project_id', helper_get_current_project());
# Override the current page to make sure we get the appropriate project-specific configuration
$g_project_override = $f_project_id;
access_ensure_project_level(config_get('view_summary_threshold'));
$t_user_id = auth_get_current_user_id();
$t_project_ids = user_get_all_accessible_projects($t_user_id, $f_project_id);
$t_specific_where = helper_project_specific_where($f_project_id, $t_user_id);
$t_resolved = config_get('bug_resolved_status_threshold');
# the issue may have passed through the status we consider resolved
#  (e.g., bug is CLOSED, not RESOLVED). The linkage to the history field
#  will look up the most recent 'resolved' status change and return it as well
$t_query = 'SELECT b.id, b.date_submitted, b.last_updated, MAX(h.date_modified) as hist_update, b.status
	FROM {bug} b LEFT JOIN {bug_history} h
		ON b.id = h.bug_id  AND h.type=0 AND h.field_name=\'status\' AND h.new_value=' . db_param() . '
		WHERE b.status >=' . db_param() . ' AND ' . $t_specific_where . '
		GROUP BY b.id, b.status, b.date_submitted, b.last_updated
		ORDER BY b.id ASC';
$t_result = db_query($t_query, array($t_resolved, $t_resolved));
$t_bug_count = 0;
$t_bug_id = 0;
$t_largest_diff = 0;
$t_total_time = 0;
Example #17
0
/**
 * Return all versions for the specified project, including subprojects
 * @param int $p_project_id
 * @param int $p_released
 * @param bool $p_obsolete
 * @return array
 */
function version_get_all_rows_with_subs($p_project_id, $p_released = null, $p_obsolete = false)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_query_params = array();
    if ($p_released === null) {
        $t_released_where = '';
    } else {
        $c_released = (int) $p_released;
        $t_released_where = "AND ( released = " . db_param() . " )";
        $t_query_params[] = $c_released;
    }
    if ($p_obsolete === null) {
        $t_obsolete_where = '';
    } else {
        $t_obsolete_where = "AND ( obsolete = " . db_param() . " )";
        $t_query_params[] = $p_obsolete;
    }
    $t_project_version_table = db_get_table('project_version');
    $query = "SELECT * FROM {$t_project_version_table}\n\t\t\t\t  WHERE {$t_project_where} {$t_released_where} {$t_obsolete_where}\n\t\t\t\t  ORDER BY date_order DESC";
    $result = db_query_bound($query, $t_query_params);
    $rows = array();
    while ($row = db_fetch_array($result)) {
        $rows[] = $row;
    }
    return $rows;
}
Example #18
0
/**
 * get the status percentages
 * @return array key is the status value, value is the percentage of bugs for the status
 */
function get_percentage_by_status()
{
    $t_mantis_bug_table = db_get_table('bug');
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    # checking if it's a per project statistic or all projects
    $t_specific_where = helper_project_specific_where($t_project_id, $t_user_id);
    $query = "SELECT status, COUNT(*) AS number\n\t\t\t\tFROM {$t_mantis_bug_table}\n\t\t\t\tWHERE {$t_specific_where}";
    if (!access_has_project_level(config_get('private_bug_threshold'))) {
        $query .= ' AND view_state < ' . VS_PRIVATE;
    }
    $query .= ' GROUP BY status';
    $result = db_query_bound($query);
    $t_bug_count = 0;
    $t_status_count_array = array();
    while ($row = db_fetch_array($result)) {
        $t_status_count_array[$row['status']] = $row['number'];
    }
    $t_bug_count = array_sum($t_status_count_array);
    foreach ($t_status_count_array as $t_status => $t_value) {
        $t_status_count_array[$t_status] = round($t_value / $t_bug_count * 100);
    }
    return $t_status_count_array;
}
Example #19
0
/**
 * get news count (selected project plus site wide posts)
 *
 * @param int $p_project_id project id
 * @param bool $p_global site wide news i.e. ALL_PROJECTS
 * @return int news count
 */
function news_get_count($p_project_id, $p_global = true)
{
    $t_news_table = db_get_table('news');
    $t_project_where = helper_project_specific_where($p_project_id);
    $t_query = "SELECT COUNT(*) FROM {$t_news_table} WHERE {$t_project_where}";
    if ($p_global) {
        $t_query .= ' OR project_id=' . ALL_PROJECTS;
    }
    $result = db_query_bound($t_query);
    return db_result($result, 0);
}
Example #20
0
function create_cumulative_bydate()
{
    $t_clo_val = config_get('bug_closed_status_threshold');
    $t_res_val = config_get('bug_resolved_status_threshold');
    $t_bug_table = db_get_table('bug');
    $t_history_table = db_get_table('bug_history');
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    $specific_where = helper_project_specific_where($t_project_id, $t_user_id);
    # Get all the submitted dates
    $query = "SELECT date_submitted\n\t\t\t\tFROM {$t_bug_table}\n\t\t\t\tWHERE {$specific_where}\n\t\t\t\tORDER BY date_submitted";
    $result = db_query_bound($query);
    $bug_count = db_num_rows($result);
    for ($i = 0; $i < $bug_count; $i++) {
        $row = db_fetch_array($result);
        # rationalise the timestamp to a day to reduce the amount of data
        $t_date = $row['date_submitted'];
        $t_date = (int) ($t_date / SECONDS_PER_DAY);
        if (isset($metrics[$t_date])) {
            $metrics[$t_date][0]++;
        } else {
            $metrics[$t_date] = array(1, 0, 0);
        }
    }
    # ## Get all the dates where a transition from not resolved to resolved may have happened
    #    also, get the last updated date for the bug as this may be all the information we have
    $query = "SELECT {$t_bug_table}.id, last_updated, date_modified, new_value, old_value\n\t\t\tFROM {$t_bug_table} LEFT JOIN {$t_history_table}\n\t\t\tON {$t_bug_table}.id = {$t_history_table}.bug_id\n\t\t\tWHERE {$specific_where}\n\t\t\t\t\t\tAND {$t_bug_table}.status >= '{$t_res_val}'\n\t\t\t\t\t\tAND ( ( {$t_history_table}.new_value >= '{$t_res_val}'\n\t\t\t\t\t\t\t\tAND {$t_history_table}.field_name = 'status' )\n\t\t\t\t\t\tOR {$t_history_table}.id is NULL )\n\t\t\tORDER BY {$t_bug_table}.id, date_modified ASC";
    $result = db_query($query);
    $bug_count = db_num_rows($result);
    $t_last_id = 0;
    $t_last_date = 0;
    for ($i = 0; $i < $bug_count; $i++) {
        $row = db_fetch_array($result);
        $t_id = $row['id'];
        # if h_last_updated is NULL, there were no appropriate history records
        #  (i.e. pre 0.18 data), use last_updated from bug table instead
        if (NULL == $row['date_modified']) {
            $t_date = $row['last_updated'];
        } else {
            if ($t_res_val > $row['old_value']) {
                $t_date = $row['date_modified'];
            }
        }
        if ($t_id != $t_last_id) {
            if (0 != $t_last_id) {
                # rationalise the timestamp to a day to reduce the amount of data
                $t_date_index = (int) ($t_last_date / SECONDS_PER_DAY);
                if (isset($metrics[$t_date_index])) {
                    $metrics[$t_date_index][1]++;
                } else {
                    $metrics[$t_date_index] = array(0, 1, 0);
                }
            }
            $t_last_id = $t_id;
        }
        $t_last_date = $t_date;
    }
    ksort($metrics);
    $metrics_count = count($metrics);
    $t_last_opened = 0;
    $t_last_resolved = 0;
    foreach ($metrics as $i => $vals) {
        $t_date = $i * SECONDS_PER_DAY;
        $t_metrics[0][$t_date] = $t_last_opened = $metrics[$i][0] + $t_last_opened;
        $t_metrics[1][$t_date] = $t_last_resolved = $metrics[$i][1] + $t_last_resolved;
        $t_metrics[2][$t_date] = $t_metrics[0][$t_date] - $t_metrics[1][$t_date];
    }
    return $t_metrics;
}
Example #21
0
/**
 * Return all versions for the specified project, including sub-projects
 * @param integer $p_project_id A valid project identifier.
 * @param integer $p_released   Released status.
 * @param boolean $p_obsolete   Obsolete status.
 * @return array
 */
function version_get_all_rows_with_subs( $p_project_id, $p_released = null, $p_obsolete = false ) {
	$t_project_where = helper_project_specific_where( $p_project_id );

	$t_query_params = array();

	if( $p_released === null ) {
		$t_released_where = '';
	} else {
		$c_released = (bool)$p_released;
		$t_released_where = 'AND ( released = ' . db_param() . ' )';
		$t_query_params[] = $c_released;
	}

	if( $p_obsolete === null ) {
		$t_obsolete_where = '';
	} else {
		$t_obsolete_where = 'AND ( obsolete = ' . db_param() . ' )';
		$t_query_params[] = (bool)$p_obsolete;
	}

	$t_query = 'SELECT * FROM {project_version}
				  WHERE ' . $t_project_where . ' ' . $t_released_where . ' ' . $t_obsolete_where . '
				  ORDER BY date_order DESC';
	$t_result = db_query( $t_query, $t_query_params );
	$t_rows = array();
	while( $t_row = db_fetch_array( $t_result ) ) {
		$t_rows[] = $t_row;
	}
	return $t_rows;
}
Example #22
0
function html_status_percentage_legend()
{
    $t_mantis_bug_table = config_get('mantis_bug_table');
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    #checking if it's a per project statistic or all projects
    $t_specific_where = helper_project_specific_where($t_project_id, $t_user_id);
    $query = "SELECT status, COUNT(*) AS number\r\n\t\t\t\tFROM {$t_mantis_bug_table}\r\n\t\t\t\tWHERE {$t_specific_where}\r\n\t\t\t\tGROUP BY status";
    $result = db_query($query);
    $t_bug_count = 0;
    $t_status_count_array = array();
    while ($row = db_fetch_array($result)) {
        $t_status_count_array[$row['status']] = $row['number'];
        $t_bug_count += $row['number'];
    }
    $t_arr = explode_enum_string(config_get('status_enum_string'));
    $enum_count = count($t_arr);
    if ($t_bug_count > 0) {
        echo '<br />';
        echo '<table class="width100" cellspacing="1">';
        echo '<tr>';
        echo '<td class="form-title" colspan="' . $enum_count . '">' . lang_get('issue_status_percentage') . '</td>';
        echo '</tr>';
        echo '<tr>';
        for ($i = 0; $i < $enum_count; $i++) {
            $t_s = explode_enum_arr($t_arr[$i]);
            $t_color = get_status_color($t_s[0]);
            $t_status = $t_s[0];
            if (!isset($t_status_count_array[$t_status])) {
                $t_status_count_array[$t_status] = 0;
            }
            $width = round($t_status_count_array[$t_status] / $t_bug_count * 100);
            if ($width > 0) {
                echo "<td class=\"small-caption-center\" width=\"{$width}%\" bgcolor=\"{$t_color}\">{$width}%</td>";
            }
        }
        echo '</tr>';
        echo '</table>';
    }
}
Example #23
0
/**
 * Print the legend for the status percentage
 * @return null
 */
function html_status_percentage_legend()
{
    $t_mantis_bug_table = db_get_table('mantis_bug_table');
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    # checking if it's a per project statistic or all projects
    $t_specific_where = helper_project_specific_where($t_project_id, $t_user_id);
    $query = "SELECT status, COUNT(*) AS number\n\t\t\t\tFROM {$t_mantis_bug_table}\n\t\t\t\tWHERE {$t_specific_where}";
    if (!access_has_project_level(config_get('private_bug_threshold'))) {
        $query .= ' AND view_state < ' . VS_PRIVATE;
    }
    $query .= ' GROUP BY status';
    $result = db_query_bound($query);
    $t_bug_count = 0;
    $t_status_count_array = array();
    while ($row = db_fetch_array($result)) {
        $t_status_count_array[$row['status']] = $row['number'];
        $t_bug_count += $row['number'];
    }
    $t_enum_values = MantisEnum::getValues(config_get('status_enum_string'));
    $enum_count = count($t_enum_values);
    if ($t_bug_count > 0) {
        echo '<br />';
        echo '<table class="width100" cellspacing="1">';
        echo '<tr>';
        echo '<td class="form-title" colspan="' . $enum_count . '">' . lang_get('issue_status_percentage') . '</td>';
        echo '</tr>';
        echo '<tr>';
        foreach ($t_enum_values as $t_status) {
            $t_color = get_status_color($t_status);
            if (!isset($t_status_count_array[$t_status])) {
                $t_status_count_array[$t_status] = 0;
            }
            $width = round($t_status_count_array[$t_status] / $t_bug_count * 100);
            if ($width > 0) {
                echo "<td class=\"small-caption-center\" width=\"{$width}%\" bgcolor=\"{$t_color}\">{$width}%</td>";
            }
        }
        echo '</tr>';
        echo '</table>';
    }
}
Example #24
0
/**
 * return the number of open reported bugs by a user in a project
 *
 * @param integer $p_user_id    A valid user identifier.
 * @param integer $p_project_id A valid project identifier.
 * @return integer
 */
function user_get_reported_open_bug_count($p_user_id, $p_project_id = ALL_PROJECTS)
{
    $t_where_prj = helper_project_specific_where($p_project_id, $p_user_id) . ' AND';
    $t_resolved = config_get('bug_resolved_status_threshold');
    $t_query = 'SELECT COUNT(*) FROM {bug}
				  WHERE ' . $t_where_prj . '
						  status<' . db_param() . ' AND
						  reporter_id=' . db_param();
    $t_result = db_query($t_query, array($t_resolved, $p_user_id));
    return db_result($t_result);
}
Example #25
0
function version_get_all_rows_with_subs($p_project_id, $p_released = null)
{
    $t_project_where = helper_project_specific_where($p_project_id);
    if ($p_released === null) {
        $t_released_where = '';
    } else {
        $c_released = db_prepare_int($p_released);
        $t_released_where = "AND ( released = {$c_released} )";
    }
    $t_project_version_table = config_get('mantis_project_version_table');
    $query = "SELECT *\r\n\t\t\t\t  FROM {$t_project_version_table}\r\n\t\t\t\t  WHERE {$t_project_where} {$t_released_where}\r\n\t\t\t\t  ORDER BY date_order DESC";
    $result = db_query($query);
    $count = db_num_rows($result);
    $rows = array();
    for ($i = 0; $i < $count; $i++) {
        $row = db_fetch_array($result);
        $row['date_order'] = db_unixtimestamp($row['date_order']);
        $rows[] = $row;
    }
    return $rows;
}
Example #26
0
/**
 * print build option list
 * @param string $p_build The current build value.
 * @return void
 */
function print_build_option_list($p_build = '')
{
    $t_overall_build_arr = array();
    $t_project_id = helper_get_current_project();
    $t_project_where = helper_project_specific_where($t_project_id);
    # Get the "found in" build list
    $t_query = 'SELECT DISTINCT build
				FROM {bug}
				WHERE ' . $t_project_where . '
				ORDER BY build DESC';
    $t_result = db_query($t_query);
    while ($t_row = db_fetch_array($t_result)) {
        $t_overall_build_arr[] = $t_row['build'];
    }
    $t_max_length = config_get('max_dropdown_length');
    foreach ($t_overall_build_arr as $t_build_unescaped) {
        $t_build = string_attribute($t_build_unescaped);
        echo '<option value="' . $t_build . '"';
        check_selected($p_build, $t_build_unescaped);
        echo '>' . string_shorten($t_build, $t_max_length) . '</option>';
    }
}
Example #27
0
/**
 * Return an array containing all profiles used in a given project
 * @param int $p_project_id
 * @return array
 */
function profile_get_all_for_project( $p_project_id ) {
	$t_project_where = helper_project_specific_where( $p_project_id );

	$t_bug_table = db_get_table( 'bug' );
	$t_user_profile_table = db_get_table( 'user_profile' );

	# using up.* causes an SQL error on MS SQL since up.description is of type text
	$query = "SELECT DISTINCT(up.id), up.user_id, up.platform, up.os, up.os_build
				  FROM $t_user_profile_table up, $t_bug_table b
				  WHERE $t_project_where
				  AND up.id = b.profile_id
				  ORDER BY platform, os, os_build";
	$result = db_query_bound( $query );

	$t_rows = array();
	$t_row_count = db_num_rows( $result );

	for( $i = 0;$i < $t_row_count;$i++ ) {
		array_push( $t_rows, db_fetch_array( $result ) );
	}

	return $t_rows;
}
Example #28
0
function print_build_option_list($p_build = '')
{
    $t_bug_table = db_get_table('bug');
    $t_overall_build_arr = array();
    $t_project_id = helper_get_current_project();
    $t_project_where = helper_project_specific_where($t_project_id);
    # Get the "found in" build list
    $query = "SELECT DISTINCT build\n\t\t\t\tFROM {$t_bug_table}\n\t\t\t\tWHERE {$t_project_where}\n\t\t\t\tORDER BY build DESC";
    $result = db_query_bound($query);
    $option_count = db_num_rows($result);
    for ($i = 0; $i < $option_count; $i++) {
        $row = db_fetch_array($result);
        $t_overall_build_arr[] = $row['build'];
    }
    $t_max_length = config_get('max_dropdown_length');
    foreach ($t_overall_build_arr as $t_build_unescaped) {
        $t_build = string_attribute($t_build_unescaped);
        echo "<option value=\"{$t_build}\"";
        check_selected($p_build, $t_build_unescaped);
        echo ">" . string_shorten($t_build, $t_max_length) . "</option>";
    }
}
Example #29
0
function print_build_option_list($p_build = '')
{
    $t_bug_table = config_get('mantis_bug_table');
    $t_overall_build_arr = array();
    $t_project_id = helper_get_current_project();
    $t_project_where = helper_project_specific_where($t_project_id);
    # Get the "found in" build list
    $query = "SELECT DISTINCT build\r\n\t\t\t\tFROM {$t_bug_table}\r\n\t\t\t\tWHERE {$t_project_where}\r\n\t\t\t\tORDER BY build DESC";
    $result = db_query($query);
    $option_count = db_num_rows($result);
    for ($i = 0; $i < $option_count; $i++) {
        $row = db_fetch_array($result);
        $t_overall_build_arr[] = $row['build'];
    }
    foreach ($t_overall_build_arr as $t_build) {
        print "<option value=\"{$t_build}\"";
        check_selected($p_build, $t_build);
        print ">" . string_shorten($t_build) . "</option>";
    }
}