
if you want to use the recurring call functionality within versions below 1.2,
simply replace the bug_recur function with this one.
In addition make sure you create a cusom-filed, type date with the name of "DueDate"


	# --------------------
	#Reschedule a recurring issue. Also make copies of issue notes, attachments,
	function bug_recur( $p_bug_id, $p_target_project_id = null, $p_copy_custom_fields = false, $p_copy_relationships = false,
		$p_copy_history = false, $p_copy_attachments = false, $p_copy_bugnotes = false, $p_copy_monitoring_users = false, $recurring ) {
		global $g_db;

		$t_mantis_custom_field_string_table	= config_get( 'mantis_custom_field_string_table' );
		$t_mantis_custom_field_table	    = config_get( 'mantis_custom_field_table' );
		$t_mantis_bug_file_table			= config_get( 'mantis_bug_file_table' );
		$t_mantis_bugnote_table				= config_get( 'mantis_bugnote_table' );
		$t_mantis_bugnote_text_table		= config_get( 'mantis_bugnote_text_table' );
		$t_mantis_bug_monitor_table			= config_get( 'mantis_bug_monitor_table' );
		$t_mantis_bug_history_table			= config_get( 'mantis_bug_history_table' );
		$t_mantis_db = $g_db;

		$t_bug_id = db_prepare_int( $p_bug_id );
		$t_target_project_id = db_prepare_int( $p_target_project_id );


		$t_bug_data = new BugData;
		$t_bug_data = bug_get( $t_bug_id, true );

		# retrieve the project id associated with the bug
		if ( ( $p_target_project_id == null ) || is_blank( $p_target_project_id ) ) {
			$t_target_project_id = $t_bug_data->project_id;
		}

		$t_bug_data->project_id = $t_target_project_id;

		$t_new_bug_id = bug_create( $t_bug_data );

		# MASC ATTENTION: IF THE SOURCE BUG HAS TO HANDLER THE bug_create FUNCTION CAN TRY TO AUTO-ASSIGN THE BUG
		# WE FORCE HERE TO DUPLICATE THE SAME HANDLER OF THE SOURCE BUG
		# @@@ VB: Shouldn't we check if the handler in the source project is also a handler in the destination project?
		bug_set_field( $t_new_bug_id, 'handler_id', $t_bug_data->handler_id );

		bug_set_field( $t_new_bug_id, 'duplicate_id', $t_bug_data->duplicate_id );
		$curstat= config_get( 'recur_stat' );
		bug_set_field( $t_new_bug_id, 'status', $curstat);
		bug_set_field( $t_new_bug_id, 'resolution', $t_bug_data->resolution );
		bug_set_field( $t_new_bug_id, 'projection', $t_bug_data->projection );
		bug_set_field( $t_new_bug_id, 'date_submitted', $t_mantis_db->DBTimeStamp( $t_bug_data->date_submitted ), false );
		bug_set_field( $t_new_bug_id, 'last_updated', $t_mantis_db->DBTimeStamp( $t_bug_data->last_updated ), false );
		bug_set_field( $t_new_bug_id, 'eta', $t_bug_data->eta );
		bug_set_field( $t_new_bug_id, 'fixed_in_version', $t_bug_data->fixed_in_version );
		bug_set_field( $t_new_bug_id, 'sponsorship_total', 0 );
		bug_set_field( $t_new_bug_id, 'sticky', 0 );

		# COPY CUSTOM FIELDS
		if ( $p_copy_custom_fields ) {
			$query = "SELECT $t_mantis_custom_field_string_table.field_id, $t_mantis_custom_field_string_table.bug_id, name,value
					   FROM $t_mantis_custom_field_string_table,$t_mantis_custom_field_table
					   WHERE bug_id = '$t_bug_id' and $t_mantis_custom_field_string_table.field_id = $t_mantis_custom_field_table.id;";
			$result = db_query( $query );
			$t_count = db_num_rows( $result );

			for ( $i = 0 ; $i < $t_count ; $i++ ) {
				$t_bug_custom = db_fetch_array( $result );

				$c_field_id = db_prepare_int( $t_bug_custom['field_id'] );
				$c_new_bug_id = db_prepare_int( $t_new_bug_id );
				$c_value = db_prepare_string( $t_bug_custom['value'] );
		//
		// CN-, calculate the duedate 
		//
		if ( $t_bug_custom['name'] == "DueDate" ) {
			if ($recurring == 74){
				$c_value= calcduedate((mktime(0,0,0,date("m"),date("d"),date("Y"))),1) ;
			}
			if ($recurring == 75){
				$c_value= calcduedate((mktime(0,0,0,date("m"),date("d"),date("Y"))),5) ;
			}
			if ($recurring == 76){
				$c_value= calcduedate((mktime(0,0,0,date("m"),date("d"),date("Y"))),22) ;
			}
			if ($recurring == 77){
//				$c_value= mktime(0,0,0,date("m")+3,date("d"),date("Y")) ;
				$c_value= calcduedate((mktime(0,0,0,date("m"),date("d"),date("Y"))),65) ;
			}
			if ($recurring == 78){
//				$c_value= mktime(0,0,0,date("m")+6,date("d"),date("Y")) ;
				$c_value= calcduedate((mktime(0,0,0,date("m"),date("d"),date("Y"))),130) ;
			}
			if ($recurring == 79){
//				$c_value= mktime(0,0,0,date("m")+12,date("d"),date("Y")) ;
				$c_value= calcduedate((mktime(0,0,0,date("m"),date("d"),date("Y"))),260) ;
			}
		}
		//
		// CN
		//
				$query = "INSERT INTO $t_mantis_custom_field_string_table
						   ( field_id, bug_id, value )
						   VALUES ('$c_field_id', '$c_new_bug_id', '$c_value')";
				db_query( $query );
			}
		}

		# COPY RELATIONSHIPS
		if ( $p_copy_relationships ) {
			if ( ON == config_get( 'enable_relationship' ) ) {
				relationship_copy_all( $t_bug_id,$t_new_bug_id );
			}
		}

		# Copy bugnotes
		if ( $p_copy_bugnotes ) {
			$query = "SELECT *
					  FROM $t_mantis_bugnote_table
					  WHERE bug_id = '$t_bug_id';";
			$result = db_query( $query );
			$t_count = db_num_rows( $result );

			for ( $i = 0; $i < $t_count; $i++ ) {
				$t_bug_note = db_fetch_array( $result );
				$t_bugnote_text_id = $t_bug_note['bugnote_text_id'];

				$query2 = "SELECT *
						   FROM $t_mantis_bugnote_text_table
						   WHERE id = '$t_bugnote_text_id';";
				$result2 = db_query( $query2 );
				$t_count2 = db_num_rows( $result2 );

				$t_bugnote_text_insert_id = -1;
				if ( $t_count2 > 0 ) {
					$t_bugnote_text = db_fetch_array( $result2 );
					$t_bugnote_text['note'] = db_prepare_string( $t_bugnote_text['note'] );

					$query2 = "INSERT INTO $t_mantis_bugnote_text_table
							   ( note )
							   VALUES ( '" . $t_bugnote_text['note'] . "' );";
					db_query( $query2 );
					$t_bugnote_text_insert_id = db_insert_id( $t_mantis_bugnote_text_table );
				}

				$query2 = "INSERT INTO $t_mantis_bugnote_table
						   ( bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified )
						   VALUES ( '$t_new_bug_id',
						   			'" . $t_bug_note['reporter_id'] . "',
						   			'$t_bugnote_text_insert_id',
						   			'" . $t_bug_note['view_state'] . "',
						   			'" . $t_bug_note['date_submitted'] . "',
						   			'" . $t_bug_note['last_modified'] . "' );";
				db_query( $query2 );
			}
		}

		# Copy attachments
		if ( $p_copy_attachments ) {
			$query = "SELECT *
					  FROM $t_mantis_bug_file_table
					  WHERE bug_id = '$t_bug_id';";
			$result = db_query( $query );
			$t_count = db_num_rows( $result );

			$t_bug_file = array();
			for ( $i = 0; $i < $t_count; $i++ ) {
				$t_bug_file = db_fetch_array( $result );

				# prepare the new diskfile name and then copy the file
				$t_file_path = dirname( $t_bug_file['folder'] );
				$t_new_diskfile_name = $t_file_path . file_generate_unique_name( 'bug-' . $p_file_name, $t_file_path );
				$t_new_file_name = file_get_display_name( $t_bug_file['filename'] );
				if ( ( config_get( 'file_upload_method' ) == DISK ) ) {
					copy( $t_bug_file['diskfile'], $t_new_diskfile_name );
					chmod( $t_new_diskfile_name, 0400 ); # make file read only in the file system
				}

				$query = "INSERT INTO $t_mantis_bug_file_table
						( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content )
						VALUES ( '$t_new_bug_id',
								 '" . db_prepare_string( $t_bug_file['title'] ) . "',
								 '" . db_prepare_string( $t_bug_file['description'] ) . "',
								 '" . db_prepare_string( $t_new_diskfile_name ) . "',
								 '" . db_prepare_string( $t_new_file_name ) . "',
								 '" . db_prepare_string( $t_bug_file['folder'] ) . "',
								 '" . db_prepare_int( $t_bug_file['filesize'] ) . "',
								 '" . db_prepare_string( $t_bug_file['file_type'] ) . "',
								 '" . db_prepare_string( $t_bug_file['date_added'] ) . "',
								 '" . db_prepare_string( $t_bug_file['content'] ) . "');";
				db_query( $query );
			}
		}

		# Copy users monitoring bug
		if ( $p_copy_monitoring_users ) {
			$query = "SELECT *
					  FROM $t_mantis_bug_monitor_table
					  WHERE bug_id = '$t_bug_id';";
			$result = db_query( $query );
			$t_count = db_num_rows( $result );

			for ( $i = 0; $i < $t_count; $i++ ) {
				$t_bug_monitor = db_fetch_array( $result );
				$query = "INSERT INTO $t_mantis_bug_monitor_table
						 ( user_id, bug_id )
						 VALUES ( '" . $t_bug_monitor['user_id'] . "', '$t_new_bug_id' );";
				db_query( $query );
			}
		}

		# COPY HISTORY
		history_delete( $t_new_bug_id );	# should history only be deleted inside the if statement below?
		if ( $p_copy_history ) {
			$query = "SELECT *
					  FROM $t_mantis_bug_history_table
					  WHERE bug_id = '$t_bug_id';";
			$result = db_query( $query );
			$t_count = db_num_rows( $result );

			for ( $i = 0; $i < $t_count; $i++ ) {
				$t_bug_history = db_fetch_array( $result );
				$query = "INSERT INTO $t_mantis_bug_history_table
						  ( user_id, bug_id, date_modified, field_name, old_value, new_value, type )
						  VALUES ( '" . db_prepare_int( $t_bug_history['user_id'] ) . "',
						  		   '$t_new_bug_id',
						  		   '" . db_prepare_string( $t_bug_history['date_modified'] ) . "',
						  		   '" . db_prepare_string( $t_bug_history['field_name'] ) . "',
						  		   '" . db_prepare_string( $t_bug_history['old_value'] ) . "',
						  		   '" . db_prepare_string( $t_bug_history['new_value'] ) . "',
						  		   '" . db_prepare_int( $t_bug_history['type'] ) . "' );";
				db_query( $query );
			}
		}

		return $t_new_bug_id;
	}
