diff -Nuar original/EmailReporting/core/Mail/Parser.php new/EmailReporting/core/Mail/Parser.php --- original/EmailReporting/core/Mail/Parser.php 2010-10-19 18:48:26.000000000 +0200 +++ new/EmailReporting/core/Mail/Parser.php 2011-09-15 11:43:00.000000000 +0200 @@ -13,7 +13,10 @@ private $_content; private $_from; + private $_to; private $_subject; + private $_cc; + private $_date; private $_charset = 'auto'; private $_priority; private $_transferencoding; @@ -99,7 +102,10 @@ if ( extension_loaded( 'mbstring' ) ) { $this->_from = $this->process_encoding( $this->_from ); + $this->_to = $this->process_encoding( $this->_to ); $this->_subject = $this->process_encoding( $this->_subject ); + $this->_cc = $this->process_encoding( $this->_cc ); + $this->_date = $this->process_encoding( $this->_date ); $this->_body = $this->process_encoding( $this->_body ); } } @@ -114,6 +120,21 @@ return( $this->_subject ); } + public function cc() + { + return( $this->_cc ); + } + + public function mail_to() + { + return( $this->_to ); + } + + public function mail_date() + { + return( $this->_date ); + } + public function priority() { return( $this->_priority ); @@ -133,6 +154,22 @@ { $this->setFrom( $structure->headers['from'] ); $this->setSubject( $structure->headers['subject'] ); + + if( isset( $structure->headers['cc'] ) ) + { + $this->setCC( $structure->headers['cc'] ); + } + + if( isset( $structure->headers['date'] ) ) + { + $this->setDate( $structure->headers['date'] ); + } + + if( isset( $structure->headers['to'] ) ) + { + $this->setTo( $structure->headers['to'] ); + } + $this->setContentType( $structure->ctype_primary, $structure->ctype_secondary ); if ( isset( $structure->ctype_parameters[ 'charset' ] ) ) @@ -171,6 +208,21 @@ $this->_subject = $subject; } + private function setCC( $cc ) + { + $this->_cc = $cc; + } + + private function setDate( $date ) + { + $this->_date = $date; + } + + private function setTo( $to ) + { + $this->_to = $to; + } + private function setCharset( $charset ) { if ( extension_loaded( 'mbstring' ) && $this->_charset === 'auto' ) diff -Nuar original/EmailReporting/core/mail_api.php new/EmailReporting/core/mail_api.php --- original/EmailReporting/core/mail_api.php 2010-11-06 23:23:16.000000000 +0100 +++ new/EmailReporting/core/mail_api.php 2011-09-15 12:00:34.000000000 +0200 @@ -58,6 +58,10 @@ private $_mail_removed_reply_text; private $_mail_reporter_id; private $_mail_save_from; + private $_mail_save_to; + private $_mail_save_note_subject; + private $_mail_save_cc; + private $_mail_save_date; private $_mail_tmp_directory; private $_mail_use_bug_priority; private $_mail_use_reporter; @@ -109,6 +113,10 @@ $this->_mail_removed_reply_text = plugin_config_get( 'mail_removed_reply_text' ); $this->_mail_reporter_id = plugin_config_get( 'mail_reporter_id' ); $this->_mail_save_from = plugin_config_get( 'mail_save_from' ); + $this->_mail_save_to = plugin_config_get( 'mail_save_to' ); + $this->_mail_save_note_subject = plugin_config_get( 'mail_save_note_subject'); + $this->_mail_save_cc = plugin_config_get( 'mail_save_cc' ); + $this->_mail_save_date = plugin_config_get( 'mail_save_date' ); $this->_mail_tmp_directory = plugin_config_get( 'mail_tmp_directory' ); $this->_mail_use_bug_priority = plugin_config_get( 'mail_use_bug_priority' ); $this->_mail_use_reporter = plugin_config_get( 'mail_use_reporter' ); @@ -447,15 +455,15 @@ $t_mp->parse(); - $t_email[ 'From' ] = $t_mp->from(); - $t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] ); - $t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] ); - - $t_email[ 'Subject' ] = trim( $t_mp->subject() ); - - $t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() ); - - $t_email[ 'X-Mantis-Parts' ] = $t_mp->parts(); + $t_email[ 'From' ] = $t_mp->from(); + $t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] ); + $t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] ); + $t_email[ 'Subject' ] = trim( $t_mp->subject() ); + $t_email[ 'CC' ] = trim( $t_mp->cc() ); + $t_email[ 'Date' ] = trim( $t_mp->mail_date() ); + $t_email[ 'To' ] = trim( $t_mp->mail_to() ); + $t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() ); + $t_email[ 'X-Mantis-Parts' ] = $t_mp->parts(); if ( $this->_mail_use_bug_priority ) { @@ -602,8 +610,16 @@ $t_description = $p_email[ 'X-Mantis-Body' ]; $t_description = $this->identify_replies( $t_description ); - $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + $t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description ); + $t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description ); + if( array_key_exists( $p_email[ 'CC' ] ) && !empty( $p_email[ 'CC' ] ) ) + { + $t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description ); + } + $t_description = $this->apply_mail_save_to( $p_email[ 'To' ], $t_description ); + $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + # Event integration # Core mantis event already exists within bignote_add function $t_bugnote_text = event_signal( 'EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id ); @@ -650,7 +666,19 @@ $t_bug_data->status = $this->_bug_submit_status; $t_bug_data->summary = $p_email[ 'Subject' ]; - $t_bug_data->description = $this->apply_mail_save_from( $p_email[ 'From' ], $p_email[ 'X-Mantis-Body' ] ); + $t_description = $p_email[ 'X-Mantis-Body' ]; + $t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description ); + $t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description ); + + if( array_key_exists( $p_email[ 'CC' ] ) && !empty( $p_email[ 'CC' ] ) ) + { + $t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description ); + } + + $t_description = $this->apply_mail_save_to( $p_email[ 'To' ], $t_description ); + $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + + $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = $this->_default_bug_steps_to_reproduce; $t_bug_data->additional_information = $this->_default_bug_additional_info; @@ -1034,7 +1062,7 @@ # return the bug's id from the subject private function get_bug_id_from_subject( $p_mail_subject ) { - preg_match( "/\[.*?\s([0-9]{1,7}?)\]/u", $p_mail_subject, $v_matches ); + preg_match( "/.*\[.*?(0*[0-9]{1,7}?)\s*\]/u", $p_mail_subject, $v_matches ); if ( isset( $v_matches[ 1 ] ) ) { @@ -1119,13 +1147,62 @@ { if ( $this->_mail_save_from ) { - return( 'Email from: ' . $p_from . "\n\n" . $p_description ); + return( 'From: ' . $p_from . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- + # Add the save to text if enabled + private function apply_mail_save_to( $p_to, $p_description ) + { + if ( $this->_mail_save_to ) + { + return( 'To: ' . $p_to . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- + # Add the save subject text if enabled + private function apply_mail_subject( $p_subject, $p_description ) + { + if ( $this->_mail_save_note_subject ) + { + return( 'Subject: ' . $p_subject . "\n\n\n" . $p_description ); } return( $p_description ); } # -------------------- + # Add the save cc text if enabled + private function apply_mail_save_cc( $p_cc, $p_description ) + { + if ( $this->_mail_save_cc ) + { + return( 'CC: ' . $p_cc . "\n" . $p_description ); + } + + return( $p_description ); + } + + + # -------------------- + # Add the save date text if enabled + private function apply_mail_save_date( $p_date, $p_description ) + { + if ( $this->_mail_save_date ) + { + return( 'Date: ' . $p_date . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- # Show memory usage in debug mode private function show_memory_usage( $p_location ) { diff -Nuar original/EmailReporting/EmailReporting.php new/EmailReporting/EmailReporting.php --- original/EmailReporting/EmailReporting.php 2010-11-11 23:31:02.000000000 +0100 +++ new/EmailReporting/EmailReporting.php 2011-09-15 11:43:00.000000000 +0200 @@ -48,6 +48,9 @@ # Is this plugin allowed to process and add bugnotes to existing issues 'mail_add_bugnotes' => ON, + # Add email subject to a note or new bug report + 'mail_save_note_subject' => OFF, + # Add complete email into the attachments 'mail_add_complete_email' => OFF, @@ -133,6 +136,15 @@ # Write sender of the message into the bug report 'mail_save_from' => ON, + # Write recipient (To) of the message into the bug report + 'mail_save_to' => OFF, + + # Write CC into the bug report + 'mail_save_cc' => OFF, + + # Write Date into the bug report + 'mail_save_date' => OFF, + # Do you want to secure the EmailReporting script so that it cannot be run # via a webserver? 'mail_secured_script' => ON, @@ -474,5 +486,10 @@ plugin_config_set( 'mail_mantisbt_url_fix', $t_path ); } } + if ( $t_config_version <= 10 ) + { + plugin_config_set( 'mail_save_note_subject', ON ); + plugin_config_set( 'config_version', 11 ); + } } } diff -Nuar original/EmailReporting/lang/strings_english.txt new/EmailReporting/lang/strings_english.txt --- original/EmailReporting/lang/strings_english.txt 2010-10-19 18:44:46.000000000 +0200 +++ new/EmailReporting/lang/strings_english.txt 2011-09-15 11:43:00.000000000 +0200 @@ -51,7 +51,11 @@ $s_plugin_EmailReporting_mail_remove_replies_after = 'Use this text to identify the start of a reply'; $s_plugin_EmailReporting_mail_removed_reply_text = 'Use this text if replies have been removed from the email'; $s_plugin_EmailReporting_mail_reporter_id = 'The default / fallback reporter user for issues created by email'; -$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue report'; +$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_to = 'Write the recipient (To) of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_cc = 'Write the CC of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_date = 'Write the Date of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_note_subject = 'Write the email subject into the issue/bugnote'; $s_plugin_EmailReporting_mail_secured_script = 'Block this script from running via a webserver (recommended = "Yes")'; $s_plugin_EmailReporting_mail_tmp_directory = 'Directory for saving temporary email content'; $s_plugin_EmailReporting_mail_use_bug_priority = 'Look for priority header field'; diff -Nuar original/EmailReporting/pages/manage_config_edit.php new/EmailReporting/pages/manage_config_edit.php --- original/EmailReporting/pages/manage_config_edit.php 2010-10-07 15:08:38.000000000 +0200 +++ new/EmailReporting/pages/manage_config_edit.php 2011-09-15 11:43:00.000000000 +0200 @@ -26,6 +26,10 @@ 'mail_removed_reply_text' => gpc_get_string( 'mail_removed_reply_text' ), 'mail_reporter_id' => gpc_get_int( 'mail_reporter_id' ), 'mail_save_from' => gpc_get_bool( 'mail_save_from' ), + 'mail_save_to' => gpc_get_bool( 'mail_save_to' ), + 'mail_save_cc' => gpc_get_bool( 'mail_save_cc' ), + 'mail_save_date' => gpc_get_bool( 'mail_save_date' ), + 'mail_save_note_subject' => gpc_get_bool( 'mail_save_note_subject'), 'mail_secured_script' => gpc_get_bool( 'mail_secured_script' ), 'mail_tmp_directory' => ERP_prepare_directory_string( gpc_get_string( 'mail_tmp_directory' ) ), 'mail_use_bug_priority' => gpc_get_bool( 'mail_use_bug_priority' ), diff -Nuar original/EmailReporting/pages/manage_config.php new/EmailReporting/pages/manage_config.php --- original/EmailReporting/pages/manage_config.php 2010-10-07 15:08:26.000000000 +0200 +++ new/EmailReporting/pages/manage_config.php 2011-09-15 11:43:00.000000000 +0200 @@ -65,6 +65,10 @@ ERP_output_config_option( 'mail_remove_replies', 'boolean', -2 ); ERP_output_config_option( 'mail_email_receive_own', 'boolean', -2 ); ERP_output_config_option( 'mail_save_from', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_to', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_cc', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_date', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_note_subject', 'boolean', -2 ); ERP_output_config_option( NULL, 'empty' ); ERP_output_config_option( 'priority_feature_options', 'header' );