This commit is contained in:
Eloy Lafuente (stronk7) 2015-03-24 22:00:07 +01:00
commit fb42902b28
2 changed files with 14 additions and 4 deletions

View file

@ -1118,7 +1118,9 @@ $string['maxsizeandattachmentsandareasize'] = 'Maximum size for new files: {$a->
$string['memberincourse'] = 'People in the course'; $string['memberincourse'] = 'People in the course';
$string['messagebody'] = 'Message body'; $string['messagebody'] = 'Message body';
$string['messagedselectedusers'] = 'Selected users have been messaged and the recipient list has been reset.'; $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['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:availableupdate'] = 'Available update notifications';
$string['messageprovider:backup'] = 'Backup notifications'; $string['messageprovider:backup'] = 'Backup notifications';
$string['messageprovider:badgecreatornotice'] = 'Badge creator notifications'; $string['messageprovider:badgecreatornotice'] = 'Badge creator notifications';

View file

@ -154,16 +154,24 @@ if (!empty($messagebody) && !$edit && !$deluser && ($preview || $send)) {
echo '<input type="submit" name="edit" value="'.get_string('update').'" /></p>'; echo '<input type="submit" name="edit" value="'.get_string('update').'" /></p>';
echo "\n</form>"; echo "\n</form>";
} else if (!empty($send)) { } else if (!empty($send)) {
$good = 1; $fails = array();
foreach ($SESSION->emailto[$id] as $user) { 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')); echo $OUTPUT->heading(get_string('messagedselectedusers'));
unset($SESSION->emailto[$id]); unset($SESSION->emailto[$id]);
unset($SESSION->emailselect[$id]); unset($SESSION->emailselect[$id]);
} else { } 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>'; echo '<p align="center"><a href="index.php?id='.$id.'">'.get_string('backtoparticipants').'</a></p>';
} }