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

4c79b5
4c79b5
# Mantis - a php based bugtracking system
4c79b5
4c79b5
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
4c79b5
# Copyright (C) 2002 - 2008  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
	#   $Revision: 2643 $
4c79b5
	#     $Author: al $    
4c79b5
	#       $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $  
4c79b5
	#------------------------------
4c79b5
4c79b5
	# This page stores the reported bug
4c79b5
4c79b5
	require_once( 'core.php' );
4c79b5
4c79b5
	$t_core_path = config_get( 'core_path' );
4c79b5
4c79b5
	require_once( $t_core_path.'string_api.php' );
4c79b5
	require_once( $t_core_path.'file_api.php' );
4c79b5
	require_once( $t_core_path.'bug_api.php' );
4c79b5
	require_once( $t_core_path.'custom_field_api.php' );
4c79b5
4c79b5
	# helper_ensure_post();
4c79b5
4c79b5
	access_ensure_project_level( config_get('report_bug_threshold' ) );
4c79b5
4c79b5
	$t_bug_data = new BugData;
4c79b5
	$t_bug_data->build				= gpc_get_string( 'build', '' );
4c79b5
	$t_bug_data->platform				= gpc_get_string( 'platform', '' );
4c79b5
	$t_bug_data->os					= gpc_get_string( 'os', '' );
4c79b5
	$t_bug_data->os_build				= gpc_get_string( 'os_build', '' );
4c79b5
	$t_bug_data->version			= gpc_get_string( 'product_version', '' );
4c79b5
	$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
4c79b5
	$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
4c79b5
	$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
4c79b5
4c79b5
	$t_bug_data->category				= gpc_get_string( 'category', config_get( 'default_bug_category' ) );
4c79b5
	$t_bug_data->reproducibility		= gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) );
4c79b5
	$t_bug_data->severity				= gpc_get_int( 'severity', config_get( 'default_bug_severity' ) );
4c79b5
	$t_bug_data->priority				= gpc_get_int( 'priority', config_get( 'default_bug_priority' ) );
4c79b5
	$t_bug_data->summary				= gpc_get_string( 'summary' );
4c79b5
	$t_bug_data->description			= gpc_get_string( 'description' );
4c79b5
	$t_bug_data->steps_to_reproduce	= gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) );
4c79b5
	$t_bug_data->additional_information	= gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) );
4c79b5
4c79b5
	$f_file					= gpc_get_file( 'file', null ); #@@@ (thraxisp) Note that this always returns a structure
4c79b5
															# size = 0, if no file
4c79b5
	$f_report_stay			= gpc_get_bool( 'report_stay', false );
4c79b5
	$t_bug_data->project_id			= gpc_get_int( 'project_id' );
4c79b5
4c79b5
	$t_bug_data->reporter_id		= auth_get_current_user_id();
4c79b5
4c79b5
	$t_bug_data->summary			= trim( $t_bug_data->summary );
4c79b5
4c79b5
	$t_bug_data->target_version		= access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id ) ? gpc_get_string( 'target_version', '' ) : '';
4c79b5
4c79b5
	# if a profile was selected then let's use that information
4c79b5
	if ( 0 != $t_bug_data->profile_id ) {
4c79b5
		if ( profile_is_global( $t_bug_data->profile_id ) ) {
4c79b5
			$row = user_get_profile_row( ALL_USERS, $t_bug_data->profile_id );
4c79b5
		} else {
4c79b5
			$row = user_get_profile_row( $t_bug_data->reporter_id, $t_bug_data->profile_id );
4c79b5
		}
4c79b5
4c79b5
		if ( is_blank( $t_bug_data->platform ) ) {
4c79b5
			$t_bug_data->platform = $row['platform'];
4c79b5
		}
4c79b5
		if ( is_blank( $t_bug_data->os ) ) {
4c79b5
			$t_bug_data->os = $row['os'];
4c79b5
		}
4c79b5
		if ( is_blank( $t_bug_data->os_build ) ) {
4c79b5
			$t_bug_data->os_build = $row['os_build'];
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) );
4c79b5
4c79b5
	# Validate the custom fields before adding the bug.
4c79b5
	$t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id );
4c79b5
	foreach( $t_related_custom_field_ids as $t_id ) {
4c79b5
		$t_def = custom_field_get_definition( $t_id );
4c79b5
		if ( $t_def['require_report'] && ( gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ) == '' ) ) {
4c79b5
			error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
4c79b5
			trigger_error( ERROR_EMPTY_FIELD, ERROR );
4c79b5
		}
4c79b5
		if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) {
4c79b5
			error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
4c79b5
			trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	# Create the bug
4c79b5
	$t_bug_id = bug_create( $t_bug_data );
4c79b5
4c79b5
	# Handle the file upload
4c79b5
	if ( !is_blank( $f_file['tmp_name'] ) && ( 0 < $f_file['size'] ) ) {
4c79b5
    	$f_file_error =  ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0;
4c79b5
		file_add( $t_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error );
4c79b5
	}
4c79b5
4c79b5
	# Handle custom field submission
4c79b5
	foreach( $t_related_custom_field_ids as $t_id ) {
4c79b5
		# Do not set custom field value if user has no write access.
4c79b5
		if( !custom_field_has_write_access( $t_id, $t_bug_id ) ) {
4c79b5
			continue;
4c79b5
		}
4c79b5
4c79b5
		$t_def = custom_field_get_definition( $t_id );
4c79b5
		if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) {
4c79b5
			error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
4c79b5
			trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	$f_master_bug_id = gpc_get_int( 'm_id', 0 );
4c79b5
	$f_rel_type = gpc_get_int( 'rel_type', -1 );
4c79b5
4c79b5
	if ( $f_master_bug_id > 0 ) {
4c79b5
		# it's a child generation... let's create the relationship and add some lines in the history
4c79b5
4c79b5
		# update master bug last updated
4c79b5
		bug_update_date( $f_master_bug_id );
4c79b5
4c79b5
		# Add log line to record the cloning action
4c79b5
		history_log_event_special( $t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id );
4c79b5
		history_log_event_special( $f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id );
4c79b5
4c79b5
		if ( $f_rel_type >= 0 ) {
4c79b5
			# Add the relationship
4c79b5
			relationship_add( $t_bug_id, $f_master_bug_id, $f_rel_type );
4c79b5
	
4c79b5
			# Add log line to the history (both issues)
4c79b5
			history_log_event_special( $f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $t_bug_id );
4c79b5
			history_log_event_special( $t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id );
4c79b5
	
4c79b5
			# Send the email notification
4c79b5
			email_relationship_added( $f_master_bug_id, $t_bug_id, relationship_get_complementary_type( $f_rel_type ) );
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	email_new_bug( $t_bug_id );
4c79b5
4c79b5
	helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) );
4c79b5
4c79b5
	html_page_top1();
4c79b5
4c79b5
	if ( ! $f_report_stay ) {
4c79b5
		html_meta_redirect( 'view_all_bug_page.php' );
4c79b5
	}
4c79b5
4c79b5
	html_page_top2();
4c79b5
?>
4c79b5
4c79b5
4c79b5
	echo '

' . lang_get( 'operation_successful' ) . '

';
4c79b5
	print_bracket_link( string_get_bug_view_url( $t_bug_id ), lang_get( 'view_submitted_bug_link' ) . " $t_bug_id" );
4c79b5
	print_bracket_link( 'view_all_bug_page.php', lang_get( 'view_bugs_link' ) );
4c79b5
4c79b5
	if ( $f_report_stay ) {
4c79b5
?>
4c79b5
	

4c79b5
	<form method="post" action="<?php echo string_get_bug_report_url() ?>">
4c79b5
		<input type="hidden" name="category" 		value="<?php echo $t_bug_data->category ?>" />
4c79b5
		<input type="hidden" name="severity" 		value="<?php echo $t_bug_data->severity ?>" />
4c79b5
		<input type="hidden" name="reproducibility" 	value="<?php echo $t_bug_data->reproducibility ?>" />
4c79b5
		<input type="hidden" name="profile_id" 		value="<?php echo $t_bug_data->profile_id ?>" />
4c79b5
		<input type="hidden" name="platform" 		value="<?php echo $t_bug_data->platform ?>" />
4c79b5
		<input type="hidden" name="os" 			value="<?php echo $t_bug_data->os ?>" />
4c79b5
		<input type="hidden" name="os_build" 		value="<?php echo $t_bug_data->os_build ?>" />
4c79b5
		<input type="hidden" name="product_version" 	value="<?php echo $t_bug_data->version ?>" />
4c79b5
		<input type="hidden" name="target_version" 	value="<?php echo $t_bug_data->target_version ?>" />
4c79b5
		<input type="hidden" name="build" 		value="<?php echo $t_bug_data->build ?>" />
4c79b5
		<input type="hidden" name="report_stay" 	value="1" />
4c79b5
		<input type="hidden" name="view_state"		value="<?php echo $t_bug_data->view_state ?>" />
4c79b5
		<input type="submit" class="button" 		value="<?php echo lang_get( 'report_more_bugs' ) ?>" />
4c79b5
	</form>
4c79b5
	

4c79b5
4c79b5
	}
4c79b5
?>
4c79b5
4c79b5
4c79b5