View Issue Details

IDProjectCategoryView StatusLast Update
0025600mantisbtemailpublic2019-03-14 11:02
Reporterfman Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version2.19.0 
Target VersionFixed in Version 
Summary0025600: Using custom function to customize mail contents
Description

I've done several searches hitting the forum and other tickets.
My proposal is a simple and silly one

  1. create a new configuration option
    $g_func_email_format_bug_message = ''; // standard function will be used

  2. change function email_format_bug_message( array $p_visible_bug_data )

Before the line containing
<b> $t_normal_date_format = config_get( 'normal_date_format' ); </b>

add:

// check if config exists to use a custom function
$t_project_id = $p_visible_bug_data['email_project_id'];
$t_custom_func =
config_get( 'func_email_format_bug_message', null, null, $t_project_id );

if( null != $t_custom_func && '' != trim($t_custom_func) ) {
if( function_exists($t_custom_func) ) {
return call_user_func($t_custom_func, $p_visible_bug_data);
}
}

  1. create the function in the file
    custom_functions_inc.php

Nothing brilliant I did it following other excellent examples found in the MantisBT code.

please let me know if you would like to have a pull request for this

regards

TagsNo tags attached.

Activities

dregad

dregad

2019-03-14 06:23

developer   ~0061671

I don't necessarily support the approach as - although not officially deprecated - custom functions are kind of obsolete, but anyway, defining a new one does not require creating a new config option.

Have a look at the admin guide on custom functions and how helper_call_custom_function() handles calling the default (defined in core/custom_functions_api.php) or custom / override one (in config/custom_functions_inc.php) based on a convention in the function's name.

fman

fman

2019-03-14 07:49

reporter   ~0061673

Thanks for your answer
I've added the new config option to allow to define a different function for each project if needed. (my fault I've not explained it the description)
If the custom_function approach is deprecated, the only other option I see will be to use the event/plugin system, but because there is no (yet) a standard EVENT a custom one needs to be defined.

thanks again

dregad

dregad

2019-03-14 11:02

developer   ~0061674

the only other option I see will be to use the event/plugin system, but because there is no (yet) a standard EVENT a custom one needs to be defined

That would be the better approach indeed. Feel free to propose a pull request to introduce a new event.

Issue History

Date Modified Username Field Change
2019-03-14 03:57 fman New Issue
2019-03-14 06:23 dregad Note Added: 0061671
2019-03-14 07:49 fman Note Added: 0061673
2019-03-14 11:02 dregad Note Added: 0061674