View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0003362 | mantisbt | public | 2003-09-17 01:23 | 2004-02-29 07:17 | |
| Reporter | vboctor | Assigned To | vboctor | ||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | git trunk | ||||
| Summary | 0003362: Generic email notifications | ||||
| Description | Currently Mantis supports a fixed set of email notifications. For example, when a bug is submitted, status changed to feedback, assigned, resolved, closed, reopened or deleted. This is ok if the users do not define their own statuses. For example, the user may want to introduce statuses like: fixed, tested-failed, tested-pass. In this case users will won't to have notifications in these cases and be able to control who should get notifications. There should be notifications for bug updates as well (without changing the handler or the status, i.e. description field changed), and again users should be able to configure who should get it. | ||||
| Additional Information | Attached is a patch that implements the above change. It can be applied on CVS HEAD which is currently close to 0.18.0rc1 release. Note that the patch is not supported and the implementation may change by the next version. However, you can test it and provide feedback. I expect this feature will be integrated in version 0.18.1. | ||||
| Tags | No tags attached. | ||||
| Attached Files | generic_email_notifications.diff (10,759 bytes)
Index: config_defaults_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v
retrieving revision 1.130
diff -u -r1.130 config_defaults_inc.php
--- config_defaults_inc.php 1 Sep 2003 14:06:57 -0000 1.130
+++ config_defaults_inc.php 16 Sep 2003 23:16:36 -0000
@@ -146,14 +146,13 @@
# If a user category is not listed for an action, the default from the config
# option above is used. The possible actions are:
#
- # 'new': a new bug has been added
+ # 'new': a new bug has been added
# 'assigned': a bug has been assigned
- # 'resolved': a bug has been resolved
- # 'bugnote': a bugnote has been added to a bug
- # 'reopened': a bugnote has been reopened
- # 'closed': a bug has been closed
+ # 'reopened': a bug has been reopened
# 'deleted': a bug has been deleted
- # 'feedback': a bug has been put into the FEEDBACK state
+ # 'updated': a bug has been updated
+ # 'bugnote': a bugnote has been added to a bug
+ # '<status>': eg: 'resolved', 'closed', 'feedback', 'acknowledged', ...etc.
#
# If you wanted to have all developers get notified of new bugs you might add
# the following lines to your config file:
Index: core/bug_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/bug_api.php,v
retrieving revision 1.44
diff -u -r1.44 bug_api.php
--- core/bug_api.php 11 Sep 2003 14:14:57 -0000 1.44
+++ core/bug_api.php 16 Sep 2003 23:16:39 -0000
@@ -551,49 +551,29 @@
# Update the last update date
bug_update_date( $p_bug_id );
- # @@@ VBOCTOR: I don't like the following code since it hard-codes some assumptions
- # about the bug states and when an email should be sent. There should
- # be configuration options that achieves the same in a generic way.
- # Suggestion:
- # - An email should always be sent if the handler is changed, independent
- # of whether the status is changed or not. The configs should specify
- # who is to be notified in this case.
- # - The first index of $g_notify_flags should be the status id rather
- # a string that corresponds to it. For example, _NEW rather than
- # 'new'.
- # - $s_bug_update_notification[<status>] that is to be used to
- # determine the message to be displayed at the top of the email.
- #
- # If we should notify and it's in feedback state then send an email
- switch ( $p_bug_data->status ) {
- case NEW_:
- # This will be used in the case where auto-assign = OFF, in this case the bug can be
- # assigned/unassigned while the status is NEW.
- # @@@ In case of unassigned, the e-mail will still say ASSIGNED, but it will be shown
- # that the handler is empty + history ( old_handler => @null@ ).
- if ( $p_bug_data->handler_id != $t_old_data->handler_id ) {
- email_assign( $p_bug_id );
- }
- break;
- case FEEDBACK:
- if ( $p_bug_data->status!= $t_old_data->status ) {
- email_feedback( $p_bug_id );
- }
- break;
- case ASSIGNED:
- if ( ( $p_bug_data->handler_id != $t_old_data->handler_id )
- || ( $p_bug_data->status != $t_old_data->status ) ) {
- email_assign( $p_bug_id );
- }
- break;
- case RESOLVED:
- email_resolved( $p_bug_id );
- break;
- case CLOSED:
- email_close( $p_bug_id );
- break;
+ $t_action_prefix = 'email_notification_title_for_action_bug_';
+ $t_status_prefix = 'email_notification_title_for_status_bug_';
+
+ # bug assigned
+ if ( $t_old_data->handler_id != $p_bug_data->handler_id )
+ {
+ $t_message = lang_get_defaulted( $t_action_prefix . 'assigned', '' );
+ email_generic( $p_bug_id, 'assigned', $t_message );
+ return true;
}
-
+
+ # status changed
+ if ( $t_old_data->status != $p_bug_data->status ) {
+ $t_status = get_enum_to_string( config_get( 'status_enum_string' ), $p_bug_data->status );
+ $t_status = str_replace( ' ', '', $t_status );
+ $t_message = lang_get_defaulted( $t_status_prefix . $t_status, '' );
+ email_generic( $p_bug_id, $t_status, $t_message );
+ return true;
+ }
+
+ # generic update notification
+ $t_message = lang_get_defaulted( $t_action_prefix . 'updated' , '' );
+ email_generic( $p_bug_id, 'updated', $t_message );
return true;
}
Index: core/email_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/email_api.php,v
retrieving revision 1.63
diff -u -r1.63 email_api.php
--- core/email_api.php 31 Aug 2003 11:32:20 -0000 1.63
+++ core/email_api.php 16 Sep 2003 23:16:41 -0000
@@ -341,28 +341,34 @@
email_send( $v_email, lang_get( 'news_password_msg' ), $t_message );
}
# --------------------
+ # send a generic email
+ function email_generic( $p_bug_id, $p_notify_type, $p_message = null ) {
+ $t_bcc = email_build_bcc_list( $p_bug_id, $p_notify_type );
+ email_bug_info( $p_bug_id, $p_message, $t_bcc );
+ }
+ # --------------------
# send notices when a new bug is added
function email_new_bug( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'new' );
- email_bug_info( $p_bug_id, lang_get( 'new_bug_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_action_bug_submitted' ), $t_bcc );
}
# --------------------
# send notices when a new bugnote
function email_bugnote_add( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'bugnote' );
- email_bug_info( $p_bug_id, lang_get( 'email_bugnote_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_action_bugnote_submitted' ), $t_bcc );
}
# --------------------
# send notices when a bug is RESOLVED
function email_resolved( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'resolved' );
- email_bug_info( $p_bug_id, lang_get( 'email_resolved_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_status_bug_resolved' ), $t_bcc );
}
# --------------------
# send notices when a bug is CLOSED
function email_close( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'closed' );
- email_bug_info( $p_bug_id, lang_get( 'email_close_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_status_bug_closed' ), $t_bcc );
}
# --------------------
# send notices when a bug is set to FEEDBACK
@@ -374,19 +380,19 @@
# send notices when a bug is REOPENED
function email_reopen( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'reopened' );
- email_bug_info( $p_bug_id, lang_get( 'email_reopen_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_action_bug_reopened' ), $t_bcc );
}
# --------------------
# send notices when a bug is ASSIGNED
function email_assign( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'assigned' );
- email_bug_info( $p_bug_id, lang_get( 'email_assigned_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_action_bug_assigned' ), $t_bcc );
}
# --------------------
# send notices when a bug is DELETED
function email_bug_deleted( $p_bug_id ) {
$t_bcc = email_build_bcc_list( $p_bug_id, 'deleted' );
- email_bug_info( $p_bug_id, lang_get( 'email_bug_deleted_msg' ), $t_bcc );
+ email_bug_info( $p_bug_id, lang_get( 'email_notification_title_for_action_bug_deleted' ), $t_bcc );
}
# --------------------
# Build the bug info part of the message
@@ -415,7 +421,7 @@
$t_sta_str = get_enum_element( 'status', $v_status );
$t_rep_str = get_enum_element( 'reproducibility', $v_reproducibility );
$t_message = $g_email_separator1."\n";
- if ( $p_message != lang_get( 'email_bug_deleted_msg' ) ) {
+ if ( $p_message != lang_get( 'email_notification_title_for_action_bug_deleted' ) ) {
$t_message .= string_get_bug_view_url_with_fqdn( $p_bug_id ) . "\n";
$t_message .= $g_email_separator1."\n";
}
@@ -540,7 +546,10 @@
# build message
$t_category = '';
- $t_message = $p_message."\n";
+ $t_message = '';
+ if ( ( $p_message !== null ) && ( !is_blank( $p_message ) ) ) {
+ $t_message .= $p_message."\n";
+ }
$t_message .= email_build_bug_message( $p_bug_id, $p_message, $t_category );
$t_message .= email_build_bugnote_message( $p_bug_id );
$t_message .= email_build_history_message( $p_bug_id );
Index: lang/strings_english.txt
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v
retrieving revision 1.144
diff -u -r1.144 strings_english.txt
--- lang/strings_english.txt 11 Sep 2003 14:14:57 -0000 1.144
+++ lang/strings_english.txt 16 Sep 2003 23:16:44 -0000
@@ -242,14 +242,19 @@
$s_account_name_msg = 'Your account name is';
$s_news_password_msg = 'Here is your new password';
-$s_new_bug_msg = 'The following NEW bug has been ADDED.';
-$s_email_bugnote_msg = 'A BUGNOTE has been added to this bug.';
-$s_email_resolved_msg = 'The following bug has been RESOLVED.';
-$s_email_close_msg = 'The following bug has been CLOSED';
-$s_email_feedback_msg = 'The following bug requires your FEEDBACK.';
-$s_email_reopen_msg = 'The following bug has been REOPENED.';
-$s_email_assigned_msg = 'The following bug has been ASSIGNED.';
-$s_email_bug_deleted_msg = 'The following bug has been DELETED.';
+$s_email_notification_title_for_status_bug_feedback = 'The following bug requires your FEEDBACK.';
+$s_email_notification_title_for_status_bug_acknowledged = 'The following bug has been ACKNOWLEDGED.';
+$s_email_notification_title_for_status_bug_confirmed = 'The following bug has been CONFIRMED.';
+$s_email_notification_title_for_status_bug_assigned = 'The following bug has been ASSIGNED.';
+$s_email_notification_title_for_status_bug_resolved = 'The following bug has been RESOLVED.';
+$s_email_notification_title_for_status_bug_closed = 'The following bug has been CLOSED';
+
+$s_email_notification_title_for_action_bug_assigned = 'The following bug has been ASSIGNED.';
+$s_email_notification_title_for_action_bug_reopened = 'The following bug has been REOPENED.';
+$s_email_notification_title_for_action_bug_deleted = 'The following bug has been DELETED.';
+$s_email_notification_title_for_action_bug_submitted = 'The following bug has been SUBMITTED.';
+
+$s_email_notification_title_for_action_bugnote_submitted = 'A BUGNOTE has been added to this bug.';
$s_email_reporter = 'Reporter';
$s_email_handler = 'Handler';
| ||||