diff --git a/EmailReporting.php b/EmailReporting.php index 41b26bf..89c400c 100644 --- a/EmailReporting.php +++ b/EmailReporting.php @@ -169,9 +169,11 @@ function install() if ( $t_mail_reporter_id === 'Mail' ) { + // The plugin variable path_erp is not yet available. So path_erp cannot be used here + require_once( config_get_global( 'plugin_path' ) . 'EmailReporting' . '/' . 'core/config_api.php' ); + # We need to allow blank emails for a sec - config_set_cache( 'allow_blank_email', ON, CONFIG_TYPE_STRING ); - config_set_global( 'allow_blank_email', ON ); + ERP_set_temporary_overwrite( 'allow_blank_email', ON ); $t_rand = mt_rand( 1000, 99999 ); @@ -305,9 +307,10 @@ function ERP_update_check( ) if ( $t_user_email === 'nomail' ) { + require_once( plugin_config_get( 'path_erp', NULL, TRUE ) . 'core/config_api.php' ); + # We need to allow blank emails for a sec - config_set_cache( 'allow_blank_email', ON, CONFIG_TYPE_STRING ); - config_set_global( 'allow_blank_email', ON ); + ERP_set_temporary_overwrite( 'allow_blank_email', ON ); user_set_email( $t_user_id, '' ); } diff --git a/core/config_api.php b/core/config_api.php index 59eed9a..11dd0c2 100644 --- a/core/config_api.php +++ b/core/config_api.php @@ -221,6 +221,15 @@ function ERP_print_documentation_link( $p_a_name = '' ) echo '[?]'; } + # This overwrites a specific configuration option for the current request + function ERP_set_temporary_overwrite( $p_config_name, $p_value ) + { + global $g_cache_bypass_lookup; + + $g_cache_bypass_lookup[ $p_config_name ] = TRUE; + config_set_global( $p_config_name, $p_value ); + } + # -------------------- # output a configuration option # This function is only meant to be used by the EmailReporting plugin or by other plugins within the EVENT_ERP_OUTPUT_MAILBOX_FIELDS event @@ -617,12 +626,10 @@ function ERP_custom_function_print_encryption_option_list( $p_sel_value ) function ERP_custom_function_print_global_category_option_list( $p_sel_value ) { // Need to disable allow_no_category for a moment - config_set_cache( 'allow_no_category', OFF, CONFIG_TYPE_STRING ); - config_set_global( 'allow_no_category', OFF ); + ERP_set_temporary_overwrite( 'allow_no_category', OFF ); // Need to disable inherit projects for one moment. - config_set_cache( 'subprojects_inherit_categories', OFF, CONFIG_TYPE_STRING ); - config_set_global( 'subprojects_inherit_categories', OFF ); + ERP_set_temporary_overwrite( 'subprojects_inherit_categories', OFF ); $t_sel_value = $p_sel_value; if ( $t_sel_value === NULL ) diff --git a/core/mail_api.php b/core/mail_api.php index d3046d5..cd0db13 100644 --- a/core/mail_api.php +++ b/core/mail_api.php @@ -159,8 +159,7 @@ public function __construct( $p_test_only = FALSE ) $t_mail_email_receive_own = plugin_config_get( 'mail_email_receive_own' ); if ( $t_mail_email_receive_own ) { - config_set_cache( 'email_receive_own', ON, CONFIG_TYPE_STRING ); - config_set_global( 'email_receive_own', ON ); + ERP_set_temporary_overwrite( 'email_receive_own', ON ); } $this->_functionality_enabled = TRUE; @@ -721,6 +720,9 @@ private function add_bug( &$p_email, $p_overwrite_project_id = FALSE ) $this->fix_empty_fields( $p_email ); + $t_project_id = ( ( $p_overwrite_project_id === FALSE ) ? $this->_mailbox[ 'project_id' ] : $p_overwrite_project_id ); + ERP_set_temporary_overwrite( 'project_override', $t_project_id ); + $t_bug_data = new BugData; $t_bug_data->build = ''; $t_bug_data->platform = ''; @@ -747,10 +749,13 @@ private function add_bug( &$p_email, $p_overwrite_project_id = FALSE ) $t_bug_data->additional_information = $this->_default_bug_additional_info; $t_bug_data->due_date = date_get_null(); - $t_bug_data->project_id = ( ( $p_overwrite_project_id === FALSE ) ? $this->_mailbox[ 'project_id' ] : $p_overwrite_project_id ); + $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $p_email[ 'Reporter_id' ]; + // This function might do stuff that EmailReporting cannot handle. Disabled + //helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); + // @TODO@ Disabled for now but possibly needed for other future features # Validate the custom fields before adding the bug. /* $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); diff --git a/doc/CHANGELOG.bug_report_mail.txt b/doc/CHANGELOG.bug_report_mail.txt index 20a302f..6d8666b 100644 --- a/doc/CHANGELOG.bug_report_mail.txt +++ b/doc/CHANGELOG.bug_report_mail.txt @@ -68,6 +68,8 @@ Jan 2011 - EmailReporting-0.9.0-DEV - Increased mbstring supported charsets by adding all aliases using mb_encoding_aliases - mail_encoding configuration option has been deleted as it was no longer necessary and could only cause miss configurations - Added a warning that EmailReporting could have problems if the mbstring extension is not available + - The method for temporarily overwriting existing settings has been changed to address project specific settings problems + - Fixed an issue with email notifications not working properly for project specific email notification settings Nov 2010 - EmailReporting-0.8.4 - Improved the project category list diff --git a/pages/bug_report_mail.php b/pages/bug_report_mail.php index ef3da81..8309bfc 100644 --- a/pages/bug_report_mail.php +++ b/pages/bug_report_mail.php @@ -36,7 +36,7 @@ $t_mail_mantisbt_url_fix = plugin_config_get( 'mail_mantisbt_url_fix', '' ); if ( isset( $GLOBALS[ 't_dir_emailreporting_adjust' ] ) && !is_blank( $t_mail_mantisbt_url_fix ) ) { - config_set_global( 'path', $t_mail_mantisbt_url_fix ); + ERP_set_temporary_overwrite( 'path', $t_mail_mantisbt_url_fix ); } // Register the user that is currently running this script