Blame Identity/Models/Html/Mantis/1.1.2-1.fc9/summary_page.php

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

d6e8d8
d6e8d8
d6e8d8
d6e8d8

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