*** history_api_orig.php	Wed Sep  1 14:26:35 2004
--- history_api.php	Wed Sep  1 15:20:36 2004
***************
*** 102,108 ****
  	# Retrieves the raw history events for the specified bug id and returns it in an array
  	# The array is indexed from 0 to N-1.  The second dimension is: 'date', 'userid', 'username',
  	# 'field','type','old_value','new_value'
! 	function history_get_raw_events_array( $p_bug_id ) {
  		$t_mantis_bug_history_table	= config_get( 'mantis_bug_history_table' );
  		$t_mantis_user_table		= config_get( 'mantis_user_table' );
  		$t_history_order			= config_get( 'history_order' );
--- 102,108 ----
  	# Retrieves the raw history events for the specified bug id and returns it in an array
  	# The array is indexed from 0 to N-1.  The second dimension is: 'date', 'userid', 'username',
  	# 'field','type','old_value','new_value'
! 	function history_get_raw_events_array( $p_bug_id, $p_user_id = null ) {
  		$t_mantis_bug_history_table	= config_get( 'mantis_bug_history_table' );
  		$t_mantis_user_table		= config_get( 'mantis_user_table' );
  		$t_history_order			= config_get( 'history_order' );
***************
*** 119,141 ****
  				WHERE bug_id='$c_bug_id'
  				ORDER BY date_modified $t_history_order,id";
  		$result = db_query( $query );
! 		$raw_history_count = db_num_rows( $result );
! 		$raw_history = array();
  
! 		for ( $i=0; $i < $raw_history_count; ++$i ) {
! 			$row = db_fetch_array( $result );
  			extract( $row, EXTR_PREFIX_ALL, 'v' );
  
! 			$raw_history[$i]['date']	= db_unixtimestamp( $v_date_modified );
! 			$raw_history[$i]['userid']	= $v_user_id;
  
  			# user_get_name handles deleted users, and username vs realname
! 			$raw_history[$i]['username'] = user_get_name( $v_user_id );
  
! 			$raw_history[$i]['field']		= $v_field_name;
! 			$raw_history[$i]['type']		= $v_type;
! 			$raw_history[$i]['old_value']	= $v_old_value;
! 			$raw_history[$i]['new_value']	= $v_new_value;
  		} # end for loop
  
  		return $raw_history;
--- 119,147 ----
  				WHERE bug_id='$c_bug_id'
  				ORDER BY date_modified $t_history_order,id";
  		$result = db_query( $query );
! 		$count=0;
!         $raw_history = array();
  
!         while($row = db_fetch_array( $result )) {
  			extract( $row, EXTR_PREFIX_ALL, 'v' );
  
!             # make sure the user has read permission to the custom field
!             $v_field_id = custom_field_get_id($v_field_name);
!             if(!empty($v_field_id) && !custom_field_has_read_access($v_field_id, $p_bug_id, $p_user_id)) {
!                     continue;
!             }
! 
! 			$raw_history[$count]['date']	= db_unixtimestamp( $v_date_modified );
! 			$raw_history[$count]['userid']	= $v_user_id;
  
  			# user_get_name handles deleted users, and username vs realname
! 			$raw_history[$count]['username'] = user_get_name( $v_user_id );
  
! 			$raw_history[$count]['field']		= $v_field_name;
! 			$raw_history[$count]['type']		= $v_type;
! 			$raw_history[$count]['old_value']	= $v_old_value;
! 			$raw_history[$count++]['new_value']	= $v_new_value;
!             
  		} # end for loop
  
  		return $raw_history;
