Skip to content

Commit

Permalink
MDL-48499 messages: Show which users have not received bulk messages
Browse files Browse the repository at this point in the history
  • Loading branch information
danielneis authored and Daniel Neis Araujo committed Mar 24, 2015
1 parent a149d6a commit 77acc5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,9 @@
$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';
Expand Down
16 changes: 12 additions & 4 deletions user/messageselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,24 @@
echo '<input type="submit" name="edit" value="'.get_string('update').'" /></p>';
echo "\n</form>";
} 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 '<ul>';
foreach ($fails as $f) {
echo '<li>', $f, '</li>';
}
echo '</ul>';
}
echo '<p align="center"><a href="index.php?id='.$id.'">'.get_string('backtoparticipants').'</a></p>';
}
Expand Down

0 comments on commit 77acc5d

Please sign in to comment.