Blame Identity/Webenv/Mantis/1.1.2-1.fc9/summary_page.php

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

ef5584
ef5584
ef5584
ef5584

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