Skip to content

Commit

Permalink
Fix bug #7953, #7971, #8362, #8647, #8509
Browse files Browse the repository at this point in the history
Moved checks for adding a bugnote into the bugnote add function.
Added configuration option for allowing adding time tracking
without bugnote text.  This defaults to ON. Moved email on adding
a bugnote into the bugnote add function with a parameter to specify
whether an email should be sent or not. Defaults to send email.  Updated
calls to bugnote add to prevent sending the email in cases where an email is
already being sent.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@5187 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Daryn Warriner committed Apr 21, 2008
1 parent 50704ec commit bda0f40
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 50 deletions.
4 changes: 2 additions & 2 deletions api/soap/mc_issue_api.php
Expand Up @@ -535,7 +535,7 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) {
}

$t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state );
bugnote_add( $t_issue_id, $t_note['text'], '0:00', $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id );
bugnote_add( $t_issue_id, $t_note['text'], '0:00', $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id, FALSE );
}
}

Expand Down Expand Up @@ -699,7 +699,7 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {

// TODO: consider supporting updating of bugnotes and detecting the ones that haven't changed.
$t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state );
bugnote_add( $p_issue_id, $t_note['text'], '0:00', $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id );
bugnote_add( $p_issue_id, $t_note['text'], '0:00', $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id, FALSE );
}
}

Expand Down
2 changes: 1 addition & 1 deletion bug_reminder.php
Expand Up @@ -75,7 +75,7 @@
$f_to = $t_to;
}
$t_attr = '|' . implode( '|', $f_to ) . '|';
bugnote_add( $f_bug_id, $f_body, 0, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr );
bugnote_add( $f_bug_id, $f_body, 0, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr, NULL, FALSE );
}

html_page_top1();
Expand Down
4 changes: 2 additions & 2 deletions bug_update.php
Expand Up @@ -193,8 +193,8 @@
}

# Add a bugnote if there is one
if ( ( !is_blank( $f_bugnote_text ) ) && ( false == $t_bug_note_set ) ) {
bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private );
if ( false == $t_bug_note_set ) {
bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, 0, '', NULL, FALSE );
}

# Update the bug entry, notify if we haven't done so already
Expand Down
18 changes: 5 additions & 13 deletions bugnote_add.php
Expand Up @@ -51,20 +51,12 @@
$g_project_override = $t_bug->project_id;
}

$c_time_tracking = helper_duration_to_minutes( $f_time_tracking );

# check for blank bugnote
# @@@ VB: Do we want to ban adding a time without an associated note?
# @@@ VB: Do we want to differentiate email notifications for normal notes from time tracking entries?
if ( !is_blank( $f_bugnote_text ) || ( $c_time_tracking > 0 ) ) {
$t_note_type = ( $c_time_tracking > 0 ) ? TIME_TRACKING : BUGNOTE;
bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, $t_note_type );

# only send email if the text is not blank, otherwise, it is just recording of time without a comment.
if ( !is_blank( $f_bugnote_text ) ) {
email_bugnote_add( $f_bug_id );
}
}
$t_bugnote_added = bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, $t_note_type );
if ( !$t_bugnote_added ) {
error_parameters( lang_get( 'bugnote' ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}

print_successful_redirect_to_bug( $f_bug_id );
?>
3 changes: 3 additions & 0 deletions config_defaults_inc.php
Expand Up @@ -1949,6 +1949,9 @@
# access level required to run reports
$g_time_tracking_reporting_threshold = MANAGER;

#allow time tracking to be recorded without a bugnote
$g_time_tracking_without_note = ON;

#############################
# Profile Related Settings
#############################
Expand Down
38 changes: 18 additions & 20 deletions core/bug_api.php
Expand Up @@ -1319,10 +1319,8 @@ function bug_assign( $p_bug_id, $p_user_id, $p_bugnote_text='', $p_bugnote_priva
history_log_event_direct( $c_bug_id, 'status', $h_status, $t_ass_val );
history_log_event_direct( $c_bug_id, 'handler_id', $h_handler_id, $p_user_id );

# Add bugnote if supplied
if ( !is_blank( $p_bugnote_text ) ) {
bugnote_add( $p_bug_id, $p_bugnote_text, 0, $p_bugnote_private );
}
# Add bugnote if supplied ignore false return
bugnote_add( $p_bug_id, $p_bugnote_text, 0, $p_bugnote_private, 0, '', NULL, FALSE );

# updated the last_updated date
bug_update_date( $p_bug_id );
Expand All @@ -1341,12 +1339,12 @@ function bug_assign( $p_bug_id, $p_user_id, $p_bugnote_text='', $p_bugnote_priva
function bug_close( $p_bug_id, $p_bugnote_text = '', $p_bugnote_private = false, $p_time_tracking = '0:00' ) {
$p_bugnote_text = trim( $p_bugnote_text );

bug_set_field( $p_bug_id, 'status', CLOSED );
# Add bugnote if supplied ignore a false return
# Moved bugnote_add before bug_set_field calls in case time_tracking_no_note is off.
# Error condition stopped execution but status had already been changed
bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private, 0, '', NULL, FALSE );

# Add bugnote if supplied
if ( !is_blank( $p_bugnote_text ) ) {
bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private );
}
bug_set_field( $p_bug_id, 'status', CLOSED );

email_close( $p_bug_id );
email_relationship_child_closed( $p_bug_id );
Expand All @@ -1360,10 +1358,15 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bug
$c_resolution = (int)$p_resolution;
$p_bugnote_text = trim( $p_bugnote_text );

# Add bugnote if supplied
# Moved bugnote_add before bug_set_field calls in case time_tracking_no_note is off.
# Error condition stopped execution but status had already been changed
bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private, 0, '', NULL, FALSE );

$t_duplicate = !is_blank( $p_duplicate_id ) && ( $p_duplicate_id != 0 );
if ( $t_duplicate ) {
if ( $p_bug_id == $p_duplicate_id ) {
trigger_error( ERROR_BUG_DUPLICATE_SELF, ERROR ); # never returns
trigger_error( ERROR_BUG_DUPLICATE_SELF, ERROR ); # never returns
}

# the related bug exists...
Expand Down Expand Up @@ -1410,11 +1413,6 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bug
bug_set_field( $p_bug_id, 'handler_id', $p_handler_id );
}

# Add bugnote if supplied
if ( !is_blank( $p_bugnote_text ) ) {
bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private );
}

email_resolved( $p_bug_id );
email_relationship_child_resolved( $p_bug_id );

Expand All @@ -1430,14 +1428,14 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bug
function bug_reopen( $p_bug_id, $p_bugnote_text='', $p_time_tracking = '0:00', $p_bugnote_private = false ) {
$p_bugnote_text = trim( $p_bugnote_text );

# Add bugnote if supplied
# Moved bugnote_add before bug_set_field calls in case time_tracking_no_note is off.
# Error condition stopped execution but status had already been changed
bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private, 0, '', NULL, FALSE );

bug_set_field( $p_bug_id, 'status', config_get( 'bug_reopen_status' ) );
bug_set_field( $p_bug_id, 'resolution', config_get( 'bug_reopen_resolution' ) );

# Add bugnote if supplied
if ( !is_blank( $p_bugnote_text ) ) {
bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private );
}

email_reopen( $p_bug_id );

return true;
Expand Down
42 changes: 30 additions & 12 deletions core/bugnote_api.php
Expand Up @@ -99,20 +99,33 @@ function bugnote_is_user_reporter( $p_bugnote_id, $p_user_id ) {
# Add a bugnote to a bug
#
# return the ID of the new bugnote
function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = 0, $p_attr = '', $p_user_id = null ) {
$c_bug_id = db_prepare_int( $p_bug_id );

$c_time_tracking = helper_duration_to_minutes( $p_time_tracking );
$c_private = db_prepare_bool( $p_private );
$c_type = db_prepare_int( $p_type );
function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = 0, $p_attr = '', $p_user_id = null, $p_send_email=TRUE ) {
$c_bug_id = db_prepare_int( $p_bug_id );
$c_time_tracking = helper_duration_to_minutes( $p_time_tracking );
$c_private = db_prepare_bool( $p_private );
$c_type = db_prepare_int( $p_type );

$t_bugnote_text_table = db_get_table( 'mantis_bugnote_text_table' );
$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );

$t_time_tracking_enabled = config_get( 'time_tracking_enabled' );
$t_time_tracking_without_note = config_get( 'time_tracking_without_note' );

if ( ON == $t_time_tracking_enabled && $c_time_tracking > 0 ) {
if ( is_blank( $p_bugnote_text ) && OFF == $t_time_tracking_without_note ) {
error_parameters( lang_get( 'bugnote' ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}
$c_type = TIME_TRACKING;
} else if ( is_blank( $p_bugnote_text ) ) {
return false;
}

# insert bugnote text
$query = "INSERT INTO $t_bugnote_text_table
( note )
VALUES
( " . db_param(0) . " )";
( note )
VALUES
( " . db_param(0) . " )";
db_query_bound( $query, Array( $p_bugnote_text ) );

# retrieve bugnote text id number
Expand All @@ -135,9 +148,9 @@ function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p

# insert bugnote info
$query = "INSERT INTO $t_bugnote_table
(bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking )
VALUES
(" . db_param(0) . ", " . db_param(1) . "," . db_param(2) . ", " . db_param(3) . ", " . db_param(4) . "," . db_param(5) . ", " . db_param(6) . ", " . db_param(7) . ", " . db_param(8) . " )";
(bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking )
VALUES
(" . db_param(0) . ", " . db_param(1) . "," . db_param(2) . ", " . db_param(3) . ", " . db_param(4) . "," . db_param(5) . ", " . db_param(6) . ", " . db_param(7) . ", " . db_param(8) . " )";
db_query_bound( $query, Array( $c_bug_id, $c_user_id, $t_bugnote_text_id, $t_view_state, db_now(), db_now(), $c_type, $p_attr, $c_time_tracking ) );

# get bugnote id
Expand All @@ -149,6 +162,11 @@ function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p
# log new bug
history_log_event_special( $p_bug_id, BUGNOTE_ADDED, bugnote_format_id( $t_bugnote_id ) );

# only send email if the text is not blank, otherwise, it is just recording of time without a comment.
if ( TRUE == $p_send_email && !is_blank( $p_bugnote_text ) ) {
email_bugnote_add( $p_bug_id );
}

return $t_bugnote_id;
}

Expand Down

0 comments on commit bda0f40

Please sign in to comment.