|
|
Choosing A Webhost: |
mantisbt/core html_api.php,1.142,1.143: msg#00096bug-tracking.mantis.cvs
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16878/core Modified Files: html_api.php Log Message: Fixed 5013: html_status_percentage_legend() generates notices Index: html_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v retrieving revision 1.142 retrieving revision 1.143 diff -u -d -r1.142 -r1.143 --- html_api.php 17 Dec 2004 15:21:23 -0000 1.142 +++ html_api.php 18 Dec 2004 12:23:57 -0000 1.143 @@ -697,54 +697,62 @@ $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 if ( ALL_PROJECTS == $t_project_id ) { # Only projects to which the user have access $t_accessible_projects_array = user_get_accessible_projects( $t_user_id ); if ( count( $t_accessible_projects_array ) > 0 ) { - $specific_where = ' (project_id='. implode( ' OR project_id=', $t_accessible_projects_array ).')'; + $t_specific_where = 'WHERE (project_id='. implode( ' OR project_id=', $t_accessible_projects_array ).')'; } else { - $specific_where = '1=1'; + $t_specific_where = ''; } } else { - $specific_where = " project_id='$t_project_id'"; + $t_specific_where = "WHERE project_id='$t_project_id'"; } - + + # Can't we use a more efficient query that is based on DISTINCT statuses + COUNT? $query = "SELECT status FROM $t_mantis_bug_table - WHERE $specific_where - ORDER BY status"; + $t_specific_where"; $result = db_query( $query ); - - $bug_count = db_num_rows( $result ); - $t_status_array = array(); - while ( $row = db_fetch_array( $result ) ) { - $t_status_array[] = $row[status]; - } + $t_bug_count = db_num_rows( $result ); + $t_status_count_array = array(); - $t_status_count_array = array_count_values( $t_status_array ); + while ( $row = db_fetch_array( $result ) ) { + $t_current_status = $row['status']; - PRINT '<br />'; - PRINT '<table class="width100" cellspacing="0">'; - PRINT '<tr>'; + if ( isset( $t_status_count_array[$t_current_status] ) ) { + $t_status_count_array[$t_current_status]++; + } else { + $t_status_count_array[$t_current_status] = 1; + } + } + echo '<table class="width100" cellspacing="0">'; + echo '<tr>'; $t_arr = explode_enum_string( config_get( 'status_enum_string' ) ); $enum_count = count( $t_arr ); for ( $i=0; $i < $enum_count; $i++) { $t_s = explode_enum_arr( $t_arr[$i] ); $t_color = get_status_color( $t_s[0] ); - $width = round( ( $t_status_count_array[ $t_s[0] ] / $bug_count ) * 100 ); - + $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) { PRINT "<td class=\"small-caption-center\" width=\"$width%\" bgcolor=\"$t_color\">$width%</td>"; } } - PRINT '</tr>'; - PRINT '</table>'; + echo '</tr>'; + echo '</table>'; } # -------------------- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: mantisbt config_defaults_inc.php,1.231,1.232, Paul Richards |
|---|---|
| Next by Date: | mantisbt config_defaults_inc.php,1.232,1.233, Paul Richards |
| Previous by Thread: | mantisbt/core file_api.php,1.61,1.62, masc |
| Next by Thread: | mantisbt config_defaults_inc.php,1.232,1.233, Paul Richards |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |