From 77acc5d7a7e4a6c1915bd1c265a591a750de23d0 Mon Sep 17 00:00:00 2001 From: Daniel Neis Araujo Date: Thu, 4 Dec 2014 11:37:09 -0200 Subject: [PATCH] MDL-48499 messages: Show which users have not received bulk messages --- lang/en/moodle.php | 2 ++ user/messageselect.php | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 4b1272c0e6c..fa7c3baa0a8 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').'

'; }