Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged branch 'MDL-26185_m20' of git://github.com/andyjdavis/moodle.g…

…it and fixed conflicts
  • Loading branch information...
commit 7d1fb2f6eca79ebccb733aab17252eb8cb8c54f9 2 parents 227e54d + a6e29ac
@samhemelryk samhemelryk authored
Showing with 11 additions and 13 deletions.
  1. +11 −13 message/output/email/message_output_email.php
View
24 message/output/email/message_output_email.php
@@ -46,21 +46,19 @@ function send_message($eventdata) {
return true;
}
- //hold onto email preference because /admin/cron.php sends a lot of messages at once
- static $useremailaddresses = array();
+ //the user the email is going to
+ $recipient = null;
- //check user preference for where user wants email sent
- if (!array_key_exists($eventdata->userto->id, $useremailaddresses)) {
- $useremailaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_email_email', $eventdata->userto->email, $eventdata->userto->id);
+ //check if the recipient has a different email address specified in their messaging preferences Vs their user profile
+ $emailmessagingpreference = get_user_preferences('message_processor_email_email', null, $eventdata->userto);
+ if (!empty($emailmessagingpreference)) {
+ //clone to avoid altering the actual user object
+ $recipient = clone($eventdata->userto);
+ $recipient->email = $emailmessagingpreference;
+ } else {
+ $recipient = $eventdata->userto;
}
- $usertoemailaddress = $useremailaddresses[$eventdata->userto->id];
-
- if ( !empty($usertoemailaddress)) {
- $userto->email = $usertoemailaddress;
- }
-
- $result = email_to_user($eventdata->userto, $eventdata->userfrom,
- $eventdata->subject, $eventdata->fullmessage, $eventdata->fullmessagehtml);
+ $result = email_to_user($recipient, $eventdata->userfrom, $eventdata->subject, $eventdata->fullmessage, $eventdata->fullmessagehtml);
return $result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.