diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 2e570307580..0590bd1c2f4 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1118,7 +1118,9 @@ $string['maxsizeandattachmentsandareasize'] = 'Maximum size for new files: {$a-> $string['memberincourse'] = 'People in the course'; $string['messagebody'] = 'Message body'; $string['messagedselectedusers'] = 'Selected users have been messaged and the recipient list has been reset.'; +$string['messagedselecteduserfailed'] = 'The message was not sent to user {$a->fullname}.'; $string['messagedselectedusersfailed'] = 'Something went wrong while messaging selected users. Some may have received the email.'; +$string['messagedselectedcountusersfailed'] = 'A problem occurred and {$a} messages have not been sent.'; $string['messageprovider:availableupdate'] = 'Available update notifications'; $string['messageprovider:backup'] = 'Backup notifications'; $string['messageprovider:badgecreatornotice'] = 'Badge creator notifications'; diff --git a/user/messageselect.php b/user/messageselect.php index 42ebb32a74b..56a22ddfaae 100644 --- a/user/messageselect.php +++ b/user/messageselect.php @@ -154,16 +154,24 @@ if (!empty($messagebody) && !$edit && !$deluser && ($preview || $send)) { echo '

'; echo "\n"; } else if (!empty($send)) { - $good = 1; + $fails = array(); foreach ($SESSION->emailto[$id] as $user) { - $good = $good && message_post_message($USER, $user, $messagebody, $format); + if (!message_post_message($USER, $user, $messagebody, $format)) { + $user->fullname = fullname($user); + $fails[] = get_string('messagedselecteduserfailed', 'moodle', $user); + }; } - if (!empty($good)) { + if (empty($fails)) { echo $OUTPUT->heading(get_string('messagedselectedusers')); unset($SESSION->emailto[$id]); unset($SESSION->emailselect[$id]); } else { - echo $OUTPUT->heading(get_string('messagedselectedusersfailed')); + echo $OUTPUT->heading(get_string('messagedselectedcountusersfailed', 'moodle', count($fails))); + echo ''; } echo '

'.get_string('backtoparticipants').'

'; }