Skip to content

Commit

Permalink
Fixed an issue with email notifications not working properly for proj…
Browse files Browse the repository at this point in the history
…ect specific email notification

The method for temporarily overwriting existing settings has been changed to address project specific settings problems
  • Loading branch information
SL-Gundam committed Mar 14, 2013
1 parent a7985e1 commit 9b2eca2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
11 changes: 7 additions & 4 deletions EmailReporting.php
Expand Up @@ -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 );

Expand Down Expand Up @@ -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, '' );
}
Expand Down
15 changes: 11 additions & 4 deletions core/config_api.php
Expand Up @@ -221,6 +221,15 @@ function ERP_print_documentation_link( $p_a_name = '' )
echo '<a href="http://www.mantisbt.org/wiki/doku.php/mantisbt:emailreporting#' . $t_a_name . '" target="_blank">[?]</a>';
}

# 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
Expand Down Expand Up @@ -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 )
Expand Down
11 changes: 8 additions & 3 deletions core/mail_api.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = '';
Expand All @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions doc/CHANGELOG.bug_report_mail.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/bug_report_mail.php
Expand Up @@ -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
Expand Down

0 comments on commit 9b2eca2

Please sign in to comment.