### Eclipse Workspace Patch 1.0 #P dirt_new Index: core/email_api.php =================================================================== RCS file: ./core/email_api.php,v retrieving revision 1.3 diff -u -r1.3 email_api.php --- core/email_api.php 22 Apr 2009 14:23:04 -0000 1.3 +++ core/email_api.php 22 Apr 2009 18:17:57 -0000 @@ -706,6 +706,8 @@ # -------------------- # This function sends an email message based on the supplied email data. + # Issue 6856: Have reminders come from the user who sent it rather than the + # standard email. function email_send( $p_email_data ) { global $g_phpMailer_smtp; @@ -714,6 +716,7 @@ $t_recipient = trim( $t_email_data->email ); $t_subject = string_email( trim( $t_email_data->subject ) ); $t_message = string_email_links( trim( $t_email_data->body ) ); + $t_from_user_id = $t_email_data->from; $t_debug_email = config_get( 'debug_email' ); @@ -767,10 +770,15 @@ $mail->Priority = $t_email_data->metadata['priority']; # Urgent = 1, Not Urgent = 5, Disable = 0 $mail->CharSet = $t_email_data->metadata['charset']; $mail->Host = config_get( 'smtp_host' ); - $mail->From = config_get( 'from_email' ); - $mail->Sender = escapeshellcmd( config_get( 'return_path_email' ) ); - $mail->FromName = config_get( 'from_name'); - + if ($t_from_user_id == null){ + $mail->From = config_get( 'from_email' ); + $mail->Sender = escapeshellcmd( config_get( 'return_path_email' ) ); + $mail->FromName = config_get( 'from_name'); + } else { + $mail->From = user_get_email( $t_from_user_id ); + $mail->Sender = user_get_email( $t_from_user_id ); + $mail->FromName = user_get_realname( $t_from_user_id ); + } if ( !is_blank( config_get( 'smtp_username' ) ) ) { # Use SMTP Authentication $mail->SMTPAuth = true; @@ -867,6 +875,8 @@ # # @@@ 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. + # Issue 6856: Have the reminder come from the person who sent it rather than the + # standard email function email_bug_reminder( $p_recipients, $p_bug_id, $p_message ) { if ( !is_array( $p_recipients ) ) { @@ -877,7 +887,8 @@ $t_sender_id = auth_get_current_user_id(); $t_sender = user_get_name( $t_sender_id ); - $t_subject = email_build_subject( $p_bug_id ); + # Issue 6822: Made reminders more distinct by adding Reminder to the title + $t_subject = "REMINDER: ".email_build_subject( $p_bug_id ); $t_date = date( config_get( 'normal_date_format' ) ); $result = array(); @@ -906,7 +917,11 @@ } if ( OFF == config_get( 'email_send_using_cronjob' ) ) { - email_send_all(); + if (config_get ('reminders_from_user') == ON){ + email_send_all_from_user($t_sender_id); + } else { + email_send_all(); + } } return $result; @@ -926,7 +941,7 @@ } # build subject - $t_subject = '['.$p_visible_bug_data['email_project'].' ' + $t_subject = 'DIRT ['.$p_visible_bug_data['email_project'].' ' .bug_format_id( $p_visible_bug_data['email_bug'] ) .']: '.$p_visible_bug_data['email_summary']; @@ -1210,4 +1225,32 @@ return $t_bug_data; } + + # Issue 6856: Have the reminder come from the user that sent it rather than the + # standard email. + function email_send_all_from_user($p_user_id) { + $t_ids = email_queue_get_ids(); + + $t_emails_recipients_failed = array(); + $t_start = microtime_float(); + foreach ( $t_ids as $t_id ) { + $t_email_data = email_queue_get( $t_id ); + + # check if email was not found. This can happen if another request picks up the email first and sends it. + if ( $t_email_data === false ) { + continue; + } + + $t_email_data->from = $p_user_id; + + # if unable to place the email in the email server queue, then the connection to the server is down, + # and hence no point to continue trying with the rest of the emails. + if ( !email_send( $t_email_data ) ) { + if ( microtime_float() - $t_start > 5) + break; + else + continue; + } + } + } ?>