Blame Extras/Mantis/1.1.2-1.fc9/summary_page.php

4c79b5
4c79b5
# Mantis - a php based bugtracking system
4c79b5
4c79b5
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
4c79b5
# Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
4c79b5
4c79b5
# Mantis is free software: you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation, either version 2 of the License, or
4c79b5
# (at your option) any later version.
4c79b5
#
4c79b5
# Mantis is distributed in the hope that it will be useful,
4c79b5
# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c79b5
# GNU General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
4c79b5
4c79b5
	# --------------------------------------------------------
4c79b5
	# $Id: summary_page.php,v 1.54.2.1 2007-10-13 22:34:43 giallu Exp $
4c79b5
	# --------------------------------------------------------
4c79b5
?>
4c79b5
4c79b5
	require_once( 'core.php' );
4c79b5
4c79b5
	$t_core_path = config_get( 'core_path' );
4c79b5
4c79b5
	require_once( $t_core_path.'summary_api.php' );
4c79b5
?>
4c79b5
4c79b5
	access_ensure_project_level( config_get( 'view_summary_threshold' ) );
4c79b5
4c79b5
	$f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
4c79b5
4c79b5
	# Override the current page to make sure we get the appropriate project-specific configuration
4c79b5
	$g_project_override = $f_project_id;
4c79b5
4c79b5
	$t_user_id = auth_get_current_user_id();
4c79b5
4c79b5
	# @@@ giallu: this block of code is duplicated from helper_project_specific_where
4c79b5
	# the only diff is the commented line below: can we do better than this ?
4c79b5
	if ( ALL_PROJECTS == $f_project_id ) {
4c79b5
		$t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
4c79b5
		foreach ( $t_topprojects as $t_project ) {
4c79b5
			$t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
4c79b5
		}
4c79b5
4c79b5
		$t_project_ids = array_unique( $t_project_ids );
4c79b5
	} else {
4c79b5
		# access_ensure_project_level( VIEWER, $p_project_id );
4c79b5
		$t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $f_project_id );
4c79b5
		array_unshift( $t_project_ids, $f_project_id );
4c79b5
	}
4c79b5
4c79b5
	$t_project_ids = array_map( 'db_prepare_int', $t_project_ids );
4c79b5
4c79b5
	if ( 0 == count( $t_project_ids ) ) {
4c79b5
		$specific_where = ' 1 <> 1';
4c79b5
	} elseif ( 1 == count( $t_project_ids ) ) {
4c79b5
		$specific_where = ' project_id=' . $t_project_ids[0];
4c79b5
	} else {
4c79b5
		$specific_where = ' project_id IN (' . join( ',', $t_project_ids ) . ')';
4c79b5
	}
4c79b5
	# end @@@ block
4c79b5
4c79b5
	$t_bug_table = config_get( 'mantis_bug_table' );
4c79b5
	$t_history_table = config_get( 'mantis_bug_history_table' );
4c79b5
4c79b5
	$t_resolved = config_get( 'bug_resolved_status_threshold' );
4c79b5
	# the issue may have passed through the status we consider resolved
4c79b5
	#  (e.g., bug is CLOSED, not RESOLVED). The linkage to the history field
4c79b5
	#  will look up the most recent 'resolved' status change and return it as well
4c79b5
	$query = "SELECT b.id, b.date_submitted, b.last_updated, MAX(h.date_modified) as hist_update, b.status 
4c79b5
        FROM $t_bug_table b LEFT JOIN $t_history_table h 
4c79b5
            ON b.id = h.bug_id  AND h.type=0 AND h.field_name='status' AND h.new_value='$t_resolved'  
4c79b5
            WHERE b.status >='$t_resolved' AND $specific_where
4c79b5
            GROUP BY b.id, b.status, b.date_submitted, b.last_updated 
4c79b5
            ORDER BY b.id ASC";
4c79b5
	$result = db_query( $query );
4c79b5
	$bug_count = db_num_rows( $result );
4c79b5
4c79b5
	$t_bug_id       = 0;
4c79b5
	$t_largest_diff = 0;
4c79b5
	$t_total_time   = 0;
4c79b5
	for ($i=0;$i<$bug_count;$i++) {
4c79b5
		$row = db_fetch_array( $result );
4c79b5
		$t_date_submitted = db_unixtimestamp( $row['date_submitted'] );		
4c79b5
		$t_id = $row['id'];
4c79b5
		$t_status = $row['status'];
4c79b5
		if ( $row['hist_update'] !== NULL ) {
4c79b5
            $t_last_updated   = db_unixtimestamp( $row['hist_update'] );
4c79b5
        } else {
4c79b5
        	$t_last_updated   = db_unixtimestamp( $row['last_updated'] );
4c79b5
        }
4c79b5
		  
4c79b5
		if ($t_last_updated < $t_date_submitted) {
4c79b5
			$t_last_updated   = 0;
4c79b5
			$t_date_submitted = 0;
4c79b5
		}
4c79b5
4c79b5
		$t_diff = $t_last_updated - $t_date_submitted;
4c79b5
		$t_total_time = $t_total_time + $t_diff;
4c79b5
		if ( $t_diff > $t_largest_diff ) {
4c79b5
			$t_largest_diff = $t_diff;
4c79b5
			$t_bug_id = $row['id'];
4c79b5
		}
4c79b5
	}
4c79b5
	if ( $bug_count < 1 ) {
4c79b5
		$bug_count = 1;
4c79b5
	}
4c79b5
	$t_average_time 	= $t_total_time / $bug_count;
4c79b5
4c79b5
	$t_largest_diff 	= number_format( $t_largest_diff / 86400, 2 );
4c79b5
	$t_total_time		= number_format( $t_total_time / 86400, 2 );
4c79b5
	$t_average_time 	= number_format( $t_average_time / 86400, 2 );
4c79b5
4c79b5
	$t_orct_arr = preg_split( '/[\)\/\(]/', lang_get( 'orct' ), -1, PREG_SPLIT_NO_EMPTY );
4c79b5
4c79b5
	$t_orcttab = "";
4c79b5
	foreach ( $t_orct_arr as $t_orct_s ) {
4c79b5
		$t_orcttab .= '';
4c79b5
		$t_orcttab .= $t_orct_s;
4c79b5
		$t_orcttab .= '';
4c79b5
	}
4c79b5
?>
4c79b5
4c79b5
4c79b5
4c79b5

4c79b5
4c79b5
4c79b5
4c79b5

4c79b5
4c79b5
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
4c79b5
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
					if ($t_bug_id>0) {
4c79b5
						print_bug_link( $t_bug_id );
4c79b5
					}
4c79b5
				?>
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
			
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
4c79b5
		
4c79b5
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
			$t_arr = explode_enum_string( config_get( 'resolution_enum_string' ) );
4c79b5
			$enum_count = count( $t_arr );
4c79b5
4c79b5
			for ($i=0;$i<$enum_count;$i++) {
4c79b5
				print '';
4c79b5
				$t_s = explode_enum_arr( $t_arr[$i] );
4c79b5
				$c_s[0] = db_prepare_string( $t_s[0] );
4c79b5
				echo get_enum_element( 'resolution', $c_s[0] );
4c79b5
				print '';
4c79b5
			}
4c79b5
4c79b5
			print '';
4c79b5
			print lang_get( 'percentage_errors' );
4c79b5
			print '';
4c79b5
			?>
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
			
4c79b5
				
4c79b5
			
4c79b5
			
4c79b5
			$t_arr = explode_enum_string( config_get( 'resolution_enum_string' ) );
4c79b5
			$enum_count = count( $t_arr );
4c79b5
4c79b5
			for ($i=0;$i<$enum_count;$i++) {
4c79b5
				print '';
4c79b5
				$t_s = explode_enum_arr( $t_arr[$i] );
4c79b5
				$c_s[0] = db_prepare_string( $t_s[0] );
4c79b5
				echo get_enum_element( 'resolution', $c_s[0] );
4c79b5
				print '';
4c79b5
			}
4c79b5
4c79b5
			print '';
4c79b5
			print lang_get( 'percentage_fixed' );
4c79b5
			print '';
4c79b5
			?>
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5