[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/ -> summary_api.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: summary_api.php,v 1.55.2.2 2007-10-13 22:35:43 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      ### Summary printing API ###
  25  
  26      # --------------------
  27  	function summary_helper_print_row( $p_label, $p_open, $p_resolved, $p_closed, $p_total ) {
  28          printf( '<tr %s>', helper_alternate_class() );
  29          printf( '<td width="50%%">%s</td>', string_display( $p_label ) );
  30          printf( '<td width="12%%" class="right">%s</td>', $p_open );
  31          printf( '<td width="12%%" class="right">%s</td>', $p_resolved );
  32          printf( '<td width="12%%" class="right">%s</td>', $p_closed );
  33          printf( '<td width="12%%" class="right">%s</td>', $p_total );
  34          print( '</tr>' );
  35      }
  36      # --------------------
  37      # Used in summary reports
  38      # Given the enum string this function prints out the summary
  39      # for each enum setting
  40      # The enum field name is passed in through $p_enum
  41  	function summary_print_by_enum( $p_enum_string, $p_enum ) {
  42          $t_project_id = helper_get_current_project();
  43          $t_user_id = auth_get_current_user_id();
  44  
  45          $t_project_filter = helper_project_specific_where( $t_project_id );
  46          if ( ' 1<>1' == $t_project_filter ) {
  47              return;
  48          }
  49          
  50          $t_filter_prefix = config_get( 'bug_count_hyperlink_prefix' );
  51          $t_arr = explode_enum_string( $p_enum_string );
  52          $enum_count = count( $t_arr );
  53  
  54          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
  55          $t_status_query = ( 'status' == $p_enum ) ? '' : ' ,status ';          
  56          $query = "SELECT COUNT(id) as bugcount, $p_enum $t_status_query 
  57                  FROM $t_mantis_bug_table
  58                  WHERE $t_project_filter
  59                  GROUP BY $p_enum $t_status_query 
  60                  ORDER BY $p_enum $t_status_query";
  61          $result = db_query( $query );
  62  
  63          $t_last_value = -1;
  64          $t_bugs_open = 0;
  65          $t_bugs_resolved = 0;
  66          $t_bugs_closed = 0;
  67          $t_bugs_total = 0;
  68  
  69          $t_resolved_val = config_get( 'bug_resolved_status_threshold' );
  70          $t_closed_val = CLOSED;
  71  
  72          while ( $row = db_fetch_array( $result ) ) {
  73              if ( ( $row[$p_enum] != $t_last_value ) &&
  74                  ( -1 != $t_last_value ) ) {
  75                  # Build up the hyperlinks to bug views
  76                  $t_bug_link = '';
  77                  switch ( $p_enum ) {
  78                      case 'status':
  79                          $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_status=' . $t_last_value;
  80                          break;
  81                      case 'severity':
  82                          $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_severity=' . $t_last_value;
  83                          break;
  84                      case 'resolution':
  85                          $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_resolution=' . $t_last_value;
  86                          break;
  87                      case 'priority':
  88                          $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_priority=' . $t_last_value;
  89                          break;
  90                  }
  91  
  92                  if ( !is_blank( $t_bug_link ) ) {
  93                      if ( 0 < $t_bugs_open ) {
  94                          $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
  95                      } else {
  96                          if ( ( 'status' == $p_enum ) && ( $t_last_value >= $t_resolved_val ) ) {
  97                              $t_bugs_open = '-';
  98                          }
  99                      }
 100                      if ( 0 < $t_bugs_resolved ) {
 101                          $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
 102                      } else {
 103                          if ( ( 'status' == $p_enum ) && ( ( $t_last_value < $t_resolved_val ) || ( $t_last_value >= $t_closed_val ) ) ) {
 104                              $t_bugs_resolved = '-';
 105                          }
 106                      }
 107                      if ( 0 < $t_bugs_closed ) {
 108                          $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 109                      } else {
 110                          if ( ( 'status' == $p_enum ) && ( $t_last_value < $t_closed_val ) ){
 111                              $t_bugs_closed = '-';
 112                          }
 113                      }
 114                      if ( 0 < $t_bugs_total ) {
 115                          $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 116                      }
 117                  }
 118  
 119                  summary_helper_print_row( get_enum_element( $p_enum, $t_last_value), $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 120  
 121                  $t_bugs_open        = 0;
 122                  $t_bugs_resolved    = 0;
 123                  $t_bugs_closed        = 0;
 124                  $t_bugs_total        = 0;
 125              }
 126  
 127              $t_bugs_total += $row['bugcount'];
 128              if ( $t_closed_val <= $row['status'] ) {
 129                  $t_bugs_closed += $row['bugcount'];
 130              } else if ( $t_resolved_val <= $row['status'] ) {
 131                  $t_bugs_resolved += $row['bugcount'];
 132              } else {
 133                  $t_bugs_open += $row['bugcount'];
 134              }
 135              $t_last_value = $row[$p_enum];
 136          }
 137  
 138          if ( 0 < $t_bugs_total ) {
 139              # Build up the hyperlinks to bug views
 140              $t_bug_link = '';
 141              switch ( $p_enum ) {
 142                  case 'status':
 143                      $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_status=' . $t_last_value;
 144                      break;
 145                  case 'severity':
 146                      $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_severity=' . $t_last_value;
 147                      break;
 148                  case 'resolution':
 149                      $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_resolution=' . $t_last_value;
 150                      break;
 151                  case 'priority':
 152                      $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;show_priority=' . $t_last_value;
 153                      break;
 154              }
 155  
 156              if ( !is_blank( $t_bug_link ) ) {
 157                  if ( 0 < $t_bugs_open ) {
 158                      $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
 159                  } else {
 160                      if ( ( 'status' == $p_enum ) && ( $t_last_value >= $t_resolved_val ) ) {
 161                          $t_bugs_open = '-';
 162                      }
 163                  }
 164                  if ( 0 < $t_bugs_resolved ) {
 165                      $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
 166                      } else {
 167                          if ( ( 'status' == $p_enum ) && ( ( $t_last_value < $t_resolved_val ) || ( $t_last_value >= $t_closed_val ) ) ) {
 168                              $t_bugs_resolved = '-';
 169                      }
 170                  }
 171                  if ( 0 < $t_bugs_closed ) {
 172                      $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 173                      } else {
 174                          if ( ( 'status' == $p_enum ) && ( $t_last_value < $t_closed_val ) ){
 175                              $t_bugs_closed = '-';
 176                          }
 177                  }
 178                  if ( 0 < $t_bugs_total ) {
 179                      $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 180                  }
 181              }
 182  
 183              summary_helper_print_row( get_enum_element( $p_enum, $t_last_value), $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 184          }
 185      }
 186  
 187  
 188      # --------------------
 189      # prints the bugs submitted in the last X days (default is 1 day) for the
 190      # current project
 191  	function summary_new_bug_count_by_date( $p_time_length=1 ) {
 192          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 193  
 194          $c_time_length = (int)$p_time_length;
 195  
 196          $t_project_id = helper_get_current_project();
 197          $t_user_id = auth_get_current_user_id();
 198  
 199          $specific_where = helper_project_specific_where( $t_project_id );
 200          if ( ' 1<>1' == $specific_where ) {
 201              return;
 202          }
 203  
 204          $query = "SELECT COUNT(*)
 205                  FROM $t_mantis_bug_table
 206                  WHERE ".db_helper_compare_days(db_now(),"date_submitted","<= '$c_time_length'")." AND $specific_where";
 207          $result = db_query( $query );
 208          return db_result( $result, 0 );
 209      }
 210  
 211  
 212      # --------------------
 213      # returns the number of bugs resolved in the last X days (default is 1 day) for the
 214      # current project
 215  	function summary_resolved_bug_count_by_date( $p_time_length = 1 ) {
 216          $t_bug_table = config_get( 'mantis_bug_table' );
 217          $t_bug_history_table = config_get( 'mantis_bug_history_table' );
 218          $t_resolved = config_get( 'bug_resolved_status_threshold' );
 219  
 220          $c_time_length = (int)$p_time_length;
 221  
 222          $t_project_id = helper_get_current_project();
 223          $t_user_id = auth_get_current_user_id();
 224  
 225          $specific_where = helper_project_specific_where( $t_project_id );
 226          if ( ' 1<>1' == $specific_where ) {
 227              return;
 228          }
 229  
 230          $query = "SELECT COUNT(DISTINCT(b.id))
 231                  FROM $t_bug_table b
 232                  LEFT JOIN $t_bug_history_table h
 233                  ON b.id = h.bug_id 
 234                  AND h.type = " . NORMAL_TYPE ."
 235                  AND h.field_name = 'status' 
 236                  WHERE b.status >= '$t_resolved' 
 237                  AND h.old_value < '$t_resolved'
 238                  AND h.new_value >= '$t_resolved'
 239                  AND ".db_helper_compare_days(db_now(),"date_modified","<= '$c_time_length'")." 
 240                  AND $specific_where";
 241          $result = db_query( $query );
 242          return db_result( $result, 0 );
 243      }
 244  
 245      # --------------------
 246      # This function shows the number of bugs submitted in the last X days
 247      # An array of integers representing days is passed in
 248  	function summary_print_by_date( $p_date_array ) {
 249          $arr_count = count( $p_date_array );
 250          foreach ( $p_date_array as $t_days ) {
 251              $t_new_count = summary_new_bug_count_by_date( $t_days );
 252              $t_resolved_count = summary_resolved_bug_count_by_date( $t_days );
 253  
 254              $t_start_date = mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) - $t_days ), date( 'Y' ) );
 255              $t_new_bugs_link = '<a class="subtle" href="' 
 256                  . config_get( 'bug_count_hyperlink_prefix' ) 
 257                  . '&amp;do_filter_by_date=on&amp;start_year=' . date( 'Y', $t_start_date ) 
 258                  . '&amp;start_month=' . date( 'm', $t_start_date ) 
 259                  . '&amp;start_day=' . date( 'd', $t_start_date ) 
 260                  . '&amp;hide_status=">';
 261              
 262              print( "<tr " . helper_alternate_class() . ">\n" );
 263              print( "    <td width=\"50%\">".  $t_days . "</td>\n" );
 264  
 265              if ( $t_new_count > 0 ) {
 266                  print( "    <td class=\"right\">$t_new_bugs_link$t_new_count</a></td>\n" );
 267              } else {
 268                  print( "    <td class=\"right\">$t_new_count</td>\n" );
 269              }
 270              print( "    <td class=\"right\">$t_resolved_count</td>\n" );
 271  
 272              $t_balance = $t_new_count - $t_resolved_count;
 273              $t_style = "";
 274              if ( $t_balance > 0 ) {
 275                  # we are talking about bugs: a balance > 0 is "negative" for the project...
 276                  $t_style = " negative";
 277                  $t_balance = sprintf( '%+d', $t_balance ); # "+" modifier added in PHP >= 4.3.0
 278              } elseif ( $t_balance < 0 ) {
 279                  $t_style = " positive";
 280                  $t_balance = sprintf( '%+d', $t_balance );
 281              }
 282  
 283              print( "\n<td class=\"right$t_style\">$t_balance</td>\n" );
 284              print( "</tr>\n" );
 285          } # end foreach
 286      }
 287  
 288  
 289      # Print list of open bugs with the highest activity score
 290      # the score is calculated assigning one "point" for each history event 
 291      # associated with the bug
 292  	function summary_print_by_activity() {
 293          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 294          $t_mantis_history_table = config_get( 'mantis_bug_history_table' );
 295  
 296          $t_project_id = helper_get_current_project();
 297          $t_user_id = auth_get_current_user_id();
 298          $t_resolved = config_get( 'bug_resolved_status_threshold' );
 299  
 300          $specific_where = helper_project_specific_where( $t_project_id );
 301          if ( ' 1<>1' == $specific_where ) {
 302              return;
 303          }
 304          $query = "SELECT COUNT(h.id) as count, b.id, b.summary
 305                  FROM $t_mantis_bug_table AS b, $t_mantis_history_table AS h
 306                  WHERE h.bug_id = b.id
 307                  AND b.status < $t_resolved
 308                  AND $specific_where
 309                  GROUP BY h.bug_id, b.id, b.summary, b.last_updated
 310                  ORDER BY count DESC, b.last_updated DESC";
 311          $result = db_query( $query );
 312  
 313          $t_count = 0;
 314          $t_private_bug_threshold = config_get( 'private_bug_threshold' );
 315          while ( $row = db_fetch_array( $result ) ) {
 316              // Skip private bugs unless user has proper permissions
 317              if ( ( VS_PRIVATE == bug_get_field( $row['id'], 'view_state' ) ) && 
 318              ( false == access_has_bug_level( $t_private_bug_threshold, $row['id'] ) ) ) {
 319                  continue;
 320              }
 321  
 322              if ( $t_count++ == 10 ) break;
 323  
 324              $t_bugid = string_get_bug_view_link( $row['id'] );
 325              $t_summary = $row['summary'];
 326              $t_notescount = $row['count'];
 327  
 328              print "<tr " . helper_alternate_class() . ">\n";
 329              print "<td class=\"small\">$t_bugid - $t_summary</td><td class=\"right\">$t_notescount</td>\n";
 330              print "</tr>\n";
 331          }
 332      }
 333  
 334  
 335      # Print list of bugs opened from the longest time
 336  	function summary_print_by_age() {
 337          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 338  
 339          $t_project_id = helper_get_current_project();
 340          $t_user_id = auth_get_current_user_id();
 341          $t_resolved = config_get( 'bug_resolved_status_threshold' );
 342  
 343          $specific_where = helper_project_specific_where( $t_project_id );
 344          if ( ' 1<>1' == $specific_where ) {
 345              return;
 346          }
 347          $query = "SELECT * FROM $t_mantis_bug_table
 348                  WHERE status < $t_resolved
 349                  AND $specific_where
 350                  ORDER BY date_submitted ASC, priority DESC";
 351          $result = db_query( $query );
 352  
 353          $t_count = 0;
 354          $t_private_bug_threshold = config_get( 'private_bug_threshold' );
 355          while ( $row = db_fetch_array( $result ) ) {
 356              // Skip private bugs unless user has proper permissions
 357              if ( ( VS_PRIVATE == bug_get_field( $row['id'], 'view_state' ) ) && 
 358              ( false == access_has_bug_level( $t_private_bug_threshold, $row['id'] ) ) ) {
 359                  continue;
 360              }
 361  
 362              if ( $t_count++ == 10 ) break;
 363  
 364              $t_bugid = string_get_bug_view_link( $row['id'] );
 365              $t_summary = $row['summary'];
 366              $t_days_open = intval ( ( time() - strtotime( $row['date_submitted'] ) ) / 86400 );
 367  
 368              print "<tr " . helper_alternate_class() . ">\n";
 369              print "<td class=\"small\">$t_bugid - $t_summary</td><td class=\"right\">$t_days_open</td>\n";
 370              print "</tr>\n";
 371          }
 372      }
 373  
 374      # --------------------
 375      # print bug counts by assigned to each developer
 376  	function summary_print_by_developer() {
 377          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 378          $t_mantis_user_table = config_get( 'mantis_user_table' );
 379  
 380          $t_project_id = helper_get_current_project();
 381          $t_user_id = auth_get_current_user_id();
 382  
 383          $specific_where = helper_project_specific_where( $t_project_id );
 384          if ( ' 1<>1' == $specific_where ) {
 385              return;
 386          }
 387  
 388          $query = "SELECT COUNT(id) as bugcount, handler_id, status
 389                  FROM $t_mantis_bug_table
 390                  WHERE handler_id>0 AND $specific_where
 391                  GROUP BY handler_id, status
 392                  ORDER BY handler_id, status";
 393          $result = db_query( $query );
 394  
 395          $t_last_handler = -1;
 396          $t_bugs_open = 0;
 397          $t_bugs_resolved = 0;
 398          $t_bugs_closed = 0;
 399          $t_bugs_total = 0;
 400  
 401          $t_resolved_val = RESOLVED;
 402          $t_closed_val = CLOSED;
 403  
 404          while ( $row = db_fetch_array( $result ) ) {
 405              extract( $row, EXTR_PREFIX_ALL, 'v' );
 406  
 407              if ( ($v_handler_id != $t_last_handler) && (-1 != $t_last_handler) ) {
 408                  $t_user = user_get_name( $t_last_handler );
 409  
 410                  $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;handler_id=' . $t_last_handler;
 411                  if ( 0 < $t_bugs_open ) {
 412                      $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
 413                  }
 414                  if ( 0 < $t_bugs_resolved ) {
 415                      $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED .'">' . $t_bugs_resolved . '</a>';
 416                  }
 417                  if ( 0 < $t_bugs_closed ) {
 418                      $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 419                  }
 420                  if ( 0 < $t_bugs_total ) {
 421                      $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 422                  }
 423  
 424                  summary_helper_print_row( $t_user, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 425  
 426                  $t_bugs_open = 0;
 427                  $t_bugs_resolved = 0;
 428                  $t_bugs_closed = 0;
 429                  $t_bugs_total = 0;
 430              }
 431  
 432              $t_bugs_total += $v_bugcount;
 433              if ( $t_closed_val <= $row['status'] ) {
 434                  $t_bugs_closed += $v_bugcount;
 435              } else if ( $t_resolved_val <= $row['status'] ) {
 436                  $t_bugs_resolved += $v_bugcount;
 437              } else {
 438                  $t_bugs_open += $v_bugcount;
 439              }
 440              $t_last_handler = $v_handler_id;
 441          }
 442  
 443          if ( 0 < $t_bugs_total ) {
 444              $t_user = user_get_name( $t_last_handler );
 445  
 446              $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;handler_id=' . $t_last_handler;
 447              if ( 0 < $t_bugs_open ) {
 448                  $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
 449              }
 450              if ( 0 < $t_bugs_resolved ) {
 451                  $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
 452              }
 453              if ( 0 < $t_bugs_closed ) {
 454                  $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 455              }
 456              if ( 0 < $t_bugs_total ) {
 457                  $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 458              }
 459  
 460              summary_helper_print_row( $t_user, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 461          }
 462      }
 463      # --------------------
 464      # print bug counts by reporter id
 465  	function summary_print_by_reporter() {
 466          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 467          $t_mantis_user_table = config_get( 'mantis_user_table' );
 468          $t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
 469  
 470          $t_project_id = helper_get_current_project();
 471          $t_user_id = auth_get_current_user_id();
 472  
 473          $specific_where = helper_project_specific_where( $t_project_id );
 474          if ( ' 1<>1' == $specific_where ) {
 475              return;
 476          }
 477  
 478          $query = "SELECT reporter_id, COUNT(*) as num
 479                  FROM $t_mantis_bug_table
 480                  WHERE $specific_where
 481                  GROUP BY reporter_id
 482                  ORDER BY num DESC";
 483          $result = db_query( $query, $t_reporter_summary_limit );
 484  
 485          while ( $row = db_fetch_array( $result ) ) {
 486              $v_reporter_id = $row['reporter_id'];
 487              $query = "SELECT COUNT(id) as bugcount, status FROM $t_mantis_bug_table
 488                      WHERE reporter_id=$v_reporter_id
 489                      AND $specific_where
 490                      GROUP BY status
 491                      ORDER BY status";
 492              $result2 = db_query( $query );
 493  
 494              $last_reporter = -1;
 495              $t_bugs_open = 0;
 496              $t_bugs_resolved = 0;
 497              $t_bugs_closed = 0;
 498              $t_bugs_total = 0;
 499  
 500              $t_resolved_val = RESOLVED;
 501              $t_closed_val = CLOSED;
 502  
 503              while ( $row2 = db_fetch_array( $result2 ) ) {
 504                  $t_bugs_total += $row2['bugcount'];
 505                  if ( $t_closed_val <= $row2['status'] ) {
 506                      $t_bugs_closed += $row2['bugcount'];
 507                  } else if ( $t_resolved_val <= $row2['status'] ) {
 508                      $t_bugs_resolved += $row2['bugcount'];
 509                     } else {
 510                      $t_bugs_open += $row2['bugcount'];
 511                      }
 512              }
 513  
 514              if ( 0 < $t_bugs_total ) {
 515                  $t_user = user_get_name( $v_reporter_id );
 516  
 517                  $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;reporter_id=' . $v_reporter_id;
 518                  if ( 0 < $t_bugs_open ) {
 519                      $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
 520                  }
 521                  if ( 0 < $t_bugs_resolved ) {
 522                      $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
 523                  }
 524                  if ( 0 < $t_bugs_closed ) {
 525                      $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 526                  }
 527                  if ( 0 < $t_bugs_total ) {
 528                      $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 529                  }
 530  
 531                  summary_helper_print_row( $t_user, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 532              }
 533          }
 534      }
 535      # --------------------
 536      # print a bug count per category
 537  	function summary_print_by_category() {
 538          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 539          $t_mantis_project_table = config_get( 'mantis_project_table' );
 540          $t_summary_category_include_project = config_get( 'summary_category_include_project' );
 541  
 542          $t_project_id = helper_get_current_project();
 543          $t_user_id = auth_get_current_user_id();
 544  
 545          $specific_where = helper_project_specific_where( $t_project_id );
 546          if ( ' 1<>1' == $specific_where ) {
 547              return;
 548          }
 549          $t_project_query = ( ON == $t_summary_category_include_project ) ? 'project_id, ' : '';
 550  
 551          $query = "SELECT COUNT(id) as bugcount, $t_project_query category, status
 552                  FROM $t_mantis_bug_table
 553                  WHERE category>'' AND $specific_where
 554                  GROUP BY $t_project_query category, status
 555                  ORDER BY $t_project_query category, status";
 556  
 557          $result = db_query( $query );
 558  
 559          $last_category = -1;
 560          $last_project = -1;
 561          $t_bugs_open = 0;
 562          $t_bugs_resolved = 0;
 563          $t_bugs_closed = 0;
 564          $t_bugs_total = 0;
 565  
 566          $t_resolved_val = RESOLVED;
 567          $t_closed_val = CLOSED;
 568  
 569          while ( $row = db_fetch_array( $result ) ) {
 570              extract( $row, EXTR_PREFIX_ALL, 'v' );
 571  
 572              if ( ( $v_category != $last_category ) && ( $last_category != -1 ) ) {
 573                  $label = $last_category;
 574                  if ( ( ON == $t_summary_category_include_project ) && ( ALL_PROJECTS == $t_project_id ) ) {
 575                      $label = sprintf( '[%s] %s', project_get_name( $last_project ), $label );
 576                  }
 577  
 578                  $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;show_category=' . urlencode( $last_category );
 579                  if ( 0 < $t_bugs_open ) {
 580                      $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
 581                  }
 582                  if ( 0 < $t_bugs_resolved ) {
 583                      $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
 584                  }
 585                  if ( 0 < $t_bugs_closed ) {
 586                      $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 587                  }
 588                  if ( 0 < $t_bugs_total ) {
 589                      $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 590                  }
 591  
 592                  summary_helper_print_row( $label, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 593  
 594                  $t_bugs_open = 0;
 595                  $t_bugs_resolved = 0;
 596                  $t_bugs_closed = 0;
 597                  $t_bugs_total = 0;
 598              }
 599  
 600              $t_bugs_total += $row['bugcount'];
 601              if ( $t_closed_val <= $row['status'] ) {
 602                  $t_bugs_closed += $row['bugcount'];
 603              } else if ( $t_resolved_val <= $row['status'] ) {
 604                  $t_bugs_resolved += $row['bugcount'];
 605              } else {
 606                  $t_bugs_open += $row['bugcount'];
 607              }
 608  
 609              $last_category = $v_category;
 610              if ( ( ON == $t_summary_category_include_project ) && ( ALL_PROJECTS == $t_project_id ) ) {
 611                  $last_project = $v_project_id;
 612              }
 613          }
 614  
 615          if ( 0 < $t_bugs_total ) {
 616              $label = $last_category;
 617              if ( ( ON == $t_summary_category_include_project ) && ( ALL_PROJECTS == $t_project_id ) ) {
 618                  $label = sprintf( '[%s] %s', project_get_name( $last_project ), $label );
 619              }
 620  
 621              $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;show_category=' . urlencode( $last_category );
 622              if ( !is_blank( $t_bug_link ) ) {
 623                  if ( 0 < $t_bugs_open ) {
 624                      $t_bugs_open = $t_bug_link . '&amp;hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
 625                  }
 626                  if ( 0 < $t_bugs_resolved ) {
 627                      $t_bugs_resolved = $t_bug_link . '&amp;show_status=' . RESOLVED . '&amp;hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
 628                  }
 629                  if ( 0 < $t_bugs_closed ) {
 630                      $t_bugs_closed = $t_bug_link . '&amp;show_status=' . CLOSED . '&amp;hide_status=">' . $t_bugs_closed . '</a>';
 631                  }
 632                  if ( 0 < $t_bugs_total ) {
 633                      $t_bugs_total = $t_bug_link . '&amp;hide_status=">' . $t_bugs_total . '</a>';
 634                  }
 635              }
 636  
 637              summary_helper_print_row( $label, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 638          }
 639      }
 640      # --------------------
 641      # print bug counts by project
 642  	function summary_print_by_project( $p_projects = null, $p_level = 0, $p_cache = null ) {
 643          $t_mantis_bug_table     = config_get( 'mantis_bug_table' );
 644          $t_mantis_project_table = config_get( 'mantis_project_table' );
 645  
 646          $t_project_id = helper_get_current_project();
 647  
 648          if ( null == $p_projects ) {
 649              if ( ALL_PROJECTS == $t_project_id ) {
 650                  $p_projects = current_user_get_accessible_projects();
 651              } else {
 652                  $p_projects = Array( $t_project_id );
 653              }
 654          }
 655  
 656          # Retrieve statistics one time to improve performance.
 657          if ( null === $p_cache ) {
 658              $query = "SELECT project_id, status, COUNT( status ) AS bugcount
 659                      FROM $t_mantis_bug_table
 660                      GROUP BY project_id, status";
 661  
 662              $result = db_query( $query );
 663              $p_cache = Array();
 664  
 665              $t_resolved_val = RESOLVED;
 666              $t_closed_val = CLOSED;
 667  
 668              while ( $row = db_fetch_array( $result ) ) {
 669                  extract( $row, EXTR_PREFIX_ALL, 'v' );
 670                  if ( $t_closed_val <= $v_status ) {
 671                      if ( isset( $p_cache[ $v_project_id ][ 'closed'   ] ) ) {
 672                          $p_cache[ $v_project_id ][ 'closed'   ]  += $v_bugcount;
 673                      } else {
 674                          $p_cache[ $v_project_id ][ 'closed'   ]  = $v_bugcount;
 675                      }
 676                  } else if ( $t_resolved_val <= $v_status ) {
 677                      if ( isset( $p_cache[ $v_project_id ][ 'resolved' ] ) ) {
 678                          $p_cache[ $v_project_id ][ 'resolved' ]  += $v_bugcount;
 679                      } else {
 680                          $p_cache[ $v_project_id ][ 'resolved' ]  = $v_bugcount;
 681                      }
 682                  } else {
 683                      if ( isset( $p_cache[ $v_project_id ][ 'open'     ] ) ) {
 684                          $p_cache[ $v_project_id ][ 'open'     ]  += $v_bugcount;
 685                      } else {
 686                          $p_cache[ $v_project_id ][ 'open'     ]  = $v_bugcount;
 687                      }
 688                  }
 689              }
 690          }
 691  
 692          foreach ( $p_projects as $t_project ) {
 693              $t_name = str_repeat( "&raquo; ", $p_level ) . project_get_name( $t_project );
 694  
 695              $t_pdata = isset( $p_cache[ $t_project ] ) ? $p_cache[ $t_project ]
 696                           : array( 'open' => 0, 'resolved' => 0, 'closed' => 0 );
 697  
 698              $t_bugs_open     = isset( $t_pdata['open'] ) ? $t_pdata['open'] : 0;
 699              $t_bugs_resolved = isset( $t_pdata['resolved'] ) ? $t_pdata['resolved'] : 0;
 700              $t_bugs_closed   = isset( $t_pdata['closed'] ) ? $t_pdata['closed'] : 0;
 701              $t_bugs_total    = $t_bugs_open + $t_bugs_resolved + $t_bugs_closed;
 702  
 703              summary_helper_print_row( $t_name, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
 704  
 705              $t_subprojects = current_user_get_accessible_subprojects( $t_project );
 706  
 707              if ( count( $t_subprojects ) > 0 ) {
 708                  summary_print_by_project( $t_subprojects, $p_level + 1, $p_cache );
 709              }
 710          }
 711      }
 712      # --------------------
 713      # Print developer / resolution report
 714  	function summary_print_developer_resolution( $p_resolution_enum_string ) {
 715          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 716          $t_mantis_user_table = config_get( 'mantis_user_table' );
 717  
 718          $t_project_id = helper_get_current_project();
 719          $t_user_id = auth_get_current_user_id();
 720  
 721          # Organise an array of resolution values to be used later
 722          $t_res_arr = explode_enum_string( $p_resolution_enum_string );
 723          $enum_res_count = count( $t_res_arr );
 724          $c_res_s = array();
 725          for ( $i = 0; $i < $enum_res_count; $i++ ) {
 726              $t_res_s = explode_enum_arr( $t_res_arr[$i] );
 727              $c_res_s[$i] = db_prepare_string( $t_res_s[0] );
 728          }
 729  
 730          $specific_where = helper_project_specific_where( $t_project_id );
 731          if ( ' 1<>1' == $specific_where ) {
 732              return;
 733          }
 734  
 735          $specific_where .= ' AND handler_id > 0';
 736          # Get all of the bugs and split them up into an array
 737          $query = "SELECT COUNT(id) as bugcount, handler_id, resolution
 738                  FROM $t_mantis_bug_table
 739                  WHERE $specific_where
 740                  GROUP BY handler_id, resolution
 741                  ORDER BY handler_id, resolution";
 742          $result = db_query( $query );
 743  
 744          $t_handler_res_arr = array();
 745          $t_arr = db_fetch_array( $result );
 746          while ( $t_arr ) {
 747              if ( !isset( $t_handler_res_arr[$t_arr['handler_id']] ) ) {
 748                  $t_handler_res_arr[$t_arr['handler_id']] = array();
 749                  $t_handler_res_arr[$t_arr['handler_id']]['total'] = 0;
 750              }
 751              if ( !isset( $t_handler_res_arr[$t_arr['handler_id']][$t_arr['resolution']] ) ) {
 752                  $t_handler_res_arr[$t_arr['handler_id']][$t_arr['resolution']] = 0;
 753              }
 754              $t_handler_res_arr[$t_arr['handler_id']][$t_arr['resolution']] += $t_arr['bugcount'];
 755              $t_handler_res_arr[$t_arr['handler_id']]['total'] += $t_arr['bugcount'];
 756  
 757              $t_arr = db_fetch_array( $result );
 758          }
 759  
 760          $t_filter_prefix = config_get( 'bug_count_hyperlink_prefix' );
 761          $t_row_count = 0;
 762          # We now have a multi dimensional array of users and resolutions, with the value of each resolution for each user
 763          foreach( $t_handler_res_arr as $t_handler_id => $t_arr2 ) {
 764              # Only print developers who have had at least one bug assigned to them. This helps
 765              # prevent divide by zeroes, showing developers not on this project, and showing
 766              # users that aren't actually developers...
 767  
 768              if ( $t_arr2['total'] > 0 ) {
 769                  PRINT '<tr align="center" ' . helper_alternate_class( $t_row_count ) . '>';
 770                  $t_row_count++;
 771                  PRINT '<td>';
 772                  PRINT user_get_name( $t_handler_id );
 773                  PRINT '</td>';
 774  
 775                  # We need to track the percentage of bugs that are considered fix, as well as
 776                  # those that aren't considered bugs to begin with (when looking at %age)
 777                  $t_bugs_fixed = 0;
 778                  $t_bugs_notbugs = 0;
 779                  for ( $j = 0; $j < $enum_res_count; $j++ ) {
 780                      $res_bug_count = 0;
 781  
 782                      if ( isset( $t_arr2[$c_res_s[$j]] ) ) {
 783                          $res_bug_count = $t_arr2[$c_res_s[$j]];
 784                      }
 785  
 786                      PRINT '<td>';
 787                      if ( 0 < $res_bug_count ) {
 788                          $t_bug_link = '<a class="subtle" href="' . $t_filter_prefix . '&amp;handler_id=' . $t_handler_id;
 789                          $t_bug_link = $t_bug_link . '&amp;show_resolution=' .  $c_res_s[$j] . '">';
 790                          PRINT $t_bug_link . $res_bug_count . '</a>';
 791                      } else {
 792                          PRINT $res_bug_count;
 793                      }
 794                      PRINT '</td>';
 795  
 796                      # These resolutions are considered fixed
 797                      if ( FIXED == $c_res_s[$j] ) {
 798                          $t_bugs_fixed += $res_bug_count;
 799                      }
 800                      # These are not counted as bugs
 801                      else if ( (WONT_FIX == $c_res_s[$j] )  ||
 802                                (SUSPENDED == $c_res_s[$j] ) ||
 803                                (DUPLICATE == $c_res_s[$j] ) ||
 804                                (NOT_A_BUG == $c_res_s[$j] ) ) {
 805                          $t_bugs_notbugs += $res_bug_count;
 806                      }
 807                  }
 808  
 809                  $t_percent_fixed = 0;
 810                  if ( ( $t_arr2['total'] - $t_bugs_notbugs ) > 0 ) {
 811                      $t_percent_fixed = ( $t_bugs_fixed / ( $t_arr2['total'] - $t_bugs_notbugs ) );
 812                  }
 813                  PRINT '<td>';
 814                  printf( '% 1.0f%%', ( $t_percent_fixed * 100 ) );
 815                  PRINT '</td>';
 816                  PRINT '</tr>';
 817              }
 818          }
 819      }
 820      # --------------------
 821      # Print reporter / resolution report
 822  	function summary_print_reporter_resolution( $p_resolution_enum_string ) {
 823          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 824          $t_mantis_user_table = config_get( 'mantis_user_table' );
 825          $t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
 826  
 827          $t_project_id = helper_get_current_project();
 828          $t_user_id = auth_get_current_user_id();
 829  
 830          # Organise an array of resolution values to be used later
 831          $t_res_arr = explode_enum_string( $p_resolution_enum_string );
 832          $enum_res_count = count( $t_res_arr );
 833          $c_res_s = array();
 834          for ( $i = 0; $i < $enum_res_count; $i++ ) {
 835              $t_res_s = explode_enum_arr( $t_res_arr[$i] );
 836              $c_res_s[$i] = db_prepare_string( $t_res_s[0] );
 837          }
 838  
 839          # Checking if it's a per project statistic or all projects
 840          $specific_where = helper_project_specific_where( $t_project_id );
 841          if ( ' 1<>1' == $specific_where ) {
 842              return;
 843          }
 844  
 845          # Get all of the bugs and split them up into an array
 846          $query = "SELECT COUNT(id) as bugcount, reporter_id, resolution
 847                  FROM $t_mantis_bug_table
 848                  WHERE $specific_where
 849                  GROUP BY reporter_id, resolution";
 850          $result = db_query( $query );
 851  
 852          $t_reporter_res_arr = array();
 853          $t_reporter_bugcount_arr = array();
 854          $t_arr = db_fetch_array( $result );
 855          while ( $t_arr ) {
 856              if ( !isset( $t_reporter_res_arr[$t_arr['reporter_id']] ) ) {
 857                  $t_reporter_res_arr[$t_arr['reporter_id']] = array();
 858                  $t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
 859              }
 860              if ( !isset( $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] ) ) {
 861                  $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] = 0;
 862              }
 863              $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] += $t_arr['bugcount'];
 864              $t_reporter_bugcount_arr[$t_arr['reporter_id']] += $t_arr['bugcount'];
 865  
 866              $t_arr = db_fetch_array( $result );
 867          }
 868  
 869          # Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
 870          arsort( $t_reporter_bugcount_arr );
 871  
 872          $t_row_count = 0;
 873          # We now have a multi dimensional array of users and resolutions, with the value of each resolution for each user
 874          foreach( $t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs ) {
 875              # Limit the number of reporters listed
 876              if ( $t_row_count > $t_reporter_summary_limit ) {
 877                  break;
 878              }
 879  
 880              # Only print reporters who have reported at least one bug. This helps
 881              # prevent divide by zeroes, showing reporters not on this project, and showing
 882              # users that aren't actually reporters...
 883              if ( $t_total_user_bugs > 0 ) {
 884                  $t_arr2 = $t_reporter_res_arr[$t_reporter_id];
 885  
 886                  PRINT '<tr align="center" ' . helper_alternate_class( $t_row_count ) . '>';
 887                  $t_row_count++;
 888                  PRINT '<td>';
 889                  PRINT user_get_name( $t_reporter_id );
 890                  PRINT '</td>';
 891  
 892                  # We need to track the percentage of bugs that are considered fix, as well as
 893                  # those that aren't considered bugs to begin with (when looking at %age)
 894                  $t_bugs_fixed = 0;
 895                  $t_bugs_notbugs = 0;
 896                  for ( $j = 0; $j < $enum_res_count; $j++ ) {
 897                      $res_bug_count = 0;
 898  
 899                      if ( isset( $t_arr2[$c_res_s[$j]] ) ) {
 900                          $res_bug_count = $t_arr2[$c_res_s[$j]];
 901                      }
 902  
 903                      PRINT '<td>';
 904                      if ( 0 < $res_bug_count ) {
 905                          $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;reporter_id=' . $t_reporter_id;
 906                          $t_bug_link = $t_bug_link . '&amp;show_resolution=' .  $c_res_s[$j] . '">';
 907                          PRINT $t_bug_link . $res_bug_count . '</a>';
 908                      } else {
 909                          PRINT $res_bug_count;
 910                      }
 911                      PRINT '</td>';
 912  
 913                      # These resolutions are considered fixed
 914                      if ( FIXED == $c_res_s[$j] ) {
 915                          $t_bugs_fixed += $res_bug_count;
 916                      }
 917                      # These are not counted as bugs
 918                      else if ( (UNABLE_TO_DUPLICATE == $c_res_s[$j] ) ||
 919                                (DUPLICATE == $c_res_s[$j] ) ||
 920                                (NOT_A_BUG == $c_res_s[$j] ) ) {
 921                          $t_bugs_notbugs += $res_bug_count;
 922                      }
 923                  }
 924  
 925                  $t_percent_errors = 0;
 926                  if ( $t_total_user_bugs > 0 ) {
 927                      $t_percent_errors = ( $t_bugs_notbugs / $t_total_user_bugs );
 928                  }
 929                  PRINT '<td>';
 930                  printf( '% 1.0f%%', ( $t_percent_errors * 100 ) );
 931                  PRINT '</td>';
 932                  PRINT '</tr>';
 933              }
 934          }
 935      }    # --------------------
 936      # Print reporter effectiveness report
 937  	function summary_print_reporter_effectiveness( $p_severity_enum_string, $p_resolution_enum_string ) {
 938          $t_mantis_bug_table = config_get( 'mantis_bug_table' );
 939          $t_mantis_user_table = config_get( 'mantis_user_table' );
 940          $t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
 941  
 942          $t_project_id = helper_get_current_project();
 943          $t_user_id = auth_get_current_user_id();
 944  
 945          # These are our overall "values" for severities and non-bug results
 946          $t_severity_multiplier[FEATURE] = 1;
 947          $t_severity_multiplier[TRIVIAL] = 2;
 948          $t_severity_multiplier[TEXT] = 3;
 949          $t_severity_multiplier[TWEAK] = 2;
 950          $t_severity_multiplier[MINOR] = 5;
 951          $t_severity_multiplier[MAJOR] = 8;
 952          $t_severity_multiplier[CRASH] = 8;
 953          $t_severity_multiplier[BLOCK] = 10;
 954          $t_severity_multiplier['average'] = 5;
 955  
 956          $t_notbug_multiplier[UNABLE_TO_DUPLICATE] = 2;
 957          $t_notbug_multiplier[DUPLICATE] = 3;
 958          $t_notbug_multiplier[NOT_A_BUG] = 5;
 959  
 960          $t_sev_arr = explode_enum_string( $p_severity_enum_string );
 961          $enum_sev_count = count( $t_sev_arr );
 962          $c_sev_s = array();
 963          for ( $i = 0; $i < $enum_sev_count; $i++ ) {
 964              $t_sev_s = explode_enum_arr( $t_sev_arr[$i] );
 965              $c_sev_s[$i] = db_prepare_string( $t_sev_s[0] );
 966          }
 967  
 968          $t_res_arr = explode_enum_string( $p_resolution_enum_string );
 969          $enum_res_count = count( $t_res_arr );
 970          $c_res_s = array();
 971          for ( $i = 0; $i < $enum_res_count; $i++ ) {
 972              $t_res_s = explode_enum_arr( $t_res_arr[$i] );
 973              $c_res_s[$i] = db_prepare_string( $t_res_s[0] );
 974          }
 975  
 976          # Checking if it's a per project statistic or all projects
 977          $specific_where = helper_project_specific_where( $t_project_id );
 978          if ( ' 1<>1' == $specific_where ) {
 979              return;
 980          }
 981  
 982          # Get all of the bugs and split them up into an array
 983          $query = "SELECT COUNT(id) as bugcount, reporter_id, resolution, severity
 984                  FROM $t_mantis_bug_table
 985                  WHERE $specific_where
 986                  GROUP BY reporter_id, resolution, severity";
 987          $result = db_query( $query );
 988  
 989          $t_reporter_ressev_arr = array();
 990          $t_reporter_bugcount_arr = array();
 991          $t_arr = db_fetch_array( $result );
 992          while ( $t_arr ) {
 993              if ( !isset( $t_reporter_ressev_arr[$t_arr['reporter_id']] ) ) {
 994                  $t_reporter_ressev_arr[$t_arr['reporter_id']] = array();
 995                  $t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
 996              }
 997              if ( !isset( $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']] ) ) {
 998                  $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']] = array();
 999                  $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] = 0;
1000              }
1001              if ( !isset( $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] ) ) {
1002                  $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] = 0;
1003              }
1004              $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] += $t_arr['bugcount'];
1005              $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] += $t_arr['bugcount'];
1006              $t_reporter_bugcount_arr[$t_arr['reporter_id']] += $t_arr['bugcount'];
1007  
1008              $t_arr = db_fetch_array( $result );
1009          }
1010  
1011          # Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
1012          arsort( $t_reporter_bugcount_arr );
1013  
1014          $t_row_count = 0;
1015          # We now have a multi dimensional array of users, resolutions and severities, with the
1016          # value of each resolution and severity for each user
1017          foreach( $t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs ) {
1018              # Limit the number of reporters listed
1019              if ( $t_row_count > $t_reporter_summary_limit ) {
1020                  break;
1021              }
1022  
1023              # Only print reporters who have reported at least one bug. This helps
1024              # prevent divide by zeroes, showing reporters not on this project, and showing
1025              # users that aren't actually reporters...
1026              if ( $t_total_user_bugs > 0 ) {
1027                  $t_arr2 = $t_reporter_ressev_arr[$t_reporter_id];
1028  
1029                  PRINT '<tr ' . helper_alternate_class( $t_row_count ) . '>';
1030                  $t_row_count++;
1031                  PRINT '<td>';
1032                  PRINT user_get_name( $t_reporter_id );
1033                  PRINT '</td>';
1034  
1035                  $t_total_severity = 0;
1036                  $t_total_errors = 0;
1037                  for ( $j = 0; $j < $enum_sev_count; $j++ ) {
1038                      if ( !isset( $t_arr2[$c_sev_s[$j]] ) ) {
1039                          continue;
1040                      }
1041  
1042                      $sev_bug_count = $t_arr2[$c_sev_s[$j]]['total'];
1043                      $t_sev_mult = $t_severity_multiplier['average'];
1044                      if ( $t_severity_multiplier[$c_sev_s[$j]] ) {
1045                          $t_sev_mult = $t_severity_multiplier[$c_sev_s[$j]];
1046                      }
1047  
1048                      if ( $sev_bug_count > 0 ) {
1049                          $t_total_severity += ( $sev_bug_count * $t_sev_mult );
1050                      }
1051  
1052                      # Calculate the "error value" of bugs reported
1053                      $t_notbug_res_arr = array( UNABLE_TO_DUPLICATE, DUPLICATE, NOT_A_BUG );
1054  
1055                      foreach ( $t_notbug_res_arr as $t_notbug_res ) {
1056                          if ( isset( $t_arr2[$c_sev_s[$j]][$t_notbug_res] ) ) {
1057                              $t_notbug_mult = 1;
1058                              if ( $t_notbug_multiplier[$t_notbug_res] ) {
1059                                  $t_notbug_mult = $t_notbug_multiplier[$t_notbug_res];
1060                              }
1061  
1062                              $t_total_errors += ( $t_sev_mult * $t_notbug_mult );
1063                          }
1064                      }
1065                  }
1066                  PRINT '<td>';
1067                  PRINT $t_total_severity;
1068                  PRINT '</td>';
1069                  PRINT '<td>';
1070                  PRINT $t_total_errors;
1071                  PRINT '</td>';
1072                  PRINT '<td>';
1073                  PRINT ( $t_total_severity - $t_total_errors );
1074                  PRINT '</td>';
1075                  PRINT '</tr>';
1076              }
1077          }
1078      }
1079  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics