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

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

f2e824
f2e824
f2e824
f2e824

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