Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4490a54b9139
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: afa498b99ca7
Choose a head ref
  • 6 commits
  • 7 files changed
  • 1 contributor

Commits on Feb 6, 2013

  1. Copy the full SHA
    f4753ec View commit details

Commits on Feb 7, 2013

  1. Removed trailing ':' from reminder_sent_to language string

    This is for consistency, as except for error messages punctuation is
    generally added by the code.
    
    Issue #2971
    dregad committed Feb 7, 2013
    Copy the full SHA
    611b6f7 View commit details
  2. Improve handling of reminders' recipients list truncation

    Replaced the previous method of truncating the list to a hardcoded
    number of entries (50), to a more robust approach based on the size of
    the underlying database field (250 chars, note_attr in bugnote table).
    
    Added a message on the REMINDER bugnote, to inform user that the list of
    recipients stored with the note, was actually truncated (Users should
    refer to the issue's history to see who actually received the reminder).
    
    This functionality relies on a hack, i.e. to indicate that the list was
    truncated, bug_reminder.php is not storing the trailing delimiter in the
    note_attr field, and this is picked up in bugnote_view_inc.php to
    display the note to the user's attention.
    
    Fixes #15470
    dregad committed Feb 7, 2013
    Copy the full SHA
    bf6f0c6 View commit details
  3. Copy the full SHA
    de4e0fa View commit details
  4. Fix return value of email_bug_reminder()

    The function now returns an array containing only the users to whom the
    reminder e-mail was actually sent (i.e. excludes failures, blank e-mails,
    etc).
    
    In addition, the return value is now an array of user id's instead of
    user names, which indeed makes more sense from an API perspective, as
    mentioned by Julian Fitzell in 5ea3d0b,
    since the function's only caller is bug_reminder.php which exclusively
    relies on user id's.
    
    Fixes #15472
    dregad committed Feb 7, 2013
    Copy the full SHA
    1002f8a View commit details
  5. bug_reminder.php does not handle unsent reminders

    Reminders are not logged in history (or the bugnote) if the e-mail was not
    actually sent to the recipient.
    
    The function now uses email_bug_reminder()'s return value instead of the
    full user-provided list of recipients for inclusion in the reminder's
    bugnote and to add history entries.
    
    Fixes #15471
    dregad committed Feb 7, 2013
    Copy the full SHA
    afa498b View commit details
Showing with 69 additions and 31 deletions.
  1. +27 −13 bug_reminder.php
  2. +23 −6 bugnote_view_inc.php
  3. +1 −0 core/constant_inc.php
  4. +10 −10 core/email_api.php
  5. +4 −0 core/history_api.php
  6. +3 −1 lang/strings_english.txt
  7. +1 −1 print_bugnote_inc.php
40 changes: 27 additions & 13 deletions bug_reminder.php
Original file line number Diff line number Diff line change
@@ -51,14 +51,18 @@

access_ensure_bug_level( config_get( 'bug_reminder_threshold' ), $f_bug_id );

# Automically add recipients to monitor list if they are above the monitor
# Automatically add recipients to monitor list if they are above the monitor
# threshold, option is enabled, and not reporter or handler.
foreach ( $f_to as $t_recipient )
{
if ( ON == config_get( 'reminder_recipients_monitor_bug' ) &&
access_has_bug_level( config_get( 'monitor_bug_threshold' ), $f_bug_id ) &&
!bug_is_user_handler( $f_bug_id, $t_recipient ) &&
!bug_is_user_reporter( $f_bug_id, $t_recipient ) ) {
$t_reminder_recipients_monitor_bug = config_get( 'reminder_recipients_monitor_bug' );
$t_monitor_bug_threshold = config_get( 'monitor_bug_threshold' );
$t_handler = bug_get_field( $f_bug_id, 'handler_id' );
$t_reporter = bug_get_field( $f_bug_id, 'reporter_id' );
foreach ( $f_to as $t_recipient ) {
if ( ON == $t_reminder_recipients_monitor_bug
&& access_has_bug_level( $t_monitor_bug_threshold, $f_bug_id )
&& $t_recipient != $t_handler
&& $t_recipient != $t_reporter
) {
bug_monitor( $f_bug_id, $t_recipient );
}
}
@@ -67,17 +71,27 @@

# Add reminder as bugnote if store reminders option is ON.
if ( ON == config_get( 'store_reminders' ) ) {
if ( count( $f_to ) > 50 ) { # too many recipients to log, truncate the list
$t_to = array();
for ( $i=0; $i<50; $i++ ) {
$t_to[] = $f_to[$i];
# Build list of recipients, truncated to note_attr fields's length
$t_attr = '|';
$t_length = 0;
foreach( $result as $t_id ) {
$t_recipient = $t_id . '|';
$t_length += strlen( $t_recipient );
if( $t_length > 250 ) {
# Remove trailing delimiter to indicate truncation
$t_attr = rtrim( $t_attr, '|' );
break;
}
$f_to = $t_to;
$t_attr .= $t_recipient;
}
$t_attr = '|' . implode( '|', $f_to ) . '|';
bugnote_add( $f_bug_id, $f_body, 0, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr, NULL, FALSE );
}

# Add history entries for all sent reminders
foreach ( $result as $t_recipient ) {
history_log_event_special( $f_bug_id, BUG_REMINDER_SENT, $t_recipient );
}

form_security_purge( 'bug_reminder' );

html_page_top( null, string_get_bug_view_url( $f_bug_id ) );
29 changes: 23 additions & 6 deletions bugnote_view_inc.php
Original file line number Diff line number Diff line change
@@ -179,14 +179,31 @@
<?php
switch ( $t_bugnote->note_type ) {
case REMINDER:
echo '<em>' . lang_get( 'reminder_sent_to' ) . lang_get( 'word_separator' );
$t_note_attr = utf8_substr( $t_bugnote->note_attr, 1, utf8_strlen( $t_bugnote->note_attr ) - 2 );
$t_to = array();
foreach ( explode( '|', $t_note_attr ) as $t_recipient ) {
$t_to[] = prepare_user_name( $t_recipient );
echo '<em>';

# List of recipients; remove surrounding delimiters
$t_recipients = trim( $t_bugnote->note_attr, '|' );

if( empty( $t_recipients ) ) {
echo lang_get( 'reminder_sent_none' );
} else {
# If recipients list's last char is not a delimiter, it was truncated
$t_truncated = ( '|' != utf8_substr( $t_bugnote->note_attr, utf8_strlen( $t_bugnote->note_attr ) - 1 ) );

# Build recipients list for display
$t_to = array();
foreach ( explode( '|', $t_recipients ) as $t_recipient ) {
$t_to[] = prepare_user_name( $t_recipient );
}

echo lang_get( 'reminder_sent_to' ) . ': '
. implode( ', ', $t_to )
. ( $t_truncated ? ' (' . lang_get( 'reminder_list_truncated' ) . ')' : '' );
}
echo implode( ', ', $t_to ) . '</em><br /><br />';

echo '</em><br /><br />';
break;

case TIME_TRACKING:
if ( access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id ) ) {
echo '<b>', lang_get( 'time_tracking_time_spent' ) . ' ' . $t_time_tracking_hhmm, '</b><br /><br />';
1 change: 1 addition & 0 deletions core/constant_inc.php
Original file line number Diff line number Diff line change
@@ -190,6 +190,7 @@
define( 'TAG_RENAMED', 27 );
define( 'BUG_REVISION_DROPPED', 28 );
define( 'BUGNOTE_REVISION_DROPPED', 29 );
define( 'BUG_REMINDER_SENT', 30 );
define( 'PLUGIN_HISTORY', 100 );

# bug revisions
20 changes: 10 additions & 10 deletions core/email_api.php
Original file line number Diff line number Diff line change
@@ -791,7 +791,7 @@ function email_bug_deleted( $p_bug_id ) {
* @param string $p_subject
* @param string $p_message
* @param array $p_headers
* @return int
* @return int e-mail queue id, or NULL if e-mail was not stored
*/
function email_store( $p_recipient, $p_subject, $p_message, $p_headers = null ) {
$t_recipient = trim( $p_recipient );
@@ -1113,14 +1113,12 @@ function email_append_domain( $p_email ) {
}

/**
* Send a bug reminder to each of the given user, or to each user if the first parameter is an array
* return an array of usernames to which the reminder was successfully sent
* Send a bug reminder to the given user(s), or to each user if the first parameter is an array
*
* @todo I'm not sure this shouldn't return an array of user ids... more work for the caller but cleaner from an API point of view.
* @param array $p_recipients
* @param int $p_bug_id
* @param string $p_message
* @return null
* @param int|array $p_recipients user id or list of user ids array to send reminder to
* @param int $p_bug_id Issue for which the reminder is sent
* @param string $p_message Optional message to add to the e-mail
* @return array List of users ids to whom the reminder e-mail was actually sent
*/
function email_bug_reminder( $p_recipients, $p_bug_id, $p_message ) {
if( !is_array( $p_recipients ) ) {
@@ -1141,10 +1139,9 @@ function email_bug_reminder( $p_recipients, $p_bug_id, $p_message ) {
lang_push( user_pref_get_language( $t_recipient, $t_project_id ) );

$t_email = user_get_email( $t_recipient );
$result[] = user_get_name( $t_recipient );

if( access_has_project_level( config_get( 'show_user_email_threshold' ), $t_project_id, $t_recipient ) ) {
$t_sender_email = ' <' . current_user_get_field( 'email' ) . '>';
$t_sender_email = ' <' . user_get_email( $t_sender_id ) . '>';
} else {
$t_sender_email = '';
}
@@ -1153,6 +1150,9 @@ function email_bug_reminder( $p_recipients, $p_bug_id, $p_message ) {

if( ON == config_get( 'enable_email_notification' ) ) {
$t_id = email_store( $t_email, $t_subject, $t_contents );
if( $t_id !== null ) {
$result[] = $t_recipient;
}
log_event( LOG_EMAIL, "queued reminder email #$t_id for U$t_recipient" );
}

4 changes: 4 additions & 0 deletions core/history_api.php
Original file line number Diff line number Diff line change
@@ -477,6 +477,10 @@ function history_localize_item( $p_field_name, $p_type, $p_old_value, $p_new_val
$p_old_value = user_get_name( $p_old_value );
$t_note = lang_get( 'bug_monitor' ) . ': ' . $p_old_value;
break;
case BUG_REMINDER_SENT:
$p_old_value = user_get_name( $p_old_value );
$t_note = lang_get( 'reminder_sent_to' ) . ': ' . $p_old_value;
break;
case BUG_UNMONITOR:
$p_old_value = user_get_name( $p_old_value );
$t_note = lang_get( 'bug_end_monitor' ) . ': ' . $p_old_value;
4 changes: 3 additions & 1 deletion lang/strings_english.txt
Original file line number Diff line number Diff line change
@@ -584,7 +584,9 @@ $s_from = 'From';
$s_to = 'To';
$s_sent_you_this_reminder_about = 'sent you this reminder about';
$s_bug_reminder = 'Send a reminder';
$s_reminder_sent_to = 'Reminder sent to:';
$s_reminder_sent_to = 'Reminder sent to';
$s_reminder_sent_none = 'No reminders could be sent';
$s_reminder_list_truncated = 'recipients list truncated, refer to Issue History for full list';
$s_bug_send_button = 'Send';
$s_reminder = 'Reminder';
$s_reminder_explain = 'This note will be sent to the recipients listed requesting feedback on this issue.';
2 changes: 1 addition & 1 deletion print_bugnote_inc.php
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@
<?php
switch ( $v3_note_type ) {
case REMINDER:
echo '<div class="italic">' . lang_get( 'reminder_sent_to' ) . lang_get( 'word_separator' );
echo '<div class="italic">' . lang_get( 'reminder_sent_to' ) . ': ';
$v3_note_attr = utf8_substr( $v3_note_attr, 1, utf8_strlen( $v3_note_attr ) - 2 );
$t_to = array();
foreach ( explode( '|', $v3_note_attr ) as $t_recipient ) {