MDL-29814 message: made html personal messages store a plain text version as a fallback
authorAndrew Davis <andrew@moodle.com>
Sat, 19 Nov 2011 07:35:23 +0000 (15:35 +0800)
committerAndrew Davis <andrew@moodle.com>
Sat, 19 Nov 2011 07:35:23 +0000 (15:35 +0800)
message/lib.php

index a9c8fff..8fe66be 100644 (file)
@@ -2013,8 +2013,10 @@ function message_post_message($userfrom, $userto, $message, $format) {
     $eventdata->subject          = get_string_manager()->get_string('unreadnewmessage', 'message', fullname($userfrom), $userto->lang);
 
     if ($format == FORMAT_HTML) {
     $eventdata->subject          = get_string_manager()->get_string('unreadnewmessage', 'message', fullname($userfrom), $userto->lang);
 
     if ($format == FORMAT_HTML) {
-        $eventdata->fullmessage      = '';
         $eventdata->fullmessagehtml  = $message;
         $eventdata->fullmessagehtml  = $message;
+        //some message processors may revert to sending plain text even if html is supplied
+        //so we keep both plain and html versions if we're intending to send html
+        $eventdata->fullmessage = html_to_text($eventdata->fullmessagehtml);
     } else {
         $eventdata->fullmessage      = $message;
         $eventdata->fullmessagehtml  = '';
     } else {
         $eventdata->fullmessage      = $message;
         $eventdata->fullmessagehtml  = '';